]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9874 - implement use of translate:<profile> - squashed
authorTihomir Culjaga <tculjaga@gmail.com>
Wed, 4 Jan 2017 14:18:30 +0000 (08:18 -0600)
committerTihomir Culjaga <tculjaga@gmail.com>
Mon, 9 Jan 2017 22:03:38 +0000 (16:03 -0600)
src/mod/applications/mod_translate/mod_translate.c

index 5fbf8fbe32e5e97677d0d6dd3af1d6f0167b0379..d1a18f35e3d86f7c5ed4a258a68a5b98b718d70e 100644 (file)
@@ -258,9 +258,11 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
        switch_channel_t *channel = switch_core_session_get_channel(session);
        char *translated_dest = NULL;
        char *translated_cid_num = NULL;
+       char *translated_ani = NULL;
        char *translate_profile = NULL;
        char *areacode = NULL;
 
+
        if (!caller_profile) {
                if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
@@ -271,7 +273,12 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Processing %s <%s>->%s in translate\n",
                                          caller_profile->caller_id_name, caller_profile->caller_id_number, caller_profile->destination_number);
 
-       if ((translate_profile = (char *) switch_channel_get_variable(channel, "translate_profile"))) {
+
+
+       if ((translate_profile = (char *) arg)) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                 "using translate:<profile> [%s] for translate profile\n",translate_profile);
+       } else  if ((translate_profile = (char *) switch_channel_get_variable(channel, "translate_profile"))) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
                                                  "using translate_profile variable [%s] for translate profile\n", translate_profile);
        } else  if ((translate_profile = (char *) switch_channel_get_variable(channel, "country"))) {
@@ -295,14 +302,21 @@ SWITCH_STANDARD_DIALPLAN(translate_dialplan_hunt)
 
        translate_number((char *) caller_profile->destination_number, translate_profile, &translated_dest, session, NULL, NULL);
        translate_number((char *) caller_profile->caller_id_number, translate_profile, &translated_cid_num, session, NULL, NULL);
-       /* maybe we should translate ani/aniii here too? */
+       translate_number((char *) caller_profile->ani, translate_profile, &translated_ani, session, NULL, NULL);
+
+       /* maybe we should translate aniii here too? */ 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO,
-                                         "Profile: [%s] Translated Destination: [%s] Translated CID: [%s]\n", translate_profile, translated_dest, translated_cid_num);
+                                         "Profile: [%s], Translated Destination: [%s], Translated CID: [%s], Translated ANI: [%s]\n", translate_profile, translated_dest, translated_cid_num, translated_ani);
 
        if (!zstr(translated_cid_num)) {
                caller_profile->caller_id_number = translated_cid_num;
        }
 
+       if (!zstr(translated_ani)) {
+               caller_profile->ani = translated_ani;
+       }
+
+
        if (!zstr(translated_dest)) {
                caller_profile->destination_number = translated_dest;
        }