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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 9 13:41:14 CDT 2014


Author: rmudgett
Date: Wed Jul  9 13:41:11 2014
New Revision: 418253

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418253
Log:
Rebased accountcode changes for trunk.

Modified:
    team/rmudgett/cel_accountcode/CHANGES
    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/cel.c
    team/rmudgett/cel_accountcode/main/channel.c
    team/rmudgett/cel_accountcode/main/core_unreal.c
    team/rmudgett/cel_accountcode/main/dial.c
    team/rmudgett/cel_accountcode/main/pbx.c
    team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c

Modified: team/rmudgett/cel_accountcode/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/CHANGES?view=diff&rev=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/CHANGES (original)
+++ team/rmudgett/cel_accountcode/CHANGES Wed Jul  9 13:41:11 2014
@@ -11,6 +11,32 @@
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 12 to Asterisk 13 --------------------
 ------------------------------------------------------------------------------
+
+accountcode
+------------------
+ - Added functional peeraccount support.  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 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.
 
 app_dahdibarge
 ------------------

Modified: team/rmudgett/cel_accountcode/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/UPGRADE.txt?view=diff&rev=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/UPGRADE.txt (original)
+++ team/rmudgett/cel_accountcode/UPGRADE.txt Wed Jul  9 13:41:11 2014
@@ -50,6 +50,13 @@
    update their dialplans to use ',' instead of '|' as a delimiter, and should
    use the Set dialplan application instead of the MSet dialplan application.
 
+accountcode:
+ - Accountcode behavior changed somewhat to add functional peeraccount
+   support.  The main change is that local channels now cross accountcode
+   and peeraccount across the special bridge between the ;1 and ;2 channels
+   just like channels between normal bridges.  See the CHANGES file for
+   more information.
+
 ARI:
  - The ARI version has been changed from 1.0.0 to 1.1.0. This is to reflect
    the backwards compatible changes listed below.

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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_dial.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_dial.c Wed Jul  9 13:41:11 2014
@@ -956,7 +956,7 @@
 			ast_connected_line_copy_from_caller(ast_channel_connected(c), ast_channel_caller(in));
 		}
 
-		ast_channel_accountcode_set(c, ast_channel_accountcode(in));
+		ast_channel_req_accountcodes(c, in, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
 
 		ast_channel_appl_set(c, "AppDial");
 		ast_channel_data_set(c, "(Outgoing Line)");
@@ -2524,9 +2524,7 @@
 
 		ast_channel_dialed(tc)->transit_network_select = ast_channel_dialed(chan)->transit_network_select;
 
-		if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
-			ast_channel_accountcode_set(tc, ast_channel_accountcode(chan));
-		}
+		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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_followme.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_followme.c Wed Jul  9 13:41:11 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_accountcode_set(outbound, ast_channel_accountcode(caller));
+			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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_queue.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_queue.c Wed Jul  9 13:41:11 2014
@@ -4125,6 +4125,8 @@
 
 	ast_channel_lock_both(tmp->chan, qe->chan);
 
+	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);
 	}
@@ -4663,7 +4665,7 @@
 							ast_party_connected_line_copy(&o->connected, ast_channel_connected(in));
 						}
 
-						ast_channel_accountcode_set(o->chan, ast_channel_accountcode(in));
+						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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/include/asterisk/channel.h (original)
+++ team/rmudgett/cel_accountcode/include/asterisk/channel.h Wed Jul  9 13:41:11 2014
@@ -1380,6 +1380,45 @@
  * \retval non-NULL channel on success
  */
 struct ast_channel *ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause);
+
+enum ast_channel_requestor_relationship {
+	/*! The requestor is the future bridge peer of the channel. */
+	AST_CHANNEL_REQUESTOR_BRIDGE_PEER,
+	/*! The requestor is to be replaced by the channel. */
+	AST_CHANNEL_REQUESTOR_REPLACEMENT,
+};
+
+/*!
+ * \brief Setup new channel accountcodes from the requestor channel after ast_request().
+ * \since 13.0.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 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 13.0.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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge.c Wed Jul  9 13:41:11 2014
@@ -3789,7 +3789,11 @@
 		return AST_BRIDGE_TRANSFER_FAIL;
 	}
 
+	ast_channel_lock_both(local, transferer);
+	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);
 
 	if (new_channel_cb) {
 		new_channel_cb(local, user_data_wrapper, AST_BRIDGE_TRANSFER_MULTI_PARTY);
@@ -3948,12 +3952,15 @@
 
 	local_chan = ast_request("Local", ast_channel_nativeformats(chan1), NULL, chan1,
 			dest, &cause);
-
 	if (!local_chan) {
 		return AST_BRIDGE_TRANSFER_FAIL;
 	}
 
+	ast_channel_lock_both(local_chan, chan1);
+	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);
 
 	if (bridge2) {
 		res = ast_local_setup_bridge(local_chan, bridge2, chan2, NULL);

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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge_basic.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge_basic.c Wed Jul  9 13:41:11 2014
@@ -2982,10 +2982,17 @@
 		return NULL;
 	}
 
+	ast_channel_lock_both(chan, caller);
+
+	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));
 
 	ast_bridge_set_transfer_variables(chan, ast_channel_name(caller), 1);
+
+	ast_channel_unlock(chan);
+	ast_channel_unlock(caller);
 
 	/* Before we actually dial out let's inherit appropriate information. */
 	copy_caller_data(chan, caller);

Modified: team/rmudgett/cel_accountcode/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/cel.c?view=diff&rev=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/cel.c (original)
+++ team/rmudgett/cel_accountcode/main/cel.c Wed Jul  9 13:41:11 2014
@@ -946,7 +946,7 @@
 	r->application_name = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_APPNAME), "");
 	r->application_data = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_APPDATA), "");
 	r->account_code     = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_ACCTCODE), "");
-	r->peer_account     = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_ACCTCODE), "");
+	r->peer_account     = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_PEERACCT), "");
 	r->unique_id        = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_UNIQUEID), "");
 	r->linked_id        = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_LINKEDID), "");
 	r->amaflag          = ast_event_get_ie_uint(e, AST_EVENT_IE_CEL_AMAFLAGS);

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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/channel.c (original)
+++ team/rmudgett/cel_accountcode/main/channel.c Wed Jul  9 13:41:11 2014
@@ -5630,9 +5630,12 @@
 		if (oh->parent_channel) {
 			call_forward_inherit(new_chan, oh->parent_channel, orig);
 		}
-		if (oh->account) {
+		if (!ast_strlen_zero(oh->account)) {
 			ast_channel_lock(new_chan);
+			ast_channel_stage_snapshot(new_chan);
 			ast_channel_accountcode_set(new_chan, oh->account);
+			ast_channel_peeraccount_set(new_chan, oh->account);
+			ast_channel_stage_snapshot_done(new_chan);
 			ast_channel_unlock(new_chan);
 		}
 	} else if (caller) { /* no outgoing helper so use caller if available */
@@ -5641,9 +5644,9 @@
 	ast_set_flag(ast_channel_flags(new_chan), AST_FLAG_ORIGINATED);
 
 	ast_channel_lock_both(orig, new_chan);
-	ast_channel_accountcode_set(new_chan, ast_channel_accountcode(orig));
 	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_req_accountcodes(new_chan, orig, AST_CHANNEL_REQUESTOR_REPLACEMENT);
 	ast_channel_unlock(new_chan);
 	ast_channel_unlock(orig);
 
@@ -5706,9 +5709,12 @@
 			ast_channel_unlock(oh->parent_channel);
 			ast_channel_unlock(chan);
 		}
-		if (oh->account) {
+		if (!ast_strlen_zero(oh->account)) {
 			ast_channel_lock(chan);
+			ast_channel_stage_snapshot(chan);
 			ast_channel_accountcode_set(chan, oh->account);
+			ast_channel_peeraccount_set(chan, oh->account);
+			ast_channel_stage_snapshot_done(chan);
 			ast_channel_unlock(chan);
 		}
 	}
@@ -5736,6 +5742,12 @@
 		connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
 	}
 	ast_channel_set_connected_line(chan, &connected, NULL);
+	if (requestor) {
+		ast_channel_lock_both(chan, (struct ast_channel *) requestor);
+		ast_channel_req_accountcodes(chan, requestor, AST_CHANNEL_REQUESTOR_BRIDGE_PEER);
+		ast_channel_unlock(chan);
+		ast_channel_unlock((struct ast_channel *) requestor);
+	}
 
 	if (ast_call(chan, addr, 0)) {	/* ast_call failed... */
 		ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
@@ -5956,15 +5968,20 @@
 			return NULL;
 		}
 
-		/* Set newly created channel callid to same as the requestor */
 		if (requestor) {
-			struct ast_callid *callid = ast_channel_callid(requestor);
+			struct ast_callid *callid;
+
+			ast_channel_lock_both(c, (struct ast_channel *) requestor);
+
+			/* Set the newly created channel's callid to the same as the requestor. */
+			callid = ast_channel_callid(requestor);
 			if (callid) {
-				ast_channel_lock(c);
 				ast_channel_callid_set(c, callid);
-				ast_channel_unlock(c);
 				callid = ast_callid_unref(callid);
 			}
+
+			ast_channel_unlock(c);
+			ast_channel_unlock((struct ast_channel *) requestor);
 		}
 
 		joint_cap = ast_format_cap_destroy(joint_cap);
@@ -5985,6 +6002,88 @@
 	AST_RWLIST_UNLOCK(&backends);
 
 	return NULL;
+}
+
+/*!
+ * \internal
+ * \brief Setup new channel accountcodes from the requestor channel after ast_request().
+ * \since 13.0.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
+	 * so local channels can propagate accountcodes to the ;2
+	 * channel before ast_call().
+	 *
+	 * The secondary reason is to propagate the CHANNEL(peeraccount)
+	 * value set before Dial, FollowMe, and Queue while maintaining
+	 * the historic straight across accountcode propagation as a
+	 * fallback.
+	 */
+	switch (relationship) {
+	case AST_CHANNEL_REQUESTOR_BRIDGE_PEER:
+		/* Crossover the requestor's accountcode and peeraccount */
+		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_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));
+		}
+		break;
+	case AST_CHANNEL_REQUESTOR_REPLACEMENT:
+		/* Pass the requestor's accountcode and peeraccount straight. */
+		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/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/core_unreal.c?view=diff&rev=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/core_unreal.c (original)
+++ team/rmudgett/cel_accountcode/main/core_unreal.c Wed Jul  9 13:41:11 2014
@@ -36,6 +36,7 @@
 
 #include "asterisk/causes.h"
 #include "asterisk/channel.h"
+#include "asterisk/stasis_channels.h"
 #include "asterisk/pbx.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/astobj2.h"
@@ -100,6 +101,7 @@
 	struct ast_unreal_pvt *p;
 	struct ast_channel *otherchan = NULL;
 	ast_chan_write_info_t *write_info;
+	char *info_data;
 
 	if (option != AST_OPTION_CHANNEL_WRITE) {
 		return -1;
@@ -112,10 +114,19 @@
 		return -1;
 	}
 
-	if (!strcmp(write_info->function, "CHANNEL")
-		&& !strncasecmp(write_info->data, "hangup_handler_", 15)) {
-		/* Block CHANNEL(hangup_handler_xxx) writes to the other unreal channel. */
-		return 0;
+	info_data = write_info->data;
+	if (!strcmp(write_info->function, "CHANNEL")) {
+		if (!strncasecmp(info_data, "hangup_handler_", 15)) {
+			/* Block CHANNEL(hangup_handler_xxx) writes to the other unreal channel. */
+			return 0;
+		}
+
+		/* Crossover the accountcode and peeraccount to cross the unreal bridge. */
+		if (!strcasecmp(info_data, "accountcode")) {
+			info_data = "peeraccount";
+		} else if (!strcasecmp(info_data, "peeraccount")) {
+			info_data = "accountcode";
+		}
 	}
 
 	/* get the tech pvt */
@@ -140,7 +151,7 @@
 	ao2_unlock(p);
 
 	ast_channel_lock(otherchan);
-	res = write_info->write_fn(otherchan, write_info->function, write_info->data, write_info->value);
+	res = write_info->write_fn(otherchan, write_info->function, info_data, write_info->value);
 	ast_channel_unlock(otherchan);
 
 setoption_cleanup:
@@ -642,6 +653,8 @@
 	struct ast_var_t *varptr;
 	struct ast_var_t *clone_var;
 
+	ast_channel_stage_snapshot(semi2);
+
 	/*
 	 * Note that cid_num and cid_name aren't passed in the
 	 * ast_channel_alloc calls in ast_unreal_new_channels().  It's
@@ -651,11 +664,16 @@
 
 	ast_party_dialed_copy(ast_channel_dialed(semi2), ast_channel_dialed(semi1));
 
+	/* Crossover the CallerID and conected-line to cross the unreal bridge. */
 	ast_connected_line_copy_to_caller(ast_channel_caller(semi2), ast_channel_connected(semi1));
 	ast_connected_line_copy_from_caller(ast_channel_connected(semi2), ast_channel_caller(semi1));
 
 	ast_channel_language_set(semi2, ast_channel_language(semi1));
-	ast_channel_accountcode_set(semi2, ast_channel_accountcode(semi1));
+
+	/* Crossover the accountcode and peeraccount to cross the unreal bridge. */
+	ast_channel_accountcode_set(semi2, ast_channel_peeraccount(semi1));
+	ast_channel_peeraccount_set(semi2, ast_channel_accountcode(semi1));
+
 	ast_channel_musicclass_set(semi2, ast_channel_musicclass(semi1));
 
 	ast_channel_cc_params_init(semi2, ast_channel_get_cc_config_params(semi1));
@@ -682,6 +700,8 @@
 		}
 	}
 	ast_channel_datastore_inherit(semi1, semi2);
+
+	ast_channel_stage_snapshot_done(semi2);
 }
 
 int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge *bridge, unsigned int flags)

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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/dial.c (original)
+++ team/rmudgett/cel_accountcode/main/dial.c Wed Jul  9 13:41:11 2014
@@ -318,7 +318,12 @@
 	cap_request = NULL;
 	cap_all_audio = ast_format_cap_destroy(cap_all_audio);
 
-	ast_channel_lock(channel->owner);
+	if (chan) {
+		ast_channel_lock_both(chan, channel->owner);
+	} else {
+		ast_channel_lock(channel->owner);
+	}
+
 	ast_channel_stage_snapshot(channel->owner);
 
 	ast_channel_appl_set(channel->owner, "AppDial2");
@@ -339,12 +344,13 @@
 		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_accountcode_set(channel->owner, ast_channel_accountcode(chan));
+		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));
 
 		ast_channel_adsicpe_set(channel->owner, ast_channel_adsicpe(chan));
 		ast_channel_transfercapability_set(channel->owner, ast_channel_transfercapability(chan));
+		ast_channel_unlock(chan);
 	}
 
 	ast_channel_stage_snapshot_done(channel->owner);

Modified: team/rmudgett/cel_accountcode/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/pbx.c?view=diff&rev=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/main/pbx.c (original)
+++ team/rmudgett/cel_accountcode/main/pbx.c Wed Jul  9 13:41:11 2014
@@ -10347,8 +10347,11 @@
 	if (vars) {
 		ast_set_variables(dialed, vars);
 	}
-	if (account) {
+	if (!ast_strlen_zero(account)) {
+		ast_channel_stage_snapshot(dialed);
 		ast_channel_accountcode_set(dialed, account);
+		ast_channel_peeraccount_set(dialed, account);
+		ast_channel_stage_snapshot_done(dialed);
 	}
 	ast_set_flag(ast_channel_flags(dialed), AST_FLAG_ORIGINATED);
 	ast_channel_unlock(dialed);

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=418253&r1=418252&r2=418253
==============================================================================
--- team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c (original)
+++ team/rmudgett/cel_accountcode/res/parking/parking_bridge_features.c Wed Jul  9 13:41:11 2014
@@ -235,6 +235,7 @@
 
 	/* Before we actually dial out let's inherit appropriate information. */
 	ast_channel_lock_both(parker, parkee);
+	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