]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add vars
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 11 Dec 2007 15:14:33 +0000 (15:14 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 11 Dec 2007 15:14:33 +0000 (15:14 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6640 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_dptools/mod_dptools.c

index 42dbbc7958cd7cc43c78b719b7b996eb8e5e200c..4c59f94b8fbc9551decd4b5385d56145919d7032 100644 (file)
@@ -1446,6 +1446,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
        const char *dest = NULL;
        static switch_call_cause_t cause;
        unsigned int timelimit = 60;
+       switch_channel_t *new_channel = NULL;
 
        user = switch_core_session_strdup(session, outbound_profile->destination_number);
 
@@ -1460,6 +1461,19 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
                goto done;
        }
 
+       if ((x_params = switch_xml_child(x_domain, "params"))) {
+               for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
+                       const char *var = switch_xml_attr(x_param, "name");
+                       const char *val = switch_xml_attr(x_param, "value");
+                       
+                       if (!strcasecmp(var, "dial-string")) {
+                               dest = val;
+                               break;
+                       }
+
+               }
+       }
+
        if ((x_params = switch_xml_child(x_user, "params"))) {
                for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
                        const char *var = switch_xml_attr(x_param, "name");
@@ -1486,11 +1500,12 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
                }
                
                d_dest = switch_channel_expand_variables(channel, dest);
-
+               
                if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, NULL, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
                        const char *context;
                        switch_caller_profile_t *cp;
-                       switch_channel_t *new_channel = switch_core_session_get_channel(*new_session);
+
+                       new_channel = switch_core_session_get_channel(*new_session);
                        
                        if ((context = switch_channel_get_variable(new_channel, "inbound_context"))) {
                                if ((cp = switch_channel_get_caller_profile(new_channel))) {
@@ -1506,6 +1521,25 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
                }
        }
 
+       if (new_channel && xml) {
+               if ((x_params = switch_xml_child(x_domain, "variables"))) {
+                       for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
+                               const char *var = switch_xml_attr(x_param, "name");
+                               const char *val = switch_xml_attr(x_param, "value");
+                               switch_channel_set_variable(new_channel, var, val);
+                       }
+               }
+
+               if ((x_params = switch_xml_child(x_user, "variables"))) {
+                       for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
+                               const char *var = switch_xml_attr(x_param, "name");
+                               const char *val = switch_xml_attr(x_param, "value");
+                               switch_channel_set_variable(new_channel, var, val);
+                       }
+               }
+               
+       }
+
        if (xml) {
                switch_xml_free(xml);
        }