]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Revert r369024,368998,368964,368962,368790,367161,365395,364761 for now.
authorJason Parker <jparker@digium.com>
Tue, 26 Jun 2012 18:14:39 +0000 (18:14 +0000)
committerJason Parker <jparker@digium.com>
Tue, 26 Jun 2012 18:14:39 +0000 (18:14 +0000)
These changes ended up being made a bit prematurely.

git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369410 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_mixmonitor.c
apps/app_voicemail.c
apps/app_voicemail.exports.in
channels/chan_sip.c
include/asterisk/app.h
include/asterisk/app_voicemail.h
include/asterisk/callerid.h
main/app.c
main/callerid.c
tests/test_voicemail_api.c

index 01075062bab1fb5da9550f9e9b0df58819c241d2..dbefb300ba4a26920c713b773d37918e79a161b4 100644 (file)
@@ -98,8 +98,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                        <option name="m">
                                                <argument name="mailbox" required="true" />
                                                <para>Create a copy of the recording as a voicemail in each indicated <emphasis>mailbox</emphasis>
-                                               separated by commas eg. m(1111@default,2222@default,...).  Folders can be optionally specified using
-                                               the syntax: mailbox@context/folder</para>
+                                               separated by commas eg. m(1111@default,2222@default,...)</para>
                                                <note><para>The recording will be deleted once all the copies are made.</para></note>
                                        </option>
                                </optionlist>
@@ -160,54 +159,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                        <para>This action may be used to mute a MixMonitor recording.</para>
                </description>
        </manager>
-       <manager name="MixMonitor" language="en_US">
-               <synopsis>
-                       Record a call and mix the audio during the recording.  Use of StopMixMonitor is required
-                       to guarantee the audio file is available for processing during dialplan execution.
-               </synopsis>
-               <syntax>
-                       <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
-                       <parameter name="Channel" required="true">
-                               <para>Used to specify the channel to record.</para>
-                       </parameter>
-                       <parameter name="File">
-                               <para>Is the name of the file created in the monitor spool directory.
-                               Defaults to the same name as the channel (with slashes replaced with dashes).
-                               This argument is optional if you specify to record unidirectional audio with
-                               either the r(filename) or t(filename) options in the options field. If
-                               neither MIXMONITOR_FILENAME or this parameter is set, the mixed stream won't
-                               be recorded.</para>
-                       </parameter>
-                       <parameter name="options">
-                               <para>Options that apply to the MixMonitor in the same way as they
-                               would apply if invoked from the MixMonitor application. For a list of
-                               available options, see the documentation for the mixmonitor application. </para>
-                       </parameter>
-               </syntax>
-               <description>
-                       <para>This action records the audio on the current channel to the specified file.</para>
-                       <variablelist>
-                               <variable name="MIXMONITOR_FILENAME">
-                                       <para>Will contain the filename used to record the mixed stream.</para>
-                               </variable>
-                       </variablelist>
-               </description>
-       </manager>
-       <manager name="StopMixMonitor" language="en_US">
-               <synopsis>
-                       Stop recording a call through MixMonitor, and free the recording's file handle.
-               </synopsis>
-               <syntax>
-                       <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
-                       <parameter name="Channel" required="true">
-                               <para>The name of the channel monitored.</para>
-                       </parameter>
-               </syntax>
-               <description>
-                       <para>This action stops the audio recording that was started with the <literal>MixMonitor</literal>
-                       action on the current channel.</para>
-               </description>
-       </manager>
 
  ***/
 
@@ -226,7 +177,6 @@ static const char * const mixmonitor_spy_type = "MixMonitor";
 struct vm_recipient {
        char mailbox[AST_MAX_CONTEXT];
        char context[AST_MAX_EXTENSION];
-       char folder[80];
        AST_LIST_ENTRY(vm_recipient) list;
 };
 
@@ -360,10 +310,9 @@ static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook)
  */
 static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const char *vm_recipients)
 {
-       /* recipients are in a single string with a format format resembling "mailbox@context/INBOX,mailbox2@context2,mailbox3@context3/Work" */
+       /* recipients are in a single string with a format format resembling "mailbox@context,mailbox2@context2, mailbox3@context3" */
        char *cur_mailbox = ast_strdupa(vm_recipients);
        char *cur_context;
-       char *cur_folder;
        char *next;
        int elements_processed = 0;
 
@@ -373,12 +322,6 @@ static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const c
                        *(next++) = '\0';
                }
 
-               if ((cur_folder = strchr(cur_mailbox, '/'))) {
-                       *(cur_folder++) = '\0';
-               } else {
-                       cur_folder = "INBOX";
-               }
-
                if ((cur_context = strchr(cur_mailbox, '@'))) {
                        *(cur_context++) = '\0';
                } else {
@@ -386,6 +329,7 @@ static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const c
                }
 
                if (!ast_strlen_zero(cur_mailbox) && !ast_strlen_zero(cur_context)) {
+
                        struct vm_recipient *recipient;
                        if (!(recipient = ast_malloc(sizeof(*recipient)))) {
                                ast_log(LOG_ERROR, "Failed to allocate recipient. Aborting function.\n");
@@ -393,11 +337,11 @@ static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const c
                        }
                        ast_copy_string(recipient->context, cur_context, sizeof(recipient->context));
                        ast_copy_string(recipient->mailbox, cur_mailbox, sizeof(recipient->mailbox));
-                       ast_copy_string(recipient->folder, cur_folder, sizeof(recipient->folder));
 
                        /* Add to list */
                        ast_verb(5, "Adding %s@%s to recipient list\n", recipient->mailbox, recipient->context);
                        AST_LIST_INSERT_HEAD(&mixmonitor->recipient_list, recipient, list);
+
                } else {
                        ast_log(LOG_ERROR, "Failed to properly parse extension and/or context from element %d of recipient string: %s\n", elements_processed, vm_recipients);
                }
@@ -466,11 +410,9 @@ static void copy_to_voicemail(struct mixmonitor *mixmonitor, char *ext)
        recording_data.call_priority = mixmonitor->call_priority;
 
        AST_LIST_TRAVERSE(&mixmonitor->recipient_list, recipient, list) {
-               /* context, mailbox, and folder need to be set per recipient */
+               /* context and mailbox need to be set per recipient */
                ast_string_field_set(&recording_data, context, recipient->context);
                ast_string_field_set(&recording_data, mailbox, recipient->mailbox);
-               ast_string_field_set(&recording_data, folder, recipient->folder);
-
                ast_verb(4, "MixMonitor attempting to send voicemail copy to %s@%s\n", recording_data.mailbox,
                        recording_data.context);
                ast_app_copy_recording_to_vm(&recording_data);
@@ -962,95 +904,6 @@ static int manager_mute_mixmonitor(struct mansession *s, const struct message *m
        return AMI_SUCCESS;
 }
 
-static int manager_mixmonitor(struct mansession *s, const struct message *m)
-{
-       struct ast_channel *c = NULL;
-
-       const char *name = astman_get_header(m, "Channel");
-       const char *id = astman_get_header(m, "ActionID");
-       const char *file = astman_get_header(m, "File");
-       const char *options = astman_get_header(m, "Options");
-
-       int res;
-       char args[PATH_MAX] = "";
-       if (ast_strlen_zero(name)) {
-               astman_send_error(s, m, "No channel specified");
-               return AMI_SUCCESS;
-       }
-
-       c = ast_channel_get_by_name(name);
-
-       if (!c) {
-               astman_send_error(s, m, "No such channel");
-               return AMI_SUCCESS;
-       }
-
-       strcpy(args, file);
-       strcat(args, ",");
-       strcat(args, options);
-
-       ast_channel_lock(c);
-       res = mixmonitor_exec(c, args);
-       ast_channel_unlock(c);
-
-       if (res) {
-               astman_send_error(s, m, "Could not start monitoring channel");
-               return AMI_SUCCESS;
-       }
-
-       astman_append(s, "Response: Success\r\n");
-
-       if (!ast_strlen_zero(id)) {
-               astman_append(s, "ActionID: %s\r\n", id);
-       }
-
-       astman_append(s, "\r\n");
-
-       c = ast_channel_unref(c);
-
-       return AMI_SUCCESS;
-}
-
-static int manager_stop_mixmonitor(struct mansession *s, const struct message *m)
-{
-       struct ast_channel *c = NULL;
-
-       const char *name = astman_get_header(m, "Channel");
-       const char *id = astman_get_header(m, "ActionID");
-
-       int res;
-       if (ast_strlen_zero(name)) {
-               astman_send_error(s, m, "No channel specified");
-               return AMI_SUCCESS;
-       }
-
-       c = ast_channel_get_by_name(name);
-
-       if (!c) {
-               astman_send_error(s, m, "No such channel");
-               return AMI_SUCCESS;
-       }
-
-       res = stop_mixmonitor_exec(c, NULL);
-
-       if (res) {
-               astman_send_error(s, m, "Could not stop monitoring channel");
-               return AMI_SUCCESS;
-       }
-
-       astman_append(s, "Response: Success\r\n");
-
-       if (!ast_strlen_zero(id)) {
-               astman_append(s, "ActionID: %s\r\n", id);
-       }
-
-       astman_append(s, "\r\n");
-
-       c = ast_channel_unref(c);
-
-       return AMI_SUCCESS;
-}
-
 static struct ast_cli_entry cli_mixmonitor[] = {
        AST_CLI_DEFINE(handle_cli_mixmonitor, "Execute a MixMonitor command")
 };
@@ -1063,8 +916,6 @@ static int unload_module(void)
        res = ast_unregister_application(stop_app);
        res |= ast_unregister_application(app);
        res |= ast_manager_unregister("MixMonitorMute");
-       res |= ast_manager_unregister("MixMonitor");
-       res |= ast_manager_unregister("StopMixMonitor");
        
        return res;
 }
@@ -1077,8 +928,6 @@ static int load_module(void)
        res = ast_register_application_xml(app, mixmonitor_exec);
        res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec);
        res |= ast_manager_register_xml("MixMonitorMute", 0, manager_mute_mixmonitor);
-       res |= ast_manager_register_xml("MixMonitor", 0, manager_mixmonitor);
-       res |= ast_manager_register_xml("StopMixMonitor", 0, manager_stop_mixmonitor);
 
        return res;
 }
index 15a1cf93560b3b8e1d642596c5a7a114fec812ac..20185fdc9f4e44cf9c9a6bbff44ff34cf3cea283 100644 (file)
@@ -113,6 +113,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/module.h"
 #include "asterisk/adsi.h"
 #include "asterisk/app.h"
+#include "asterisk/app_voicemail.h"
 #include "asterisk/manager.h"
 #include "asterisk/dsp.h"
 #include "asterisk/localtime.h"
@@ -968,22 +969,10 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
 static int is_valid_dtmf(const char *key);
 static void read_password_from_file(const char *secretfn, char *password, int passwordlen);
 static int write_password_to_file(const char *secretfn, const char *password);
+struct ast_str *vm_mailbox_snapshot_str(const char *mailbox, const char *context);
 static const char *substitute_escapes(const char *value);
 static void free_user(struct ast_vm_user *vmu);
 
-static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD);
-static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
-
-static int vm_msg_forward(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, int *msg_ids, int delete_old);
-static int vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, int *old_msg_nums, const char *newfolder, int *new_msg_nums);
-static int vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, int *msgs);
-static int vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb);
-
-#ifdef TEST_FRAMEWORK
-static int vm_test_destroy_user(const char *context, const char *mailbox);
-static int vm_test_create_user(const char *context, const char *mailbox);
-#endif
-
 struct ao2_container *inprocess_container;
 
 struct inprocess {
@@ -1767,12 +1756,6 @@ static const char *mbox(struct ast_vm_user *vmu, int id)
        return (id >= 0 && id < ARRAY_LEN(mailbox_folders)) ? mailbox_folders[id] : "Unknown";
 }
 
-static const char *vm_index_to_foldername(int id)
-{
-       return mbox(NULL, id);
-}
-
-
 static int get_folder_by_name(const char *name)
 {
        size_t i;
@@ -5774,7 +5757,7 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
        /* At this point, the actual creation of a voicemail message should be finished.
         * Now we just need to copy the files being recorded into the receiving folder. */
 
-       create_dirpath(dir, sizeof(dir), recipient->context, recipient->mailbox, recdata->folder);
+       create_dirpath(dir, sizeof(dir), recipient->context, recipient->mailbox, "INBOX");
 
 #ifdef IMAP_STORAGE
        /* make recipient info into an inboxcount friendly string */
@@ -10293,7 +10276,7 @@ static int play_message_by_id(struct ast_channel *chan, const char *mailbox, con
        }
 
        /* Iterate through every folder, find the msg, and play it */
-       for (i = 0; i < ARRAY_LEN(mailbox_folders) && !played; i++) {
+       for (i = 0; i < AST_VM_FOLDER_NUMBER && !played; i++) {
                ast_copy_string(vms.username, mailbox, sizeof(vms.username));
                vms.lastmsg = -1;
 
@@ -13556,9 +13539,6 @@ static int unload_module(void)
 #endif
        ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
        ast_uninstall_vm_functions();
-#ifdef TEST_FRAMEWORK
-       ast_uninstall_vm_test_functions();
-#endif
        ao2_ref(inprocess_container, -1);
 
        if (poll_thread != AST_PTHREADT_NULL)
@@ -13615,15 +13595,7 @@ static int load_module(void)
        ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
        ast_data_register_multiple(vm_data_providers, ARRAY_LEN(vm_data_providers));
 
-       ast_install_vm_functions(has_voicemail, inboxcount, inboxcount2, messagecount, sayname, msg_create_from_file,
-                                vm_index_to_foldername,
-                                vm_mailbox_snapshot_create, vm_mailbox_snapshot_destroy,
-                                vm_msg_move, vm_msg_remove, vm_msg_forward, vm_msg_play);
-
-#ifdef TEST_FRAMEWORK
-       ast_install_vm_test_functions(vm_test_create_user, vm_test_destroy_user);
-#endif
-
+       ast_install_vm_functions(has_voicemail, inboxcount, inboxcount2, messagecount, sayname, msg_create_from_file);
        ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, SENTINEL);
        ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, SENTINEL);
 
@@ -14158,7 +14130,7 @@ static struct ast_vm_msg_snapshot *vm_msg_snapshot_destroy(struct ast_vm_msg_sna
 
 #ifdef TEST_FRAMEWORK
 
-static int vm_test_destroy_user(const char *context, const char *mailbox)
+int ast_vm_test_destroy_user(const char *context, const char *mailbox)
 {
        struct ast_vm_user *vmu;
 
@@ -14176,7 +14148,7 @@ static int vm_test_destroy_user(const char *context, const char *mailbox)
        return 0;
 }
 
-static int vm_test_create_user(const char *context, const char *mailbox)
+int ast_vm_test_create_user(const char *context, const char *mailbox)
 {
        struct ast_vm_user *vmu;
 
@@ -14255,6 +14227,9 @@ static int vm_msg_snapshot_create(struct ast_vm_user *vmu,
                if ((value = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
                        ast_string_field_set(msg_snapshot, duration, value);
                }
+               if ((value = ast_variable_retrieve(msg_cfg, "message", "folder_dir"))) {
+                       ast_string_field_set(msg_snapshot, folder_dir, value);
+               }
                if ((value = ast_variable_retrieve(msg_cfg, "message", "flag"))) {
                        ast_string_field_set(msg_snapshot, flag, value);
                }
@@ -14303,7 +14278,7 @@ static int vm_msg_snapshot_create(struct ast_vm_user *vmu,
        return 0;
 }
 
-static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *mailbox,
+struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
        const char *context,
        const char *folder,
        int descending,
@@ -14329,7 +14304,7 @@ static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *ma
 
        if (!(ast_strlen_zero(folder))) {
                /* find the folder index */
-               for (i = 0; i < ARRAY_LEN(mailbox_folders); i++) {
+               for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
                        if (!strcasecmp(mailbox_folders[i], folder)) {
                                this_index_only = i;
                                break;
@@ -14349,14 +14324,7 @@ static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *ma
                return NULL;
        }
 
-       if (!(mailbox_snapshot->snapshots = ast_calloc(ARRAY_LEN(mailbox_folders), sizeof(*mailbox_snapshot->snapshots)))) {
-               ast_free(mailbox_snapshot);
-               return NULL;
-       }
-
-       mailbox_snapshot->folders = ARRAY_LEN(mailbox_folders);
-
-       for (i = 0; i < mailbox_snapshot->folders; i++) {
+       for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
                int combining_old = 0;
                if ((i == old_index) && (combine_INBOX_and_OLD)) {
                        combining_old = 1;
@@ -14411,26 +14379,63 @@ snapshot_cleanup:
        return mailbox_snapshot;
 }
 
-static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
+struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 {
        int i;
        struct ast_vm_msg_snapshot *msg_snapshot;
 
-       for (i = 0; i < mailbox_snapshot->folders; i++) {
+       for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
                while ((msg_snapshot = AST_LIST_REMOVE_HEAD(&mailbox_snapshot->snapshots[i], msg))) {
                        msg_snapshot = vm_msg_snapshot_destroy(msg_snapshot);
                }
        }
-       ast_free(mailbox_snapshot->snapshots);
        ast_free(mailbox_snapshot);
        return NULL;
 }
 
+struct ast_str *vm_mailbox_snapshot_str(const char *mailbox, const char *context)
+{
+       struct ast_vm_mailbox_snapshot *mailbox_snapshot = ast_vm_mailbox_snapshot_create(mailbox, context, NULL, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0);
+       struct ast_vm_msg_snapshot *msg_snapshot;
+       int i;
+       struct ast_str *str;
+
+       if (!mailbox_snapshot) {
+               return NULL;
+       }
+
+       if (!(str = ast_str_create(512))) {
+               return NULL;
+               mailbox_snapshot = ast_vm_mailbox_snapshot_destroy(mailbox_snapshot);
+       }
+
+       for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
+               ast_str_append(&str, 0, "FOLDER: %s\n", mailbox_folders[i]);
+               AST_LIST_TRAVERSE(&mailbox_snapshot->snapshots[i], msg_snapshot, msg) {
+                       ast_str_append(&str, 0, "MSG Number:   %d\n", msg_snapshot->msg_number);
+                       ast_str_append(&str, 0, "MSG ID:       %s\n", msg_snapshot->msg_id);
+                       ast_str_append(&str, 0, "CALLER ID:    %s\n", msg_snapshot->callerid);
+                       ast_str_append(&str, 0, "CALLER CHAN:  %s\n", msg_snapshot->callerchan);
+                       ast_str_append(&str, 0, "CALLER EXTEN: %s\n", msg_snapshot->exten);
+                       ast_str_append(&str, 0, "DATE:         %s\n", msg_snapshot->origdate);
+                       ast_str_append(&str, 0, "TIME:         %s\n", msg_snapshot->origtime);
+                       ast_str_append(&str, 0, "DURATION:     %s\n", msg_snapshot->duration);
+                       ast_str_append(&str, 0, "FOLDER NAME:  %s\n", msg_snapshot->folder_name);
+                       ast_str_append(&str, 0, "FOLDER DIR:   %s\n", msg_snapshot->folder_dir);
+                       ast_str_append(&str, 0, "FLAG:         %s\n", msg_snapshot->folder_dir);
+                       ast_str_append(&str, 0, "\n");
+               }
+       }
+
+       mailbox_snapshot = ast_vm_mailbox_snapshot_destroy(mailbox_snapshot);
+       return str;
+}
+
 /*!
  * \brief common bounds checking and existence check for Voicemail API functions.
  *
  * \details
- * This is called by vm_msg_move, vm_msg_remove, and vm_msg_forward to
+ * This is called by ast_vm_msg_move, ast_vm_msg_remove, and ast_vm_msg_forward to
  * ensure that data passed in are valid. This tests the following:
  *
  * 1. No negative indexes are given.
@@ -14482,7 +14487,7 @@ static void notify_new_state(struct ast_vm_user *vmu)
        queue_mwi_event(ext_context, urgent, new, old);
 }
 
-static int vm_msg_forward(const char *from_mailbox,
+int ast_vm_msg_forward(const char *from_mailbox,
        const char *from_context,
        const char *from_folder,
        const char *to_mailbox,
@@ -14619,7 +14624,7 @@ vm_forward_cleanup:
        return res;
 }
 
-static int vm_msg_move(const char *mailbox,
+int ast_vm_msg_move(const char *mailbox,
        const char *context,
        size_t num_msgs,
        const char *oldfolder,
@@ -14714,7 +14719,7 @@ vm_move_cleanup:
        return res;
 }
 
-static int vm_msg_remove(const char *mailbox,
+int ast_vm_msg_remove(const char *mailbox,
        const char *context,
        size_t num_msgs,
        const char *folder,
@@ -14808,7 +14813,15 @@ vm_remove_cleanup:
        return res;
 }
 
-static int vm_msg_play(struct ast_channel *chan,
+const char *ast_vm_index_to_foldername(unsigned int index)
+{
+       if (index >= AST_VM_FOLDER_NUMBER) {
+               return "";
+       }
+       return mailbox_folders[index];
+}
+
+int ast_vm_msg_play(struct ast_channel *chan,
        const char *mailbox,
        const char *context,
        const char *folder,
@@ -14926,7 +14939,7 @@ play2_msg_cleanup:
  * AST_MODULE_INFO(, , "Comedian Mail (Voicemail System)"
  */
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, tdesc,
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, tdesc,
                .load = load_module,
                .unload = unload_module,
                .reload = reload,
index 3520d2216627b9ccbd55f547a6dc6636129bd502..e66bb359c874875ccfcf9ade5d8690ebfe303187 100644 (file)
                LINKER_SYMBOL_PREFIXmm_notify;
                LINKER_SYMBOL_PREFIXmm_searched;
                LINKER_SYMBOL_PREFIXmm_status;
+               LINKER_SYMBOL_PREFIXast_vm_mailbox_snapshot_create;
+               LINKER_SYMBOL_PREFIXast_vm_mailbox_snapshot_destroy;
+               LINKER_SYMBOL_PREFIXast_vm_msg_move;
+               LINKER_SYMBOL_PREFIXast_vm_msg_remove;
+               LINKER_SYMBOL_PREFIXast_vm_msg_forward;
+               LINKER_SYMBOL_PREFIXast_vm_index_to_foldername;
+               LINKER_SYMBOL_PREFIXast_vm_msg_play;
+               LINKER_SYMBOL_PREFIXast_vm_test_create_user;
+               LINKER_SYMBOL_PREFIXast_vm_test_destroy_user;
        local:
                *;
 };
index dba896cbd68fb97a3ced3876ca01850f3b7c1036..dd4deccb6bbfbb6992dd9ad361b5cd1943659149 100644 (file)
@@ -683,8 +683,7 @@ static const struct sip_reasons {
        { AST_REDIRECTING_REASON_FOLLOW_ME, "follow-me" },
        { AST_REDIRECTING_REASON_OUT_OF_ORDER, "out-of-service" },
        { AST_REDIRECTING_REASON_AWAY, "away" },
-       { AST_REDIRECTING_REASON_CALL_FWD_DTE, "unknown"},
-       { AST_REDIRECTING_REASON_SEND_TO_VM, "send_to_vm"},
+       { AST_REDIRECTING_REASON_CALL_FWD_DTE, "unknown"}
 };
 
 
@@ -15391,7 +15390,7 @@ static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq, char **name, c
                        }
                        /* Remove enclosing double-quotes */
                        if (*reason_param == '"')
-                               reason_param = ast_strip_quoted(reason_param, "\"", "\"");
+                               ast_strip_quoted(reason_param, "\"", "\"");
                        if (!ast_strlen_zero(reason_param)) {
                                sip_set_redirstr(p, reason_param);
                                if (p->owner) {
@@ -23674,8 +23673,6 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
        int localtransfer = 0;
        int attendedtransfer = 0;
        int res = 0;
-       struct ast_party_redirecting redirecting;
-       struct ast_set_party_redirecting update_redirecting;
 
        if (req->debug) {
                ast_verbose("Call %s got a SIP call transfer from %s: (REFER)!\n",
@@ -23980,25 +23977,13 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
        }
        ast_set_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);  /* Delay hangup */
 
-       /* When a call is transferred to voicemail from a Digium phone, there may be
-        * a Diversion header present in the REFER with an appropriate reason parameter
-        * set. We need to update the redirecting information appropriately.
-        */
-       ast_party_redirecting_init(&redirecting);
-       memset(&update_redirecting, 0, sizeof(update_redirecting));
-       change_redirecting_information(p, req, &redirecting, &update_redirecting, FALSE);
-
-       /* Do not hold the pvt lock during a call that causes an indicate or an async_goto.
-        * Those functions lock channels which will invalidate locking order if the pvt lock
-        * is held.*/
-       sip_pvt_unlock(p);
-       ast_channel_update_redirecting(current.chan2, &redirecting, &update_redirecting);
-       ast_party_redirecting_free(&redirecting);
-
+       /* Do not hold the pvt lock during the indicate and async_goto. Those functions
+        * lock channels which will invalidate locking order if the pvt lock is held.*/
        /* For blind transfers, move the call to the new extensions. For attended transfers on multiple
         * servers - generate an INVITE with Replaces. Either way, let the dial plan decided
         * indicate before masquerade so the indication actually makes it to the real channel
         * when using local channels with MOH passthru */
+       sip_pvt_unlock(p);
        ast_indicate(current.chan2, AST_CONTROL_UNHOLD);
        res = ast_async_goto(current.chan2, refer_to_context, refer_to, 1);
 
index 38914d322fa22b92e85dd540f097d958bfe15fef..54bc93f6722bd7d5cae27bff40ef09e8e67ca93c 100644 (file)
@@ -27,7 +27,6 @@
 #include "asterisk/strings.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/file.h"
-#include "asterisk/linkedlists.h"
 
 struct ast_flags64;
 
@@ -158,52 +157,13 @@ int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int
 int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel 
                *macro_chan, const char * const macro_name, const char * const macro_args);
 
-enum ast_vm_snapshot_sort_val {
-       AST_VM_SNAPSHOT_SORT_BY_ID = 0,
-       AST_VM_SNAPSHOT_SORT_BY_TIME,
-};
-
-struct ast_vm_msg_snapshot {
-       AST_DECLARE_STRING_FIELDS(
-               AST_STRING_FIELD(msg_id);
-               AST_STRING_FIELD(callerid);
-               AST_STRING_FIELD(callerchan);
-               AST_STRING_FIELD(exten);
-               AST_STRING_FIELD(origdate);
-               AST_STRING_FIELD(origtime);
-               AST_STRING_FIELD(duration);
-               AST_STRING_FIELD(folder_name);
-               AST_STRING_FIELD(flag);
-       );
-       unsigned int msg_number;
-
-       AST_LIST_ENTRY(ast_vm_msg_snapshot) msg;
-};
-
-struct ast_vm_mailbox_snapshot {
-       int total_msg_num;
-       int folders;
-       /* Things are not quite as they seem here.  This points to an allocated array of lists. */
-       AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) *snapshots;
-};
-
-/*!
- * \brief Voicemail playback callback function definition
- *
- * \param channel to play the file back on.
- * \param location of file on disk
- * \param duration of file in seconds. This will be zero if msg is very short or
- * has an unknown duration.
- */
-typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
-
 /*!
  * \brief Set voicemail function callbacks
  * \param[in] has_voicemail_func set function pointer
- * \param[in] inboxcount_func set function pointer
  * \param[in] inboxcount2_func set function pointer
- * \param[in] messagecount_func set function pointer
  * \param[in] sayname_func set function pointer
+ * \param[in] inboxcount_func set function pointer
+ * \param[in] messagecount_func set function pointer
  * \version 1.6.1 Added inboxcount2_func, sayname_func
  */
 void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder),
@@ -211,52 +171,10 @@ void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, con
                              int (*inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs),
                              int (*messagecount_func)(const char *context, const char *mailbox, const char *folder),
                              int (*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context),
-                             int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data),
-                             const char *vm_index_to_foldername(int id),
-                             struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_create)(const char *mailbox,
-                               const char *context,
-                               const char *folder,
-                               int descending,
-                               enum ast_vm_snapshot_sort_val sort_val,
-                               int combine_INBOX_and_OLD),
-                             struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_destroy)(struct ast_vm_mailbox_snapshot *mailbox_snapshot),
-                             int (*vm_msg_move)(const char *mailbox,
-                               const char *context,
-                               size_t num_msgs,
-                               const char *oldfolder,
-                               int *old_msg_ids,
-                               const char *newfolder,
-                               int *new_msg_ids),
-                             int (*vm_msg_remove)(const char *mailbox,
-                               const char *context,
-                               size_t num_msgs,
-                               const char *folder,
-                               int *msgs),
-                             int (*vm_msg_forward)(const char *from_mailbox,
-                               const char *from_context,
-                               const char *from_folder,
-                               const char *to_mailbox,
-                               const char *to_context,
-                               const char *to_folder,
-                               size_t num_msgs,
-                               int *msg_ids,
-                               int delete_old),
-                             int (*vm_msg_play)(struct ast_channel *chan,
-                               const char *mailbox,
-                               const char *context,
-                               const char *folder,
-                               const char *msg_num,
-                               ast_vm_msg_play_cb cb));
+                             int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data));
 
 void ast_uninstall_vm_functions(void);
 
-#ifdef TEST_FRAMEWORK
-void ast_install_vm_test_functions(int (*vm_test_destroy_user)(const char *context, const char *mailbox),
-                                  int (*vm_test_create_user)(const char *context, const char *mailbox));
-
-void ast_uninstall_vm_test_functions(void);
-#endif
-
 /*!
  * \brief
  * param[in] vm_rec_data Contains data needed to make the recording.
@@ -320,133 +238,6 @@ int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *c
  */
 int ast_app_messagecount(const char *context, const char *mailbox, const char *folder);
 
-/*!
- * \brief Return name of folder, given an id
- * \param[in] id Folder id
- * \return Name of folder
- */
-const char *ast_vm_index_to_foldername(int id);
-
-/*
- * \brief Create a snapshot of a mailbox which contains information about every msg.
- *
- * \param mailbox, the mailbox to look for
- * \param context, the context to look for the mailbox in
- * \param folder, OPTIONAL.  When not NULL only msgs from the specified folder will be included.
- * \param desending, list the msgs in descending order rather than ascending order.
- * \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
- *        in the INBOX folder of the snapshot. This allows the snapshot to represent the
- *        OLD and INBOX messages in sorted order merged together.
- *
- * \retval snapshot on success
- * \retval NULL on failure
- */
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
-       const char *context,
-       const char *folder,
-       int descending,
-       enum ast_vm_snapshot_sort_val sort_val,
-       int combine_INBOX_and_OLD);
-
-/*
- * \brief destroy a snapshot
- *
- * \param mailbox_snapshot The snapshot to destroy.
- * \retval NULL
- */
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
-
-/*!
- * \brief Move messages from one folder to another
- *
- * \param mailbox The mailbox to which the folders belong
- * \param context The voicemail context for the mailbox
- * \param num_msgs The number of messages to move
- * \param oldfolder The folder from where messages should be moved
- * \param old_msg_nums The message IDs of the messages to move
- * \param newfolder The folder to which messages should be moved
- * \param new_msg_ids[out] An array of message IDs for the messages as they are in the
- * new folder. This array must be num_msgs sized.
- *
- * \retval -1 Failure
- * \retval 0 Success
- */
-int ast_vm_msg_move(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *oldfolder,
-       int *old_msg_ids,
-       const char *newfolder,
-       int *new_msg_ids);
-
-/*!
- * \brief Remove/delete messages from a mailbox folder.
- *
- * \param mailbox The mailbox from which to delete messages
- * \param context The voicemail context for the mailbox
- * \param num_msgs The number of messages to delete
- * \param folder The folder from which to remove messages
- * \param msgs The message IDs of the messages to delete
- *
- * \retval -1 Failure
- * \retval 0 Success
- */
-int ast_vm_msg_remove(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *folder,
-       int *msgs);
-
-/*!
- * \brief forward a message from one mailbox to another.
- *
- * \brief from_mailbox The original mailbox the message is being forwarded from
- * \brief from_context The voicemail context of the from_mailbox
- * \brief from_folder The folder from which the message is being forwarded
- * \brief to_mailbox The mailbox to forward the message to
- * \brief to_context The voicemail context of the to_mailbox
- * \brief to_folder The folder to which the message is being forwarded
- * \brief num_msgs The number of messages being forwarded
- * \brief msg_ids The message IDs of the messages in from_mailbox to forward
- * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
- * Otherwise, the messages will remain in the from_mailbox.
- *
- * \retval -1 Failure
- * \retval 0 Success
- */
-int ast_vm_msg_forward(const char *from_mailbox,
-       const char *from_context,
-       const char *from_folder,
-       const char *to_mailbox,
-       const char *to_context,
-       const char *to_folder,
-       size_t num_msgs,
-       int *msg_ids,
-       int delete_old);
-
-/*!
- * \brief Play a voicemail msg back on a channel.
- *
- * \param mailbox msg is in.
- * \param context of mailbox.
- * \param voicemail folder to look in.
- * \param message number in the voicemailbox to playback to the channel.
- *
- * \retval 0 success
- * \retval -1 failure
- */
-int ast_vm_msg_play(struct ast_channel *chan,
-       const char *mailbox,
-       const char *context,
-       const char *folder,
-       const char *msg_num,
-       ast_vm_msg_play_cb cb);
-
-#ifdef TEST_FRAMEWORK
-int ast_vm_test_destroy_user(const char *context, const char *mailbox);
-int ast_vm_test_create_user(const char *context, const char *mailbox);
-#endif
-
 /*! \brief Safely spawn an external program while closing file descriptors
        \note This replaces the \b system call in all Asterisk modules
 */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..11b1df43073e0083bdde01c0519607b55fa0052c 100644 (file)
@@ -0,0 +1,214 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * David Vossel <dvossel@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Voice Mail API
+ * \author David Vossel <dvossel@digium.com>
+ */
+
+#ifndef _ASTERISK_VM_H
+#define _ASTERISK_VM_H
+
+#include "asterisk/stringfields.h"
+#include "asterisk/linkedlists.h"
+
+#define AST_VM_FOLDER_NUMBER 12
+
+enum ast_vm_snapshot_sort_val {
+       AST_VM_SNAPSHOT_SORT_BY_ID = 0,
+       AST_VM_SNAPSHOT_SORT_BY_TIME,
+};
+
+struct ast_vm_msg_snapshot {
+       AST_DECLARE_STRING_FIELDS(
+               AST_STRING_FIELD(msg_id);
+               AST_STRING_FIELD(callerid);
+               AST_STRING_FIELD(callerchan);
+               AST_STRING_FIELD(exten);
+               AST_STRING_FIELD(origdate);
+               AST_STRING_FIELD(origtime);
+               AST_STRING_FIELD(duration);
+               AST_STRING_FIELD(folder_name);
+               AST_STRING_FIELD(folder_dir);
+               AST_STRING_FIELD(flag);
+       );
+       unsigned int msg_number;
+
+       AST_LIST_ENTRY(ast_vm_msg_snapshot) msg;
+};
+
+struct ast_vm_mailbox_snapshot {
+       int total_msg_num;
+       AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) snapshots[AST_VM_FOLDER_NUMBER];
+};
+
+/*
+ * \brief Create a snapshot of a mailbox which contains information about every msg.
+ *
+ * \param mailbox, the mailbox to look for
+ * \param context, the context to look for the mailbox in
+ * \param folder, OPTIONAL.  When not NULL only msgs from the specified folder will be included.
+ * \param desending, list the msgs in descending order rather than ascending order.
+ * \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
+ *        in the INBOX folder of the snapshot. This allows the snapshot to represent the
+ *        OLD and INBOX messages in sorted order merged together.
+ *
+ * \retval snapshot on success
+ * \retval NULL on failure
+ */
+struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
+       const char *context,
+       const char *folder,
+       int descending,
+       enum ast_vm_snapshot_sort_val sort_val,
+       int combine_INBOX_and_OLD);
+
+/*
+ * \brief destroy a snapshot
+ *
+ * \param mailbox_snapshot The snapshot to destroy.
+ * \retval NULL
+ */
+struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
+
+/*!
+ * \brief Move messages from one folder to another
+ *
+ * \param mailbox The mailbox to which the folders belong
+ * \param context The voicemail context for the mailbox
+ * \param num_msgs The number of messages to move
+ * \param oldfolder The folder from where messages should be moved
+ * \param old_msg_nums The message IDs of the messages to move
+ * \param newfolder The folder to which messages should be moved
+ * \param new_msg_ids[out] An array of message IDs for the messages as they are in the
+ * new folder. This array must be num_msgs sized.
+ *
+ * \retval -1 Failure
+ * \retval 0 Success
+ */
+int ast_vm_msg_move(const char *mailbox,
+       const char *context,
+       size_t num_msgs,
+       const char *oldfolder,
+       int *old_msg_ids,
+       const char *newfolder,
+       int *new_msg_ids);
+
+/*!
+ * \brief Remove/delete messages from a mailbox folder.
+ *
+ * \param mailbox The mailbox from which to delete messages
+ * \param context The voicemail context for the mailbox
+ * \param num_msgs The number of messages to delete
+ * \param folder The folder from which to remove messages
+ * \param msgs The message IDs of the messages to delete
+ * 
+ * \retval -1 Failure
+ * \retval 0 Success
+ */
+int ast_vm_msg_remove(const char *mailbox,
+       const char *context,
+       size_t num_msgs,
+       const char *folder,
+       int *msgs);
+
+/*!
+ * \brief forward a message from one mailbox to another.
+ *
+ * \brief from_mailbox The original mailbox the message is being forwarded from
+ * \brief from_context The voicemail context of the from_mailbox
+ * \brief from_folder The folder from which the message is being forwarded
+ * \brief to_mailbox The mailbox to forward the message to
+ * \brief to_context The voicemail context of the to_mailbox
+ * \brief to_folder The folder to which the message is being forwarded
+ * \brief num_msgs The number of messages being forwarded
+ * \brief msg_ids The message IDs of the messages in from_mailbox to forward
+ * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
+ * Otherwise, the messages will remain in the from_mailbox.
+ *
+ * \retval -1 Failure
+ * \retval 0 Success
+ */
+int ast_vm_msg_forward(const char *from_mailbox,
+       const char *from_context,
+       const char *from_folder,
+       const char *to_mailbox,
+       const char *to_context,
+       const char *to_folder,
+       size_t num_msgs,
+       int *msg_ids,
+       int delete_old);
+
+/*!
+ * \brief Voicemail playback callback function definition
+ *
+ * \param channel to play the file back on.
+ * \param location of file on disk
+ * \param duration of file in seconds. This will be zero if msg is very short or
+ * has an unknown duration.
+ */
+typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
+
+/*!
+ * \brief Play a voicemail msg back on a channel.
+ *
+ * \param mailbox msg is in.
+ * \param context of mailbox.
+ * \param voicemail folder to look in.
+ * \param message number in the voicemailbox to playback to the channel.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_vm_msg_play(struct ast_channel *chan,
+       const char *mailbox,
+       const char *context,
+       const char *folder,
+       const char *msg_num,
+       ast_vm_msg_play_cb cb);
+
+/*!
+ * \brief Get the name of a folder given its numeric index
+ *
+ * \param index The integer value of the mailbox.
+ * \retval "" Invalid index provided
+ * \retval other The name of the mailbox
+ */
+const char *ast_vm_index_to_foldername(unsigned int index);
+
+#ifdef TEST_FRAMEWORK
+/*!
+ * \brief Add a user to the voicemail system for test purposes
+ * \param context The context of the mailbox
+ * \param mailbox The mailbox for the user
+ * \retval 0 success
+ * \retval other failure
+ */
+int ast_vm_test_create_user(const char *context, const char *mailbox);
+
+/*!
+ * \brief Dispose of a user.  This should be used to destroy a user that was
+ * previously created using ast_vm_test_create_user
+ * \param context The context of the mailbox
+ * \param mailbox The mailbox for the user to destroy
+ */
+int ast_vm_test_destroy_user(const char *context, const char *mailbox);
+
+#endif
+
+#endif
index eb25d27125f2cf69673af6467a5534ec364c8f13..e052f64781625a5a511d43cb06e3088747dedff9 100644 (file)
@@ -400,7 +400,6 @@ enum AST_REDIRECTING_REASON {
        AST_REDIRECTING_REASON_OUT_OF_ORDER,
        AST_REDIRECTING_REASON_AWAY,
        AST_REDIRECTING_REASON_CALL_FWD_DTE,           /* This is something defined in Q.931, and no I don't know what it means */
-       AST_REDIRECTING_REASON_SEND_TO_VM,
 };
 
 /*!
index acd24b9abb8a8f2ed9f22e896ba9667f482e1eca..7626b512eb0b7a8d5f68c5752c6fc27e636200f9 100644 (file)
@@ -274,83 +274,13 @@ static int (*ast_inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *ne
 static int (*ast_sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context) = NULL;
 static int (*ast_messagecount_func)(const char *context, const char *mailbox, const char *folder) = NULL;
 static int (*ast_copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data) = NULL;
-static const char *(*ast_vm_index_to_foldername_func)(int id) = NULL;
-static struct ast_vm_mailbox_snapshot *(*ast_vm_mailbox_snapshot_create_func)(const char *mailbox,
-       const char *context,
-       const char *folder,
-       int descending,
-       enum ast_vm_snapshot_sort_val sort_val,
-       int combine_INBOX_and_OLD) = NULL;
-static struct ast_vm_mailbox_snapshot *(*ast_vm_mailbox_snapshot_destroy_func)(struct ast_vm_mailbox_snapshot *mailbox_snapshot) = NULL;
-static int (*ast_vm_msg_move_func)(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *oldfolder,
-       int *old_msg_ids,
-       const char *newfolder,
-       int *new_msg_ids) = NULL;
-static int (*ast_vm_msg_remove_func)(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *folder,
-       int *msgs) = NULL;
-static int (*ast_vm_msg_forward_func)(const char *from_mailbox,
-       const char *from_context,
-       const char *from_folder,
-       const char *to_mailbox,
-       const char *to_context,
-       const char *to_folder,
-       size_t num_msgs,
-       int *msg_ids,
-       int delete_old) = NULL;
-static int (*ast_vm_msg_play_func)(struct ast_channel *chan,
-       const char *mailbox,
-       const char *context,
-       const char *folder,
-       const char *msg_num,
-       ast_vm_msg_play_cb cb) = NULL;
 
 void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder),
                              int (*inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs),
                              int (*inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs),
                              int (*messagecount_func)(const char *context, const char *mailbox, const char *folder),
                              int (*sayname_func)(struct ast_channel *chan, const char *mailbox, const char *context),
-                             int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data),
-                             const char *vm_index_to_foldername_func(int id),
-                             struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_create_func)(const char *mailbox,
-                               const char *context,
-                               const char *folder,
-                               int descending,
-                               enum ast_vm_snapshot_sort_val sort_val,
-                               int combine_INBOX_and_OLD),
-                             struct ast_vm_mailbox_snapshot *(*vm_mailbox_snapshot_destroy_func)(struct ast_vm_mailbox_snapshot *mailbox_snapshot),
-                             int (*vm_msg_move_func)(const char *mailbox,
-                               const char *context,
-                               size_t num_msgs,
-                               const char *oldfolder,
-                               int *old_msg_ids,
-                               const char *newfolder,
-                               int *new_msg_ids),
-                             int (*vm_msg_remove_func)(const char *mailbox,
-                               const char *context,
-                               size_t num_msgs,
-                               const char *folder,
-                               int *msgs),
-                             int (*vm_msg_forward_func)(const char *from_mailbox,
-                               const char *from_context,
-                               const char *from_folder,
-                               const char *to_mailbox,
-                               const char *to_context,
-                               const char *to_folder,
-                               size_t num_msgs,
-                               int *msg_ids,
-                               int delete_old),
-                             int (*vm_msg_play_func)(struct ast_channel *chan,
-                               const char *mailbox,
-                               const char *context,
-                               const char *folder,
-                               const char *msg_num,
-                               ast_vm_msg_play_cb cb))
+                             int (*copy_recording_to_vm_func)(struct ast_vm_recording_data *vm_rec_data))
 {
        ast_has_voicemail_func = has_voicemail_func;
        ast_inboxcount_func = inboxcount_func;
@@ -358,13 +288,6 @@ void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, con
        ast_messagecount_func = messagecount_func;
        ast_sayname_func = sayname_func;
        ast_copy_recording_to_vm_func = copy_recording_to_vm_func;
-       ast_vm_index_to_foldername_func = vm_index_to_foldername_func;
-       ast_vm_mailbox_snapshot_create_func = vm_mailbox_snapshot_create_func;
-       ast_vm_mailbox_snapshot_destroy_func = vm_mailbox_snapshot_destroy_func;
-       ast_vm_msg_move_func = vm_msg_move_func;
-       ast_vm_msg_remove_func = vm_msg_remove_func;
-       ast_vm_msg_forward_func = vm_msg_forward_func;
-       ast_vm_msg_play_func = vm_msg_play_func;
 }
 
 void ast_uninstall_vm_functions(void)
@@ -375,33 +298,8 @@ void ast_uninstall_vm_functions(void)
        ast_messagecount_func = NULL;
        ast_sayname_func = NULL;
        ast_copy_recording_to_vm_func = NULL;
-       ast_vm_index_to_foldername_func = NULL;
-       ast_vm_mailbox_snapshot_create_func = NULL;
-       ast_vm_mailbox_snapshot_destroy_func = NULL;
-       ast_vm_msg_move_func = NULL;
-       ast_vm_msg_remove_func = NULL;
-       ast_vm_msg_forward_func = NULL;
-       ast_vm_msg_play_func = NULL;
 }
 
-#ifdef TEST_FRAMEWORK
-int (*ast_vm_test_create_user_func)(const char *context, const char *mailbox) = NULL;
-int (*ast_vm_test_destroy_user_func)(const char *context, const char *mailbox) = NULL;
-
-void ast_install_vm_test_functions(int (*vm_test_create_user_func)(const char *context, const char *mailbox),
-                                  int (*vm_test_destroy_user_func)(const char *context, const char *mailbox))
-{
-       ast_vm_test_create_user_func = vm_test_create_user_func;
-       ast_vm_test_destroy_user_func = vm_test_destroy_user_func;
-}
-
-void ast_uninstall_vm_test_functions(void)
-{
-       ast_vm_test_create_user_func = NULL;
-       ast_vm_test_destroy_user_func = NULL;
-}
-#endif
-
 int ast_app_has_voicemail(const char *mailbox, const char *folder)
 {
        static int warned = 0;
@@ -504,108 +402,6 @@ int ast_app_messagecount(const char *context, const char *mailbox, const char *f
        return 0;
 }
 
-const char *ast_vm_index_to_foldername(int id)
-{
-       if (ast_vm_index_to_foldername_func) {
-               return ast_vm_index_to_foldername_func(id);
-       }
-       return NULL;
-}
-
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
-       const char *context,
-       const char *folder,
-       int descending,
-       enum ast_vm_snapshot_sort_val sort_val,
-       int combine_INBOX_and_OLD)
-{
-       if (ast_vm_mailbox_snapshot_create_func) {
-               return ast_vm_mailbox_snapshot_create_func(mailbox, context, folder, descending, sort_val, combine_INBOX_and_OLD);
-       }
-       return NULL;
-}
-
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
-{
-       if (ast_vm_mailbox_snapshot_destroy_func) {
-               return ast_vm_mailbox_snapshot_destroy_func(mailbox_snapshot);
-       }
-       return NULL;
-}
-
-int ast_vm_msg_move(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *oldfolder,
-       int *old_msg_ids,
-       const char *newfolder,
-       int *new_msg_ids)
-{
-       if (ast_vm_msg_move_func) {
-               return ast_vm_msg_move_func(mailbox, context, num_msgs, oldfolder, old_msg_ids, newfolder, new_msg_ids);
-       }
-       return 0;
-}
-
-int ast_vm_msg_remove(const char *mailbox,
-       const char *context,
-       size_t num_msgs,
-       const char *folder,
-       int *msgs)
-{
-       if (ast_vm_msg_remove_func) {
-               return ast_vm_msg_remove_func(mailbox, context, num_msgs, folder, msgs);
-       }
-       return 0;
-}
-
-int ast_vm_msg_forward(const char *from_mailbox,
-       const char *from_context,
-       const char *from_folder,
-       const char *to_mailbox,
-       const char *to_context,
-       const char *to_folder,
-       size_t num_msgs,
-       int *msg_ids,
-       int delete_old)
-{
-       if (ast_vm_msg_forward_func) {
-               return ast_vm_msg_forward_func(from_mailbox, from_context, from_folder, to_mailbox, to_context, to_folder, num_msgs, msg_ids, delete_old);
-       }
-       return 0;
-}
-
-int ast_vm_msg_play(struct ast_channel *chan,
-       const char *mailbox,
-       const char *context,
-       const char *folder,
-       const char *msg_num,
-       ast_vm_msg_play_cb cb)
-{
-       if (ast_vm_msg_play_func) {
-               return ast_vm_msg_play_func(chan, mailbox, context, folder, msg_num, cb);
-       }
-       return 0;
-}
-
-#ifdef TEST_FRAMEWORK
-int ast_vm_test_create_user(const char *context, const char *mailbox)
-{
-       if (ast_vm_test_create_user_func) {
-               return ast_vm_test_create_user_func(context, mailbox);
-       }
-       return 0;
-}
-
-int ast_vm_test_destroy_user(const char *context, const char *mailbox)
-{
-       if (ast_vm_test_destroy_user_func) {
-               return ast_vm_test_destroy_user_func(context, mailbox);
-       }
-       return 0;
-}
-#endif
-
 int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration) 
 {
        const char *ptr;
index d9c65c416170804bc7def13474b52ae34c7df311..3af85b467b3cfb8dc43b73b8176910df7ba145ed 100644 (file)
@@ -1203,7 +1203,6 @@ static const struct ast_value_translation redirecting_reason_types[] = {
        { AST_REDIRECTING_REASON_OUT_OF_ORDER,   "out_of_order", "Called DTE Out-Of-Order" },
        { AST_REDIRECTING_REASON_AWAY,           "away",         "Callee is Away" },
        { AST_REDIRECTING_REASON_CALL_FWD_DTE,   "cf_dte",       "Call Forwarding By The Called DTE" },
-       { AST_REDIRECTING_REASON_SEND_TO_VM,     "send_to_vm",   "Call is being redirected to user's voicemail"},
 /* *INDENT-ON* */
 };
 
index f405978ec2e7feda88f66512e02e32a4db39fba4..a0311143bf6771d88250f3cb927fffc1b1c97546 100644 (file)
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/paths.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
+#include "asterisk/app_voicemail.h"
 
 /*! \internal \brief Permissions to set on the voicemail directories we create
  * - taken from app_voicemail */
@@ -127,6 +128,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                        VM_API_STRING_FIELD_VERIFY((expected)->origtime, msg->origtime); \
                        VM_API_STRING_FIELD_VERIFY((expected)->duration, msg->duration); \
                        VM_API_STRING_FIELD_VERIFY((expected)->folder_name, msg->folder_name); \
+                       /* We are currently not going to check folder_dir, since its never written out. */ \
+                       /* VM_API_STRING_FIELD_VERIFY((expected)->folder_dir, msg->folder_dir); \ */ \
                        VM_API_STRING_FIELD_VERIFY((expected)->flag, msg->flag); \
                        VM_API_INT_VERIFY((expected)->msg_number, msg->msg_number); \
                        break; \
@@ -315,13 +318,13 @@ static struct ast_vm_msg_snapshot *test_vm_api_create_mock_snapshot(const char *
  * \returns 0 on success
  * \returns 1 on failure
  */
-static int test_vm_api_create_voicemail_folder(const char *folder_path)
+static int test_vm_api_create_voicemail_folder(struct ast_vm_msg_snapshot *snapshot)
 {
        mode_t mode = VOICEMAIL_DIR_MODE;
        int res;
 
-       if ((res = ast_mkdir(folder_path, mode))) {
-               ast_log(AST_LOG_ERROR, "ast_mkdir '%s' failed: %s\n", folder_path, strerror(res));
+       if ((res = ast_mkdir(snapshot->folder_dir, mode))) {
+               ast_log(AST_LOG_ERROR, "ast_mkdir '%s' failed: %s\n", snapshot->folder_dir, strerror(res));
                return 1;
        }
        return 0;
@@ -350,23 +353,24 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
         */
        snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
                ast_config_AST_SPOOL_DIR, context, mailbox, snapshot->folder_name);
+       ast_string_field_set(snapshot, folder_dir, folder_path);
        snprintf(msg_path, sizeof(msg_path), "%s/msg%04d.txt",
-               folder_path, snapshot->msg_number);
+               snapshot->folder_dir, snapshot->msg_number);
        snprintf(snd_path, sizeof(snd_path), "%s/msg%04d.gsm",
-               folder_path, snapshot->msg_number);
+               snapshot->folder_dir, snapshot->msg_number);
        snprintf(beep_path, sizeof(beep_path), "%s/sounds/en/beep.gsm", ast_config_AST_VAR_DIR);
 
-       if (test_vm_api_create_voicemail_folder(folder_path)) {
+       if (test_vm_api_create_voicemail_folder(snapshot)) {
                return 1;
        }
 
-       if (ast_lock_path(folder_path) == AST_LOCK_FAILURE) {
-               ast_log(AST_LOG_ERROR, "Unable to lock directory %s\n", folder_path);
+       if (ast_lock_path(snapshot->folder_dir) == AST_LOCK_FAILURE) {
+               ast_log(AST_LOG_ERROR, "Unable to lock directory %s\n", snapshot->folder_dir);
                return 1;
        }
 
        if (symlink(beep_path, snd_path)) {
-               ast_unlock_path(folder_path);
+               ast_unlock_path(snapshot->folder_dir);
                ast_log(AST_LOG_ERROR, "Failed to create a symbolic link from %s to %s: %s\n",
                        beep_path, snd_path, strerror(errno));
                return 1;
@@ -375,7 +379,7 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
        if (!(msg_file = fopen(msg_path, "w"))) {
                /* Attempt to remove the sound file */
                unlink(snd_path);
-               ast_unlock_path(folder_path);
+               ast_unlock_path(snapshot->folder_dir);
                ast_log(AST_LOG_ERROR, "Failed to open %s for writing\n", msg_path);
                return 1;
        }
@@ -413,11 +417,11 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
        fclose(msg_file);
 
        if (chmod(msg_path, VOICEMAIL_FILE_MODE) < 0) {
-               ast_unlock_path(folder_path);
+               ast_unlock_path(snapshot->folder_dir);
                ast_log(AST_LOG_ERROR, "Couldn't set permissions on voicemail text file %s: %s", msg_path, strerror(errno));
                return 1;
        }
-       ast_unlock_path(folder_path);
+       ast_unlock_path(snapshot->folder_dir);
 
        return 0;
 }
@@ -435,13 +439,16 @@ static void test_vm_api_remove_voicemail(struct ast_vm_msg_snapshot *snapshot)
                return;
        }
 
-       snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
-               ast_config_AST_SPOOL_DIR, "default", snapshot->exten, snapshot->folder_name);
+       if (ast_strlen_zero(snapshot->folder_dir)) {
+               snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
+                       ast_config_AST_SPOOL_DIR, "default", snapshot->exten, snapshot->folder_name);
+               ast_string_field_set(snapshot, folder_dir, folder_path);
+       }
 
        snprintf(msg_path, sizeof(msg_path), "%s/msg%04d.txt",
-                       folder_path, snapshot->msg_number);
+                       snapshot->folder_dir, snapshot->msg_number);
        snprintf(snd_path, sizeof(snd_path), "%s/msg%04d.gsm",
-                       folder_path, snapshot->msg_number);
+                       snapshot->folder_dir, snapshot->msg_number);
        unlink(msg_path);
        unlink(snd_path);
 
@@ -618,6 +625,7 @@ static void test_vm_api_test_teardown(void)
 static void test_vm_api_update_test_snapshots(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 {
        int i, j;
+       char folder_path[PATH_MAX];
        struct ast_vm_msg_snapshot *msg;
 
        for (i = 0; i < TOTAL_SNAPSHOTS; ++i) {
@@ -631,6 +639,13 @@ static void test_vm_api_update_test_snapshots(struct ast_vm_mailbox_snapshot *ma
                                        ast_string_field_set(test_snapshots[i], origtime, msg->origtime);
                                        ast_string_field_set(test_snapshots[i], duration, msg->duration);
                                        ast_string_field_set(test_snapshots[i], folder_name, msg->folder_name);
+                                       /* TODO: because the folder_dir isn't updated in a snapshot, this will
+                                        * always be NULL.  We need to recreate the folder path here
+                                       ast_string_field_set(test_snapshots[i], folder_dir, msg->folder_dir);
+                                       */
+                                       snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
+                                               ast_config_AST_SPOOL_DIR, "default", test_snapshots[i]->exten, test_snapshots[i]->folder_name);
+                                       ast_string_field_set(test_snapshots[i], folder_dir, folder_path);
                                        ast_string_field_set(test_snapshots[i], flag, msg->flag);
                                        test_snapshots[i]->msg_number = msg->msg_number;
                                }