[svn-commits] mmichelson: branch group/issue8824 r151887 - /team/group/issue8824/apps/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 24 15:55:17 CDT 2008


Author: mmichelson
Date: Fri Oct 24 15:55:17 2008
New Revision: 151887

URL: http://svn.digium.com/view/asterisk?view=rev&rev=151887
Log:
Work out the logic behind connected line information when
multiple destinations are dialed.

So, here's how it works. In app_dial and app_queue, there
is a structure for representing an outgoing call (app_queue
calls this structure a callattempt, for instance). When we
allocate our call attempts (before ever requesting channels
or calling), we first check to see if the dialing channel
has had a connected line number set on it. If it is, we take
this as an indication that some information has been set before
the dial has taken place and that we'd like to use this if
no updating information comes in. Cool.

Later, when we request the outgoing channel, we check to see
if there is a callerid number set. If there is not, then we set
some sort of flag to indicate that the callerid from the far
end sucks.

When new connected line information comes in, we update the
callattempt's connected line structure with the new info we
just got.

When someone finally answers the phone, our first preference is
to use whatever connected line information we have saved in the
callattempt's connected line element. If the number portion is
NULL, then we take this to mean that we never set any connected
line information there, so we fall back to the callerid for the
channel. If that sucks, then we send no connected line update on
the channel.

The most questionable thing that's happening right now is that
we set outgoing connected line based on the fact that the number
portion is non-NULL, which may be fallacious. More tests will help
to confirm all of this.


Modified:
    team/group/issue8824/apps/app_dial.c
    team/group/issue8824/apps/app_queue.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=151887&r1=151886&r2=151887
==============================================================================
--- team/group/issue8824/apps/app_dial.c (original)
+++ team/group/issue8824/apps/app_dial.c Fri Oct 24 15:55:17 2008
@@ -627,14 +627,14 @@
 			if (ast_test_flag64(o, DIAL_STILLGOING) && c->_state == AST_STATE_UP) {
 				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_connected_line_collect_caller(&connected_caller, &c->cid);
-						connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-						ast_connected_line_update(in, &connected_caller);
-					}
-					/* XXX Redundant code. Fix later */
 					if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
-						ast_connected_line_update(in, &o->connected);
+						if (o->connected.id.number) {
+							ast_connected_line_update(in, &o->connected);
+						} else if (!ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
+							ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
+							connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+							ast_connected_line_update(in, &connected_caller);
+						}
 					}
 					peer = c;
 					ast_copy_flags64(peerflags, o,
@@ -674,11 +674,14 @@
 					/* This is our guy if someone answered. */
 					if (!peer) {
 						ast_verb(3, "%s answered %s\n", c->name, in->name);
-						/* XXX Need to figure out whether to use the o->connected or c->cid here */
-						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
-							ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
-							connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-							ast_connected_line_update(in, &connected_caller);
+						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
+							if (o->connected.id.number) {
+								ast_connected_line_update(in, &o->connected);
+							} else if (!ast_test_flag64(o, DIAL_NOCONNECTEDLINE)) {
+								ast_party_connected_line_collect_caller(&connected_caller, &c->cid);
+								connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+								ast_connected_line_update(in, &connected_caller);
+							}
 						}
 						peer = c;
 						if (peer->cdr) {
@@ -694,10 +697,6 @@
 							DIAL_NOFORWARDHTML);
 						ast_string_field_set(c, dialcontext, "");
 						ast_copy_string(c->exten, "", sizeof(c->exten));
-						/* XXX Yes, I know this is redundant. Will fix */
-						if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
-							ast_connected_line_update(in, &o->connected);
-						}
 						if (CAN_EARLY_BRIDGE(peerflags, in, peer))
 							/* Setup early bridge if appropriate */
 							ast_channel_early_bridge(in, peer);
@@ -1451,8 +1450,14 @@
 
 		ast_channel_lock(chan);
 		datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL);
-		/* Might as well while the channel's locked, right?\n */
-		ast_party_connected_line_copy(&tmp->connected, &chan->connected);
+		/* If the incoming channel has previously had connected line information
+		 * set on it (perhaps through the CONNECTED_LINE dialplan function) then
+		 * seed the calllist's connected line information with this previously
+		 * acquired info
+		 */
+		if (chan->connected.id.number) {
+			ast_party_connected_line_copy(&tmp->connected, &chan->connected);
+		}
 		ast_channel_unlock(chan);
 
 		if (datastore)

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=151887&r1=151886&r2=151887
==============================================================================
--- team/group/issue8824/apps/app_queue.c (original)
+++ team/group/issue8824/apps/app_queue.c Fri Oct 24 15:55:17 2008
@@ -2495,14 +2495,14 @@
 			if (o->stillgoing && (o->chan) &&  (o->chan->_state == AST_STATE_UP)) {
 				if (!peer) {
 					ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
-					if (update_connectedline && o->update_connectedline) {
-						ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
-						connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-						ast_connected_line_update(in, &connected_caller);
-					}
-					/*XXX Yes, I know, you don't have to tell me */
-					if (update_connectedline && qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
-						ast_connected_line_update(in, &o->connected);
+					if (update_connectedline) {
+						if (o->connected.id.number) {
+							ast_connected_line_update(in, &o->connected);
+						} else if (o->update_connectedline) {
+							ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
+							connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+							ast_connected_line_update(in, &connected_caller);
+						}
 					}
 					peer = o;
 				}
@@ -2579,14 +2579,14 @@
 							/* This is our guy if someone answered. */
 							if (!peer) {
 								ast_verb(3, "%s answered %s\n", o->chan->name, in->name);
-								if (update_connectedline && o->update_connectedline) {
-									ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
-									connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
-									ast_connected_line_update(in, &connected_caller);
-								}
-								/*XXX THis is redundant. Fix later */
-								if (update_connectedline && qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
-									ast_connected_line_update(in, &o->connected);
+								if (update_connectedline) {
+									if (o->connected.id.number) {
+										ast_connected_line_update(in, &o->connected);
+									} else if (o->update_connectedline) {
+										ast_party_connected_line_collect_caller(&connected_caller, &o->chan->cid);
+										connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+										ast_connected_line_update(in, &connected_caller);
+									}
 								}
 								peer = o;
 							}
@@ -3340,7 +3340,15 @@
 		AST_LIST_UNLOCK(dialed_interfaces);
 
 		ast_channel_lock(qe->chan);
-		ast_party_connected_line_copy(&tmp->connected, &qe->chan->connected);
+		/* If any pre-existing connected line information exists on this
+		 * channel, like from the CONNECTED_LINE dialplan function, use this
+		 * to seed the connected line information. It may, of course, be updated
+		 * during the call
+		 */
+		if (qe->chan->connected.id.number) {
+			ast_party_connected_line_copy(&tmp->connected, &qe->chan->connected);
+		}
+		ast_channel_unlock(qe->chan);
 		
 		if (di) {
 			free(tmp);




More information about the svn-commits mailing list