issue #5564
authorKevin P. Fleming <kpfleming@digium.com>
Tue, 1 Nov 2005 21:11:57 +0000 (21:11 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Tue, 1 Nov 2005 21:11:57 +0000 (21:11 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6935 65c4cc65-6c06-0410-ace0-fbb531ad65f3

ChangeLog
apps/app_parkandannounce.c
channel.c
include/asterisk/channel.h

index f34134d..6206f02 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2005-11-01  Kevin P. Fleming  <kpfleming@digium.com>
 
+       * apps/app_parkandannounce.c (parkandannounce_exec): supply parent channel to ast_request_and_dial so channel variables can be inherited (issue #5564)
+       * include/asterisk/channel.h: add parent_channel field
+       * channel.c (__ast_request_and_dial): use parent_channel field to inherit variables into new channel
+
        * apps/app_cut.c (cut_internal): use ast_separate_app_args() instead of open code (issue #5560)
 
        * apps/app_mixmonitor.c (launch_monitor_thread): ast_strlen_zero can handle NULL input (issue #5561)
index 6c9650f..1db9101 100755 (executable)
@@ -77,6 +77,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
        char *s,*orig_s;
 
        struct ast_channel *dchan;
+       struct outgoing_helper oh;
        int outstate;
 
        struct localuser *u;
@@ -178,7 +179,9 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
 
        /* Now place the call to the extention */
 
-       dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name);
+       memset(&oh, 0, sizeof(oh));
+       oh.parent_channel = chan;
+       dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
 
        if(dchan) {
                if(dchan->_state == AST_STATE_UP) {
index b67dc70..e244843 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -2355,8 +2355,12 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, void *d
        chan = ast_request(type, format, data, &cause);
        if (chan) {
                if (oh) {
-                       ast_set_variables(chan, oh->vars);
-                       ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
+                       if (oh->vars)   
+                               ast_set_variables(chan, oh->vars);
+                       if (oh->cid_num && *oh->cid_num && oh->cid_name && *oh->cid_name)
+                               ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
+                       if (oh->parent_channel)
+                               ast_channel_inherit_variables(oh->parent_channel, chan);
                }
                ast_set_callerid(chan, cid_num, cid_name, cid_num);
 
index 6599edb..ce5975d 100755 (executable)
@@ -434,6 +434,7 @@ struct chanmon;
        oh.cid_num = cid_num; \
        oh.cid_name = cid_name; \
        oh.vars = vars; \
+       oh.parent_channel = NULL; \
 } 
 
 struct outgoing_helper {
@@ -443,6 +444,7 @@ struct outgoing_helper {
        const char *cid_num;
        const char *cid_name;
        struct ast_variable *vars;
+       struct ast_channel *parent_channel;
 };
 
 #define AST_CDR_TRANSFER       (1 << 0)