[asterisk-commits] dvossel: branch dvossel/call_forward_api_trunk r198632 - in /team/dvossel/cal...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 1 13:54:07 CDT 2009


Author: dvossel
Date: Mon Jun  1 13:54:04 2009
New Revision: 198632

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=198632
Log:
Copy inherited information into new forwarded chan.

Modified:
    team/dvossel/call_forward_api_trunk/include/asterisk/channel.h
    team/dvossel/call_forward_api_trunk/main/channel.c
    team/dvossel/call_forward_api_trunk/main/features.c

Modified: team/dvossel/call_forward_api_trunk/include/asterisk/channel.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/dvossel/call_forward_api_trunk/include/asterisk/channel.h?view=diff&rev=198632&r1=198631&r2=198632
==============================================================================
--- team/dvossel/call_forward_api_trunk/include/asterisk/channel.h (original)
+++ team/dvossel/call_forward_api_trunk/include/asterisk/channel.h Mon Jun  1 13:54:04 2009
@@ -1082,14 +1082,15 @@
 
 /*!
  * \brief Forwards a call to a new channel specified by the original channel's call_forward str.  If possible, the new forwarded channel is created and returned while the original one is terminated.
- * \param orig original channel requesting the call forward
+ * \param caller in channel that requested orig
+ * \param orig channel being replaced by the call forward channel
  * \param timeout maximum amount of time to wait for setup of new forward channel
  * \param format requested channel format
  * \param oh Outgoing helper used with original channel
  * \param outstate reason why unsuccessful (if uncuccessful)
  * \return Returns the forwarded call's ast_channel on success or NULL on failure
  */
-struct ast_channel *ast_call_forward(struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
 
 /*!
  * \brief Register a channel technology (a new channel driver)

Modified: team/dvossel/call_forward_api_trunk/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/dvossel/call_forward_api_trunk/main/channel.c?view=diff&rev=198632&r1=198631&r2=198632
==============================================================================
--- team/dvossel/call_forward_api_trunk/main/channel.c (original)
+++ team/dvossel/call_forward_api_trunk/main/channel.c Mon Jun  1 13:54:04 2009
@@ -3944,10 +3944,11 @@
 	}
 }
 
-struct ast_channel *ast_call_forward(struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate)
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate)
 {
 	char tmpchan[256];
 	struct ast_channel *new = NULL;
+	struct ast_party_redirecting *apr = &orig->redirecting;
 	char *data, *type;
 	int cause = 0;
 
@@ -3972,7 +3973,9 @@
 		return NULL;
 	}
 
-	/* Copy important information from orig channel to new channel */
+	ast_channel_set_redirecting(new, apr);
+
+	/* Copy/inherit important information into new channel */
 	if (oh) {
 		if (oh->vars)
 			ast_set_variables(new, oh->vars);
@@ -3980,17 +3983,23 @@
 		if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name))
 			ast_set_callerid(new, oh->cid_num, oh->cid_name, oh->cid_num);
 		if (oh->parent_channel) {
+			ast_channel_update_redirecting(oh->parent_channel, apr);
 			ast_channel_inherit_variables(oh->parent_channel, new);
 			ast_channel_datastore_inherit(oh->parent_channel, new);
 		}
 		if (oh->account)
 			ast_cdr_setaccount(new, oh->account);
+	} else if (caller) { /* no outgoing helper so use caller if avaliable */
+		ast_channel_update_redirecting(caller, apr);
+		ast_channel_inherit_variables(caller, new);
+		ast_channel_datastore_inherit(caller, new);
 	}
 
 	ast_channel_lock(orig);
 	while (ast_channel_trylock(new)) {
 		CHANNEL_DEADLOCK_AVOIDANCE(orig);
 	}
+	ast_string_field_set(new, accountcode, orig->accountcode);
 	ast_party_caller_copy(&new->cid, &orig->cid);
 	ast_party_connected_line_copy(&new->connected, &orig->connected);
 	ast_channel_unlock(new);
@@ -4063,7 +4072,7 @@
 			if (timeout > -1)
 				timeout = res;
 			if (!ast_strlen_zero(chan->call_forward)) {
-				if (!(chan = ast_call_forward(chan, &timeout, format, oh, outstate))) {
+				if (!(chan = ast_call_forward(NULL, chan, &timeout, format, oh, outstate))) {
 					return NULL;
 				}
 				continue;

Modified: team/dvossel/call_forward_api_trunk/main/features.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/dvossel/call_forward_api_trunk/main/features.c?view=diff&rev=198632&r1=198631&r2=198632
==============================================================================
--- team/dvossel/call_forward_api_trunk/main/features.c (original)
+++ team/dvossel/call_forward_api_trunk/main/features.c Mon Jun  1 13:54:04 2009
@@ -2344,7 +2344,7 @@
 
 		if (chan && (chan == active_channel)){
 			if (!ast_strlen_zero(chan->call_forward)) {
-				if (!(chan = ast_call_forward(chan, &to, format, NULL, outstate))) {
+				if (!(chan = ast_call_forward(caller, chan, &to, format, NULL, outstate))) {
 					return NULL;
 				}
 				continue;




More information about the asterisk-commits mailing list