[asterisk-commits] rmudgett: trunk r276347 - in /trunk: ./ addons/ apps/ channels/ funcs/ includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 14 10:48:50 CDT 2010


Author: rmudgett
Date: Wed Jul 14 10:48:36 2010
New Revision: 276347

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276347
Log:
ast_callerid restructuring

The purpose of this patch is to eliminate struct ast_callerid since it has
turned into a miscellaneous collection of various party information.

Eliminate struct ast_callerid and replace it with the following struct
organization:

struct ast_party_name {
	char *str;
	int char_set;
	int presentation;
	unsigned char valid;
};
struct ast_party_number {
	char *str;
	int plan;
	int presentation;
	unsigned char valid;
};
struct ast_party_subaddress {
	char *str;
	int type;
	unsigned char odd_even_indicator;
	unsigned char valid;
};
struct ast_party_id {
	struct ast_party_name name;
	struct ast_party_number number;
	struct ast_party_subaddress subaddress;
	char *tag;
};
struct ast_party_dialed {
	struct {
		char *str;
		int plan;
	} number;
	struct ast_party_subaddress subaddress;
	int transit_network_select;
};
struct ast_party_caller {
	struct ast_party_id id;
	char *ani;
	int ani2;
};

The new organization adds some new information as well.

* The party name and number now have their own presentation value that can
be manipulated independently.  ISDN supplies the presentation value for
the name and number at different times with the possibility that they
could be different.

* The party name and number now have a valid flag.  Before this change the
name or number string could be empty if the presentation were restricted.
Most channel drivers assume that the name or number is then simply not
available instead of indicating that the name or number was restricted.

* The party name now has a character set value.  SIP and Q.SIG have the
ability to indicate what character set a name string is using so it could
be presented properly.

* The dialed party now has a numbering plan value that could be useful to
have available.

The various channel drivers will need to be updated to support the new
core features as needed.  They have simply been converted to supply
current functionality at this time.


The following items of note were either corrected or enhanced:

* The CONNECTEDLINE() and REDIRECTING() dialplan functions were
consolidated into func_callerid.c to share party id handling code.

* CALLERPRES() is now deprecated because the name and number have their
own presentation values.

* Fixed app_alarmreceiver.c write_metadata().  The workstring[] could
contain garbage.  It also can only contain the caller id number so using
ast_callerid_parse() on it is silly.  There was also a typo in the
CALLERNAME if test.

* Fixed app_rpt.c using ast_callerid_parse() on the channel's caller id
number string.  ast_callerid_parse() alters the given buffer which in this
case is the channel's caller id number string.  Then using
ast_shrink_phone_number() could alter it even more.

* Fixed caller ID name and number memory leak in chan_usbradio.c.

* Fixed uninitialized char arrays cid_num[] and cid_name[] in
sig_analog.c.

* Protected access to a caller channel with lock in chan_sip.c.

* Clarified intent of code in app_meetme.c sla_ring_station() and
dial_trunk().  Also made save all caller ID data instead of just the name
and number strings.

* Simplified cdr.c set_one_cid().  It hand coded the ast_callerid_merge()
function.

* Corrected some weirdness with app_privacy.c's use of caller
presentation.

Review:	https://reviewboard.asterisk.org/r/702/

Removed:
    trunk/funcs/func_connectedline.c
    trunk/funcs/func_redirecting.c
Modified:
    trunk/UPGRADE.txt
    trunk/addons/chan_ooh323.c
    trunk/apps/app_alarmreceiver.c
    trunk/apps/app_amd.c
    trunk/apps/app_dial.c
    trunk/apps/app_directed_pickup.c
    trunk/apps/app_disa.c
    trunk/apps/app_dumpchan.c
    trunk/apps/app_fax.c
    trunk/apps/app_followme.c
    trunk/apps/app_macro.c
    trunk/apps/app_meetme.c
    trunk/apps/app_minivm.c
    trunk/apps/app_osplookup.c
    trunk/apps/app_parkandannounce.c
    trunk/apps/app_privacy.c
    trunk/apps/app_queue.c
    trunk/apps/app_readexten.c
    trunk/apps/app_rpt.c
    trunk/apps/app_setcallerid.c
    trunk/apps/app_sms.c
    trunk/apps/app_stack.c
    trunk/apps/app_talkdetect.c
    trunk/apps/app_voicemail.c
    trunk/apps/app_while.c
    trunk/apps/app_zapateller.c
    trunk/channels/chan_agent.c
    trunk/channels/chan_console.c
    trunk/channels/chan_dahdi.c
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_h323.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_jingle.c
    trunk/channels/chan_local.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_misdn.c
    trunk/channels/chan_oss.c
    trunk/channels/chan_phone.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_unistim.c
    trunk/channels/chan_usbradio.c
    trunk/channels/chan_vpb.cc
    trunk/channels/sig_analog.c
    trunk/channels/sig_analog.h
    trunk/channels/sig_pri.c
    trunk/channels/sig_ss7.c
    trunk/funcs/func_blacklist.c
    trunk/funcs/func_callerid.c
    trunk/funcs/func_dialplan.c
    trunk/include/asterisk/callerid.h
    trunk/include/asterisk/channel.h
    trunk/main/app.c
    trunk/main/callerid.c
    trunk/main/ccss.c
    trunk/main/cdr.c
    trunk/main/cel.c
    trunk/main/channel.c
    trunk/main/cli.c
    trunk/main/dial.c
    trunk/main/features.c
    trunk/main/file.c
    trunk/main/manager.c
    trunk/main/pbx.c
    trunk/res/res_agi.c
    trunk/res/snmp/agent.c
    trunk/tests/test_substitution.c

Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Wed Jul 14 10:48:36 2010
@@ -81,6 +81,9 @@
 * VoiceMailMain and VMAuthenticate, if a '*' is entered in the first position
   of a Mailbox or Password, will, if it exists, jump to the 'a' extension in
   the current dialplan context.
+
+* The CALLERPRES() dialplan function is deprecated in favor of
+  CALLERID(num-pres) and CALLERID(name-pres).
 
 * Environment variables that start with "AST_" are reserved to the system and
   may no longer be set from the dialplan.

Modified: trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/addons/chan_ooh323.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/addons/chan_ooh323.c (original)
+++ trunk/addons/chan_ooh323.c Wed Jul 14 10:48:36 2010
@@ -922,24 +922,23 @@
 	}
 	ast_mutex_lock(&p->lock);
 	ast_set_flag(p, H323_OUTGOING);
-	if (ast->connected.id.number) {
-     		if(p->callerid_num)   free(p->callerid_num);
-		p->callerid_num = strdup(ast->connected.id.number);
-	}
-
-	if (ast->connected.id.name) {
-      		if(p->callerid_name)
-			free(p->callerid_name);
-		p->callerid_name = strdup(ast->connected.id.name);
-	} else if (ast->connected.id.number) {
-      		if(p->callerid_name)
-			free(p->callerid_name);
-		p->callerid_name = strdup(ast->connected.id.number);
+	if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+		free(p->callerid_num);
+		p->callerid_num = strdup(ast->connected.id.number.str);
+	}
+
+	if (ast->connected.id.name.valid && ast->connected.id.name.str) {
+		free(p->callerid_name);
+		p->callerid_name = strdup(ast->connected.id.name.str);
+	} else if (ast->connected.id.number.valid && ast->connected.id.number.str) {
+		free(p->callerid_name);
+		p->callerid_name = strdup(ast->connected.id.number.str);
 	} else {
-		ast->connected.id.name = strdup(gCallerID);
-      		if(p->callerid_name)
-			free(p->callerid_name);
-		p->callerid_name = strdup(ast->connected.id.name);
+		ast->connected.id.name.valid = 1;
+		free(ast->connected.id.name.str);
+		ast->connected.id.name.str = strdup(gCallerID);
+		free(p->callerid_name);
+		p->callerid_name = strdup(ast->connected.id.name.str);
 	}
 
 	/* Retrieve vars */
@@ -1241,13 +1240,15 @@
 	case AST_CONTROL_SRCCHANGE:
 		ast_rtp_instance_change_source(p->rtp);
 		break;
-       	case AST_CONTROL_CONNECTED_LINE:
-		if (!ast_strlen_zero(ast->connected.id.name)) {
-			if (gH323Debug)
-				ast_log(LOG_DEBUG, "Sending connected line info for %s (%s)\n",
-				callToken, ast->connected.id.name);
-			ooSetANI(callToken, ast->connected.id.name);
-		}
+	case AST_CONTROL_CONNECTED_LINE:
+		if (!ast->connected.id.name.valid
+			|| ast_strlen_zero(ast->connected.id.name.str)) {
+			break;
+		}
+		if (gH323Debug)
+			ast_log(LOG_DEBUG, "Sending connected line info for %s (%s)\n",
+				callToken, ast->connected.id.name.str);
+		ooSetANI(callToken, ast->connected.id.name.str);
 		break;
 
       case AST_CONTROL_T38_PARAMETERS:
@@ -1539,10 +1540,15 @@
 
 	if (call->remoteDisplayName) {
 		struct ast_party_connected_line connected;
+		struct ast_set_party_connected_line update_connected;
+
+		memset(&update_connected, 0, sizeof(update_connected));
+		update_connected.id.name = 1;
 		ast_party_connected_line_init(&connected);
-		connected.id.name = (char *) call->remoteDisplayName;
+		connected.id.name.valid = 1;
+		connected.id.name.str = (char *) call->remoteDisplayName;
 		connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-		ast_channel_queue_connected_line_update(c, &connected);
+		ast_channel_queue_connected_line_update(c, &connected, &update_connected);
 	}
 	if (c->_state != AST_STATE_UP)
 		ast_setstate(c, AST_STATE_RINGING);
@@ -1590,10 +1596,15 @@
 
 	if (call->remoteDisplayName) {
 		struct ast_party_connected_line connected;
+		struct ast_set_party_connected_line update_connected;
+
+		memset(&update_connected, 0, sizeof(update_connected));
+		update_connected.id.name = 1;
 		ast_party_connected_line_init(&connected);
-		connected.id.name = (char *) call->remoteDisplayName;
+		connected.id.name.valid = 1;
+		connected.id.name.str = (char *) call->remoteDisplayName;
 		connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-		ast_channel_queue_connected_line_update(c, &connected);
+		ast_channel_queue_connected_line_update(c, &connected, &update_connected);
 	}
 	if (c->_state != AST_STATE_UP)
 		ast_setstate(c, AST_STATE_RINGING);
@@ -1983,10 +1994,15 @@
 
 			if (call->remoteDisplayName) {
 				struct ast_party_connected_line connected;
+				struct ast_set_party_connected_line update_connected;
+
+				memset(&update_connected, 0, sizeof(update_connected));
+				update_connected.id.name = 1;
 				ast_party_connected_line_init(&connected);
-				connected.id.name = (char *) call->remoteDisplayName;
+				connected.id.name.valid = 1;
+				connected.id.name.str = (char *) call->remoteDisplayName;
 				connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-				ast_channel_queue_connected_line_update(c, &connected);
+				ast_channel_queue_connected_line_update(c, &connected, &update_connected);
 			}
 
 			ast_queue_control(c, AST_CONTROL_ANSWER);

Modified: trunk/apps/app_alarmreceiver.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_alarmreceiver.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Wed Jul 14 10:48:36 2010
@@ -298,18 +298,22 @@
 	int res = 0;
 	struct timeval t;
 	struct ast_tm now;
-	char *cl,*cn;
+	char *cl;
+	char *cn;
 	char workstring[80];
 	char timestamp[80];
 	
 	/* Extract the caller ID location */
-	if (chan->cid.cid_num)
-		ast_copy_string(workstring, chan->cid.cid_num, sizeof(workstring));
-	workstring[sizeof(workstring) - 1] = '\0';
-
-	ast_callerid_parse(workstring, &cn, &cl);
-	if (cl)
-		ast_shrink_phone_number(cl);
+	ast_copy_string(workstring,
+		S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
+		sizeof(workstring));
+	ast_shrink_phone_number(workstring);
+	if (ast_strlen_zero(workstring)) {
+		cl = "<unknown>";
+	} else {
+		cl = workstring;
+	}
+	cn = S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>");
 
 	/* Get the current time */
 	t = ast_tvnow();
@@ -319,27 +323,27 @@
 	ast_strftime(timestamp, sizeof(timestamp), time_stamp_format, &now);
 
 	res = fprintf(logfile, "\n\n[metadata]\n\n");
-
-	if (res >= 0)
+	if (res >= 0) {
 		res = fprintf(logfile, "PROTOCOL=%s\n", signalling_type);
-
-	if (res >= 0)
-		res = fprintf(logfile, "CALLINGFROM=%s\n", (!cl) ? "<unknown>" : cl);
-
-	if (res >- 0)
-		res = fprintf(logfile, "CALLERNAME=%s\n", (!cn) ? "<unknown>" : cn);
-
-	if (res >= 0)
+	}
+	if (res >= 0) {
+		res = fprintf(logfile, "CALLINGFROM=%s\n", cl);
+	}
+	if (res >= 0) {
+		res = fprintf(logfile, "CALLERNAME=%s\n", cn);
+	}
+	if (res >= 0) {
 		res = fprintf(logfile, "TIMESTAMP=%s\n\n", timestamp);
-
-	if (res >= 0)
+	}
+	if (res >= 0) {
 		res = fprintf(logfile, "[events]\n\n");
-
+	}
 	if (res < 0) {
 		ast_verb(3, "AlarmReceiver: can't write metadata\n");
 		ast_debug(1,"AlarmReceiver: can't write metadata\n");
-	} else
+	} else {
 		res = 0;
+	}
 
 	return res;
 }

Modified: trunk/apps/app_amd.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_amd.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_amd.c (original)
+++ trunk/apps/app_amd.c Wed Jul 14 10:48:36 2010
@@ -188,8 +188,10 @@
 		AST_APP_ARG(argMaximumWordLength);
 	);
 
-	ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name, chan->cid.cid_ani,
-		chan->redirecting.from.number, ast_getformatname(chan->readformat));
+	ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name,
+		S_OR(chan->caller.ani, "(N/A)"),
+		S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, "(N/A)"),
+		ast_getformatname(chan->readformat));
 
 	/* Lets parse the arguments. */
 	if (!ast_strlen_zero(parse)) {

Modified: trunk/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_dial.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Wed Jul 14 10:48:36 2010
@@ -722,13 +722,6 @@
 	}
 }
 
-/*! \brief free the buffer if allocated, and set the pointer to the second arg */
-#define S_REPLACE(s, new_val) \
-	do {                      \
-		ast_free(s);          \
-		s = (new_val);        \
-	} while (0)
-
 static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
 {
 	char rexten[2] = { exten, '\0' };
@@ -773,9 +766,11 @@
 		"UniqueID: %s\r\n"
 		"DestUniqueID: %s\r\n"
 		"Dialstring: %s\r\n",
-		src->name, dst->name, S_OR(src->cid.cid_num, "<unknown>"),
-		S_OR(src->cid.cid_name, "<unknown>"), src->uniqueid,
-		dst->uniqueid, dialstring ? dialstring : "");
+		src->name, dst->name,
+		S_COR(src->caller.id.number.valid, src->caller.id.number.str, "<unknown>"),
+		S_COR(src->caller.id.name.valid, src->caller.id.name.str, "<unknown>"),
+		src->uniqueid, dst->uniqueid,
+		dialstring ? dialstring : "");
 }
 
 static void senddialendevent(struct ast_channel *src, const char *dialstatus)
@@ -859,28 +854,34 @@
 			ast_rtp_instance_early_bridge_make_compatible(c, in);
 		}
 
-		ast_channel_set_redirecting(c, &original->redirecting);
+		ast_channel_set_redirecting(c, &original->redirecting, NULL);
 		ast_channel_lock(c);
 		while (ast_channel_trylock(in)) {
 			CHANNEL_DEADLOCK_AVOIDANCE(c);
 		}
-		if (ast_strlen_zero(c->redirecting.from.number)) {
+		if (!c->redirecting.from.number.valid
+			|| ast_strlen_zero(c->redirecting.from.number.str)) {
 			/*
 			 * The call was not previously redirected so it is
 			 * now redirected from this number.
 			 */
-			S_REPLACE(c->redirecting.from.number,
-				ast_strdup(S_OR(in->macroexten, in->exten)));
-		}
-
-		c->cid.cid_tns = in->cid.cid_tns;
+			ast_party_number_free(&c->redirecting.from.number);
+			ast_party_number_init(&c->redirecting.from.number);
+			c->redirecting.from.number.valid = 1;
+			c->redirecting.from.number.str =
+				ast_strdup(S_OR(in->macroexten, in->exten));
+		}
+
+		c->dialed.transit_network_select = in->dialed.transit_network_select;
 
 		if (ast_test_flag64(o, OPT_FORCECLID)) {
-			S_REPLACE(c->cid.cid_num, ast_strdup(S_OR(in->macroexten, in->exten)));
-			S_REPLACE(c->cid.cid_name, NULL);
+			ast_party_id_free(&c->caller.id);
+			ast_party_id_init(&c->caller.id);
+			c->caller.id.number.valid = 1;
+			c->caller.id.number.str = ast_strdup(S_OR(in->macroexten, in->exten));
 			ast_string_field_set(c, accountcode, c->accountcode);
 		} else {
-			ast_party_caller_copy(&c->cid, &in->cid);
+			ast_party_caller_copy(&c->caller, &in->caller);
 			ast_string_field_set(c, accountcode, in->accountcode);
 		}
 		ast_party_connected_line_copy(&c->connected, &original->connected);
@@ -897,7 +898,7 @@
 			while (ast_channel_trylock(c)) {
 				CHANNEL_DEADLOCK_AVOIDANCE(in);
 			}
-			ast_channel_update_redirecting(in, &c->redirecting);
+			ast_channel_update_redirecting(in, &c->redirecting, NULL);
 			ast_channel_unlock(c);
 		}
 
@@ -985,10 +986,10 @@
 
 		if (!ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(outgoing, DIAL_CALLERID_ABSENT)) {
 			ast_channel_lock(outgoing->chan);
-			ast_connected_line_copy_from_caller(&connected_caller, &outgoing->chan->cid);
+			ast_connected_line_copy_from_caller(&connected_caller, &outgoing->chan->caller);
 			ast_channel_unlock(outgoing->chan);
 			connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-			ast_channel_update_connected_line(in, &connected_caller);
+			ast_channel_update_connected_line(in, &connected_caller, NULL);
 			ast_party_connected_line_free(&connected_caller);
 		}
 	}
@@ -1045,14 +1046,14 @@
 					if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
 						if (o->pending_connected_update) {
 							if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
-								ast_channel_update_connected_line(in, &o->connected);
+								ast_channel_update_connected_line(in, &o->connected, NULL);
 							}
 						} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
 							ast_channel_lock(c);
-							ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
+							ast_connected_line_copy_from_caller(&connected_caller, &c->caller);
 							ast_channel_unlock(c);
 							connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-							ast_channel_update_connected_line(in, &connected_caller);
+							ast_channel_update_connected_line(in, &connected_caller, NULL);
 							ast_party_connected_line_free(&connected_caller);
 						}
 					}
@@ -1115,14 +1116,14 @@
 						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
 							if (o->pending_connected_update) {
 								if (ast_channel_connected_line_macro(c, in, &o->connected, 1, 0)) {
-									ast_channel_update_connected_line(in, &o->connected);
+									ast_channel_update_connected_line(in, &o->connected, NULL);
 								}
 							} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
 								ast_channel_lock(c);
-								ast_connected_line_copy_from_caller(&connected_caller, &c->cid);
+								ast_connected_line_copy_from_caller(&connected_caller, &c->caller);
 								ast_channel_unlock(c);
 								connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-								ast_channel_update_connected_line(in, &connected_caller);
+								ast_channel_update_connected_line(in, &connected_caller, NULL);
 								ast_party_connected_line_free(&connected_caller);
 							}
 						}
@@ -1240,7 +1241,7 @@
 						ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n", c->name, in->name);
 						ast_party_connected_line_set_init(&connected, &o->connected);
 						ast_connected_line_parse_data(f->data.ptr, f->datalen, &connected);
-						ast_party_connected_line_set(&o->connected, &connected);
+						ast_party_connected_line_set(&o->connected, &connected, NULL);
 						ast_party_connected_line_free(&connected);
 						o->pending_connected_update = 1;
 					} else {
@@ -1617,8 +1618,9 @@
 	char *l;
 	int silencethreshold;
 
-	if (!ast_strlen_zero(chan->cid.cid_num)) {
-		l = ast_strdupa(chan->cid.cid_num);
+	if (chan->caller.id.number.valid
+		&& !ast_strlen_zero(chan->caller.id.number.str)) {
+		l = ast_strdupa(chan->caller.id.number.str);
 		ast_shrink_phone_number(l);
 		if (ast_test_flag64(opts, OPT_PRIVACY) ) {
 			ast_verb(3, "Privacy DB is '%s', clid is '%s'\n", opt_args[OPT_ARG_PRIVACY], l);
@@ -2060,11 +2062,16 @@
 		memset(&tc->whentohangup, 0, sizeof(tc->whentohangup));
 
 		/* If the new channel has no callerid, try to guess what it should be */
-		if (ast_strlen_zero(tc->cid.cid_num)) {
-			if (!ast_strlen_zero(chan->connected.id.number)) {
-				ast_set_callerid(tc, chan->connected.id.number, chan->connected.id.name, chan->connected.ani);
-			} else if (!ast_strlen_zero(chan->cid.cid_dnid)) {
-				ast_set_callerid(tc, chan->cid.cid_dnid, NULL, NULL);
+		if (!tc->caller.id.number.valid) {
+			if (chan->connected.id.number.valid) {
+				struct ast_party_caller caller;
+
+				ast_party_caller_set_init(&caller, &tc->caller);
+				caller.id = chan->connected.id;
+				caller.ani = chan->connected.ani;
+				ast_channel_set_caller_event(tc, &caller, NULL);
+			} else if (!ast_strlen_zero(chan->dialed.number.str)) {
+				ast_set_callerid(tc, chan->dialed.number.str, NULL, NULL);
 			} else if (!ast_strlen_zero(S_OR(chan->macroexten, chan->exten))) {
 				ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), NULL, NULL);
 			}
@@ -2076,25 +2083,33 @@
 			int pres;
 
 			ast_party_connected_line_set_init(&connected, &tmp->chan->connected);
-			connected.id.number = cid_num;
-			connected.id.name = cid_name;
-			connected.id.tag = cid_tag;
 			if (cid_pres) {
 				pres = ast_parse_caller_presentation(cid_pres);
-				if (pres >= 0) {
-					connected.id.number_presentation = pres;
+				if (pres < 0) {
+					pres = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
 				}
 			} else {
-				connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
-			}
-			ast_channel_set_connected_line(tmp->chan, &connected);
+				pres = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+			}
+			if (cid_num) {
+				connected.id.number.valid = 1;
+				connected.id.number.str = cid_num;
+				connected.id.number.presentation = pres;
+			}
+			if (cid_name) {
+				connected.id.name.valid = 1;
+				connected.id.name.str = cid_name;
+				connected.id.name.presentation = pres;
+			}
+			connected.id.tag = cid_tag;
+			ast_channel_set_connected_line(tmp->chan, &connected, NULL);
 		} else {
-			ast_connected_line_copy_from_caller(&tc->connected, &chan->cid);
+			ast_connected_line_copy_from_caller(&tc->connected, &chan->caller);
 		}
 
 		ast_party_redirecting_copy(&tc->redirecting, &chan->redirecting);
 
-		tc->cid.cid_tns = chan->cid.cid_tns;
+		tc->dialed.transit_network_select = chan->dialed.transit_network_select;
 
 		if (!ast_strlen_zero(chan->accountcode)) {
 			ast_string_field_set(tc, peeraccount, chan->accountcode);
@@ -2616,7 +2631,9 @@
 
 		strcpy(peer->context, chan->context);
 
-		if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
+		if (ast_test_flag64(&opts, OPT_PEER_H)
+			&& ast_exists_extension(peer, peer->context, "h", 1,
+				S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL))) {
 			int autoloopflag;
 			int found;
 			int res9;
@@ -2626,8 +2643,12 @@
 			autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
 			ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
 
-			while ((res9 = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found, 1)) == 0)
+			while ((res9 = ast_spawn_extension(peer, peer->context, peer->exten,
+				peer->priority,
+				S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL),
+				&found, 1)) == 0) {
 				peer->priority++;
+			}
 
 			if (found && res9) {
 				/* Something bad happened, or a hangup has been requested. */

Modified: trunk/apps/app_directed_pickup.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_directed_pickup.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_directed_pickup.c (original)
+++ trunk/apps/app_directed_pickup.c Wed Jul 14 10:48:36 2010
@@ -111,15 +111,15 @@
 	ast_party_connected_line_copy(&connected_caller, &target->connected);
 	connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 	if (ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
-		ast_channel_update_connected_line(chan, &connected_caller);
+		ast_channel_update_connected_line(chan, &connected_caller, NULL);
 	}
 	ast_party_connected_line_free(&connected_caller);
 
 	ast_channel_lock(chan);
-	ast_connected_line_copy_from_caller(&connected_caller, &chan->cid);
+	ast_connected_line_copy_from_caller(&connected_caller, &chan->caller);
 	ast_channel_unlock(chan);
 	connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-	ast_channel_queue_connected_line_update(chan, &connected_caller);
+	ast_channel_queue_connected_line_update(chan, &connected_caller, NULL);
 	ast_party_connected_line_free(&connected_caller);
 
 	if ((res = ast_answer(chan))) {

Modified: trunk/apps/app_disa.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_disa.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_disa.c (original)
+++ trunk/apps/app_disa.c Wed Jul 14 10:48:36 2010
@@ -308,9 +308,11 @@
 				}
 			} else {
 				if (j == '#') { /* end of extension .. maybe */
-					if (i == 0 && 
-							(ast_matchmore_extension(chan, args.context, "#", 1, chan->cid.cid_num) ||
-							 ast_exists_extension(chan, args.context, "#", 1, chan->cid.cid_num)) ) {
+					if (i == 0
+						&& (ast_matchmore_extension(chan, args.context, "#", 1,
+							S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
+							|| ast_exists_extension(chan, args.context, "#", 1,
+								S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) ) {
 						/* Let the # be the part of, or the entire extension */
 					} else {
 						break;
@@ -340,7 +342,8 @@
 				}
 
 			/* if can do some more, do it */
-			if (!ast_matchmore_extension(chan,args.context,exten,1, chan->cid.cid_num)) {
+			if (!ast_matchmore_extension(chan, args.context, exten, 1,
+				S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 				break;
 			}
 		}
@@ -352,13 +355,16 @@
 		int recheck = 0;
 		struct ast_flags cdr_flags = { AST_CDR_FLAG_POSTED };
 
-		if (!ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
+		if (!ast_exists_extension(chan, args.context, exten, 1,
+			S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 			pbx_builtin_setvar_helper(chan, "INVALID_EXTEN", exten);
 			exten[0] = 'i';
 			exten[1] = '\0';
 			recheck = 1;
 		}
-		if (!recheck || ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
+		if (!recheck
+			|| ast_exists_extension(chan, args.context, exten, 1,
+				S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 			ast_playtones_stop(chan);
 			/* We're authenticated and have a target extension */
 			if (!ast_strlen_zero(args.cid)) {

Modified: trunk/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_dumpchan.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_dumpchan.c (original)
+++ trunk/apps/app_dumpchan.c Wed Jul 14 10:48:36 2010
@@ -116,10 +116,10 @@
 			c->name,
 			c->tech->type,
 			c->uniqueid,
-			S_OR(c->cid.cid_num, "(N/A)"),
-			S_OR(c->cid.cid_name, "(N/A)"),
-			S_OR(c->cid.cid_dnid, "(N/A)"),
-			S_OR(c->redirecting.from.number, "(N/A)"),
+			S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
+			S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
+			S_OR(c->dialed.number.str, "(N/A)"),
+			S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
 			c->parkinglot,
 			c->language,
 			ast_state2str(c->_state),

Modified: trunk/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_fax.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_fax.c (original)
+++ trunk/apps/app_fax.c Wed Jul 14 10:48:36 2010
@@ -251,25 +251,25 @@
 	ast_debug(1, "  Transfer Rate:     %d\n", stat.bit_rate);
 	
 	ast_manager_event(s->chan, EVENT_FLAG_CALL,
-		      s->direction ? "FaxSent" : "FaxReceived", 
-		      "Channel: %s\r\n"
-		      "Exten: %s\r\n"
-		      "CallerID: %s\r\n"
-		      "RemoteStationID: %s\r\n"
-		      "LocalStationID: %s\r\n"
-		      "PagesTransferred: %d\r\n"
-		      "Resolution: %d\r\n"
-		      "TransferRate: %d\r\n"
-		      "FileName: %s\r\n",
-		      s->chan->name,
-		      s->chan->exten,
-		      S_OR(s->chan->cid.cid_num, ""),
-		      far_ident,
-		      local_ident,
-		      pages_transferred,
-		      stat.y_resolution,
-		      stat.bit_rate,
-		      s->file_name);
+		s->direction ? "FaxSent" : "FaxReceived",
+		"Channel: %s\r\n"
+		"Exten: %s\r\n"
+		"CallerID: %s\r\n"
+		"RemoteStationID: %s\r\n"
+		"LocalStationID: %s\r\n"
+		"PagesTransferred: %d\r\n"
+		"Resolution: %d\r\n"
+		"TransferRate: %d\r\n"
+		"FileName: %s\r\n",
+		s->chan->name,
+		s->chan->exten,
+		S_COR(s->chan->caller.id.number.valid, s->chan->caller.id.number.str, ""),
+		far_ident,
+		local_ident,
+		pages_transferred,
+		stat.y_resolution,
+		stat.bit_rate,
+		s->file_name);
 }
 
 /* === Helper functions to configure fax === */

Modified: trunk/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_followme.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Wed Jul 14 10:48:36 2010
@@ -838,7 +838,10 @@
 
 			outbound = ast_request("Local", ast_best_codec(caller->nativeformats), caller, dialarg, &dg);
 			if (outbound) {
-				ast_set_callerid(outbound, caller->cid.cid_num, caller->cid.cid_name, caller->cid.cid_num);
+				ast_set_callerid(outbound,
+					S_COR(caller->caller.id.number.valid, caller->caller.id.number.str, NULL),
+					S_COR(caller->caller.id.name.valid, caller->caller.id.name.str, NULL),
+					S_COR(caller->caller.id.number.valid, caller->caller.id.number.str, NULL));
 				ast_channel_inherit_variables(tpargs->chan, outbound);
 				ast_channel_datastore_inherit(tpargs->chan, outbound);
 				ast_string_field_set(outbound, language, tpargs->chan->language);

Modified: trunk/apps/app_macro.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_macro.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_macro.c (original)
+++ trunk/apps/app_macro.c Wed Jul 14 10:48:36 2010
@@ -298,7 +298,8 @@
 	}
 
 	snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro);
-	if (!ast_exists_extension(chan, fullmacro, "s", 1, chan->cid.cid_num)) {
+	if (!ast_exists_extension(chan, fullmacro, "s", 1,
+		S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 		if (!ast_context_find(fullmacro)) 
 			ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
 		else
@@ -370,7 +371,8 @@
 	ast_channel_unlock(chan);
 	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
 	ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
-	while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+	while (ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+		S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 		struct ast_context *c;
 		struct ast_exten *e;
 		int foundx;
@@ -386,7 +388,8 @@
 					if (ast_rdlock_context(c)) {
 						ast_log(LOG_WARNING, "Unable to lock context?\n");
 					} else {
-						e = find_matching_priority(c, chan->exten, chan->priority, chan->cid.cid_num);
+						e = find_matching_priority(c, chan->exten, chan->priority,
+							S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
 						if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */
 							ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
 							ast_copy_string(runningdata, ast_get_extension_app_data(e), sizeof(runningdata));
@@ -402,7 +405,10 @@
 		/* Reset the macro depth, if it was changed in the last iteration */
 		pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
 
-		if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num, &foundx,1))) {
+		res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority,
+			S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
+			&foundx, 1);
+		if (res) {
 			/* Something bad happened, or a hangup has been requested. */
 			if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
 		    	(res == '*') || (res == '#')) {
@@ -544,7 +550,9 @@
 				/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
 			   	normally if there is any problem */
 				if (sscanf(offsets, "%30d", &offset) == 1) {
-					if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->cid.cid_num)) {
+					if (ast_exists_extension(chan, chan->context, chan->exten,
+						chan->priority + offset + 1,
+						S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
 						chan->priority += offset;
 					}
 				}

Modified: trunk/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_meetme.c?view=diff&rev=276347&r1=276346&r2=276347
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Wed Jul 14 10:48:36 2010
@@ -1453,8 +1453,8 @@
 			if (!concise) {
 				ast_cli(a->fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s %s %02d:%02d:%02d\n",
 					user->user_no,
-					S_OR(user->chan->cid.cid_num, "<unknown>"),
-					S_OR(user->chan->cid.cid_name, "<no name>"),
+					S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+					S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"),
 					user->chan->name,
 					ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "(Admin)" : "",
 					ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "(Listen only)" : "",
@@ -1464,8 +1464,8 @@
 			} else {
 				ast_cli(a->fd, "%d!%s!%s!%s!%s!%s!%s!%s!%d!%02d:%02d:%02d\n",
 					user->user_no,
-					S_OR(user->chan->cid.cid_num, ""),
-					S_OR(user->chan->cid.cid_name, ""),
+					S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, ""),
+					S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, ""),
 					user->chan->name,
 					ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "1" : "",
 					ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "1" : "",
@@ -2660,17 +2660,17 @@
 
 	if (!sent_event) {
 		ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeJoin",
-			        "Channel: %s\r\n"
-			        "Uniqueid: %s\r\n"
-				"Meetme: %s\r\n"
-				"Usernum: %d\r\n"
-				"CallerIDnum: %s\r\n"
-			      	"CallerIDname: %s\r\n",
-			      	chan->name, chan->uniqueid, conf->confno, 
-				user->user_no,
-				S_OR(user->chan->cid.cid_num, "<unknown>"),
-				S_OR(user->chan->cid.cid_name, "<unknown>")
-				);
+			"Channel: %s\r\n"
+			"Uniqueid: %s\r\n"
+			"Meetme: %s\r\n"
+			"Usernum: %d\r\n"
+			"CallerIDnum: %s\r\n"
+			"CallerIDname: %s\r\n",
+			chan->name, chan->uniqueid, conf->confno,
+			user->user_no,
+			S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+			S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>")
+			);
 		sent_event = 1;
 	}
 
@@ -3697,18 +3697,18 @@
 
 		if (sent_event) {
 			ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
-				      "Channel: %s\r\n"
-				      "Uniqueid: %s\r\n"
-				      "Meetme: %s\r\n"
-				      "Usernum: %d\r\n"
-				      "CallerIDNum: %s\r\n"
-				      "CallerIDName: %s\r\n"
-				      "Duration: %ld\r\n",
-				      chan->name, chan->uniqueid, conf->confno, 
-				      user->user_no,
-				      S_OR(user->chan->cid.cid_num, "<unknown>"),
-				      S_OR(user->chan->cid.cid_name, "<unknown>"),
-				      (long)(now.tv_sec - user->jointime));
+				"Channel: %s\r\n"
+				"Uniqueid: %s\r\n"
+				"Meetme: %s\r\n"
+				"Usernum: %d\r\n"
+				"CallerIDNum: %s\r\n"
+				"CallerIDName: %s\r\n"
+				"Duration: %ld\r\n",
+				chan->name, chan->uniqueid, conf->confno,
+				user->user_no,
+				S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+				S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
+				(long)(now.tv_sec - user->jointime));
 		}
 
 		if (setusercount) {
@@ -4706,30 +4706,30 @@
 		while ((user = ao2_iterator_next(&user_iter))) {
 			total++;
 			astman_append(s,
-			"Event: MeetmeList\r\n"
-			"%s"
-			"Conference: %s\r\n"
-			"UserNumber: %d\r\n"
-			"CallerIDNum: %s\r\n"
-			"CallerIDName: %s\r\n"
-			"Channel: %s\r\n"
-			"Admin: %s\r\n"
-			"Role: %s\r\n"
-			"MarkedUser: %s\r\n"
-			"Muted: %s\r\n"
-			"Talking: %s\r\n"
-			"\r\n",
-			idText,
-			cnf->confno,
-			user->user_no,
-			S_OR(user->chan->cid.cid_num, "<unknown>"),
-			S_OR(user->chan->cid.cid_name, "<no name>"),
-			user->chan->name,
-			ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No",
-			ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen",
-			ast_test_flag64(&user->userflags, CONFFLAG_MARKEDUSER) ? "Yes" : "No",
-			user->adminflags & ADMINFLAG_MUTED ? "By admin" : user->adminflags & ADMINFLAG_SELFMUTED ? "By self" : "No",
-			user->talking > 0 ? "Yes" : user->talking == 0 ? "No" : "Not monitored"); 
+				"Event: MeetmeList\r\n"
+				"%s"
+				"Conference: %s\r\n"
+				"UserNumber: %d\r\n"
+				"CallerIDNum: %s\r\n"
+				"CallerIDName: %s\r\n"
+				"Channel: %s\r\n"
+				"Admin: %s\r\n"
+				"Role: %s\r\n"
+				"MarkedUser: %s\r\n"
+				"Muted: %s\r\n"
+				"Talking: %s\r\n"
+				"\r\n",
+				idText,
+				cnf->confno,
+				user->user_no,
+				S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+				S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"),
+				user->chan->name,
+				ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No",
+				ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen",
+				ast_test_flag64(&user->userflags, CONFFLAG_MARKEDUSER) ? "Yes" : "No",
+				user->adminflags & ADMINFLAG_MUTED ? "By admin" : user->adminflags & ADMINFLAG_SELFMUTED ? "By self" : "No",
+				user->talking > 0 ? "Yes" : user->talking == 0 ? "No" : "Not monitored");
 			ao2_ref(user, -1);
 		}
 		ao2_iterator_destroy(&user_iter);
@@ -5335,8 +5335,9 @@
 	char *tech, *tech_data;
 	struct ast_dial *dial;
 	struct sla_ringing_station *ringing_station;
-	const char *cid_name = NULL, *cid_num = NULL;
 	enum ast_dial_result res;
+	int caller_is_saved;
+	struct ast_party_caller caller;
 
 	if (!(dial = ast_dial_create()))
 		return -1;
@@ -5350,23 +5351,21 @@
 		return -1;
 	}
 

[... 10807 lines stripped ...]



More information about the asterisk-commits mailing list