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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 18 13:57:12 CDT 2014


Author: rmudgett
Date: Wed Jun 18 13:57:07 2014
New Revision: 416647

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416647
Log:
accountcode propagation: Initial patch that is on reviewboard r3601.

* Changed the accountcode propagation from simply setting the accountcode
of the channel initiating the call onto the outgoing channel to setting
the accountcode only if the outgoing channel doesn't already have one.
In other words, if a channel already has an accountcode it will not be
changed unless explicitly set by CHANNEL(accountcode) or an originate
method that can specify an accountcode.  The most visible effect the
change has is if the channel driver is configured with an accountcode
for new channels.

* Moved most accountcode propagation behavior into ast_request() which
eliminates several inconsistencies throughout the code.  (app_dial,
app_followme, app_queue, and the dialing API)

* Fixed the basic bridge sub-class updating peeraccount codes when the
number of channels in the bridge drops back down to two parties.

* Refactored ast_bridge_channel_update_accountcodes() to handle channels
joining/leaving the bridge.

* Fixed the basic bridge to not call the base pull method twice.

* Fixed CEL extracting the wrong ie value for the peeraccount.

* Fixed some incorrect CEL event ie types.  These seem to only be used
by the unit tests.

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/bridge_channel.h
    team/rmudgett/cel_accountcode/main/bridge_basic.c
    team/rmudgett/cel_accountcode/main/bridge_channel.c
    team/rmudgett/cel_accountcode/main/cel.c
    team/rmudgett/cel_accountcode/main/channel.c
    team/rmudgett/cel_accountcode/main/dial.c
    team/rmudgett/cel_accountcode/main/event.c
    team/rmudgett/cel_accountcode/main/pbx.c

Modified: team/rmudgett/cel_accountcode/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/UPGRADE.txt?view=diff&rev=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/UPGRADE.txt (original)
+++ team/rmudgett/cel_accountcode/UPGRADE.txt Wed Jun 18 13:57:07 2014
@@ -21,7 +21,16 @@
 ===
 ===========================================================
 
-From 12.3.0 to 12.4.0:
+From 12.3.1 to 12.4.0:
+
+ - The accountcode propagation changed from simply setting the accountcode
+   of the channel initiating the call onto the outgoing channel to setting
+   the accountcode only if the outgoing channel doesn't already have one.
+   In other words, if a channel already has an accountcode it will not be
+   changed unless explicitly set by CHANNEL(accountcode) or an originate
+   method that can specify an accountcode.  The most visible effect the
+   change has is if the channel driver is configured with an accountcode
+   for new channels.
 
  - The safe_asterisk script was previously not installed on top of an existing
    version. This caused bug-fixes in that script not to be deployed. If your

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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_dial.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_dial.c Wed Jun 18 13:57:07 2014
@@ -949,8 +949,6 @@
 		} else {
 			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_appl_set(c, "AppDial");
 		ast_channel_data_set(c, "(Outgoing Line)");
@@ -2517,9 +2515,6 @@
 
 		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));
-		}
 		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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_followme.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_followme.c Wed Jun 18 13:57:07 2014
@@ -1070,7 +1070,6 @@
 			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_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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/apps/app_queue.c (original)
+++ team/rmudgett/cel_accountcode/apps/app_queue.c Wed Jun 18 13:57:07 2014
@@ -4663,8 +4663,6 @@
 							ast_party_connected_line_copy(&o->connected, ast_channel_connected(in));
 						}
 
-						ast_channel_accountcode_set(o->chan, ast_channel_accountcode(in));
-
 						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/bridge_channel.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/include/asterisk/bridge_channel.h?view=diff&rev=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/include/asterisk/bridge_channel.h (original)
+++ team/rmudgett/cel_accountcode/include/asterisk/bridge_channel.h Wed Jun 18 13:57:07 2014
@@ -326,14 +326,15 @@
  * \param bridge_channel The channel joining the bridge
  * \param swap The channel being swapped out of the bridge. May be NULL.
  *
- * \note The bridge must be locked prior to calling this function. This should be called
- * during a \ref bridge_channel_internal_push operation, typically by a sub-class of a bridge
+ * \note The bridge must be locked prior to calling this function.
+ * \note This should be called during a \ref bridge_channel_internal_push
+ * operation, typically by a sub-class of a bridge.
  */
 void ast_bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
 
 /*!
  * \internal
- * \brief Update the accountcodes for a channel entering a bridge
+ * \brief Update the accountcodes for channels joining/leaving a bridge
  * \since 12.0.0
  *
  * This function updates the accountcode and peeraccount on channels in two-party
@@ -341,13 +342,17 @@
  * however accountcode propagation will still occur if the channel joining has an
  * accountcode.
  *
- * \param bridge_channel The channel joining the bridge
- * \param swap The channel being swapped out of the bridge. May be NULL.
- *
- * \note The bridge must be locked prior to calling this function. This should be called
- * during a \ref bridge_channel_internal_push operation, typically by a sub-class of a bridge
- */
-void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
+ * \param joining The channel joining the bridge.  May be NULL.
+ * \param leaving The channel leaving or being swapped out of the bridge. May be NULL.
+ *
+ * \note The joining and leaving parameters cannot both be NULL.
+ *
+ * \note The bridge must be locked prior to calling this function.
+ * \note This should be called during a \ref bridge_channel_internal_push
+ * or \ref bridge_channel_internal_pull operation, typically by a
+ * sub-class of a bridge.
+ */
+void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *joining, struct ast_bridge_channel *leaving);
 
 /*!
  * \brief Write a frame to the specified bridge_channel.

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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge_basic.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge_basic.c Wed Jun 18 13:57:07 2014
@@ -665,20 +665,22 @@
 		return -1;
 	}
 
+	return 0;
+}
+
+static int bridge_basic_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+{
+	struct bridge_basic_personality *personality = self->personality;
+
+	ast_assert(personality != NULL);
+
+	if (personality->details[personality->current].v_table->push
+		&& personality->details[personality->current].v_table->push(self, bridge_channel, swap)) {
+		return -1;
+	}
+
+	ast_bridge_channel_update_linkedids(bridge_channel, swap);
 	ast_bridge_channel_update_accountcodes(bridge_channel, swap);
-	ast_bridge_channel_update_linkedids(bridge_channel, swap);
-	return 0;
-}
-
-static int bridge_basic_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
-{
-	struct bridge_basic_personality *personality = self->personality;
-
-	ast_assert(personality != NULL);
-
-	if (personality->details[personality->current].v_table->push(self, bridge_channel, swap)) {
-		return -1;
-	}
 
 	return ast_bridge_base_v_table.push(self, bridge_channel, swap);
 }
@@ -692,6 +694,8 @@
 	if (personality->details[personality->current].v_table->pull) {
 		personality->details[personality->current].v_table->pull(self, bridge_channel);
 	}
+
+	ast_bridge_channel_update_accountcodes(NULL, bridge_channel);
 
 	ast_bridge_base_v_table.pull(self, bridge_channel);
 }
@@ -3315,11 +3319,9 @@
 	ast_bridge_basic_v_table.pull = bridge_basic_pull;
 	ast_bridge_basic_v_table.destroy = bridge_basic_destroy;
 
-	personality_normal_v_table = ast_bridge_base_v_table;
 	personality_normal_v_table.name = "normal";
 	personality_normal_v_table.push = bridge_personality_normal_push;
 
-	personality_atxfer_v_table = ast_bridge_base_v_table;
 	personality_atxfer_v_table.name = "attended transfer";
 	personality_atxfer_v_table.push = bridge_personality_atxfer_push;
 	personality_atxfer_v_table.pull = bridge_personality_atxfer_pull;

Modified: team/rmudgett/cel_accountcode/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/bridge_channel.c?view=diff&rev=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/bridge_channel.c (original)
+++ team/rmudgett/cel_accountcode/main/bridge_channel.c Wed Jun 18 13:57:07 2014
@@ -357,7 +357,7 @@
 
 void ast_bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 {
-	struct ast_bridge_channel *other = NULL;
+	struct ast_bridge_channel *other;
 	struct ast_bridge *bridge = bridge_channel->bridge;
 	struct ast_channel *oldest_linkedid_chan = bridge_channel->chan;
 
@@ -370,65 +370,212 @@
 	}
 
 	ast_channel_lock(bridge_channel->chan);
-	ast_channel_internal_copy_linkedid(bridge_channel->chan,
-		oldest_linkedid_chan);
+	ast_channel_internal_copy_linkedid(bridge_channel->chan, oldest_linkedid_chan);
 	ast_channel_unlock(bridge_channel->chan);
 	AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
 		if (other == swap) {
 			continue;
 		}
 		ast_channel_lock(other->chan);
-		ast_channel_internal_copy_linkedid(other->chan,
-			oldest_linkedid_chan);
+		ast_channel_internal_copy_linkedid(other->chan, oldest_linkedid_chan);
 		ast_channel_unlock(other->chan);
 	}
 }
 
-void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
-{
-	struct ast_bridge *bridge = bridge_channel->bridge;
-	struct ast_bridge_channel *other = NULL;
+/*!
+ * \internal
+ * \brief Set dest's empty peeraccount with the src's non-empty accountcode.
+ * \since 12.4.0
+ *
+ * \param dest Bridge channel to update peeraccount.
+ * \param src Bridge channel to get accountcode from.
+ *
+ * \note Both bridge_channels are already locked.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_fill_empty_peeraccount(struct ast_bridge_channel *dest, struct ast_bridge_channel *src)
+{
+	if (ast_strlen_zero(ast_channel_peeraccount(dest->chan))
+		&& !ast_strlen_zero(ast_channel_accountcode(src->chan))) {
+		ast_debug(1, "Setting channel %s peeraccount with channel %s accountcode '%s'.\n",
+			ast_channel_name(dest->chan),
+			ast_channel_name(src->chan), ast_channel_accountcode(src->chan));
+		ast_channel_peeraccount_set(dest->chan, ast_channel_accountcode(src->chan));
+	}
+}
+
+/*!
+ * \internal
+ * \brief Set dest's empty accountcode with the src's non-empty peeraccount.
+ * \since 12.4.0
+ *
+ * \param dest Bridge channel to update accountcode.
+ * \param src Bridge channel to get peeraccount from.
+ *
+ * \note Both bridge_channels are already locked.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_fill_empty_accountcode(struct ast_bridge_channel *dest, struct ast_bridge_channel *src)
+{
+	if (ast_strlen_zero(ast_channel_accountcode(dest->chan))
+		&& !ast_strlen_zero(ast_channel_peeraccount(src->chan))) {
+		ast_debug(1, "Setting channel %s accountcode with channel %s peeraccount '%s'.\n",
+			ast_channel_name(dest->chan),
+			ast_channel_name(src->chan), ast_channel_peeraccount(src->chan));
+		ast_channel_accountcode_set(dest->chan, ast_channel_peeraccount(src->chan));
+	}
+}
+
+/*!
+ * \internal
+ * \brief Set empty peeraccount and accountcode in a channel from the other channel.
+ * \since 12.4.0
+ *
+ * \param bc0 First bridge channel to update.
+ * \param bc1 Second bridge channel to update.
+ *
+ * \note Both bridge_channels are already locked.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_set_empty_accountcodes(struct ast_bridge_channel *bc0, struct ast_bridge_channel *bc1)
+{
+	/* Set empty peeraccount from the other channel's accountcode. */
+	bridge_channel_fill_empty_peeraccount(bc0, bc1);
+	bridge_channel_fill_empty_peeraccount(bc1, bc0);
+
+	/* Set empty accountcode from the other channel's peeraccount. */
+	bridge_channel_fill_empty_accountcode(bc0, bc1);
+	bridge_channel_fill_empty_accountcode(bc1, bc0);
+}
+
+/*!
+ * \internal
+ * \brief Update dest's peeraccount with the src's different accountcode.
+ * \since 12.4.0
+ *
+ * \param dest Bridge channel to update peeraccount.
+ * \param src Bridge channel to get accountcode from.
+ *
+ * \note Both bridge_channels are already locked.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_update_peeraccount(struct ast_bridge_channel *dest, struct ast_bridge_channel *src)
+{
+	if (strcmp(ast_channel_accountcode(src->chan), ast_channel_peeraccount(dest->chan))) {
+		ast_debug(1, "Changing channel %s peeraccount '%s' to match channel %s accountcode '%s'.\n",
+			ast_channel_name(dest->chan), ast_channel_peeraccount(dest->chan),
+			ast_channel_name(src->chan), ast_channel_accountcode(src->chan));
+		ast_channel_peeraccount_set(dest->chan, ast_channel_accountcode(src->chan));
+	}
+}
+
+/*!
+ * \internal
+ * \brief Update peeraccounts to match the other channel's accountcode.
+ * \since 12.4.0
+ *
+ * \param bc0 First bridge channel to update.
+ * \param bc1 Second bridge channel to update.
+ *
+ * \note Both bridge_channels are already locked.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_update_peeraccounts(struct ast_bridge_channel *bc0, struct ast_bridge_channel *bc1)
+{
+	bridge_channel_update_peeraccount(bc0, bc1);
+	bridge_channel_update_peeraccount(bc1, bc0);
+}
+
+/*!
+ * \internal
+ * \brief Update channel accountcodes because a channel is joining a bridge.
+ * \since 12.4.0
+ *
+ * \param joining Channel joining the bridge.
+ * \param swap Channel being replaced by the joining channel.  May be NULL.
+ *
+ * \note The bridge must be locked prior to calling this function.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_update_accountcodes_joining(struct ast_bridge_channel *joining, struct ast_bridge_channel *swap)
+{
+	struct ast_bridge *bridge = joining->bridge;
+	struct ast_bridge_channel *other;
+	unsigned int swap_in_bridge = 0;
+	unsigned int will_be_two_party;
+
+	/*
+	 * Only update the peeraccount to match if the joining channel
+	 * will make it a two party bridge.
+	 */
+	if (bridge->num_channels <= 2 && swap) {
+		AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
+			if (other == swap) {
+				swap_in_bridge = 1;
+				break;
+			}
+		}
+	}
+	will_be_two_party = (1 == bridge->num_channels - swap_in_bridge);
 
 	AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
 		if (other == swap) {
 			continue;
 		}
-		ast_channel_lock_both(bridge_channel->chan, other->chan);
-
-		if (!ast_strlen_zero(ast_channel_accountcode(bridge_channel->chan)) && ast_strlen_zero(ast_channel_peeraccount(other->chan))) {
-			ast_debug(1, "Setting peeraccount to %s for %s from data on channel %s\n",
-					ast_channel_accountcode(bridge_channel->chan), ast_channel_name(other->chan), ast_channel_name(bridge_channel->chan));
-			ast_channel_peeraccount_set(other->chan, ast_channel_accountcode(bridge_channel->chan));
-		}
-		if (!ast_strlen_zero(ast_channel_accountcode(other->chan)) && ast_strlen_zero(ast_channel_peeraccount(bridge_channel->chan))) {
-			ast_debug(1, "Setting peeraccount to %s for %s from data on channel %s\n",
-					ast_channel_accountcode(other->chan), ast_channel_name(bridge_channel->chan), ast_channel_name(other->chan));
-			ast_channel_peeraccount_set(bridge_channel->chan, ast_channel_accountcode(other->chan));
-		}
-		if (!ast_strlen_zero(ast_channel_peeraccount(bridge_channel->chan)) && ast_strlen_zero(ast_channel_accountcode(other->chan))) {
-			ast_debug(1, "Setting accountcode to %s for %s from data on channel %s\n",
-					ast_channel_peeraccount(bridge_channel->chan), ast_channel_name(other->chan), ast_channel_name(bridge_channel->chan));
-			ast_channel_accountcode_set(other->chan, ast_channel_peeraccount(bridge_channel->chan));
-		}
-		if (!ast_strlen_zero(ast_channel_peeraccount(other->chan)) && ast_strlen_zero(ast_channel_accountcode(bridge_channel->chan))) {
-			ast_debug(1, "Setting accountcode to %s for %s from data on channel %s\n",
-					ast_channel_peeraccount(other->chan), ast_channel_name(bridge_channel->chan), ast_channel_name(other->chan));
-			ast_channel_accountcode_set(bridge_channel->chan, ast_channel_peeraccount(other->chan));
-		}
-		if (bridge->num_channels == 2) {
-			if (strcmp(ast_channel_accountcode(bridge_channel->chan), ast_channel_peeraccount(other->chan))) {
-				ast_debug(1, "Changing peeraccount from %s to %s on %s to match channel %s\n",
-						ast_channel_peeraccount(other->chan), ast_channel_peeraccount(bridge_channel->chan), ast_channel_name(other->chan), ast_channel_name(bridge_channel->chan));
-				ast_channel_peeraccount_set(other->chan, ast_channel_accountcode(bridge_channel->chan));
-			}
-			if (strcmp(ast_channel_accountcode(other->chan), ast_channel_peeraccount(bridge_channel->chan))) {
-				ast_debug(1, "Changing peeraccount from %s to %s on %s to match channel %s\n",
-						ast_channel_peeraccount(bridge_channel->chan), ast_channel_peeraccount(other->chan), ast_channel_name(bridge_channel->chan), ast_channel_name(other->chan));
-				ast_channel_peeraccount_set(bridge_channel->chan, ast_channel_accountcode(other->chan));
-			}
-		}
-		ast_channel_unlock(bridge_channel->chan);
+		ast_assert(joining != other);
+		ast_channel_lock_both(joining->chan, other->chan);
+		bridge_channel_set_empty_accountcodes(joining, other);
+		if (will_be_two_party) {
+			bridge_channel_update_peeraccounts(joining, other);
+		}
+		ast_channel_unlock(joining->chan);
 		ast_channel_unlock(other->chan);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Update channel peeraccount codes because a channel has left a bridge.
+ * \since 12.4.0
+ *
+ * \param leaving Channel leaving the bridge. (Has already been removed actually)
+ *
+ * \note The bridge must be locked prior to calling this function.
+ *
+ * \return Nothing
+ */
+static void bridge_channel_update_accountcodes_leaving(struct ast_bridge_channel *leaving)
+{
+	struct ast_bridge *bridge = leaving->bridge;
+	struct ast_bridge_channel *first;
+	struct ast_bridge_channel *second;
+
+	if (bridge->num_channels != 2 || bridge->dissolved) {
+		return;
+	}
+
+	first = AST_LIST_FIRST(&bridge->channels);
+	second = AST_LIST_LAST(&bridge->channels);
+	ast_assert(first && first != second);
+	ast_channel_lock_both(first->chan, second->chan);
+	bridge_channel_set_empty_accountcodes(first, second);
+	bridge_channel_update_peeraccounts(first, second);
+	ast_channel_unlock(second->chan);
+	ast_channel_unlock(first->chan);
+}
+
+void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *joining, struct ast_bridge_channel *leaving)
+{
+	if (joining) {
+		bridge_channel_update_accountcodes_joining(joining, leaving);
+	} else {
+		bridge_channel_update_accountcodes_leaving(leaving);
 	}
 }
 
@@ -1747,6 +1894,8 @@
 	}
 	--bridge->num_channels;
 	AST_LIST_REMOVE(&bridge->channels, bridge_channel, entry);
+
+	bridge_channel_dissolve_check(bridge_channel);
 	bridge->v_table->pull(bridge, bridge_channel);
 
 	ast_bridge_channel_clear_roles(bridge_channel);
@@ -1760,8 +1909,6 @@
 		ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
 		ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
 	}
-
-	bridge_channel_dissolve_check(bridge_channel);
 
 	bridge->reconfigured = 1;
 	ast_bridge_publish_leave(bridge, bridge_channel->chan);

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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/cel.c (original)
+++ team/rmudgett/cel_accountcode/main/cel.c Wed Jun 18 13:57:07 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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/channel.c (original)
+++ team/rmudgett/cel_accountcode/main/channel.c Wed Jun 18 13:57:07 2014
@@ -5635,7 +5635,7 @@
 		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_accountcode_set(new_chan, oh->account);
 			ast_channel_unlock(new_chan);
@@ -5646,7 +5646,6 @@
 	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_unlock(new_chan);
@@ -5711,7 +5710,7 @@
 			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_accountcode_set(chan, oh->account);
 			ast_channel_unlock(chan);
@@ -5961,15 +5960,29 @@
 			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 newly created channel 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);
 			}
+
+			/*
+			 * Set newly created channel accountcode to the same as the
+			 * requestor if it doesn't already have one.
+			 */
+			if (ast_strlen_zero(ast_channel_accountcode(c))
+				&& !ast_strlen_zero(ast_channel_accountcode(requestor))) {
+				ast_channel_accountcode_set(c, ast_channel_accountcode(requestor));
+			}
+
+			ast_channel_unlock(c);
+			ast_channel_unlock((struct ast_channel *) requestor);
 		}
 
 		joint_cap = ast_format_cap_destroy(joint_cap);

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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/dial.c (original)
+++ team/rmudgett/cel_accountcode/main/dial.c Wed Jun 18 13:57:07 2014
@@ -322,7 +322,6 @@
 		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));
 		if (ast_strlen_zero(ast_channel_musicclass(channel->owner)))
 			ast_channel_musicclass_set(channel->owner, ast_channel_musicclass(chan));
 

Modified: team/rmudgett/cel_accountcode/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/cel_accountcode/main/event.c?view=diff&rev=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/event.c (original)
+++ team/rmudgett/cel_accountcode/main/event.c Wed Jun 18 13:57:07 2014
@@ -144,7 +144,7 @@
 	[AST_EVENT_IE_CEL_EVENT_TYPE]      = { AST_EVENT_IE_PLTYPE_UINT, "CELEventType" },
 	[AST_EVENT_IE_CEL_EVENT_TIME]      = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTime" },
 	[AST_EVENT_IE_CEL_EVENT_TIME_USEC] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTimeUSec" },
-	[AST_EVENT_IE_CEL_USEREVENT_NAME]  = { AST_EVENT_IE_PLTYPE_UINT, "CELUserEventName" },
+	[AST_EVENT_IE_CEL_USEREVENT_NAME]  = { AST_EVENT_IE_PLTYPE_STR,  "CELUserEventName" },
 	[AST_EVENT_IE_CEL_CIDNAME]         = { AST_EVENT_IE_PLTYPE_STR,  "CELCIDName" },
 	[AST_EVENT_IE_CEL_CIDNUM]          = { AST_EVENT_IE_PLTYPE_STR,  "CELCIDNum" },
 	[AST_EVENT_IE_CEL_EXTEN]           = { AST_EVENT_IE_PLTYPE_STR,  "CELExten" },
@@ -152,8 +152,8 @@
 	[AST_EVENT_IE_CEL_CHANNAME]        = { AST_EVENT_IE_PLTYPE_STR,  "CELChanName" },
 	[AST_EVENT_IE_CEL_APPNAME]         = { AST_EVENT_IE_PLTYPE_STR,  "CELAppName" },
 	[AST_EVENT_IE_CEL_APPDATA]         = { AST_EVENT_IE_PLTYPE_STR,  "CELAppData" },
-	[AST_EVENT_IE_CEL_AMAFLAGS]        = { AST_EVENT_IE_PLTYPE_STR,  "CELAMAFlags" },
-	[AST_EVENT_IE_CEL_ACCTCODE]        = { AST_EVENT_IE_PLTYPE_UINT, "CELAcctCode" },
+	[AST_EVENT_IE_CEL_AMAFLAGS]        = { AST_EVENT_IE_PLTYPE_UINT, "CELAMAFlags" },
+	[AST_EVENT_IE_CEL_ACCTCODE]        = { AST_EVENT_IE_PLTYPE_STR,  "CELAcctCode" },
 	[AST_EVENT_IE_CEL_UNIQUEID]        = { AST_EVENT_IE_PLTYPE_STR,  "CELUniqueID" },
 	[AST_EVENT_IE_CEL_USERFIELD]       = { AST_EVENT_IE_PLTYPE_STR,  "CELUserField" },
 	[AST_EVENT_IE_CEL_CIDANI]          = { AST_EVENT_IE_PLTYPE_STR,  "CELCIDani" },

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=416647&r1=416646&r2=416647
==============================================================================
--- team/rmudgett/cel_accountcode/main/pbx.c (original)
+++ team/rmudgett/cel_accountcode/main/pbx.c Wed Jun 18 13:57:07 2014
@@ -10323,7 +10323,7 @@
 	if (vars) {
 		ast_set_variables(dialed, vars);
 	}
-	if (account) {
+	if (!ast_strlen_zero(account)) {
 		ast_channel_accountcode_set(dialed, account);
 	}
 	ast_set_flag(ast_channel_flags(dialed), AST_FLAG_ORIGINATED);




More information about the asterisk-commits mailing list