[asterisk-commits] mmichelson: branch group/v14_colp r152362 - in /team/group/v14_colp: apps/ ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 28 11:03:49 CDT 2008


Author: mmichelson
Date: Tue Oct 28 11:03:49 2008
New Revision: 152362

URL: http://svn.digium.com/view/asterisk?view=rev&rev=152362
Log:
A set of changes backported from the issue8824 branch,
specifically dealing with connected line logic when multiple
parties are dialed and when local channels are dialed.

To be more specific, this deals with the fact that when
dialing multiple parties, connected line updates will
be flying in from all directions. So now, we cache these
updates and associate them with a destination dialed.
When someone answers, we then send the appropriate
connected line update.

As far as local channels go, the problem is that if
someone dialed a local channel, then the outgoing
leg of the local channel would have connected line
updates happen, but would not have complete updates
forwarded to the original calling channel. I modified
local_indicate to queue the connected line information
from the outgoing local channel instead of just the
data in the control frame.


Modified:
    team/group/v14_colp/apps/app_dial.c
    team/group/v14_colp/apps/app_queue.c
    team/group/v14_colp/channels/chan_local.c
    team/group/v14_colp/include/asterisk/channel.h
    team/group/v14_colp/main/channel.c

Modified: team/group/v14_colp/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/v14_colp/apps/app_dial.c?view=diff&rev=152362&r1=152361&r2=152362
==============================================================================
--- team/group/v14_colp/apps/app_dial.c (original)
+++ team/group/v14_colp/apps/app_dial.c Tue Oct 28 11:03:49 2008
@@ -314,6 +314,7 @@
 	struct ast_channel *chan;
 	unsigned int flags;
 	struct dial_localuser *next;
+	struct ast_party_connected_line connected;
 };
 
 
@@ -473,10 +474,18 @@
 				if (!peer) {
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "%s answered %s\n", c->name, in->name);
-					if (!single && !ast_test_flag(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag(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_flag(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
+						if (o->connected.id.number) {
+							ast_connected_line_update(in, &o->connected);
+						} else if (!ast_test_flag(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_flag(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
+						ast_connected_line_update(in, &o->connected);
 					}
 					peer = c;
 					ast_copy_flags(peerflags, o,
@@ -578,10 +587,14 @@
 					if (!peer) {
 						if (option_verbose > 2)
 							ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", c->name, in->name);
-						if (!single && !ast_test_flag(peerflags, OPT_IGNORE_CONNECTEDLINE) && !ast_test_flag(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_flag(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
+							if (o->connected.id.number) {
+								ast_connected_line_update(in, &o->connected);
+							} else if (!ast_test_flag(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) {
@@ -653,9 +666,18 @@
 					ast_indicate(in, AST_CONTROL_SRCUPDATE);
 					break;
 				case AST_CONTROL_CONNECTED_LINE:
-					if (!single || ast_test_flag(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
+					if (ast_test_flag(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
 						if (option_verbose > 2)
 							ast_verbose (VERBOSE_PREFIX_3 "Connected line update to %s prevented.\n", in->name);
+					} else if (!single) {
+						struct ast_party_connected_line connected;
+						if (option_verbose > 2) {
+							ast_verbose(VERBOSE_PREFIX_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_parse_connected_line_data(f->data, f->datalen, &connected);
+						ast_party_connected_line_set(&o->connected, &connected);
+						ast_party_connected_line_free(&connected);
 					} else {
 						if (option_verbose > 2)
 							ast_verbose (VERBOSE_PREFIX_3 "%s connected line has changed, passing it to %s\n", c->name, in->name);
@@ -1203,6 +1225,14 @@
 
 		ast_channel_lock(chan);
 		datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL);
+		/* 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/v14_colp/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/v14_colp/apps/app_queue.c?view=diff&rev=152362&r1=152361&r2=152362
==============================================================================
--- team/group/v14_colp/apps/app_queue.c (original)
+++ team/group/v14_colp/apps/app_queue.c Tue Oct 28 11:03:49 2008
@@ -320,6 +320,7 @@
 	time_t lastcall;
 	struct member *member;
 	int update_connectedline;
+	struct ast_party_connected_line connected;
 };
 
 
@@ -2167,10 +2168,14 @@
 				if (!peer) {
 					if (option_verbose > 2)
 						ast_verbose( VERBOSE_PREFIX_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);
+					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;
 				}
@@ -2250,10 +2255,14 @@
 							if (!peer) {
 								if (option_verbose > 2)
 									ast_verbose( VERBOSE_PREFIX_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);
+								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;
 							}
@@ -2301,6 +2310,15 @@
 							if (!update_connectedline) {
 								if (option_verbose > 2)
 									ast_verbose(VERBOSE_PREFIX_3 "Connected line update to %s prevented.\n", in->name);
+							} else if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { 
+								struct ast_party_connected_line connected;
+								if (option_verbose > 2) {
+									ast_verbose(VERBOSE_PREFIX_3 "%s connected line has changed. Saving it until answer for %s\n", o->chan->name, in->name);
+								}
+								ast_party_connected_line_set_init(&connected, &o->connected);
+								ast_parse_connected_line_data(f->data, f->datalen, &connected);
+								ast_party_connected_line_set(&o->connected, &connected);
+								ast_party_connected_line_free(&connected);
 							} else {
 								if (option_verbose > 2)
 									ast_verbose(VERBOSE_PREFIX_3 "%s connected line has changed, passing it to %s\n", o->chan->name, in->name);
@@ -2879,6 +2897,17 @@
 			}
 		}
 		AST_LIST_UNLOCK(dialed_interfaces);
+
+		ast_channel_lock(qe->chan);
+		/* 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);

Modified: team/group/v14_colp/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/group/v14_colp/channels/chan_local.c?view=diff&rev=152362&r1=152361&r2=152362
==============================================================================
--- team/group/v14_colp/channels/chan_local.c (original)
+++ team/group/v14_colp/channels/chan_local.c Tue Oct 28 11:03:49 2008
@@ -363,6 +363,13 @@
 		ast_moh_start(ast, data, NULL);
 	} else if (condition == AST_CONTROL_UNHOLD) {
 		ast_moh_stop(ast);
+	} else if (condition == AST_CONTROL_CONNECTED_LINE) {
+		/* We need to queue the actual channel's info, dawg */
+		isoutbound = IS_OUTBOUND(ast, p);
+		if (isoutbound) {
+			/*XXX investigate later for potential deadlock issues */
+			ast_queue_connected_line_update(p->owner, &p->chan->connected);
+		}
 	} else {
 		/* Queue up a frame representing the indication as a control frame */
 		ast_mutex_lock(&p->lock);

Modified: team/group/v14_colp/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/v14_colp/include/asterisk/channel.h?view=diff&rev=152362&r1=152361&r2=152362
==============================================================================
--- team/group/v14_colp/include/asterisk/channel.h (original)
+++ team/group/v14_colp/include/asterisk/channel.h Tue Oct 28 11:03:49 2008
@@ -1623,6 +1623,7 @@
 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_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src);
 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);
 

Modified: team/group/v14_colp/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/v14_colp/main/channel.c?view=diff&rev=152362&r1=152361&r2=152362
==============================================================================
--- team/group/v14_colp/main/channel.c (original)
+++ team/group/v14_colp/main/channel.c Tue Oct 28 11:03:49 2008
@@ -1479,7 +1479,30 @@
 	init->source = guide->source;
 }	/* end ast_party_connected_line_set_init() */
 
-
+/*! \brief Set the connected line information based on another connected line source
+ *
+ * This is similar to ast_party_connected_line_copy, except that NULL values for
+ * strings in the src parameter indicate not to update the corresponding dest values.
+ *
+ * \param src The source connected line to use as a guide to set the dest
+ * \param dest The connected line one wishes to update
+ *
+ * \return Nada
+ */
+void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
+{
+	ast_party_id_set(&dest->id, &src->id);
+
+	if (src->ani && src->ani != dest->ani) {
+		if (dest->ani) {
+			ast_free(dest->ani);
+		}
+		dest->ani = ast_strdup(src->ani);
+	}
+
+	dest->ani2 = src->ani2;
+	dest->source = src->source;
+}
 
 
 /* ******************************************************************* */
@@ -5345,19 +5368,7 @@
 	}
 
 	ast_channel_lock(chan);
-
-	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_party_connected_line_set(&chan->connected, connected);
 	ast_channel_unlock(chan);
 }	/* end ast_set_connected_line() */
 




More information about the asterisk-commits mailing list