[svn-commits] qwell: trunk r368966 - in /trunk: ./ apps/ include/asterisk/ main/ tests/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 14 14:40:17 CDT 2012


Author: qwell
Date: Thu Jun 14 14:40:11 2012
New Revision: 368966

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368966
Log:
Multiple revisions 368963,368965

........
  r368963 | qwell | 2012-06-14 13:47:03 -0500 (Thu, 14 Jun 2012) | 14 lines
  
  Remove global symbol requirement from app_voicemail.
  
  This uses the existing "function installation" stuff that already existed for
  other functions, like getting message counts.
  
  (closes issue AST-807)
  (issue AST-901)
  (issue AST-908)
  
  Review: https://reviewboard.asterisk.org/r/1965/
  ........
  
  Merged revisions 368962 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........
  r368965 | qwell | 2012-06-14 14:04:57 -0500 (Thu, 14 Jun 2012) | 11 lines
  
  These functions that were moved need to be static.
  
  Also wrap test functions in a #ifdef.
  
  (issue AST-807)
  (issue AST-901)
  (issue AST-908)
  ........
  
  Merged revisions 368964 from http://svn.asterisk.org/svn/asterisk/certified/branches/1.8.11
........

Merged revisions 368963,368965 from http://svn.asterisk.org/svn/asterisk/branches/10-digiumphones

Removed:
    trunk/include/asterisk/app_voicemail.h
Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c
    trunk/include/asterisk/app.h
    trunk/main/app.c
    trunk/tests/test_voicemail_api.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-10-digiumphones-merged (original)
+++ branch-10-digiumphones-merged Thu Jun 14 14:40:11 2012
@@ -1,1 +1,1 @@
-/branches/10-digiumphones:364766,365396,368791
+/branches/10-digiumphones:364766,365396,368791,368963-368965

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=368966&r1=368965&r2=368966
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Jun 14 14:40:11 2012
@@ -113,7 +113,6 @@
 #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"
@@ -1041,7 +1040,6 @@
 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 int message_range_and_existence_check(struct vm_state *vms, const char *msg_ids [], size_t num_msgs, int *msg_nums, struct ast_vm_user *vmu);
 /*!
@@ -1059,6 +1057,19 @@
  * \revval other Failure
  */
 static int save_to_folder(struct ast_vm_user *vmu, struct vm_state *vms, int msg, int box, int *newmsg, int move);
+
+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, const char *msg_ids[], int delete_old);
+static int vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder);
+static int vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *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;
 
@@ -1868,6 +1879,12 @@
 	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;
@@ -10580,7 +10597,7 @@
 	}
 
 	/* Iterate through every folder, find the msg, and play it */
-	for (i = 0; i < AST_VM_FOLDER_NUMBER && !played; i++) {
+	for (i = 0; i < ARRAY_LEN(mailbox_folders) && !played; i++) {
 		ast_copy_string(vms.username, mailbox, sizeof(vms.username));
 		vms.lastmsg = -1;
 
@@ -14096,6 +14113,9 @@
 #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)
@@ -14154,7 +14174,15 @@
 	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);
+	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_destroy_user, vm_test_create_user);
+#endif
+
 	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);
 
@@ -14689,7 +14717,7 @@
 
 #ifdef TEST_FRAMEWORK
 
-int ast_vm_test_destroy_user(const char *context, const char *mailbox)
+static int vm_test_destroy_user(const char *context, const char *mailbox)
 {
 	struct ast_vm_user *vmu;
 
@@ -14707,7 +14735,7 @@
 	return 0;
 }
 
-int ast_vm_test_create_user(const char *context, const char *mailbox)
+static int vm_test_create_user(const char *context, const char *mailbox)
 {
 	struct ast_vm_user *vmu;
 
@@ -14846,7 +14874,7 @@
 	return 0;
 }
 
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
+static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *mailbox,
 	const char *context,
 	const char *folder,
 	int descending,
@@ -14872,7 +14900,7 @@
 
 	if (!(ast_strlen_zero(folder))) {
 		/* find the folder index */
-		for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
+		for (i = 0; i < ARRAY_LEN(mailbox_folders); i++) {
 			if (!strcasecmp(mailbox_folders[i], folder)) {
 				this_index_only = i;
 				break;
@@ -14894,7 +14922,14 @@
 		return NULL;
 	}
 
-	for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
+	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++) {
 		int combining_old = 0;
 		if ((i == old_index) && (combine_INBOX_and_OLD)) {
 			combining_old = 1;
@@ -14949,62 +14984,26 @@
 	return mailbox_snapshot;
 }
 
-struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
+static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 {
 	int i;
 	struct ast_vm_msg_snapshot *msg_snapshot;
 
-	for (i = 0; i < AST_VM_FOLDER_NUMBER; i++) {
+	for (i = 0; i < mailbox_snapshot->folders; 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, "FLAG:         %s\n", msg_snapshot->flag);
-			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 ast_vm_msg_move, ast_vm_msg_remove, and ast_vm_msg_forward to
+ * This is called by vm_msg_move, vm_msg_remove, and vm_msg_forward to
  * ensure that data passed in are valid. This ensures that given the
  * desired message IDs, they can be found.
  *
@@ -15077,7 +15076,7 @@
 	queue_mwi_event(ext_context, urgent, new, old);
 }
 
-int ast_vm_msg_forward(const char *from_mailbox,
+static int vm_msg_forward(const char *from_mailbox,
 	const char *from_context,
 	const char *from_folder,
 	const char *to_mailbox,
@@ -15222,7 +15221,7 @@
 	return res;
 }
 
-int ast_vm_msg_move(const char *mailbox,
+static int vm_msg_move(const char *mailbox,
 	const char *context,
 	size_t num_msgs,
 	const char *oldfolder,
@@ -15329,7 +15328,7 @@
 	return res;
 }
 
-int ast_vm_msg_remove(const char *mailbox,
+static int vm_msg_remove(const char *mailbox,
 	const char *context,
 	size_t num_msgs,
 	const char *folder,
@@ -15430,15 +15429,7 @@
 	return res;
 }
 
-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,
+static int vm_msg_play(struct ast_channel *chan,
 	const char *mailbox,
 	const char *context,
 	const char *folder,
@@ -15555,7 +15546,7 @@
  * AST_MODULE_INFO(, , "Comedian Mail (Voicemail System)"
  */
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, tdesc,
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, tdesc,
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload,

Modified: trunk/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/app.h?view=diff&rev=368966&r1=368965&r2=368966
==============================================================================
--- trunk/include/asterisk/app.h (original)
+++ trunk/include/asterisk/app.h Thu Jun 14 14:40:11 2012
@@ -27,6 +27,7 @@
 #include "asterisk/strings.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/file.h"
+#include "asterisk/linkedlists.h"
 
 struct ast_flags64;
 
@@ -183,6 +184,35 @@
 int ast_app_run_macro(struct ast_channel *autoservice_chan,
 	struct ast_channel *macro_chan, const char *macro_name, const char *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;
+};
+
 /*!
  * \since 11
  * \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
@@ -230,12 +260,22 @@
 	struct ast_channel *sub_chan, const char *sub_location, const char *sub_args);
 
 /*!
+ * \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),
@@ -243,10 +283,51 @@
 			      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));
+			      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,
+				const char *old_msg_ids[],
+				const char *newfolder),
+			      int (*vm_msg_remove)(const char *mailbox,
+				const char *context,
+				size_t num_msgs,
+				const char *folder,
+				const char *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,
+				const char *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));
 
 
 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
@@ -310,6 +391,131 @@
  * \return Number of messages in the given context, mailbox, and folder.  If folder is NULL, folder "INBOX" is assumed.  If folder is "INBOX", includes number of messages in the "Urgent" folder.
  */
 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
+ * 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,
+	const char *old_msg_ids[],
+	const char *newfolder);
+
+/*!
+ * \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,
+	const char *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,
+	const char *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

Modified: trunk/main/app.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/app.c?view=diff&rev=368966&r1=368965&r2=368966
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Thu Jun 14 14:40:11 2012
@@ -424,13 +424,81 @@
 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,
+	const char *old_msg_ids[],
+	const char *newfolder) = NULL;
+static int (*ast_vm_msg_remove_func)(const char *mailbox,
+	const char *context,
+	size_t num_msgs,
+	const char *folder,
+	const char *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,
+	const char *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))
+			      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,
+				const char *old_msg_ids[],
+				const char *newfolder),
+			      int (*vm_msg_remove_func)(const char *mailbox,
+				const char *context,
+				size_t num_msgs,
+				const char *folder,
+				const char *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,
+				const char *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))
 {
 	ast_has_voicemail_func = has_voicemail_func;
 	ast_inboxcount_func = inboxcount_func;
@@ -438,6 +506,13 @@
 	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)
@@ -448,7 +523,32 @@
 	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)
 {
@@ -551,6 +651,107 @@
 
 	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,
+	const char *old_msg_ids[],
+	const char *newfolder)
+{
+	if (ast_vm_msg_move_func) {
+		return ast_vm_msg_move_func(mailbox, context, num_msgs, oldfolder, old_msg_ids, newfolder);
+	}
+	return 0;
+}
+
+int ast_vm_msg_remove(const char *mailbox,
+	const char *context,
+	size_t num_msgs,
+	const char *folder,
+	const char *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,
+	const char *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)
 {

Modified: trunk/tests/test_voicemail_api.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_voicemail_api.c?view=diff&rev=368966&r1=368965&r2=368966
==============================================================================
--- trunk/tests/test_voicemail_api.c (original)
+++ trunk/tests/test_voicemail_api.c Thu Jun 14 14:40:11 2012
@@ -43,7 +43,6 @@
 #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 */




More information about the svn-commits mailing list