[asterisk-commits] brushtyler: branch brushtyler/voicemail_menu_branch r212712 - /team/brushtyle...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 17 19:22:25 CDT 2009


Author: brushtyler
Date: Mon Aug 17 19:22:21 2009
New Revision: 212712

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=212712
Log:
added some function comments

Modified:
    team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c

Modified: team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c?view=diff&rev=212712&r1=212711&r2=212712
==============================================================================
--- team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c (original)
+++ team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c Mon Aug 17 19:22:21 2009
@@ -206,9 +206,6 @@
 	AST_APP_OPTION_ARG('a', OPT_AUTOPLAY, OPT_ARG_PLAYFOLDER),
 });
 
-/* this structure contains value of some variables defined in this function
- * and needed to call voicemail function by the do_menu */
-
 /*! Voicemail time zones */
 struct vm_zone {
 	AST_LIST_ENTRY(vm_zone) list;
@@ -310,8 +307,8 @@
 /*! Voicemail mailbox state */
 struct vm_state {
 	char str_dig[80];		/*!< Buffer representing pattern digited by user */
-    int retries;
-    int exiting;
+    int retries;            /*!< number of consecutive times that the user input doesn't match any pattern */
+    int exiting;            /*!< setted if the voicemail application is ending */
 	char curbox[80];
 	char username[80];
 	char curdir[PATH_MAX];
@@ -325,8 +322,6 @@
 	int urgentmessages;
 	int newmessages;
 	int oldmessages;
-	int starting;
-	int repeats;
 #ifdef IMAP_STORAGE
 	int updated;                         /*!< decremented on each mail check until 1 -allows delay */
 	long msgArray[256];
@@ -360,19 +355,22 @@
 
 static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms);
 static int forward_message(struct ast_channel *chan, char *context, struct vm_state *vms, 
-                struct ast_vm_user *sender, char *username, char *fmt, int is_tmp_message, 
-                signed char record_gain, int urgent);
-/*static void adsi_folders(struct ast_channel *chan, int start, char *label);
+        struct ast_vm_user *sender, char *username, char *fmt, int is_tmp_message, 
+        signed char record_gain, int urgent);
+/*
+static void adsi_folders(struct ast_channel *chan, int start, char *label);
 static int get_folder2(struct ast_channel *chan, char *fn, int start);
 static void adsi_delete(struct ast_channel *chan, struct vm_state *vms);
-static void adsi_status2(struct ast_channel *chan, struct vm_state *vms);*/
+static void adsi_status2(struct ast_channel *chan, struct vm_state *vms);
+*/
 static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu);
 static void apply_options(struct ast_vm_user *vmu, const char *options);
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, const char *box);
 #if !(defined(ODBC_STORAGE) || defined(IMAP_STORAGE))
 static int __has_voicemail(const char *context, const char *mailbox, const char *folder, int shortcircuit);
 #endif
-static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain);
+static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, 
+        struct vm_state *vms, int msg, int option, signed char record_gain);
 
 /* FUNCTIONS*/
 
@@ -1001,7 +999,6 @@
 
 /*
  * return the index of the last message in the directory
- * XXX check error
  */
 static int last_message_index(struct ast_vm_user *vmu, const char *dir)
 {
@@ -1800,6 +1797,7 @@
 	return 0;
 }
 
+/***/
 static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain)
 {
 	int res = 0;
@@ -1808,8 +1806,6 @@
 	const char *origtime, *context;
 	char *cid;
 	struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
-
-	vms->starting = 0; 
 
 	make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
 
@@ -1863,7 +1859,6 @@
 {
     int res = 0;
 
-	vms->starting = 0;
 	make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
 	vms->heard[vms->curmsg] = 1;
 #ifdef IMAP_STORAGE
@@ -1887,32 +1882,26 @@
  * Beginning of the main body of the new system.
  */
 
-/*
-XXX descrivere come e` strutturato il nuovo sistema altrimenti
-non si riesce a capire qual'e' il ruolo delle varie strutture
-dati, funzioni e variabili.
-
- */
-
 /* these are return codes for the function vm_exec_actions */
-enum exec_result_code{
+enum exec_result_code {
  	VMM_ERROR,	    /* some error occurred. */
 	VMM_JUMP,	    /* jump to a specific menu */
 	VMM_CONTINUE,	/* stay in the current menu */
 	VMM_RETURN,	    /* return from a submenu (up N steps in the stack) */
 };
 
+/* manteins some menu variables */
 struct exec_main_var {
 	char prefixstr[80];
 	char ext_context[256];
-    struct ast_category *endmenu_cat;
-    const char *endmenu_name;
+    struct ast_category *endmenu_cat;   /*!< the end menu category */
+    const char *endmenu_name;           /*!< the end menu name */
 	int box;
 	int useadsi;
 	int skipuser;
-	char *context;
+	char *context;                      /*!< conteins the called voicemail context */
 	int silentexit;
-	/*struct ast_flags flags = { 0 };*/
+	/* struct ast_flags flags = { 0 }; */
 	signed char record_gain;
 	int play_auto;
 	int play_folder;
@@ -1920,9 +1909,12 @@
 	int deleted;
 };
 
+/* function type definition for the voicemail action handlers */ 
 typedef int (*action_fn)(const char*, struct ast_channel*, struct vm_state*, struct ast_vm_user *vmu,
 	      struct exec_main_var* vm_var, char **result);
 
+/* this structure is used to mantein the association between function name 
+   and handler */
 struct my_vmm_funcs {
 	const char *name;
 	action_fn handler;
@@ -1931,15 +1923,11 @@
 /* this structure contains informations about the actions executed by the 
  * function vm_exec_actions */
 struct exec_result {			
-	struct ast_category * menu;	/* represents menu information when moving
-				 	 * across submenu */
-    const char * menu_name;   /* conteins the name of the current submenu */
-	enum exec_result_code code;	/* represents the return value interpretated
-				 	 * in the do_menu() */
-	int steps;			/* in case of a return it represents the 
-				 	 * number of steps to do*/
-	char digit[80];			/* digit pressed during execution of the 
-					 * function*/
+	struct ast_category *menu;  /*!< represents menu information when moving across submenu */
+    const char *menu_name;      /*!< conteins the name of the submenu */
+	enum exec_result_code code;	/*!< represents the return value interpretated in the do_menu() */
+	int steps;			        /*!< in case of a return it represents the number of steps to do */
+	char digit[80];			    /*!< digit pressed during execution of the function */
 };
 
 /*!------------ FUNCTIONS ---------------------------------*/
@@ -1989,43 +1977,60 @@
 
 /*!--------------------------------------------------------*/
 
-
+/* this structure is a list name-handler of functions that user can call 
+   in the voicemail_menu.conf file */
 static struct my_vmm_funcs my_f[] = {
-  	{"play", vmm_play},			    /* Play a sound file --- play(sound_file) */
-  	{"play_num", vmm_play_num},			    /* Play a sound file --- play_num(number) */
-	{"set_msg", vmm_set_msg},       /* Select a message in the voicemail --- set_msg(number [, folder]) */
+  	{"play", vmm_play},			    /* Play a sound file --- play(<sound_file>) */
+  	{"play_num", vmm_play_num},	    /* Play a number --- play_num(<number>) */
+	{"set_msg", vmm_set_msg},       /* Select a message in the voicemail --- set_msg(<number> [, <folder>]) */
 	{"play_msg", vmm_play_msg},		/* Play a message in the voicemail (default is the selected message) 
-                                     * --- play([number [, folder]])
-                                     * or play the unavailable, busy, greeting and temporary message
-                                     * --- play(msg_name)  */
-    {"record_msg", vmm_record},     /* Record the unavailable, busy, greeting and temporary message
-                                     * --- record_msg(msg_name) */
-    {"save_rec", vmm_save_rec},     /* Save the last recorded message as unavailable, busy, greeting or temporary
-                                     * --- save_rec(msg_name) */
-   	{"play_envelope", vmm_envelope},	    /* Play the selected message envelope --- envelope() */
-    {"save_into", vmm_save_into},   /* Save the selected message into a folder --- save_into(folder) */
+                                     * --- play_msg([<number> [, <folder>]])
+                                     * or play the unavailable, busy, greeting and temporary greeting message
+                                     * --- play_msg(<msg_name>)
+                                     * or play the last recorded message --- play_msg(rec) */
+    {"record_msg", vmm_record},     /* Record a temporary message --- record_msg() */
+    {"save_rec", vmm_save_rec},     /* Save the last recorded message as unavailable, busy, greeting or temporary greeting
+                                     * --- save_rec(<msg_name>) */
+   	{"play_envelope", vmm_envelope},    /* Play the selected message envelope --- play_envelope() */
+    {"save_into", vmm_save_into},   /* Save the selected message into a folder --- save_into(<folder>) */
     {"delete_msg", vmm_delete},		/* Set a message for deletion (default is the selected message)
-                                     * --- delete_msg([number [, folder]])
-                                     * or delete the unavailable, busy, greeting and temporary message
-                                     * --- delete_msg(msg_name)  */
+                                     * --- delete_msg([<number> [, <folder>]])
+                                     * or delete the unavailable, busy, greeting and temporary greeting message
+                                     * --- delete_msg(<msg_name>)
+                                     * or delete the last recorded message --- delete_msg(rec) */
     {"undelete_msg", vmm_delete},	/* Unset a message for deletion (default is the selected message)
-                                     * --- undelete_msg([number [, folder]]) */
-  	{"change_to", vmm_change_to},	/* Change the actual folder --- change_to(folder) */
-    {"dialout",vmm_dialout},	    /* Exec a call to a number --- dialout(number) */
-    {"forward_msg", vmm_forward_msg}, 
-    {"mb_exists", vmm_mb_exists},
-    {"msg_exists", vmm_msg_exists},
+                                     * --- undelete_msg([<number> [, <folder>]]) */
+  	{"change_to", vmm_change_to},	/* Change the actual folder --- change_to(<folder>) */
+    {"dialout",vmm_dialout},	    /* Exec a call to a number --- dialout(<number>) */
+    {"forward_msg", vmm_forward_msg},   /* Forward a message to a mailbox (default is the current message)
+                                         * --- forward_msg(<extension>)
+                                         * or forward the last recorded message --- forward_msg(<extension>, rec) */ 
+    {"mb_exists", vmm_mb_exists},   /* Check if a mailbox exists --- mb_exists(<extension>) */
+    {"msg_exists", vmm_msg_exists}, /* Check if a message exists (default is the current message)
+                                     * --- msg_exists([<number> [, <folder>]]) 
+                                     * or check the existence of unavailable, busy, greeting or temporary greeting message
+                                     * --- msg_exists(<msg_name>)
+                                     * or test if a message has been recorded --- msg_exists(rec) */
     {"change_password", vmm_change_password}, /* Change the user password --- change_password() */
- 	{NULL,0}
+ 	{NULL, 0}
 };
+
 /*!------------------------ VARIABLES ----------------------*/
 
 static struct ast_config *menu_cfg = NULL;	/* Configuration file */
-int max_retries;				/* number of retries allowed */
+int max_retries;				            /* number of retries allowed */
 
 #define debug 0
 
-/* return -1 if an error occurred, 1 if sender has a mailbox, 0 otherwise */
+/*!
+ * \brief Retrieve the sender cid of the selected message.
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param s_cid to return the sender cid
+ * 
+ * \return -1 if an error is occurred, 1 if sender has a mailbox, 0 otherwise.
+ */
 static int get_sender_cid(struct ast_channel* chan, struct vm_state* vms,
 			    struct ast_vm_user* vmu, char ** s_cid)
 {
@@ -2077,14 +2082,20 @@
     return 0;
 }
 
-/*! 
- * set the variables channel to check availability of service
+/*!
+ * \brief Set the channels variables to retrieve info on current selected message
+ * \param chan
+ * \param vms
+ * \param vmu
+ * 
+ * \return zero on success, -1 on error.
  */
 static int set_channelvar(struct ast_channel* chan, struct vm_state* vms,
 				struct ast_vm_user* vmu)
 {
     char *cid = NULL, *num = NULL, *name = NULL;
     char curmsg[10];
+    int res;
 
 #if debug
 	if (vms->curmsg < 0)
@@ -2093,18 +2104,20 @@
 
     if(!get_sender_cid(chan, vms, vmu, &cid)) {
     	ast_callerid_parse(cid, &name, &num);
+        ast_free((void *)cid);
     }
-    ast_free((void *)cid);
 
     /* convert the current message number in string */
     snprintf(curmsg, sizeof(curmsg), "%d", vms->curmsg+1);
-	pbx_builtin_setvar_helper(chan, "VM_MSG_SELECTED", vms->curmsg >= 0 ? curmsg : "0");
-	pbx_builtin_setvar_helper(chan, "VM_MSG_IS_DELETED", vms->curmsg >= 0 ? (vms->deleted[vms->curmsg] ? "1" : "0") : "");
-	pbx_builtin_setvar_helper(chan, "VM_MSG_IS_LAST", vms->curmsg >= 0 ? (vms->curmsg < vms->lastmsg ? "0" : "1") : "");
-	pbx_builtin_setvar_helper(chan, "VM_MSG_IS_FIRST", vms->curmsg >= 0 ? (vms->curmsg == 0 ? "1" : "0") : "");
-
-   	pbx_builtin_setvar_helper(chan, "VM_MSG_SENDER", vms->curmsg >= 0 && num ? num : "");
-	/*DEBUG*/
+	res = pbx_builtin_setvar_helper(chan, "VM_MSG_SELECTED", vms->curmsg >= 0 ? curmsg : "0");
+    if (!res) res = pbx_builtin_setvar_helper(chan, "VM_MSG_IS_DELETED", vms->curmsg >= 0 ? (vms->deleted[vms->curmsg] ? "1" : "0") : "");
+	if (!res) res = pbx_builtin_setvar_helper(chan, "VM_MSG_IS_LAST", vms->curmsg >= 0 ? (vms->curmsg < vms->lastmsg ? "0" : "1") : "");
+	if (!res) res = pbx_builtin_setvar_helper(chan, "VM_MSG_IS_FIRST", vms->curmsg >= 0 ? (vms->curmsg == 0 ? "1" : "0") : "");
+   	if (!res) res = pbx_builtin_setvar_helper(chan, "VM_MSG_SENDER", vms->curmsg >= 0 && num ? num : "");
+
+    if (res)
+        return -1;
+
 #if debug
     {
 	const char * DEL;
@@ -2127,17 +2140,30 @@
 	ast_log(LOG_NOTICE, "++++++++++++++++++++++++++++++++++++++\n");
     }
 #endif
-	return 1;
-}
-
+
+	return 0;
+}
+
+/*!
+ * \brief Set the channels variables to check availability of service
+ * \param chan
+ * \param vms
+ * \param vmu
+ * 
+ * \return zero on success, -1 on error.
+ */
 static int set_channelvar_full(struct ast_channel* chan, struct vm_state* vms,
 			    struct ast_vm_user* vmu)
 {
-	pbx_builtin_setvar_helper(chan, "VMU_CALLBACK", S_OR(vmu->callback, "0"));
-	pbx_builtin_setvar_helper(chan, "VMU_DIALOUT", S_OR(vmu->dialout, "0"));
-	pbx_builtin_setvar_helper(chan, "VMU_LEAVE_MSG", ast_test_flag(vmu, VM_SVMAIL) ? "1" : "0");
-
-	set_channelvar(chan, vms, vmu);
+    int res;
+
+	res = pbx_builtin_setvar_helper(chan, "VMU_CALLBACK", S_OR(vmu->callback, "0"));
+	if (!res) res = pbx_builtin_setvar_helper(chan, "VMU_DIALOUT", S_OR(vmu->dialout, "0"));
+	if (!res) res = pbx_builtin_setvar_helper(chan, "VMU_LEAVE_MSG", ast_test_flag(vmu, VM_SVMAIL) ? "1" : "0");
+
+	if (res || set_channelvar(chan, vms, vmu))
+        return -1;
+
 #if debug
     {
 	const char * c_b;
@@ -2147,7 +2173,6 @@
 	c_b = pbx_builtin_getvar_helper(chan, "VMU_CALLBACK");
 	d_o = pbx_builtin_getvar_helper(chan, "VMU_CALLBACK");
 	l_m = pbx_builtin_getvar_helper(chan, "VMU_LEAVE_MSG");
-	/*DEBUG*/
 
 	ast_log(LOG_NOTICE, "++++++++++++++++++++++++++++++++++++++\n");
 	ast_log(LOG_NOTICE, "VMU_CALLBACK: '%s'\n",c_b);
@@ -2155,10 +2180,21 @@
 	ast_log(LOG_NOTICE, "VMU_LEAVEMESS: '%s'\n",l_m);
 	ast_log(LOG_NOTICE, "++++++++++++++++++++++++++++++++++++++\n");
     }
-#endif	
-	return 1;
-}
-
+#endif
+
+	return 0;
+}
+
+/*!
+ * \brief Parse a string to retrieve the message number and folder
+ * \param args the string to parse
+ * \param chan
+ * \param vms
+ * \param fold to return the folder as second param in args
+ * \param num to return the message number as first param in args
+ * 
+ * \return zero on success, -1 on error.
+ */
 static int parse_message_num(const char* args, struct ast_channel* chan, struct vm_state* vms, 
         char **fold, int *num)
 {
@@ -2219,6 +2255,18 @@
     return 0;
 }
 
+/*!
+ * \brief Set a message as current selected message
+ * \param args can contains number and folder of the message to select
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 on error that affects only the current 
+ *  action, -1 on other errors.
+ */
 static int vmm_set_msg(const char* args, struct ast_channel* chan, struct vm_state* vms,
 		    struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2241,9 +2289,9 @@
 
     /* is not the current folder, change it */
     if (strcmp(folder, vms->curbox)) {
-        if ((res = vmm_change_to(folder, chan, vms, vmu, vm_var, NULL))) {
+        if (vmm_change_to(folder, chan, vms, vmu, vm_var, NULL)) {
             ast_log(LOG_ERROR, "An error occurred when change to folder %s\n", folder);
-            return res;
+            return -1;
         }
     }
 
@@ -2256,12 +2304,21 @@
     	res = 1;
     }
 
-    if (!res)
-        set_channelvar(chan, vms, vmu);
+    if (set_channelvar(chan, vms, vmu))
+        return -1;
 
     return res;
 }
 
+/*!
+ * \brief Check a mailbox existance
+ * \param args the mailbox number
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result is "1" if the mailbox exists, "0" otherwise
+ */
 static int vmm_mb_exists(const char* args, struct ast_channel* chan, struct vm_state* vms,
             struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2282,6 +2339,16 @@
     return 0;
 }
 
+/*!
+ * \brief Check if a message exists
+ * \param args can conteins number and folder of the message to check 
+ *  or the name of a special message (unv, busy, name, temp, rec)
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result is "1" if the message exists, "0" otherwise
+ */
 static int vmm_msg_exists(const char* args, struct ast_channel* chan, struct vm_state* vms,
             struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2349,6 +2416,18 @@
     return res;
 }
 
+/*!
+ * \brief Save the current selected message in another folder
+ * \param args the folder in which save the message
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
+ */
 static int vmm_save_into(const char* args, struct ast_channel* chan, struct vm_state* vms,
             struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2385,6 +2464,14 @@
 static int review_record_store_delete(struct ast_channel *chan, const char *args, int option, 
              struct vm_state* vms, struct ast_vm_user* vmu, struct exec_main_var* vm_var);
 
+/*!
+ * \brief Parse the greeting and special message names
+ * \param args a message name to parse
+ * \param ret the special message name used in the application
+ * 
+ * \return zero on success, -1 if the passed message name doesn't match any
+ *  special message names
+ */
 static int parse_message_type(const char *args, char **ret)
 {
     char *type = NULL;
@@ -2412,7 +2499,18 @@
     return 0;
 }
 
-/* save the temporary (last recorded) message as greeting message */
+/*!
+ * \brief Save the temporary (last recorded) message as greeting message
+ * \param args the greeting message name
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
+ */
 static int vmm_save_rec(const char* args, struct ast_channel* chan, struct vm_state* vms,
             struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2430,7 +2528,18 @@
 static int record_voicemail(struct ast_channel *chan, struct vm_state* vms,
 		    struct ast_vm_user* vmu, struct exec_main_var* vm_var);
 
-/* record a message */
+/*!
+ * \brief Record a temporary message
+ * \param args none
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
+ */
 static int vmm_record(const char* args, struct ast_channel* chan, struct vm_state* vms,
 		    struct ast_vm_user* vmu, struct exec_main_var* vm_var, char **result)
 {
@@ -2451,7 +2560,17 @@
     return record_voicemail(chan, vms, vmu, vm_var);
 }
 
-/* play an information message */
+/*!
+ * \brief Play a sound file
+ * \param args the sound name
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, -1 on errors.
+ */
 int vmm_play(const char* args, struct ast_channel* chan, struct vm_state* vms, struct ast_vm_user *vmu,
 	 struct exec_main_var* vm_var, char **result)
 {
@@ -2461,7 +2580,18 @@
 	return ast_play_and_wait(chan, args);
 }
 
-/* play a number */
+/*!
+ * \brief Play a number
+ * \param args the number
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
+ */
 int vmm_play_num(const char* args, struct ast_channel* chan, struct vm_state* vms, struct ast_vm_user *vmu,
 	 struct exec_main_var* vm_var, char **result)
 {
@@ -2473,7 +2603,18 @@
 	return say_and_wait(chan, num, chan->language);
 }
 
-/* play a message */
+/*!
+ * \brief Play a message
+ * \param args can contains the message number and folder to play
+ * \param chan
+ * \param vms
+ * \param vmu
+ * \param vm_var
+ * \param result none
+ * 
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
+ */
 static int vmm_play_msg(const char* args, struct ast_channel* chan, struct vm_state* vms, struct ast_vm_user* vmu, 
     struct exec_main_var* vm_var, char **result)
 {
@@ -2511,14 +2652,14 @@
 }
 
 /*!
- * \brief Prompts the user and records a voicemail to a mailbox.
+ * \brief Records a voicemail (voice message and information file)
  * \param chan
- * \param ext
- * \param options OPT_BUSY_GREETING, OPT_UNAVAIL_GREETING
+ * \param vms
+ * \param vmu
+ * \param vm_var
  * 
- * 
- * 
- * \return zero on success, -1 on error.
+ * \return zero on success, 1 if an error occurred but affects only the current 
+ *  action, -1 on other errors.
  */
 static int record_voicemail(struct ast_channel *chan, struct vm_state* vms,
 		    struct ast_vm_user* vmu, struct exec_main_var* vm_var)
@@ -2790,15 +2931,15 @@
 	if (strcasecmp(args, "Urgent")) 
         vm_var->in_urgent = 0;
 	res = open_mailbox(vms, vmu, args);
+    if (res == ERROR_LOCK_PATH)
+		return -1;
 
     if (vms->lastmsg < 0)
         vms->curmsg = -1;
     else
         vms->curmsg = 0;
 
-    set_channelvar_full(chan, vms, vmu);
-
-	if (res == ERROR_LOCK_PATH)
+    if (set_channelvar(chan, vms, vmu))
 		return -1;
 
 	vm_var->play_folder = folder_int(args);
@@ -3281,7 +3422,7 @@
     }
 
     /* operation on channel variables */
-   	if (set_channelvar_full(chan, vms, vmu) == 0){
+   	if (set_channelvar_full(chan, vms, vmu)){
    		ast_log(LOG_ERROR, "Error setting channel variable, leaving voicemail\n");
         vms->exiting = 1;   /* exit without jump to the end menu */
    		return depth+1;
@@ -3819,8 +3960,6 @@
 	}
 #endif
 
-	vms.repeats = 0;
-	vms.starting = 1;
 	/* before call the do_menu we ave to initialize the value of the fields of 
      * the structure exec_main_var */
 	vm_var.useadsi = useadsi;




More information about the asterisk-commits mailing list