]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add export app (set + adding to export_vars) in 1
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 16 Feb 2007 20:07:35 +0000 (20:07 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 16 Feb 2007 20:07:35 +0000 (20:07 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4299 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_core.c

index b72faa317cbe5fe1bb6ea12b3f29449915925275..d3799cf71932109a1d83cf2e301435e1a56f6d02 100644 (file)
@@ -76,6 +76,7 @@ SWITCH_BEGIN_EXTERN_C
 #define SWITCH_GRAMMAR_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "grammar"
 #endif
 
+#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
 #define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
 #define SWITCH_L_SDP_VARIABLE "switch_l_sdp"
 #define SWITCH_B_SDP_VARIABLE "switch_m_sdp"
index 0630963b4b4a4f31bc5717531d905bcc384a88a7..7b0d2e9faa5878cf921966d98ed5f2a2644e31a5 100644 (file)
@@ -210,6 +210,43 @@ static void set_function(switch_core_session_t *session, char *data)
        }
 }
 
+static void export_function(switch_core_session_t *session, char *data)
+{
+       switch_channel_t *channel;
+       char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
+
+       channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+       if (switch_strlen_zero(data)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
+       } else {
+               exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
+               var = switch_core_session_strdup(session, data);
+               val = strchr(var, '=');
+
+               if (val) {
+                       *val++ = '\0';
+            if (switch_strlen_zero(val)) {
+                val = NULL;
+            }
+               }
+               
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
+               switch_channel_set_variable(channel, var, val);
+
+               if (var && val) {
+                       if (exports) {
+                               new_exports_d = switch_mprintf("%s,%s", exports, var);
+                               new_exports = new_exports_d;
+                       } else {
+                               new_exports = var;
+                       }
+                       switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
+                       switch_safe_free(new_exports_d);
+               }
+       }
+}
 
 static void unset_function(switch_core_session_t *session, char *data)
 {
@@ -567,13 +604,22 @@ static const switch_application_interface_t set_application_interface = {
        /*.next */ &unset_application_interface
 };
 
+static const switch_application_interface_t export_application_interface = {
+       /*.interface_name */ "export",
+       /*.application_function */ export_function,
+       /* long_desc */ "Set and export a channel varaible for the channel calling the application.",
+       /* short_desc */ "Export a channel varaible across a bridge",
+       /* syntax */ "<varname>=<value>",
+       /*.next */ &set_application_interface
+};
+
 static const switch_application_interface_t info_application_interface = {
        /*.interface_name */ "info",
        /*.application_function */ info_function,
        /* long_desc */ "Display Call Info",
        /* short_desc */ "Display Call Info",
        /* syntax */ "",
-       /*.next */ &set_application_interface
+       /*.next */ &export_application_interface
 };
 
 static const switch_application_interface_t log_application_interface = {
index 3b3c6b9976b8e41720d9c2bb656b369b696b541d..d250ce18f427709f5eceffc9535f1623ad23d2c0 100644 (file)
@@ -1641,7 +1641,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
                        switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VARIABLE, switch_core_session_get_uuid(session));            
 
             /* A comma (,) separated list of variable names that should ne propagated from originator to originatee */
-                       if ((export_vars = switch_channel_get_variable(channel, "export_vars"))) {
+                       if ((export_vars = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE))) {
                                char *cptmp = switch_core_session_strdup(session, export_vars);
                                int argc;
                                char *argv[256];