[asterisk-commits] rmudgett: branch rmudgett/cel_accountcode r418214 - in /team/rmudgett/cel_acc...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 8 18:03:52 CDT 2014


Author: rmudgett
Date: Tue Jul  8 18:03:43 2014
New Revision: 418214

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418214
Log:
app_queue: Keep accountcodes on outgoing channels if present.

* Renamed ast_channel_request_accountcodes() to
ast_channel_req_accountcodes().

* Added ast_channel_req_accountcodes_precious() to preserve accountcodes.

Modified:
    team/rmudgett/cel_accountcode/UPGRADE.txt
    team/rmudgett/cel_accountcode/apps/app_dial.c
    team/rmudgett/cel_accountcode/apps/app_followme.c
    team/rmudgett/cel_accountcode/apps/app_queue.c
    team/rmudgett/cel_accountcode/include/asterisk/channel.h
    team/rmudgett/cel_accountcode/main/bridge.c
    team/rmudgett/cel_accountcode/main/bridge_basic.c
    team/rmudgett/cel_accountcode/main/channel.c
    team/rmudgett/cel_accountcode/main/dial.c
    team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c

Modified: team/rmudgett/cel_accountcode/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/UPGRADE.txt?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/UPGRADE.txt (original)
+++ team/rmudgett/cel_accountcode/UPGRADE.txt Tue Jul  8 18:03:43 2014
@@ -23,20 +23,28 @@
 
 From 12.4.0 to 12.5.0:
 
- - The accountcode propagation is now consistently propagated to outgoing
-   channels before dialing.  The channel accountcode can change from its
-   original non-empty value on channel creation for the following specific
-   reasons.  One, dialplan sets it using CHANNEL(accountcode).  Two, an
-   originate method that can specify an accountcode value.  Three, the
-   calling channel propagates its peeraccount or accountcode to the
-   outgoing channel's accountcode before dialing.  The change has two
+ - Except for Queue, the accountcode propagation is now consistently
+   propagated to outgoing channels before dialing.  The channel
+   accountcode can change from its original non-empty value on channel
+   creation for the following specific reasons.  One, dialplan sets it
+   using CHANNEL(accountcode).  Two, an originate method that can specify
+   an accountcode value.  Three, the calling channel propagates its
+   peeraccount or accountcode to the outgoing channel's accountcode before
+   dialing.  The change has two visible effects.  One, local channels now
+   cross accountcode and peeraccount across the special bridge between the
+   ;1 and ;2 channels just like channels between normal bridges.  Two, the
+   CHANNEL(peeraccount) value can now be set before Dial and FollowMe to
+   set the accountcode on the outgoing channel(s).
+
+   For Queue, an outgoing channel's non-empty accountcode will not change
+   unless explicitly set by CHANNEL(accountcode).  The change has three
    visible effects.  One, local channels now cross accountcode and
    peeraccount across the special bridge between the ;1 and ;2 channels
-   just like channels between normal bridges.  Two, the CHANNEL(peeraccount)
-   value now can be set before Dial, FollowMe, and Queue to set the
-   accountcode on the outgoing channel(s).  For Queue this now includes
-   local channel members where the accountcodes are propagated early
-   enough to be useful on the ;2 channel.
+   just like channels between normal bridges.  Two, the queue member will
+   get an accountcode if it doesn't have one and one is available from the
+   calling channel's peeraccount or accountcode.  Three, accountcode
+   propagation includes local channel members where the accountcodes are
+   propagated early enough to be available on the ;2 channel.
 
 From 12.3.2 to 12.4.0:
 

Modified: team/rmudgett/cel_accountcode/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/apps/app_dial.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_dial.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_dial.c Tue Jul  8 18:03:43 2014
@@ -950,7 +950,7 @@
 			ast_connected_line_copy_from_caller(ast_channel_connected(c), ast_channel_caller(in));
 		}
 
-		ast_channel_request_accountcodes(c, in, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+		ast_channel_req_accountcodes(c, in, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 
 		ast_channel_appl_set(c, "AppDial");
 		ast_channel_data_set(c, "(Outgoing Line)");
@@ -2517,7 +2517,7 @@
 
 		ast_channel_dialed(tc)->transit_network_select = ast_channel_dialed(chan)->transit_network_select;
 
-		ast_channel_request_accountcodes(tc, chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+		ast_channel_req_accountcodes(tc, chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 		if (ast_strlen_zero(ast_channel_musicclass(tc))) {
 			ast_channel_musicclass_set(tc, ast_channel_musicclass(chan));
 		}

Modified: team/rmudgett/cel_accountcode/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/apps/app_followme.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_followme.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_followme.c Tue Jul  8 18:03:43 2014
@@ -1070,7 +1070,7 @@
 			ast_channel_inherit_variables(caller, outbound);
 			ast_channel_datastore_inherit(caller, outbound);
 			ast_channel_language_set(outbound, ast_channel_language(caller));
-			ast_channel_request_accountcodes(outbound, caller, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+			ast_channel_req_accountcodes(outbound, caller, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 			ast_channel_musicclass_set(outbound, ast_channel_musicclass(caller));
 			ast_channel_unlock(outbound);
 			ast_channel_unlock(caller);

Modified: team/rmudgett/cel_accountcode/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/apps/app_queue.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_queue.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_queue.c Tue Jul  8 18:03:43 2014
@@ -4125,7 +4125,8 @@
 
 	ast_channel_lock_both(tmp->chan, qe->chan);
 
-	ast_channel_request_accountcodes(tmp->chan, qe->chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+	ast_channel_req_accountcodes_precious(tmp->chan, qe->chan,
+		AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 	if (qe->cancel_answered_elsewhere) {
 		ast_channel_hangupcause_set(tmp->chan, AST_CAUSE_ANSWERED_ELSEWHERE);
 	}
@@ -4664,7 +4665,7 @@
 							ast_party_connected_line_copy(&o->connected, ast_channel_connected(in));
 						}
 
-						ast_channel_request_accountcodes(o->chan, in, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+						ast_channel_req_accountcodes(o->chan, in, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 
 						if (!ast_channel_redirecting(o->chan)->from.number.valid
 							|| ast_strlen_zero(ast_channel_redirecting(o->chan)->from.number.str)) {

Modified: team/rmudgett/cel_accountcode/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/include/asterisk/channel.h?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/include/asterisk/channel.h (original)
+++ team/rmudgett/cel_accountcode/include/asterisk/channel.h Tue Jul  8 18:03:43 2014
@@ -1398,9 +1398,27 @@
  *
  * \pre The chan and requestor channels are already locked.
  *
- * \return Nothing
- */
-void ast_channel_request_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
+ * \note Pre-existing accountcodes on chan will be overwritten.
+ *
+ * \return Nothing
+ */
+void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
+
+/*!
+ * \brief Setup new channel accountcodes from the requestor channel after ast_request().
+ * \since 12.5.0
+ *
+ * \param chan New channel to get accountcodes setup.
+ * \param requestor Requesting channel to get accountcodes from.
+ * \param relationship What the new channel was created for.
+ *
+ * \pre The chan and requestor channels are already locked.
+ *
+ * \note Pre-existing accountcodes on chan will not be overwritten.
+ *
+ * \return Nothing
+ */
+void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship);
 
 /*!
  * \brief Request a channel of a given type, with data as optional information used

Modified: team/rmudgett/cel_accountcode/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/bridge.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge.c Tue Jul  8 18:03:43 2014
@@ -3732,7 +3732,7 @@
 	}
 
 	ast_channel_lock_both(local, transferer);
-	ast_channel_request_accountcodes(local, transferer, AST_CHANNEL_REQUESTOR_REPLACEMENT);
+	ast_channel_req_accountcodes(local, transferer, AST_CHANNEL_REQUESTOR_REPLACEMENT);
 	pbx_builtin_setvar_helper(local, BLINDTRANSFER, ast_channel_name(transferer));
 	ast_channel_unlock(local);
 	ast_channel_unlock(transferer);
@@ -3899,7 +3899,7 @@
 	}
 
 	ast_channel_lock_both(local_chan, chan1);
-	ast_channel_request_accountcodes(local_chan, chan1, AST_CHANNEL_REQUESTOR_REPLACEMENT);
+	ast_channel_req_accountcodes(local_chan, chan1, AST_CHANNEL_REQUESTOR_REPLACEMENT);
 	pbx_builtin_setvar_helper(local_chan, ATTENDEDTRANSFER, ast_channel_name(chan1));
 	ast_channel_unlock(local_chan);
 	ast_channel_unlock(chan1);

Modified: team/rmudgett/cel_accountcode/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/bridge_basic.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge_basic.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge_basic.c Tue Jul  8 18:03:43 2014
@@ -2984,7 +2984,7 @@
 
 	ast_channel_lock_both(chan, caller);
 
-	ast_channel_request_accountcodes(chan, caller, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+	ast_channel_req_accountcodes(chan, caller, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 
 	/* Who is transferring the call. */
 	pbx_builtin_setvar_helper(chan, "TRANSFERERNAME", ast_channel_name(caller));

Modified: team/rmudgett/cel_accountcode/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/channel.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/main/channel.c (original)
+++ team/rmudgett/cel_accountcode/main/channel.c Tue Jul  8 18:03:43 2014
@@ -5651,7 +5651,7 @@
 	ast_channel_lock_both(orig, new_chan);
 	ast_party_connected_line_copy(ast_channel_connected(new_chan), ast_channel_connected(orig));
 	ast_party_redirecting_copy(ast_channel_redirecting(new_chan), ast_channel_redirecting(orig));
-	ast_channel_request_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
+	ast_channel_req_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
 	ast_channel_unlock(new_chan);
 	ast_channel_unlock(orig);
 
@@ -5749,7 +5749,7 @@
 	ast_channel_set_connected_line(chan, &connected, NULL);
 	if (requestor) {
 		ast_channel_lock_both(chan, (struct ast_channel *) requestor);
-		ast_channel_request_accountcodes(chan, requestor, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+		ast_channel_req_accountcodes(chan, requestor, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 		ast_channel_unlock(chan);
 		ast_channel_unlock((struct ast_channel *) requestor);
 	}
@@ -6009,7 +6009,21 @@
 	return NULL;
 }
 
-void ast_channel_request_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
+/*!
+ * \internal
+ * \brief Setup new channel accountcodes from the requestor channel after ast_request().
+ * \since 12.5.0
+ *
+ * \param chan New channel to get accountcodes setup.
+ * \param requestor Requesting channel to get accountcodes from.
+ * \param relationship What the new channel was created for.
+ * \param precious TRUE if pre-existing accountcodes on chan will not be overwritten.
+ *
+ * \pre The chan and requestor channels are already locked.
+ *
+ * \return Nothing
+ */
+static void channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship, int precious)
 {
 	/*
 	 * The primary reason for the existence of this function is
@@ -6024,19 +6038,26 @@
 	switch (relationship) {
 	case AST_CHANNEL_REQUESTOR_BRIDGE_PEER:
 		/* Crossover the requestor's accountcode and peeraccount */
-		if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
+		if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
 			/*
-			 * Set it to the requestor's peeraccount.  This allows the
-			 * dialplan to indicate the accountcode to use when dialing
-			 * by setting CHANNEL(peeraccount).
+			 * The newly created channel does not have an accountcode
+			 * or we don't care.
 			 */
-			ast_channel_accountcode_set(chan, ast_channel_peeraccount(requestor));
-		} else if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
-			/*
-			 * Fallback to the historic propagation and set it to the
-			 * requestor's accountcode.
-			 */
-			ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
+			if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
+				/*
+				 * Set it to the requestor's peeraccount.  This allows the
+				 * dialplan to indicate the accountcode to use when dialing
+				 * by setting CHANNEL(peeraccount).
+				 */
+				ast_channel_accountcode_set(chan, ast_channel_peeraccount(requestor));
+			} else if (!precious
+				&& !ast_strlen_zero(ast_channel_accountcode(requestor))) {
+				/*
+				 * Fallback to the historic propagation and set it to the
+				 * requestor's accountcode.
+				 */
+				ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
+			}
 		}
 		if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
 			ast_channel_peeraccount_set(chan, ast_channel_accountcode(requestor));
@@ -6044,14 +6065,30 @@
 		break;
 	case AST_CHANNEL_REQUESTOR_REPLACEMENT:
 		/* Pass the requestor's accountcode and peeraccount straight. */
-		if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
-			ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
+		if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
+			/*
+			 * The newly created channel does not have an accountcode
+			 * or we don't care.
+			 */
+			if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
+				ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
+			}
 		}
 		if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
 			ast_channel_peeraccount_set(chan, ast_channel_peeraccount(requestor));
 		}
 		break;
 	}
+}
+
+void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
+{
+	channel_req_accountcodes(chan, requestor, relationship, 0);
+}
+
+void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
+{
+	channel_req_accountcodes(chan, requestor, relationship, 1);
 }
 
 int ast_pre_call(struct ast_channel *chan, const char *sub_args)

Modified: team/rmudgett/cel_accountcode/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/dial.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/main/dial.c (original)
+++ team/rmudgett/cel_accountcode/main/dial.c Tue Jul  8 18:03:43 2014
@@ -327,7 +327,7 @@
 		ast_connected_line_copy_from_caller(ast_channel_connected(channel->owner), ast_channel_caller(chan));
 
 		ast_channel_language_set(channel->owner, ast_channel_language(chan));
-		ast_channel_request_accountcodes(channel->owner, chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+		ast_channel_req_accountcodes(channel->owner, chan, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 		if (ast_strlen_zero(ast_channel_musicclass(channel->owner)))
 			ast_channel_musicclass_set(channel->owner, ast_channel_musicclass(chan));
 

Modified: team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c?view=diff&rev=418214&r1=418213&r2=418214
==============================================================================
--- team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c (original)
+++ team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c Tue Jul  8 18:03:43 2014
@@ -235,7 +235,7 @@
 
 	/* Before we actually dial out let's inherit appropriate information. */
 	ast_channel_lock_both(parker, parkee);
-	ast_channel_request_accountcodes(parkee, parker, AST_CHANNEL_REQUESTOR_REPLACEMENT);
+	ast_channel_req_accountcodes(parkee, parker, AST_CHANNEL_REQUESTOR_REPLACEMENT);
 	ast_connected_line_copy_from_caller(ast_channel_connected(parkee), ast_channel_caller(parker));
 	ast_channel_inherit_variables(parker, parkee);
 	ast_channel_datastore_inherit(parker, parkee);




More information about the asterisk-commits mailing list