]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_voicemail: Add ability to skip greeting and instructions when leaving voicemail...
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Fri, 25 Sep 2009 21:27:00 +0000 (21:27 +0000)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Fri, 25 Sep 2009 21:27:00 +0000 (21:27 +0000)
Add 1 or 2 of these variable in your user directory :
skip_greeting = Will skip the user greeting or generated greeting
skip_instructions = Will skip the system standards instructions to record message

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14990 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_voicemail/mod_voicemail.c

index 6f9c936d525b2226e640911b9e78b170e3bf8ca8..ace8474d718ad593de8d90e30b4d91f4fc7bff43 100644 (file)
@@ -2826,6 +2826,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
        switch_event_t *vars = NULL;
        const char *vm_cc = NULL, *vtmp, *vm_ext = NULL;
        int disk_quota = 0;
+       switch_bool_t skip_greeting = switch_true(switch_channel_get_variable(channel, "skip_greeting"));
+       switch_bool_t skip_instructions = switch_true(switch_channel_get_variable(channel, "skip_instructions"));
+
+       switch_channel_set_variable(channel, "skip_greeting", NULL);
+       switch_channel_set_variable(channel, "skip_instructions", NULL);
        
        if (!(caller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"))) {
                caller_id_name = caller_profile->caller_id_name;
@@ -2949,72 +2954,78 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
                greet_path = cbt.greeting_path;
        }
 
-  greet:
-       memset(buf, 0, sizeof(buf));
-       args.input_callback = cancel_on_dtmf;
-       args.buf = buf;
-       args.buflen = sizeof(buf);
+greet:
+       if (!skip_greeting) {
+               memset(buf, 0, sizeof(buf));
+               args.input_callback = cancel_on_dtmf;
+               args.buf = buf;
+               args.buflen = sizeof(buf);
 
-       switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL);
+               switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL);
 
-       if (!switch_strlen_zero(greet_path)) {
-               memset(buf, 0, sizeof(buf));
-               TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args));
-       } else {
-               if (!switch_strlen_zero(cbt.name_path)) {
+               if (!switch_strlen_zero(greet_path)) {
                        memset(buf, 0, sizeof(buf));
-                       TRY_CODE(switch_ivr_play_file(session, NULL, cbt.name_path, &args));
-               }
-               if (*buf == '\0') {
-                       if (!read_id) {
-                               if (!(read_id = switch_channel_get_variable(channel, "voicemail_alternate_greet_id"))) {
-                                       read_id = id;
+                       TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args));
+               } else {
+                       if (!switch_strlen_zero(cbt.name_path)) {
+                               memset(buf, 0, sizeof(buf));
+                               TRY_CODE(switch_ivr_play_file(session, NULL, cbt.name_path, &args));
+                       }
+                       if (*buf == '\0') {
+                               if (!read_id) {
+                                       if (!(read_id = switch_channel_get_variable(channel, "voicemail_alternate_greet_id"))) {
+                                               read_id = id;
+                                       }
                                }
+                               memset(buf, 0, sizeof(buf));
+                               TRY_CODE(switch_ivr_phrase_macro(session, VM_PLAY_GREETING_MACRO, read_id, NULL, &args));
                        }
-                       memset(buf, 0, sizeof(buf));
-                       TRY_CODE(switch_ivr_phrase_macro(session, VM_PLAY_GREETING_MACRO, read_id, NULL, &args));
                }
-       }
 
-       if (*buf != '\0') {
-  greet_key_press:
-               if (switch_stristr(buf, profile->login_keys)) {
-                       voicemail_check_main(session, profile, domain_name, id, 0);
-               } else if (!strcasecmp(buf, profile->operator_key) && !switch_strlen_zero(profile->operator_key)) {
-                       int argc;
-                       char *argv[4];
-                       char *mycmd;
-
-                       if (!switch_strlen_zero(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) {
-                               argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-                               if (argc >= 1 && argc <= 4) {
-                                       switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
-                                       /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
-                                       send_mail = 0;
-                                       goto end;
-                               }
-                       }
-               } else if (!strcasecmp(buf, profile->vmain_key) && !switch_strlen_zero(profile->vmain_key)) {
-                       int argc;
-                       char *argv[4];
-                       char *mycmd;
-
-                       if (!switch_strlen_zero(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) {
-                               argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
-                               if (argc >= 1 && argc <= 4) {
-                                       switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
-                                       /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
-                                       send_mail = 0;
-                                       goto end;
-                               }
+        if (*buf != '\0') {
+greet_key_press:
+            if (switch_stristr(buf, profile->login_keys)) {
+                voicemail_check_main(session, profile, domain_name, id, 0);
+            } else if (!strcasecmp(buf, profile->operator_key) && !switch_strlen_zero(profile->operator_key)) {
+                int argc;
+                char *argv[4];
+                char *mycmd;
+
+                if (!switch_strlen_zero(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) {
+                    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                    if (argc >= 1 && argc <= 4) {
+                        switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
+                        /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
+                        send_mail = 0;
+                        goto end;
+                    }
+                }
+            } else if (!strcasecmp(buf, profile->vmain_key) && !switch_strlen_zero(profile->vmain_key)) {
+                int argc;
+                char *argv[4];
+                char *mycmd;
+
+                if (!switch_strlen_zero(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) {
+                    argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                    if (argc >= 1 && argc <= 4) {
+                        switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
+                        /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
+                        send_mail = 0;
+                        goto end;
+                    }
+                }
+                       } else if (*profile->skip_greet_key && !strcasecmp(buf, profile->skip_greet_key)) {
+                               skip_instructions = SWITCH_TRUE;
+                       } else {
+                               goto greet;
                        }
-               } else if (*profile->skip_greet_key && !strcasecmp(buf, profile->skip_greet_key)) {
-                       record_macro = NULL;
-               } else {
-                       goto greet;
                }
        }
 
+       if (skip_instructions) {
+               record_macro = NULL;
+       }
+
        if (disk_quota) {
                callback_t callback = { 0 };
                char sqlstmt[256];