[asterisk-commits] rmudgett: branch group/issue8824 r142739 - in /team/group/issue8824: apps/ ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 12 10:47:55 CDT 2008


Author: rmudgett
Date: Fri Sep 12 10:47:54 2008
New Revision: 142739

URL: http://svn.digium.com/view/asterisk?view=rev&rev=142739
Log:
Connected Line API change

Modified:
    team/group/issue8824/apps/app_dial.c
    team/group/issue8824/apps/app_queue.c
    team/group/issue8824/channels/chan_agent.c
    team/group/issue8824/channels/chan_iax2.c
    team/group/issue8824/channels/chan_misdn.c
    team/group/issue8824/channels/chan_sip.c
    team/group/issue8824/funcs/func_connectedline.c
    team/group/issue8824/include/asterisk/channel.h
    team/group/issue8824/main/channel.c
    team/group/issue8824/main/features.c

Modified: team/group/issue8824/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_dial.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/apps/app_dial.c (original)
+++ team/group/issue8824/apps/app_dial.c Fri Sep 12 10:47:54 2008
@@ -555,7 +555,7 @@
 #ifdef HAVE_EPOLL
 	struct chanlist *epollo;
 #endif
-	struct ast_party_id caller_id;
+	struct ast_party_connected_line connected_caller;
 
 	if (single) {
 		/* Turn off hold music, etc */
@@ -566,8 +566,9 @@
 		ast_channel_make_compatible(outgoing->chan, in);
 
 		if (!ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(outgoing, DIAL_NOCONNECTEDLINE)) {
-			ast_party_id_collect_caller_id(&caller_id, &outgoing->chan->cid);
-			ast_connected_line_update(in, &caller_id, 0 /*! \todo XXX Need an answer value to put here */);
+			ast_party_connected_line_collect_caller(&connected_caller, &outgoing->chan->cid);
+			connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+			ast_connected_line_update(in, &connected_caller);
 		}
 	}
 
@@ -616,8 +617,9 @@
 				if (!peer) {
 					ast_verb(3, "%s answered %s\n", c->name, in->name);
 					if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
-						ast_party_id_collect_caller_id(&caller_id, &c->cid);
-						ast_connected_line_update(in, &caller_id,  0 /*! \todo XXX Need an answer value to put here */);
+						ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
+						connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+						ast_connected_line_update(in, &connected_caller);
 					}
 					peer = c;
 					ast_copy_flags64(peerflags, o,
@@ -658,8 +660,9 @@
 					if (!peer) {
 						ast_verb(3, "%s answered %s\n", c->name, in->name);
 						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
-							ast_party_id_collect_caller_id(&caller_id, &c->cid);
-							ast_connected_line_update(in, &caller_id,  0 /*! \todo XXX Need an answer value to put here */);
+							ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
+							connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+							ast_connected_line_update(in, &connected_caller);
 						}
 						peer = c;
 						if (peer->cdr) {
@@ -1516,13 +1519,13 @@
 		}
 
 		if (ast_test_flag64(peerflags, OPT_FORCE_CALLERID)) {
-			struct ast_party_id line_id;
-
-			ast_party_id_set_init(&line_id, &tc->connected.id);
-			line_id.number = cid_num;
-			line_id.name = cid_name;
-			line_id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
-			ast_set_connected_line(tc, &line_id, tc->connected.source);
+			struct ast_party_connected_line connected;
+
+			ast_party_connected_line_set_init(&connected, &tc->connected);
+			connected.id.number = cid_num;
+			connected.id.name = cid_name;
+			connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+			ast_set_connected_line(tc, &connected);
 		}
 		else {
 			S_REPLACE(tc->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));

Modified: team/group/issue8824/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/apps/app_queue.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/apps/app_queue.c (original)
+++ team/group/issue8824/apps/app_queue.c Fri Sep 12 10:47:54 2008
@@ -2399,7 +2399,7 @@
 #ifdef HAVE_EPOLL
 	struct callattempt *epollo;
 #endif
-	struct ast_party_id caller_id;
+	struct ast_party_connected_line connected_caller;
 
 	starttime = (long) time(NULL);
 #ifdef HAVE_EPOLL
@@ -2454,8 +2454,9 @@
 				if (!peer) {
 					ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
 					if (update_connectedline && o->update_connectedline) {
-						ast_party_id_collect_caller_id(&caller_id, &o->chan->cid);
-						ast_connected_line_update(in, &caller_id, 0 /*! \todo XXX Need an answer value to put here */);
+						ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
+						connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+						ast_connected_line_update(in, &connected_caller);
 					}
 					peer = o;
 				}
@@ -2524,8 +2525,9 @@
 							if (!peer) {
 								ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
 								if (update_connectedline && o->update_connectedline) {
-									ast_party_id_collect_caller_id(&caller_id, &o->chan->cid);
-									ast_connected_line_update(in, &caller_id, 0 /*! \todo XXX Need an answer value to put here */);
+									ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
+									connected_caller.source = 0;	/*! \todo XXX Need an answer value to put here */
+									ast_connected_line_update(in, &connected_caller);
 								}
 								peer = o;
 							}

Modified: team/group/issue8824/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_agent.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/channels/chan_agent.c (original)
+++ team/group/issue8824/channels/chan_agent.c Fri Sep 12 10:47:54 2008
@@ -709,7 +709,7 @@
 		time(&p->start);
 		/* Call on this agent */
 		ast_verb(3, "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
-		ast_set_connected_line(p->chan, &ast->connected.id, ast->connected.source);
+		ast_set_connected_line(p->chan, &ast->connected);
 		ast_channel_inherit_variables(ast, p->chan);
 		res = ast_call(p->chan, p->loginchan, 0);
 		CLEANUP(ast,p);

Modified: team/group/issue8824/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_iax2.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/channels/chan_iax2.c (original)
+++ team/group/issue8824/channels/chan_iax2.c Fri Sep 12 10:47:54 2008
@@ -9618,7 +9618,7 @@
 	}
 	/* Don't allow connected line updates unless we are configured to */
 	if (f.frametype == AST_FRAME_CONTROL && f.subclass == AST_CONTROL_CONNECTED_LINE) {
-		struct ast_party_id line_id;
+		struct ast_party_connected_line connected;
 
 		if (!ast_test_flag(iaxs[fr->callno], IAX_RECVCONNECTEDLINE)) {
 			ast_mutex_unlock(&iaxsl[fr->callno]);
@@ -9626,20 +9626,20 @@
 		}
 
 		/* Initialize defaults */
-		ast_party_id_init(&line_id);
-		line_id.number_presentation = iaxs[fr->callno]->calling_pres;
-
-		if (!ast_parse_connected_line_data(f.data.ptr, f.datalen, &line_id, NULL)) {
-			ast_string_field_set(iaxs[fr->callno], cid_num, line_id.number);
-			ast_string_field_set(iaxs[fr->callno], cid_name, line_id.name);
-			iaxs[fr->callno]->calling_pres = line_id.number_presentation;
+		ast_party_connected_line_init(&connected);
+		connected.id.number_presentation = iaxs[fr->callno]->calling_pres;
+
+		if (!ast_parse_connected_line_data(f.data.ptr, f.datalen, &connected)) {
+			ast_string_field_set(iaxs[fr->callno], cid_num, connected.id.number);
+			ast_string_field_set(iaxs[fr->callno], cid_name, connected.id.name);
+			iaxs[fr->callno]->calling_pres = connected.id.number_presentation;
 
 			if (iaxs[fr->callno]->owner) {
-				ast_set_callerid(iaxs[fr->callno]->owner, S_OR(line_id.number, ""), S_OR(line_id.name, ""), NULL);
-				iaxs[fr->callno]->owner->cid.cid_pres = line_id.number_presentation;
+				ast_set_callerid(iaxs[fr->callno]->owner, S_OR(connected.id.number, ""), S_OR(connected.id.name, ""), NULL);
+				iaxs[fr->callno]->owner->cid.cid_pres = connected.id.number_presentation;
 			}
 		}
-		ast_party_id_free(&line_id);
+		ast_party_connected_line_free(&connected);
 	}
 	/* Common things */
 	f.src = "IAX2";

Modified: team/group/issue8824/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_misdn.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Fri Sep 12 10:47:54 2008
@@ -5280,15 +5280,16 @@
 				bridged_ch->bc->connected = bc->connected;
 			}
 		} else {
-			struct ast_party_id line_id;
-
-			ast_party_id_init(&line_id);
-			line_id.number = bc->connected.number;
-			line_id.number_type = misdn_ton_to_ast_ton(bc->connected.number_type)
+			struct ast_party_connected_line connected;
+
+			ast_party_connected_line_init(&connected);
+			connected.id.number = bc->connected.number;
+			connected.id.number_type = misdn_ton_to_ast_ton(bc->connected.number_type)
 				| misdn_plan_to_ast_plan(bc->connected.number_plan);
-			line_id.number_presentation = misdn_pres_to_ast_pres(bc->connected.presentation)
+			connected.id.number_presentation = misdn_pres_to_ast_pres(bc->connected.presentation)
 				| misdn_screen_to_ast_screen(bc->connected.screening);
-			ast_queue_connected_line_update(ch->ast, &line_id, 0 /*! \todo XXX Need an answer value to put here */);
+			connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+			ast_queue_connected_line_update(ch->ast, &connected);
 		}
 	
 		ch->l3id=bc->l3_id;

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Fri Sep 12 10:47:54 2008
@@ -15244,7 +15244,7 @@
 	struct ast_channel *bridgepeer = NULL;
 	char *p_hdrval;
 	int rtn;
-	struct ast_party_id line_id;
+	struct ast_party_connected_line connected;
 
 	if (reinvite)
 		ast_debug(4, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
@@ -15292,11 +15292,12 @@
 			ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
 		if (!req->ignore && p->owner) {
 			if (get_rpid(p, req)) {
-				ast_party_id_init(&line_id);
-				line_id.number = (char *) p->cid_num;
-				line_id.name = (char *) p->cid_name;
-				line_id.number_presentation = p->callingpres;
-				ast_queue_connected_line_update(p->owner, &line_id, 0 /*! \todo XXX Need an answer value to put here */);
+				ast_party_connected_line_init(&connected);
+				connected.id.number = (char *) p->cid_num;
+				connected.id.name = (char *) p->cid_name;
+				connected.id.number_presentation = p->callingpres;
+				connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+				ast_queue_connected_line_update(p->owner, &connected);
 			}
 			ast_queue_control(p->owner, AST_CONTROL_RINGING);
 			if (p->owner->_state != AST_STATE_UP) {
@@ -15322,11 +15323,12 @@
 		if (!req->ignore && p->owner) {
 			if (get_rpid(p, req)) {
 				/* Queue a connected line update */
-				ast_party_id_init(&line_id);
-				line_id.number = (char *) p->cid_num;
-				line_id.name = (char *) p->cid_name;
-				line_id.number_presentation = p->callingpres;
-				ast_queue_connected_line_update(p->owner, &line_id, 0 /*! \todo XXX Need an answer value to put here */);
+				ast_party_connected_line_init(&connected);
+				connected.id.number = (char *) p->cid_num;
+				connected.id.name = (char *) p->cid_name;
+				connected.id.number_presentation = p->callingpres;
+				connected.source = 0;	/*! \todo XXX Need an answer value to put here */
+				ast_queue_connected_line_update(p->owner, &connected);
 			}
 		}
 		if (find_sdp(req)) {
@@ -17174,8 +17176,9 @@
 }
 
 
-/*! \brief Handle incoming INVITE request
-\note 	If the INVITE has a Replaces header, it is part of an
+/*!
+ * \brief Handle incoming INVITE request
+ * \note If the INVITE has a Replaces header, it is part of an
  *	attended transfer. If so, we do not go through the dial
  *	plan but try to find the active call and masquerade
  *	into it 
@@ -17413,13 +17416,14 @@
 		} else {	/* Re-invite on existing call */
 			ast_clear_flag(&p->flags[0], SIP_OUTGOING);	/* This is now an inbound dialog */
 			if (get_rpid(p, req)) {
-				struct ast_party_id line_id;
-
-				ast_party_id_init(&line_id);
-				line_id.number = (char *) p->cid_num;
-				line_id.name = (char *) p->cid_name;
-				line_id.number_presentation = p->callingpres;
-				ast_queue_connected_line_update(p->owner, &line_id, 0 /*! \todo XXX Need a transfer value to put here */);
+				struct ast_party_connected_line connected;
+
+				ast_party_connected_line_init(&connected);
+				connected.id.number = (char *) p->cid_num;
+				connected.id.name = (char *) p->cid_name;
+				connected.id.number_presentation = p->callingpres;
+				connected.source = 0;	/*! \todo XXX Need a transfer value to put here */
+				ast_queue_connected_line_update(p->owner, &connected);
 			}
 			/* Handle SDP here if we already have an owner */
 			if (find_sdp(req)) {
@@ -17953,7 +17957,7 @@
 		else
 			ast_clear_flag(&transferer->flags[0], SIP_DEFER_BYE_ON_TRANSFER);
 	} else {
-		struct ast_party_id caller_id;
+		struct ast_party_connected_line connected_caller;
 
 		/* Transfer succeeded! */
 
@@ -17968,15 +17972,19 @@
 
 		if (target.chan2) {
 			/* Tell each of the other channels to whom they are now connected */
-			ast_party_id_collect_caller_id(&caller_id, &current->chan2->cid);
-			ast_connected_line_update(target.chan2, &caller_id,  0 /*! \todo XXX Need a transfer value to put here */);
-			ast_party_id_collect_caller_id(&caller_id, &target.chan2->cid);
-			ast_connected_line_update(current->chan2, &caller_id,  0 /*! \todo XXX Need a transfer value to put here */);
+			ast_party_connected_line_collect_caller(&connected_caller, &current->chan2->cid);
+			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			ast_connected_line_update(target.chan2, &connected_caller);
+			ast_party_connected_line_collect_caller(&connected_caller, &target.chan2->cid);
+			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			ast_connected_line_update(current->chan2, &connected_caller);
 		} else {
 			/* Notify the first other party that they are connected to someone else assuming that target.chan1
 			   has progressed far enough through the dialplan to have it's called party information set. */ 
 			if (current->chan2) {
-				ast_connected_line_update(current->chan2, &target.chan1->connected.id, target.chan1->connected.source /*! \todo XXX Need a transfer value to put here */);
+				/*! \todo XXX Need a transfer value to put here (maybe) */
+				//target.chan1->connected.source = 0;
+				ast_connected_line_update(current->chan2, &target.chan1->connected);
 			}
 
 			/* We can't indicate to the called channel directly so we force the masquerade to complete
@@ -17985,8 +17993,9 @@
 			ast_do_masquerade(target.chan1);
 			ast_channel_unlock(target.chan1);
 
-			ast_party_id_collect_caller_id(&caller_id, &target.chan1->cid);
-			ast_queue_connected_line_update(target.chan1, &caller_id,  0 /*! \todo XXX Need a transfer value to put here */);
+			ast_party_connected_line_collect_caller(&connected_caller, &target.chan1->cid);
+			connected_caller.source = 0;	/*! \todo XXX Need a transfer value to put here */
+			ast_queue_connected_line_update(target.chan1, &connected_caller);
 		}
 	}
 	if (targetcall_pvt)

Modified: team/group/issue8824/funcs/func_connectedline.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/funcs/func_connectedline.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/funcs/func_connectedline.c (original)
+++ team/group/issue8824/funcs/func_connectedline.c Fri Sep 12 10:47:54 2008
@@ -82,8 +82,7 @@
 static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data,
 			       const char *value)
 {
-	struct ast_party_id line_id;
-	int source;
+	struct ast_party_connected_line connected;
 	char *val;
 
 	if (!value || !chan) {
@@ -91,8 +90,7 @@
 	}
 
 	ast_channel_lock(chan);
-	ast_party_id_set_init(&line_id, &chan->connected.id);
-	source = chan->connected.source;
+	ast_party_connected_line_set_init(&connected, &chan->connected);
 	ast_channel_unlock(chan);
 
 	value = ast_skip_blanks(value);
@@ -102,24 +100,24 @@
 		char num[256];
 
 		ast_callerid_split(value, name, sizeof(name), num, sizeof(num));
-		line_id.name = name;
-		line_id.number = num;
-		ast_connected_line_update(chan, &line_id, source);
+		connected.id.name = name;
+		connected.id.number = num;
+		ast_connected_line_update(chan, &connected);
 	} else if (!strncasecmp("name", data, 4)) {
-		line_id.name = ast_strdupa(value);
-		ast_trim_blanks(line_id.name);
-		ast_connected_line_update(chan, &line_id, source);
+		connected.id.name = ast_strdupa(value);
+		ast_trim_blanks(connected.id.name);
+		ast_connected_line_update(chan, &connected);
 	} else if (!strncasecmp("num", data, 3)) { 
-		line_id.number = ast_strdupa(value);
-		ast_trim_blanks(line_id.number);
-		ast_connected_line_update(chan, &line_id, source);
+		connected.id.number = ast_strdupa(value);
+		ast_trim_blanks(connected.id.number);
+		ast_connected_line_update(chan, &connected);
 	} else if (!strncasecmp("ton", data, 3)) {
 		val = ast_strdupa(value);
 		ast_trim_blanks(val);
 
 		if (('0' <= val[0]) && (val[0] <= '9')) {
-			line_id.number_type = atoi(val);
-			ast_connected_line_update(chan, &line_id, source);
+			connected.id.number_type = atoi(val);
+			ast_connected_line_update(chan, &connected);
 		} else {
 			ast_log(LOG_ERROR, "Unknown connectedline type of number '%s', value unchanged\n", val);
 		}
@@ -138,16 +136,16 @@
 		if (pres < 0) {
 			ast_log(LOG_ERROR, "Unknown connectedline number presentation '%s', value unchanged\n", val);
 		} else {
-			line_id.number_presentation = pres;
-			ast_connected_line_update(chan, &line_id, source);
+			connected.id.number_presentation = pres;
+			ast_connected_line_update(chan, &connected);
 		}
 	} else if (!strncasecmp("source", data, 6)) {
 		val = ast_strdupa(value);
 		ast_trim_blanks(val);
 
 		if (('0' <= val[0]) && (val[0] <= '9')) {
-			source = atoi(val);
-			ast_connected_line_update(chan, &line_id, source);
+			connected.source = atoi(val);
+			ast_connected_line_update(chan, &connected);
 		} else {
 			ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
 		}

Modified: team/group/issue8824/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/include/asterisk/channel.h?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/include/asterisk/channel.h (original)
+++ team/group/issue8824/include/asterisk/channel.h Fri Sep 12 10:47:54 2008
@@ -1796,14 +1796,14 @@
 };
 
 
-void ast_party_id_init(struct ast_party_id *init);
-void ast_party_id_collect_caller_id(struct ast_party_id *id, struct ast_callerid *cid);
-void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src);
-void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide);
-void ast_party_id_free(struct ast_party_id *doomed);
-
 void ast_party_caller_copy(struct ast_callerid *dest, const struct ast_callerid *src);
+
+void ast_party_connected_line_init(struct ast_party_connected_line *init);
 void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
+void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide);
+void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_callerid *cid);
+void ast_party_connected_line_free(struct ast_party_connected_line *doomed);
+
 void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src);
 void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide);
 void ast_party_redirecting_free(struct ast_party_redirecting *doomed);
@@ -1816,22 +1816,22 @@
  *
  * \note The channel does not need to be locked before calling this function.
  */
-void ast_set_connected_line(struct ast_channel *chan, const struct ast_party_id *id, int source);
+void ast_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected);
 
 /*!
  * \brief Parse connected line indication frame data
  */
-int ast_parse_connected_line_data(const unsigned char *data, size_t datalen, struct ast_party_id *id, int *source);
+int ast_parse_connected_line_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected);
 
 /*!
  * \brief Indicate that the connected line has changed
  */
-void ast_connected_line_update(struct ast_channel *chan, const struct ast_party_id *id, int source);
+void ast_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected);
 
 /*!
  * \brief Queue a connected line update frame on a channel
  */
-void ast_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_id *id, int source);
+void ast_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected);
 
 /*!
  * \brief Set the redirecting id information in the Asterisk channel

Modified: team/group/issue8824/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/main/channel.c?view=diff&rev=142739&r1=142738&r2=142739
==============================================================================
--- team/group/issue8824/main/channel.c (original)
+++ team/group/issue8824/main/channel.c Fri Sep 12 10:47:54 2008
@@ -1274,13 +1274,14 @@
 
 /* ******************************************************************* */
 /*!
+ * \internal
  * \brief Initialize the given party id structure.
  *
  * \param init Party id structure to initialize.
  *
  * \return Nothing
  */
-void ast_party_id_init(struct ast_party_id *init)
+static void ast_party_id_init(struct ast_party_id *init)
 {
 	init->number = NULL;
 	init->name = NULL;
@@ -1293,32 +1294,7 @@
 
 /* ******************************************************************* */
 /*!
- * \brief Collect the caller id party information from the given Asterisk channel.
- *
- * \param id Fill in the caller id party information
- * \param cid Asterisk channel caller id information.
- * 
- * \return Nothing
- * 
- * \warning This is a shallow copy.
- * \warning DO NOT call ast_party_id_free() on the filled in id structure!
- * 
- * \todo XXX This function will not be needed when the struct ast_channel.cid
- * element is deleted.
- */
-void ast_party_id_collect_caller_id(struct ast_party_id *id, struct ast_callerid *cid)
-{
-	id->number = cid->cid_num;
-	id->name = cid->cid_name;
-	id->number_type = cid->cid_ton;
-	id->number_presentation = cid->cid_pres;
-}	/* end ast_party_id_collect_caller_id() */
-
-
-
-
-/* ******************************************************************* */
-/*!
+ * \internal 
  * \brief Copy the source party id information to the destination party id.
  *
  * \param dest Destination party id
@@ -1326,7 +1302,7 @@
  *
  * \return Nothing
  */
-void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
+static void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
 {
 	if (dest == src) {
 		/* Don't copy to self */
@@ -1352,6 +1328,7 @@
 
 /* ******************************************************************* */
 /*!
+ * \internal
  * \brief Initialize the given party id structure using the given guide
  * for a set update operation.
  *
@@ -1367,7 +1344,7 @@
  *
  * \return Nothing
  */
-void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
+static void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
 {
 	init->number = NULL;
 	init->name = NULL;
@@ -1418,13 +1395,14 @@
 
 /* ******************************************************************* */
 /*!
+ * \internal
  * \brief Destroy the party id contents
  *
  * \param doomed The party id to destroy.
  *
  * \return Nothing
  */
-void ast_party_id_free(struct ast_party_id *doomed)
+static void ast_party_id_free(struct ast_party_id *doomed)
 {
 	if (doomed->number) {
 		ast_free(doomed->number);
@@ -1502,6 +1480,25 @@
 
 /* ******************************************************************* */
 /*!
+ * \brief Initialize the given connected line structure.
+ *
+ * \param init Connected line structure to initialize.
+ *
+ * \return Nothing
+ */
+void ast_party_connected_line_init(struct ast_party_connected_line *init)
+{
+	ast_party_id_init(&init->id);
+	init->ani = NULL;
+	init->ani2 = 0;
+	init->source = 0;	/*! \todo XXX Need an unknown value to put here */
+}	/* end ast_party_connected_line_init() */
+
+
+
+
+/* ******************************************************************* */
+/*!
  * \brief Copy the source connected line information to the destination connected line.
  *
  * \param dest Destination connected line
@@ -1532,14 +1529,69 @@
 
 /* ******************************************************************* */
 /*!
- * \internal
- * \brief Destroy the connected line information contents
- *
- * \param doomed The connected line information to destroy.
+ * \brief Initialize the given connected line structure using the given
+ * guide for a set update operation.
+ *
+ * \details
+ * The initialization is needed to allow a set operation to know if a
+ * value needs to be updated.  Simple integers need the guide's original
+ * value in case the set operation is not trying to set a new value.
+ * String values are simply set to NULL pointers if they are not going
+ * to be updated.
+ *
+ * \param init Connected line structure to initialize.
+ * \param guide Source connected line to use as a guide in initializing.
  *
  * \return Nothing
  */
-static void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
+void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
+{
+	ast_party_id_set_init(&init->id, &guide->id);
+	init->ani = NULL;
+	init->ani2 = guide->ani2;
+	init->source = guide->source;
+}	/* end ast_party_connected_line_set_init() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \brief Collect the caller party information into a connected line structure.
+ * 
+ * \param connected Collected caller information for the connected line
+ * \param cid Caller information.
+ * 
+ * \return Nothing
+ * 
+ * \warning This is a shallow copy.
+ * \warning DO NOT call ast_party_connected_line_free() on the filled in
+ * connected line structure!
+ */
+void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_callerid *cid)
+{
+	connected->id.number = cid->cid_num;
+	connected->id.name = cid->cid_name;
+	connected->id.number_type = cid->cid_ton;
+	connected->id.number_presentation = cid->cid_pres;
+
+	connected->ani = cid->cid_ani;
+	connected->ani2 = cid->cid_ani2;
+	connected->source = 0;	/*! \todo XXX Need an unknown value to put here */
+}	/* end ast_party_connected_line_collect_caller() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \brief Destroy the connected line information contents
+ *
+ * \param doomed The connected line information to destroy.
+ *
+ * \return Nothing
+ */
+void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
 {
 	ast_party_id_free(&doomed->id);
 
@@ -3155,15 +3207,14 @@
 	switch (condition) {
 	case AST_CONTROL_CONNECTED_LINE:
 		{
-			struct ast_party_id line_id;
-			int source;
-
-			ast_party_id_set_init(&line_id, &chan->connected.id);
-			res = ast_parse_connected_line_data(data, datalen, &line_id, &source);
+			struct ast_party_connected_line connected;
+
+			ast_party_connected_line_set_init(&connected, &chan->connected);
+			res = ast_parse_connected_line_data(data, datalen, &connected);
 			if (!res) {
-				ast_set_connected_line(chan, &line_id, source);
-			}
-			ast_party_id_free(&line_id);
+				ast_set_connected_line(chan, &connected);
+			}
+			ast_party_connected_line_free(&connected);
 		}
 		break;
 
@@ -3679,7 +3730,7 @@
 	struct ast_channel *chan;
 	int res = 0;
 	int last_subclass = 0;
-	struct ast_party_id line_id;
+	struct ast_party_connected_line connected;
 	
 	if (outstate)
 		*outstate = 0;
@@ -3712,11 +3763,11 @@
 	}
 
 	ast_set_callerid(chan, cid_num, cid_name, cid_num);
-	ast_party_id_set_init(&line_id, &chan->connected.id);
-	line_id.number = (char *) cid_num;
-	line_id.name = (char *) cid_name;
-	line_id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
-	ast_set_connected_line(chan, &line_id, chan->connected.source);
+	ast_party_connected_line_set_init(&connected, &chan->connected);
+	connected.id.number = (char *) cid_num;
+	connected.id.name = (char *) cid_name;
+	connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
+	ast_set_connected_line(chan, &connected);
 
 	if (ast_call(chan, data, 0)) {	/* ast_call failed... */
 		ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
@@ -5697,22 +5748,35 @@
 
 /* ******************************************************************* */
 /*!
- * \brief Set the connected line id information in the Asterisk channel
- *
- * \param chan Asterisk channel to set connected line id information
- * \param id Connected line id information
- * \param source Q.SIG source of connected line information
+ * \brief Set the connected line information in the Asterisk channel
+ *
+ * \param chan Asterisk channel to set connected line information
+ * \param connected Connected line information
  *
  * \return Nothing
  *
  * \note The channel does not need to be locked before calling this function.
  */
-void ast_set_connected_line(struct ast_channel *chan, const struct ast_party_id *id, int source)
-{
+void ast_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected)
+{
+	if (&chan->connected == connected) {
+		/* Don't set to self */
+		return;
+	}
+
 	ast_channel_lock(chan);
 
-	ast_party_id_set(&chan->connected.id, id);
-	chan->connected.source = source;
+	ast_party_id_set(&chan->connected.id, &connected->id);
+
+	if (connected->ani && connected->ani != chan->connected.ani) {
+		if (chan->connected.ani) {
+			ast_free(chan->connected.ani);
+		}
+		chan->connected.ani = ast_strdup(connected->ani);
+	}
+
+	chan->connected.ani2 = connected->ani2;
+	chan->connected.source = connected->source;
 
 	ast_channel_unlock(chan);
 }	/* end ast_set_connected_line() */
@@ -5738,17 +5802,16 @@
 /* ******************************************************************* */
 /*!
  * \internal
- * \brief Build the connected line id data frame.
+ * \brief Build the connected line information data frame.
  *
  * \param data Buffer to fill with the frame data
  * \param datalen Size of the buffer to fill
- * \param id Connected line id information
- * \param source Q.SIG source of connected line information
+ * \param connected Connected line information
  *
  * \retval -1 if error
  * \retval Amount of data buffer used
  */
-static int ast_build_connected_line_data(unsigned char *data, size_t datalen, const struct ast_party_id *id, int source)
+static int ast_build_connected_line_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected)
 {
 	int32_t value;
 	size_t length;
@@ -5760,8 +5823,8 @@
 	 */
 
 	/* *************** Connected line party id *************** */
-	if (id->number) {
-		length = strlen(id->number);
+	if (connected->id.number) {
+		length = strlen(connected->id.number);
 		if (0 < length) {
 			if (datalen < pos + (sizeof(data[0]) * 2) + length) {
 				ast_log(LOG_WARNING, "No space left for connected line number\n");
@@ -5769,13 +5832,13 @@
 			}
 			data[pos++] = AST_CONNECTED_LINE_NUMBER;
 			data[pos++] = length;
-			memcpy(data + pos, id->number, length);
+			memcpy(data + pos, connected->id.number, length);
 			pos += length;
 		}
 	}
 
-	if (id->name) {
-		length = strlen(id->name);
+	if (connected->id.name) {
+		length = strlen(connected->id.name);
 		if (0 < length) {
 			if (datalen < pos + (sizeof(data[0]) * 2) + length) {
 				ast_log(LOG_WARNING, "No space left for connected line name\n");
@@ -5783,7 +5846,7 @@
 			}
 			data[pos++] = AST_CONNECTED_LINE_NAME;
 			data[pos++] = length;
-			memcpy(data + pos, id->name, length);
+			memcpy(data + pos, connected->id.name, length);
 			pos += length;
 		}
 	}
@@ -5794,7 +5857,7 @@
 	}
 	data[pos++] = AST_CONNECTED_LINE_NUMBER_TYPE;
 	data[pos++] = 1;
-	data[pos++] = id->number_type;
+	data[pos++] = connected->id.number_type;
 
 	if (datalen < pos + (sizeof(data[0]) * 2) + 1) {
 		ast_log(LOG_WARNING, "No space left for connected line presentation\n");
@@ -5802,7 +5865,7 @@
 	}
 	data[pos++] = AST_CONNECTED_LINE_NUMBER_PRESENTATION;
 	data[pos++] = 1;
-	data[pos++] = id->number_presentation;
+	data[pos++] = connected->id.number_presentation;
 
 	/* Connected line source */
 	if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) {
@@ -5811,7 +5874,7 @@
 	}
 	data[pos++] = AST_CONNECTED_LINE_SOURCE;
 	data[pos++] = sizeof(value);
-	value = htonl(source);
+	value = htonl(connected->source);
 	memcpy(data + pos, &value, sizeof(value));
 	pos += sizeof(value);
 
@@ -5827,19 +5890,18 @@
  *
  * \param data Buffer with the frame data to parse
  * \param datalen Size of the buffer
- * \param id Extracted connected line id information
- * \param source Extracted Q.SIG source of connected line information (Set to NULL if don't want the value)
+ * \param connected Extracted connected line information
  *
  * \retval 0 on success.
  * \retval -1 on error.
  *
- * \note The filled in id structure needs to be initialized by
- * ast_party_id_set_init() before calling.  If defaults are not
- * required use ast_party_id_init().
- * \note The filled in id structure needs to be destroyed by
- * ast_party_id_free() when it is no longer needed.
+ * \note The filled in connected line structure needs to be initialized by
+ * ast_party_connected_line_set_init() before calling.  If defaults are not
+ * required use ast_party_connected_line_init().
+ * \note The filled in connected line structure needs to be destroyed by
+ * ast_party_connected_line_free() when it is no longer needed.
  */
-int ast_parse_connected_line_data(const unsigned char *data, size_t datalen, struct ast_party_id *id, int *source)
+int ast_parse_connected_line_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 {
 	size_t pos;
 	unsigned char ie_len;
@@ -5860,23 +5922,23 @@
 
 		switch (ie_id) {
 		case AST_CONNECTED_LINE_NUMBER:
-			if (id->number) {
-				ast_free(id->number);
-			}
-			id->number = ast_malloc(ie_len + 1);
-			if (id->number) {
-				memcpy(id->number, data + pos, ie_len);
-				id->number[ie_len] = 0;
+			if (connected->id.number) {
+				ast_free(connected->id.number);
+			}
+			connected->id.number = ast_malloc(ie_len + 1);
+			if (connected->id.number) {
+				memcpy(connected->id.number, data + pos, ie_len);
+				connected->id.number[ie_len] = 0;
 			}
 			break;
 		case AST_CONNECTED_LINE_NAME:
-			if (id->name) {
-				ast_free(id->name);
-			}
-			id->name = ast_malloc(ie_len + 1);
-			if (id->name) {
-				memcpy(id->name, data + pos, ie_len);
-				id->name[ie_len] = 0;
+			if (connected->id.name) {
+				ast_free(connected->id.name);
+			}
+			connected->id.name = ast_malloc(ie_len + 1);
+			if (connected->id.name) {
+				memcpy(connected->id.name, data + pos, ie_len);
+				connected->id.name[ie_len] = 0;
 			}
 			break;
 		case AST_CONNECTED_LINE_NUMBER_TYPE:
@@ -5884,24 +5946,22 @@
 				ast_log(LOG_WARNING, "Invalid connected line type of number (%u)\n", (unsigned) ie_len);
 				break;
 			}
-			id->number_type = data[pos];
+			connected->id.number_type = data[pos];
 			break;
 		case AST_CONNECTED_LINE_NUMBER_PRESENTATION:
 			if (ie_len != 1) {
 				ast_log(LOG_WARNING, "Invalid connected line presentation (%u)\n", (unsigned) ie_len);
 				break;
 			}
-			id->number_presentation = data[pos];
+			connected->id.number_presentation = data[pos];
 			break;
 		case AST_CONNECTED_LINE_SOURCE:
-			if (source) {
-				if (ie_len != sizeof(value)) {
-					ast_log(LOG_WARNING, "Invalid connected line source (%u)\n", (unsigned) ie_len);
-					break;
-				}
-				memcpy(&value, data + pos, sizeof(value));
-				*source = ntohl(value);
-			}
+			if (ie_len != sizeof(value)) {
+				ast_log(LOG_WARNING, "Invalid connected line source (%u)\n", (unsigned) ie_len);
+				break;
+			}
+			memcpy(&value, data + pos, sizeof(value));
+			connected->source = ntohl(value);
 			break;
 		default:
 			ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n", (unsigned) ie_id, (unsigned) ie_len);
@@ -5917,20 +5977,19 @@
 
 /* ******************************************************************* */
 /*!
- * \brief Indicate that the connected line id has changed
- *
- * \param chan Asterisk channel to indicate connected line id information
- * \param id Connected line id information
- * \param source Q.SIG source of connected line information
+ * \brief Indicate that the connected line information has changed
+ *
+ * \param chan Asterisk channel to indicate connected line information
+ * \param connected Connected line information
  *
  * \return Nothing
  */
-void ast_connected_line_update(struct ast_channel *chan, const struct ast_party_id *id, int source)
+void ast_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected)
 {
 	unsigned char data[1024];	/* This should be large enough */
 	size_t datalen;
 
-	datalen = ast_build_connected_line_data(data, sizeof(data), id, source);
+	datalen = ast_build_connected_line_data(data, sizeof(data), connected);
 	if (datalen == (size_t) -1) {
 		return;
 	}
@@ -5945,18 +6004,17 @@
 /*!
  * \brief Queue a connected line update frame on a channel
  *
- * \param chan Asterisk channel to indicate connected line id information
- * \param id Connected line id information
- * \param source Q.SIG source of connected line information
+ * \param chan Asterisk channel to indicate connected line information
+ * \param connected Connected line information
  *
  * \return Nothing
  */
-void ast_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_id *id, int source)
+void ast_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected)
 {
 	unsigned char data[1024];	/* This should be large enough */
 	size_t datalen;
 
-	datalen = ast_build_connected_line_data(data, sizeof(data), id, source);
+	datalen = ast_build_connected_line_data(data, sizeof(data), connected);
 	if (datalen == (size_t) -1) {
 		return;
 	}
@@ -5980,10 +6038,16 @@
  */

[... 48 lines stripped ...]



More information about the asterisk-commits mailing list