Add a missing part of the connected line work into trunk.
authorMark Michelson <mmichelson@digium.com>
Tue, 5 Jan 2010 18:46:19 +0000 (18:46 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 5 Jan 2010 18:46:19 +0000 (18:46 +0000)
Part of the work done for connected line was to add an optional
argument to the 'f' option to allow for the connected party information
of the outgoing channel to be set to the argument provided. This was
overlooked during the merge of the work to trunk and is being added
back now. The CHANGES file has also been updated to note this change.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@237803 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_dial.c

diff --git a/CHANGES b/CHANGES
index e15f498..cb35fa4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -127,6 +127,10 @@ Applications
  * Page has a new option 'A(x)' which will playback an announcement simultaneously
    to all paged phones (and optionally excluding the caller's one using the new
    option 'n') before the call is bridged.
  * Page has a new option 'A(x)' which will playback an announcement simultaneously
    to all paged phones (and optionally excluding the caller's one using the new
    option 'n') before the call is bridged.
+ * The 'f' option to Dial has been augmented to take an optional argument. If no
+   argument is provided, the 'f' option works as it always has. If an argument is
+   provided, then the connected party information of all outgoing channels created
+   during the Dial will be set to the argument passed to the 'f' option.
 
 Dialplan Functions
 ------------------
 
 Dialplan Functions
 ------------------
index c24a566..66e8bb8 100644 (file)
@@ -132,10 +132,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                        <para>Execute the <literal>h</literal> extension for peer after the call ends</para>
                                </option>
                                <option name="f">
                                        <para>Execute the <literal>h</literal> extension for peer after the call ends</para>
                                </option>
                                <option name="f">
-                                       <para>Force the callerid of the <emphasis>calling</emphasis> channel to be set as the
-                                       extension associated with the channel using a dialplan <literal>hint</literal>.
+                                       <argument name="x" required="false" />
+                                       <para>If <replaceable>x</replaceable> is not provided, force the callerid of the <emphasis>calling</emphasis> 
+                                       channel to be set as the extension associated with the channel using a dialplan <literal>hint</literal>.
                                        For example, some PSTNs do not allow CallerID to be set to anything
                                        For example, some PSTNs do not allow CallerID to be set to anything
-                                       other than the number assigned to the caller.</para>
+                                       other than the number assigned to the caller. If <replaceable>x</replaceable> is provided, though, then
+                                       this option behaves quite differently. Any outgoing channel created will have its connected party information
+                                       set to <replaceable>x</replaceable></para>
                                </option>
                                <option name="F" argsep="^">
                                        <argument name="context" required="false" />
                                </option>
                                <option name="F" argsep="^">
                                        <argument name="context" required="false" />
@@ -546,6 +549,7 @@ enum {
        OPT_ARG_DURATION_STOP,
        OPT_ARG_OPERMODE,
        OPT_ARG_SCREEN_NOINTRO,
        OPT_ARG_DURATION_STOP,
        OPT_ARG_OPERMODE,
        OPT_ARG_SCREEN_NOINTRO,
+       OPT_ARG_FORCECLID,
        /* note: this entry _MUST_ be the last one in the enum */
        OPT_ARG_ARRAY_SIZE,
 };
        /* note: this entry _MUST_ be the last one in the enum */
        OPT_ARG_ARRAY_SIZE,
 };
@@ -558,7 +562,7 @@ AST_APP_OPTIONS(dial_exec_options, BEGIN_OPTIONS
        AST_APP_OPTION('d', OPT_DTMF_EXIT),
        AST_APP_OPTION_ARG('D', OPT_SENDDTMF, OPT_ARG_SENDDTMF),
        AST_APP_OPTION('e', OPT_PEER_H),
        AST_APP_OPTION('d', OPT_DTMF_EXIT),
        AST_APP_OPTION_ARG('D', OPT_SENDDTMF, OPT_ARG_SENDDTMF),
        AST_APP_OPTION('e', OPT_PEER_H),
-       AST_APP_OPTION('f', OPT_FORCECLID),
+       AST_APP_OPTION_ARG('f', OPT_FORCECLID, OPT_ARG_FORCECLID),
        AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON),
        AST_APP_OPTION('g', OPT_GO_ON),
        AST_APP_OPTION_ARG('G', OPT_GOTO, OPT_ARG_GOTO),
        AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON),
        AST_APP_OPTION('g', OPT_GO_ON),
        AST_APP_OPTION_ARG('G', OPT_GOTO, OPT_ARG_GOTO),
@@ -1623,7 +1627,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
        struct cause_args num = { chan, 0, 0, 0 };
        int cause;
        char numsubst[256];
        struct cause_args num = { chan, 0, 0, 0 };
        int cause;
        char numsubst[256];
-       char cidname[AST_MAX_EXTENSION] = "";
+       char *cid_num = NULL, *cid_name = NULL;
 
        struct ast_bridge_config config = { { 0, } };
        struct timeval calldurationlimit = { 0, };
 
        struct ast_bridge_config config = { { 0, } };
        struct timeval calldurationlimit = { 0, };
@@ -1718,6 +1722,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        goto done;
        }
 
                        goto done;
        }
 
+       if (ast_test_flag64(&opts, OPT_FORCECLID) && !ast_strlen_zero(opt_args[OPT_ARG_FORCECLID]))
+               ast_callerid_parse(opt_args[OPT_ARG_FORCECLID], &cid_name, &cid_num);
        if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
                ast_cdr_reset(chan->cdr, NULL);
        if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
        if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
                ast_cdr_reset(chan->cdr, NULL);
        if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
@@ -1748,7 +1754,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
        }
        ast_channel_unlock(chan);       
        ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING | OPT_IGNORE_CONNECTEDLINE |
        }
        ast_channel_unlock(chan);       
        ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING | OPT_IGNORE_CONNECTEDLINE |
-                        OPT_CANCEL_TIMEOUT | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB);
+                        OPT_CANCEL_TIMEOUT | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB | OPT_FORCECLID);
 
        /* loop through the list of dial destinations */
        rest = args.peers;
 
        /* loop through the list of dial destinations */
        rest = args.peers;
@@ -1894,8 +1900,18 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        }
                        ast_set_flag64(tmp, DIAL_NOCONNECTEDLINE);
                }
                        }
                        ast_set_flag64(tmp, DIAL_NOCONNECTEDLINE);
                }
-               
-               ast_connected_line_copy_from_caller(&tc->connected, &chan->cid);
+
+               if (ast_test_flag64(peerflags, OPT_FORCECLID) && !ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) {
+                       struct ast_party_connected_line connected;
+
+                       ast_party_connected_line_set_init(&connected, &tmp->chan->connected);
+                       connected.id.number = cid_num;
+                       connected.id.name = cid_name;
+                       connected.id.number_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
+                       ast_channel_set_connected_line(tmp->chan, &connected);
+               } else {
+                       ast_connected_line_copy_from_caller(&tmp->chan->connected, &chan->cid);
+               }
 
                S_REPLACE(tc->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
                ast_party_redirecting_copy(&tc->redirecting, &chan->redirecting);
 
                S_REPLACE(tc->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
                ast_party_redirecting_copy(&tc->redirecting, &chan->redirecting);
@@ -1958,6 +1974,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        ast_verb(3, "Called %s\n", numsubst);
                        ast_channel_unlock(chan);
                        if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
                        ast_verb(3, "Called %s\n", numsubst);
                        ast_channel_unlock(chan);
                        if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
+                               char cidname[AST_MAX_EXTENSION];
                                ast_set_callerid(tc, tmpexten, get_cid_name(cidname, sizeof(cidname), chan), NULL);
                        }
                }
                                ast_set_callerid(tc, tmpexten, get_cid_name(cidname, sizeof(cidname), chan), NULL);
                        }
                }