[svn-commits] brushtyler: branch brushtyler/voicemail_menu_branch r206634 - in /team/brusht...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 15 10:39:41 CDT 2009


Author: brushtyler
Date: Wed Jul 15 10:39:37 2009
New Revision: 206634

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206634
Log:
Added some functionalities and documentation.

Modified:
    team/brushtyler/voicemail_menu_branch/apps/myvm/brief.txt
    team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_0.conf
    team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_1.conf
    team/brushtyler/voicemail_menu_branch/apps/newvoicemail.c

Modified: team/brushtyler/voicemail_menu_branch/apps/myvm/brief.txt
URL: http://svn.asterisk.org/svn-view/asterisk/team/brushtyler/voicemail_menu_branch/apps/myvm/brief.txt?view=diff&rev=206634&r1=206633&r2=206634
==============================================================================
--- team/brushtyler/voicemail_menu_branch/apps/myvm/brief.txt (original)
+++ team/brushtyler/voicemail_menu_branch/apps/myvm/brief.txt Wed Jul 15 10:39:37 2009
@@ -1,6 +1,8 @@
 === VOICEMAIL_MENU.CONF FILE ===
 
 A few notes on the proposed architecture for the new voicemail application.
+To use it, call the VoiceMailMenu2 application from dialplan with the same 
+arguments of the VoiceMailMenu one (the actual voicemail).
 
 The idea is that the entire behaviour of the voicemail is configurable
 through a config file. The file contains multiple sections,representing 
@@ -29,22 +31,26 @@
         start = menu_name
             ; specifies the name of the voicemail start menu. A 'menu_name' 
             ; section must exist in the voicemail_menu.conf
-        authentication_required	= yes|no
-            ; set this flag to 'no' if you want skip the autentication, 'yes' 
-            ; otherwise
+        end = menu_name
+            ; specifies the name of the voicemail end menu. 
+            ; It's optional: if exists, calling the exit() function in a menu 
+            ; the execution jump to this menu, otherwise the voicemail app is 
+            ; terminated. Calling the exit() function in this menu, the 
+            ; voicemail app is terminated.
         max_retries = n
-            ; number of maximum failed authentication before Asterisk closes 
-            ; the communication channel
+            ; number of max consecutive default action execution, before 
+            ; calling the 'timeout' actions, when the user insert no pattern 
+            ; or inserted patterns doesn't match.
         forward_key = #
-            ; set the key to forward the playing message
+            ; set the key to forward the playing of a message
         reverse_key = *
-            ; set the key to reverse the playing message
+            ; set the key to reverse the playing of a message
         pause_key   = 0
-            ; set the key to pause the playing message
+            ; set the key to pause the playing of a message
         stop_key    = 2
-            ; set the key to stop the playing message
+            ; set the key to stop the playing of a message
         restart_key = 1
-            ; set the key to restart the playing message
+            ; set the key to restart the playing of a message
 
 === Menu Sections ===
 In general each menu section contains a number of '<pattern> = <actions>'
@@ -56,12 +62,16 @@
 
 The general menu section structure is the following:
     [menu_name]
-	    ; 'init' and 'default' are the only two special pattern names
+	    ; 'init', 'default' and 'timeout' are the only special pattern names
 	    init     = actions
-            ; init actions are executed when enter in this menu
+            ; init actions are executed when enter in the menu
 	    default  = actions
             ; default actions are executed when the user input doesn't 
-            ; matches with any patterns
+            ; matches with any patterns or the user insert no pattern
+        timeout  = actions
+            ; timeout actions are executed when the inserted pattern doesn't 
+            ; match or user insert no pattern for max_retries times. 
+            ; It's optional: if omitted is implicitly called the exit() func.
 
 	    ; other patterns are used to match keypresses.
 	    ; the match is done using the same mechanism used in the
@@ -80,66 +90,151 @@
 and so on.
 
 An action list can be preceded by a conditional statement.
-	<pattern> = [IF(conditions),] action1[, action2, ...]
-If the conditions are not verified, the system behaves as if
-the pattern did not match.
+	<pattern> = [condition ?] action1[, action2, ...]
+If conditions are not verified, the system behaves as if the pattern 
+did not match.
+The condition are not verified if 0 or an empty string (NULL), 
+else it are verified. 
+If you have more then one condition, make sure that every single condition 
+are not null, otherwise an error occurs when it is evaluated. 
+However, if it happens, the application continues it's execution because the 
+condition is considered not verified.
 
 Actions
 There are 2 action types: jump actions and function actions. The jump actions 
-is used to navigate throught menus, the function actions are the real actions 
+are used to navigate throught menus, the function actions are the real actions 
 will be made by voicemail application.
 
 Jump Actions
-	call(menu_name)
+	call(<menu_name>)
         ; make a jump from a menu to another keeping trace of the caller menu. 
         ; The arg is the menu name to call. This function keep the history of 
         ; visited menus so you can return to a previous menu.
 
-	return(n)
+	return([<n>])
         ; return to a previous visited menu. The arg is the number of menus you 
         ; want come back, is optional and if omitted is implicitly 1.
 
-	jump(menu_name)
+	jump(<menu_name>)
         ; likewise call, make a jump from a menu to another but don't keep any 
         ; trace of previous menu.
 
 Function Actions
-	play_msg(current|previous|next)
-        ; start the playing of a voice message. The arg is the message we want 
-        ; to playing and is optional (if omitted will play the current message).
-
-	change_to(folder_name)
-        ; with this function user can change the actual selected folder. The 
-        ; arg is the folder name in which go
-
-	play(file)
-        ; this function playing an audio file and is used to play the menus 
-        ; instructions. The arg is the file name.
-
-	delete()
-	undelete()
-        ; The first function mark for deletion the selected message, the second 
-        ; function instead unmark previous marked messages. The real deletion 
-        ; of marked messages occurs when voicemail are correctly terminated.
-
-	dialout()
-        ; permit users to make an external call using as phone number the typed 
-        ; pattern. Before calling, Asterisk will terminate the voicemail 
-        ; application.
-
-	callback()
-        ; make a call to the selected message sender phone number. The 
-        ; voicemail application remain active and after calling user can return 
-        ; to interact with the voicemail.
-
-	envelope()
+	play(<file_name>)
+        ; play an audio file and is used to play the menus instructions. 
+        ; The arg is the file name.
+
+   	play_msg(...)
+        ; play a vocal message. Following the args use explaination
+	play_msg([<number>])
+        ; set the message as selected and then play it
+        ; <number> is the message number (relative number) we want to play
+        ; (i.e. 0 is current, -1 is previous, 1 is next, ...) and is optional 
+        ; (default value is 0).
+	play_msg(<number>, current|<folder_name>)
+        ; set the folder as actual and the message as selected, then play it
+        ; <number> is the message number (absolute number) we want to play 
+        ; (0 is the first message in the folder, 1 the second, ...) and the 
+        ; second arg is the folder name or 'current' to use the actual 
+        ; selected folder.
+    play_msg(unv|busy|name|temp)
+        ; play a greeting voice message.
+        ; The arg can be 'unv', 'busy', 'name' or 'temp' for play respectively 
+        ; the unavailable, busy, name or temporary greeting message
+    play_msg(rec)
+        ; play the last recorded (not stored) message
+
+   	play_envelope(...)
         ; playing the additional message informations (date and time of 
-        ; receipt, sender information).
-
-	leave_mess()
-        ; user can record a message in own mailbox.
-
-	save_msg(folder)
+        ; receipt, sender information). Following the args use explaination
+	play_envelope([<number>])
+        ; set the message as selected and the play the envelope
+        ; <number> is the message number (relative number) we want to play 
+        ; envelope (i.e. 0 is current, -1 is previous, 1 is next, ...) and is 
+        ; optional (default value is 0).
+	play_envelope(<number>, current|<folder_name>)
+        ; set the folder as actual and the message as selected, then play the 
+        ; envelope
+        ; <number> is the message number (absolute number) we want to play 
+        ; envelope (0 is the first message in the folder, 1 the second, ...) 
+        ; and the second arg is the folder name or 'current' to use the actual 
+        ; selected folder.
+
+	delete_msg(...)
+	undelete_msg(...)
+        ; The first function marks for deletion a message, the second instead 
+        ; unmarks a previous marked message. The real deletion of marked 
+        ; messages occurs when voicemail are correctly terminated.
+        ; Following the args use explaination
+	delete_msg([<number>])
+    undelete_msg([<number>])
+        ; set the message as selected and then mark (unmark) it for deletion
+        ; <number> is the message number (relative number) to delete (undelete)
+        ; (i.e. 0 is current, -1 is previous, 1 is next, ...) and is optional 
+        ; (default value is 0).
+	delete_msg(<number>, current|<folder_name>)
+	undelete_msg(<number>, current|<folder_name>)
+        ; set the folder as actual and the message as selected, then 
+        ; mark (unmark) it for deletion
+        ; <number> is the message number (absolute number) to delete (undelete)
+        ; (0 is the first message in the folder, 1 the second, ...) and the 
+        ; second arg is the folder name or 'current' to use the actual 
+        ; selected folder.
+    delete_msg(unv|busy|name|temp)
+        ; delete a greeting voice message.
+        ; The arg can be 'unv', 'busy', 'name' or 'temp' for delete respectively 
+        ; the unavailable, busy, name or temporary greeting message
+    delete_msg(rec)
+        ; delete the last recorded (not stored) message
+
+    record_msg()
+        ; record a message but not store it. To store the last recorded (not 
+        ; stored) message call the save_rec() function.
+
+    save_rec(...)
+        ; is used to store the last recorded (not stored) message.
+        ; Following the args use explaination
+    save_rec([<folder_name>])
+        ; store the last recorded message in the specified folder
+    save_rec(unv|busy|name|temp)
+        ; store the last recorded message as the specified greeting message
+
+	dialout(<number>)
+        ; permit users to make an external call using <number> as extension. 
+        ; Before calling, Asterisk will terminate the voicemail application.
+
+	forward_msg(...)
+        ; forward a message to another mailbox
+        ; Following the args use explaination
+	forward_msg(<number>)
+        ; forward the selected message to the specified mailbox
+        ; <number> is the recipient mailbox number
+	forward_msg(<number>, rec)
+        ; forward the last recorded message to the specified mailbox
+        ; <number> is the recipient mailbox number
+
+	change_to(<folder_name>)
+        ; with this function user can change the actual selected folder. 
+        ; <folder_name> is the name of the folder to select
+
+	save_into(<folder_name>)
         ; store the selected message in a different folder. The arg is the 
         ; folder name into store the message.
 
+    msg_exists(...)
+        ; test if a message exists
+        ; Following the args use explaination
+    msg_exists([<number>])
+        ; test if the specified message number (relative number) exists in
+        ; the actual selected folder
+    msg_exists(<number>, current|<folder_name>)
+        ; test if the specified message number (absolute number) exists in 
+        ; the specified folder
+    msg_exists(unv|busy|name|temp)
+        ; test if the specified greeting message exists
+    msg_exists(rec)
+        ; test if a message has been recorded but not stored
+
+    mb_exists(<number>)
+        ; test if the specified mailbox exists
+

Modified: team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_0.conf
URL: http://svn.asterisk.org/svn-view/asterisk/team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_0.conf?view=diff&rev=206634&r1=206633&r2=206634
==============================================================================
--- team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_0.conf (original)
+++ team/brushtyler/voicemail_menu_branch/apps/myvm/voicemail_menu-actual_0.conf Wed Jul 15 10:39:37 2009
@@ -1,67 +1,115 @@
-; Voice Mail Menu' configuration file
-;
-; In this configuration the menu is considered as organized
-; in more parts named "menu_name" the behaviour of the menu
-; is set by tha association 'digit = actions', where 'digits'
-; is a pattern present in the dialplan by the user, and
-; 'actions' is a list of "function(arguments)" separated by
+; Voice Mail Menu configuration file
+;
+; $Id$
+;
+; This configuration file replicates the exact behaviour of
+; the original app_voicemail.c with the following exceptions:
+; 
+; 1. if you press '4', '5', '6', '7', '8' or '9' when you are in 
+;    the first menu (start_menu), the default action are executed 
+;    because no actions are specified in the instructions for this 
+;    keys. The voicemail_menu-actual_1.conf replies this behaviour
+;    instead.
+; 2. ... /* TODO */
+;
+; The voicemail is organized as a set of submenus, where the user
+; can navigate through explicit input or via timeouts.
+; Each section represents a submenu, and the response to keys
+; is described by 'pattern = action-list' entries, where the
+; pattern is matched using the dialplan rules, and action-list
+; is a list of "function(arguments)" separated by
 ; 'comma. Comments are precedeed by ';'.
 ;
+; Functions are first searched among those implentented by the voicemail,
+; and if not found we use the dialplan functions.
+;
+; When entering a menu, the action corresponding to the
+; 'init' pattern is executed, if present;
+; then voicemail waits for input and tries to match the pattern,
+; executing the corresponding action if present.
+; After a matching action, the 'default' entry is executed, if present.
+; after 'max_retries' consecutive timeouts, we execute
+; execute the 'timeout' action, if not present, we exit from the voicemail.
+; 
+;
 ;------------------- global settings -----------------------;
 
 [general]
-    start = start_menu  ; starting menu name
-    end   = exit_menu   ; ending menu name
-
-    max_retries  = 3    ; max number of consecutive default 
-                        ; action's execution before exit
-
-    forward_key             = #       ; playing command
+    ; global parameters.
+    start = start_menu  ; The name of the initial menu. mandatory.
+    end   = exit_menu   ; The name of the menu invoked on exit. Optional.
+
+    max_retries  = 3    ; max number of consecutive default before declaring
+                        ; a timeout in a menu. defaults to 3
+
+    ; the following are options for the play_msg() command
+    ; XXX maybe rename them.
+    forward_key             = #
     reverse_key             = *
     pause_key               = 0
-    stop_key                = 13456789 ; it's correct???
+    stop_key                = 13456789 ; any other key
     restart_key             = 2
 
 ;--------------------- menu section ------------------------;
 ;
+; The voicemail code sets some channel variables to store relevant info.
+; In particular:
+;
+; VM_MB_NUMBER          called mailbox
+; VM_MB_CONTEXT         called context
+;
+; VM_MSG_IS_SELECTED	1 if a messege is selected, 0 otherwise
+; VM_MSG_IS_FIRST       NULL if no message is selected, 1 if the selected 
+;                       message is not the first, 0 otherwise
+; VM_MSG_IS_LAST        NULL if no message is selected, 1 if the selected 
+;                       message is not the last, 0 otherwise
+; VM_MSG_IS_DELETED     NULL if no message is selected, 1 if the selected 
+;                       message is set for deletion, 0 otherwise
+; VM_MSG_SENDER         the sender number if it's available, NULL otherwise
+;
+; VMU_CALLBACK          1 if callback is permitted, 0 otherwise
+; VMU_DIALOUT           1 if dialout is permitted, 0 otherwise
+; VMU_LEAVE_MSG         1 if you can leave a message into another mailbox, 
+;                       0 otherwise
+;
+;
 ; Main Menu
-; In the init action is used the VMCOUNT dialplan function
-; to get the number of messages stored in a mailbox folder;
-; if there are new messages, new messages folder is selected 
-; as actual folder, otherwise old messages one are selected. 
+;
+; app_voicemail starts with the INBOX or Old folder depending on the
+; presence of new messages. To replicate the behaviour, we call the
+; VMCOUNT() dialplan function to select the folder name.
 ; This permit to set a quick key to access these messages.
-;
-; Some channel vars are setted in the voicemail app code.
-; VM_USER:  called mailbox's number
-; VM_CONTEXT:  called context
-; MSG_SELECTED:  1 if a messege are selected, NULL otherwise
-; NOT_FIRST_MSG:  1 if the selected message is not the first, NULL otherwise
-; NOT_LAST_MSG:  1 if the selected message is not the last, NULL otherwise
-; VMU_NOT_DELETED:  1 if the selected message is not deleted, NULL otherwise
-; VMU_DELETED:  1 if the selected message is deleted, NULL otherwise
-; VMU_CALLBACK:  1 if callback is permitted, NULL otherwise
-; VMU_DIALOUT:  1 if dialout is permitted, NULL otherwise
-; VMU_LEAVEMESS:  1 if you can leave a message to another voicemail, NULL otherwise
 ;
 ; Note that some of the actions associated to digits are conditional,
 ; so that they are enabled or disabled depending on the status
 ; of the voice mailbox
 
 [start_menu]
-    init  = SET(VM_FOLDER=${IF(${VMCOUNT(${VM_USER}@${VM_CONTEXT},INBOX)}?INBOX:Old)}),
+    init  = SET(VM_MB=${VM_MB_NUMBER}@${VM_MB_CONTEXT}),
+          ; VM_MB conteins number at context
+    init += SET(VM_NEW_MSGS=${VMCOUNT(${VM_MB},INBOX)}), 
+          ; VM_NEW_MSG conteins the number of new messages
+    init += SET(VM_OLD_MSGS=${VMCOUNT(${VM_MB},Old)}), 
+          ; VM_OLD_MSG conteins the number of old messages
+    init += SET(VM_FOLDER=${IF(${VM_NEW_MSGS}?INBOX:Old)}), 
+          ; if there are new messages, VM_FOLDER conteins new folder name
+          ; else conteins the old folder name
     init += change_to(${VM_FOLDER}), 
-    init += SET(VM_MSGS_NUM=${VMCOUNT(${VM_USER}@${VM_CONTEXT},${VM_FOLDER})}), 
+          ; set the previous selected folder as current
+    init += SET(VM_MSGS=${VMCOUNT(${VM_MB},${VM_FOLDER})}), 
+          ; VM_MSGS conteins the number of messages in the current folder
     init += call(start_menu_intro)
+          ; play intro and instructions
 
     default = call(start_menu_instruction)
             ; play instructions
 
-    1  = IF(${MSG_SELECTED}), call(play_mess_menu)
-       ; if there are new messages, go to the new messages folder, 
-       ; else open the old messages folder and go to Play Messages Menu
+    1  = ${VM_MSG_IS_SELECTED} ? call(play_mess_menu)
+       ; if a message is selected, go to Play Message Menu
     2  = call(change_to_folder_menu),
+       ; go to Change Folder Menu
     2 += play(vm-${VM_FOLDER}), play(vm-messages)
-       ; go to Change Folder Menu
+       ; and when return play the selected folder name
     3  = call(adv_menu)
        ; go to Advanced Menu Options
     0  = call(opts_menu)
@@ -70,53 +118,74 @@
     _# = exit()
        ; exit
 
-[start_menu_intro]
+
+[start_menu_intro]  ; play the start_menu intro
+    init  = ${VM_NEW_MSGS} & ${VM_OLD_MSGS} ? jump(start_menu_intro_newold)
+          ; if there are both new and old messages, play the right intro
     init  = play(vm-youhave), 
-    init += ${IF(${VM_MSGS_NUM}?play(digits/${VM_MSGS_NUM}):play(vm-no))}, 
-    init += ${IF(${VM_MSGS_NUM}?play(vm-${VM_FOLDER}))}, 
-    init += ${IF($[${VM_MSGS_NUM}=1]?play(vm-message):play(vm-messages))}, 
+    init += ${IF(${VM_MSGS}?play_num(${VM_MSGS}):play(vm-no))}, 
+    init += ${IF(${VM_MSGS}?play(vm-${VM_FOLDER}))}, 
+    init += ${IF($[${VM_MSGS}=1]?play(vm-message):play(vm-messages))}, 
     init += jump(start_menu_instruction)
 
-[start_menu_instruction]
-    init  = ${IF(${VM_MSGS_NUM}?play(vm-onefor))}, 
-    init += ${IF(${VM_MSGS_NUM}?play(vm-${VM_FOLDER}))}, 
-    init += ${IF(${VM_MSGS_NUM}?play(vm-messages))}, 
+
+[start_menu_intro_newold]   ; play the start_menu intro when there are 
+                            ; new either old messages
+    init  = play(vm-youhave), 
+    init += play_num(${VM_NEW_MSGS}), 
+    init += play(vm-INBOX), 
+    init += play(vm-and), 
+    init += play_num(${VM_OLD_MSGS}), 
+    init += play(vm-Old), 
+    init += ${IF($[${VM_OLD_MSGS}=1]?play(vm-message):play(vm-messages))}, 
+    init += jump(start_menu_instruction)
+
+
+[start_menu_instruction]    ; play the start_menu instructions
+    init  = ${IF(${VM_MSG_IS_SELECTED}?play(vm-onefor))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-${VM_FOLDER}))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-messages))}, 
     init += play(vm-opts), 
     init += play(vm-helpexit), 
     init += return(1)
 
-
 ;-----------------------------------------------------------;
 ;
 ; Full Main Menu
 
 [start_menu_full]
-    init = call(start_menu_full_instruction)
+    init    = call(start_menu_full_instruction)
     default = call(start_menu_full_instruction)
             ; play instructions
 
-    1  = IF(${MSG_SELECTED}), jump(play_mess_menu)
-       ; if there are new messages, go to the new messages folder, 
-       ; else open the old messages folder and go to Play Messages Menu
+    1  = ${VM_MSG_IS_SELECTED} ? jump(play_mess_menu)
+       ; go to the Play Message Menu
     2  = jump(change_to_folder_menu),
+       ; go to Change Folder Menu
     2 += play(vm-${VM_FOLDER}), play(vm-messages)
-       ; go to Change Folder Menu
+       ; and when return play the selected message folder name
     3  = jump(adv_menu)
        ; go to Advanced Menu Options
-    4  = IF(${NOT_FIRST_MSG}), set_msg(-1), jump(play_mess_menu)
-    4  = play(vm-nomore)
-       ; play previous message
+    4  = ${VM_MSG_IS_FIRST} ? play(vm-nomore)
+       ; if the selected message are the first, 
+       ; there is no previous message
+    4  = set_msg(-1), jump(play_mess_menu)
+       ; select the previous message and play it
     5  = jump(play_mess_menu)
-       ; play current message
-    6  = IF(${NOT_LAST_MSG}), set_msg(+1), jump(play_mess_menu)
-    6  = play(vm-nomore)
-       ; play next message
-    7  = IF(${VMU_NOT_DELETED}), delete(), play(vm-deleted)
-       ; mark selected message for deletion
-    7  = IF(${VMU_DELETED}), undelete(), play(vm-undeleted)
-       ; unmark a previous marked message for deletion
-    8  = forward_message()
-       ; forward a message
+       ; play the current message
+    6  = ${VM_MSG_IS_LAST} ? play(vm-nomore)
+       ; if the selected message are the last, 
+       ; there is no next message
+    6  = set_msg(+1), jump(play_mess_menu)
+       ; select the next message and play it
+    7  = ${VM_MSG_IS_DELETED}=0 ? delete_msg(), play(vm-deleted)
+       ; if the selected message is not already marked for deletion, 
+       ; mark it
+    7  = ${VM_MSG_IS_DELETED} ? undelete_msg(), play(vm-undeleted)
+       ; if the selected message is marked for deletion, 
+       ; unmark it
+    8  = jump(forward_menu)
+       ; go to Forward Menu
     9  = jump(save_to_folder_menu)
        ; go to Save To Folder Menu
     0  = jump(opts_menu)
@@ -126,16 +195,20 @@
        ; exit
 
 
-[start_menu_full_instruction]
-    init  = ${IF(${VM_MSGS_NUM}?play(vm-onefor-full))}, 
-    init += ${IF(${VM_MSGS_NUM}?play(vm-${VM_FOLDER}))}, 
-    init += ${IF(${VM_MSGS_NUM}?play(vm-messages))}, 
+[start_menu_full_instruction]   ; play the start_menu_full instructions
+    init  = ${IF(${VM_MSG_IS_SELECTED}?play(vm-onefor))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-${VM_FOLDER}))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-messages))}, 
+    init += play(vm-opts), 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-onefor-full))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-${VM_FOLDER}))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-messages))}, 
     init += play(vm-opts-full), 
-    init += ${IF(${ISNULL(${NOT_FIRST_MSG})}?:play(vm-prev))}, 
+    init += ${IF(${VM_MSG_IS_FIRST}?:play(vm-prev))}, 
     init += play(vm-repeat), 
-    init += ${IF(${ISNULL(${NOT_LAST_MSG})}?:play(vm-next))}, 
-    init += ${IF(${ISNULL(${VMU_NOT_DELETED})}?:play(vm-delete))}, 
-    init += ${IF(${ISNULL(${VMU_DELETED})}?:play(vm-undelete))}, 
+    init += ${IF(${VM_MSG_IS_LAST}?:play(vm-next))}, 
+    init += ${IF($[${VM_MSG_IS_DELETED}=0]?play(vm-delete))}, 
+    init += ${IF(${VM_MSG_IS_DELETED}?play(vm-undelete))}, 
     init += play(vm-toforward), 
     init += play(vm-savemessage), 
     init += play(vm-helpexit), 
@@ -147,44 +220,54 @@
 ; Play Messages Menu
 
 [play_mess_menu]
-    init = call(play_mess_menu_intro)
+    init    = call(play_mess_menu_intro)
+            ; play intro and instructions
     default = call(play_mess_menu_instruction)
-
-    3  = call(adv_menu)
+            ; play instructions
+
+    3  = jump(adv_menu)
        ; go to Advanced Menu Options
-    4  = IF(${NOT_FIRST_MSG}), set_msg(-1), jump(play_mess_menu)
-       ; play previous message
-    4  = play(vm-nomore)
+    4  = ${VM_MSG_IS_FIRST} ? play(vm-nomore)
+       ; if the selected message are the first, 
+       ; there is no previous message
+    4  = set_msg(-1), jump(play_mess_menu)
+       ; select the previous message and play it
     5  = jump(play_mess_menu)
-       ; play current message
-    6  = IF(${NOT_LAST_MSG}), set_msg(1), jump(play_mess_menu)
-       ; play next message
-    6  = play(vm-nomore)
-    7  = IF(${VMU_NOT_DELETED}), delete(), play(vm-deleted)
-       ; mark selected message for deletion
-    7  = IF(${VMU_DELETED}), undelete(), play(vm-undeleted)
-       ; unmark a previous marked message for deletion
-    8  = forward_message()
-       ; forward a message
-    9  = call(save_to_folder_menu)
+       ; play the current message
+    6  = ${VM_MSG_IS_LAST} ? play(vm-nomore)
+       ; if the selected message are the last, 
+       ; there is no next message
+    6  = set_msg(+1), jump(play_mess_menu)
+       ; select the next message and play it
+    7  = ${VM_MSG_IS_DELETED}=0 ? delete_msg(), play(vm-deleted)
+       ; if the selected message is not already marked for deletion, 
+       ; mark it
+    7  = ${VM_MSG_IS_DELETED} ? undelete_msg(), play(vm-undeleted)
+       ; if the selected message is marked for deletion, 
+       ; unmark it
+    8  = jump(forward_menu)
+       ; go to Forward Menu
+    9  = jump(save_to_folder_menu)
        ; go to Save To Folder Menu
     *  = jump(start_menu_full)
        ; help
     _# = exit()
        ; exit
 
-[play_mess_menu_intro]
-    init  = envelope(), 
+[play_mess_menu_intro]  ; play the play_mess_menu intro
+    init  = play_envelope(), 
+          ; play additional message informations
     init += play_msg(),
+          ; play the message
     init += jump(play_mess_menu_instruction)
 
-[play_mess_menu_instruction]
+[play_mess_menu_instruction]    ; play the play_mess_menu instructions
     init  = play(vm-advopts), 
-    init += ${IF(${ISNULL(${NOT_FIRST_MSG})}?:play(vm-prev))}, 
+    init += ${IF(${VM_MSG_IS_FIRST}?:play(vm-prev))}, 
     init += play(vm-repeat), 
-    init += ${IF(${ISNULL(${NOT_LAST_MSG})}?:play(vm-next))}, 
-    init += ${IF(${ISNULL(${VMU_NOT_DELETED})}?:play(vm-delete))}, 
-    init += ${IF(${ISNULL(${VMU_DELETED})}?:play(vm-undelete))}, 
+    init += ${IF(${VM_MSG_IS_LAST}?:play(vm-next))}, 
+    init += ${IF($[${VM_MSG_IS_DELETED}=0]?play(vm-delete))}, 
+    init += ${IF(${VM_MSG_IS_DELETED}?play(vm-undelete))}, 
     init += play(vm-toforward), 
     init += play(vm-savemessage), 
     init += play(vm-helpexit), 
@@ -194,61 +277,177 @@
 ;-----------------------------------------------------------;
 ;
 ; Advanced Menu Options
+;
 ; Contains the message advanced operations o user operation 
 ; related to a message 
 
 [adv_menu]
     init    = call(adv_menu_instruction)
     default = call(adv_menu_instruction)
-
-    1  = IF(${MSG_SELECTED}), reply()
-       ; reply to sender
-    2  = IF(${VMU_CALLBACK}), callback()
-       ; call the sender
-    3  = IF(${MSG_SELECTED}), envelope()
-       ; play additional message information
-    4  = IF(${VMU_DIALOUT}), call(dialout_menu)
-       ; make an external call
-    5  = IF(${VMU_LEAVEMESS}), leave_mess()
-       ; leave a message
-    *  = return(1)
-       ; return to Main Menu
-
-
-[adv_menu_instruction]
-    init  = ${IF(${ISNULL(${MSG_SELECTED})}?:play(vm-toreply))}, 
-    init += ${IF(${ISNULL(${VMU_CALLBACK})}?:play(vm-tocallback))}, 
-    init += ${IF(${ISNULL(${MSG_SELECTED})}?:play(vm-tohearenv))}, 
-    init += ${IF(${ISNULL(${VMU_DIALOUT})}?:play(vm-tomakecall))}, 
-    init += ${IF(${ISNULL(${VMU_LEAVEMESS})}?:play(vm-leavemsg))}, 
+            ; play instructions
+
+    1  = ${VM_MSG_IS_SELECTED} ? jump(reply_menu)
+       ; go to Reply Menu to do a reply to the sender
+    2  = ${VMU_CALLBACK} ? jump(callback_menu)
+       ; if callback is permitted, go to Callback Menu
+    3  = ${VM_MSG_IS_SELECTED} ? play_envelope()
+       ; play additional message informations
+    4  = ${VMU_DIALOUT} ? jump(dialout_menu)
+       ; if permitted, make an external call
+    5  = ${VMU_LEAVE_MSG} ? jump(leave_mess_menu)
+       ; if you can leave a message, go to Leave Message Menu
+
+    *  = return(1)  ; return to Main Menu
+
+
+[adv_menu_instruction]  ; play the adv_menu instructions
+    init  = ${IF(${VM_MSG_IS_SELECTED}?play(vm-toreply))}, 
+    init += ${IF(${VMU_CALLBACK}?play(vm-tocallback))}, 
+    init += ${IF(${VM_MSG_IS_SELECTED}?play(vm-tohearenv))}, 
+    init += ${IF(${VMU_DIALOUT}?play(vm-tomakecall))}, 
+    init += ${IF(${VMU_LEAVE_MSG}?play(vm-leavemsg))}, 
     init += play(vm-starmain), 
     init += return(1)
 
 ;-----------------------------------------------------------;
 ;
+; Forward Menu
+
+[forward_menu]
+    init  = call(ask_for_extension_menu), 
+          ; ask to dial an extension
+    init += ${IF(${ISNULL(${VM_NUMBER})}?return(1))},  
+          ; no number dialed, return 
+    init += call(validate_forward_ext_menu), 
+          ; try to validate the extension
+    init += forward_msg(${VM_NUMBER}), return(1)
+          ; forward the current message and return
+
+[validate_forward_ext_menu]
+    init  = ${VM_NUMBER}=${VM_MB_NUMBER} ? play(pbx-invalid),
+          ; the recipient is also the sender, 
+    init += return(2)   ; return to Main Menu
+
+    init  = ${mb_exists(${VM_NUMBER})}=0 ? play(pbx-invalid),
+          ; the recipient mailbox doesn't exists, 
+    init += return(2)   ; return to Main Menu 
+
+    init  = return(1)   ; the recipient mailbox exists
+
+
+;-----------------------------------------------------------;
+;
+; Ask For Extension Menu
+
+[ask_for_extension_menu]
+    init    = SET(VM_NUMBER=), play(vm-extension)
+            ; reset the VM_NUMBER and ask to dial an extension
+    default = play(vm-extension)
+            ; ask to dial an extension
+    timeout = return(1)
+            ; on timeout return
+
+    _X.  = SET(VM_NUMBER=${VM_MATCHED}), return(1)
+         ; save the matched pattern and return
+    _#   = ; do nothing
+
+;-----------------------------------------------------------;
+;
+; Reply Menu
+
+[reply_menu]
+    init  = ${mb_exists(${VM_MSG_SENDER})} ? SET(VM_RECIPIENT=${VM_MSG_SENDER}),
+          ; if the sender has a mailbox, save his number
+    init += jump(leave_mess_menu)
+          ; and go to Leave Message Menu to do a reply to the sender
+
+    init  = ${VM_MSG_SENDER} ? play(vm-nobox), return(1)
+          ; sender has no mailbox but have a number, return
+
+    init  = play(vm-nonumber), return(1)
+          ; sender number not available, return
+
+;-----------------------------------------------------------;
+;
+; Leave Message Menu
+
+[leave_mess_menu]
+    init  = ${mb_exists(${VM_RECIPIENT})} ? 
+          ; if recipient has a mailbox, 
+    init += play(vm-intro), play(beep), record_msg(), 
+          ; record a message,
+    init += forward_msg(${VM_RECIPIENT}, rec), 
+          ; forward the recoded message to the mailbox
+    init += delete_msg(rec),
+          ; delete the last recorded message becouse is already forwarded
+    init += return(1)   ; and return
+
+    init  = ${VM_RECIPIENT} ? play(pbx-invalid), return(1)
+          ; if recipient has no mailbox, return
+
+    init  = call(ask_for_extension_menu), SET(VM_RECIPIENT=${VM_NUMBER}),
+          ; if no recipient, ask to user for the extension
+    init += jump(leave_mess_menu)
+          ; and then try again
+
+;-----------------------------------------------------------;
+;
+; Callback Menu
+
+[callback_menu]
+    init    = call(callback_menu_instruction)
+    default = call(callback_menu_instruction)
+            ; play instructions
+
+    1  = ${VM_MSG_SENDER} ? dialout(${VM_MSG_SENDER}), 
+       ; if sender is known, call it
+    1 += return(1)  ; and return
+
+    2  = jump(dialout_menu)
+       ; go to Dialout Menu
+
+    *  = return(1)  ; return to Main Menu
+
+
+[callback_menu_instruction] ; play the callback_menu instructions
+    init  = ${VM_MSG_SENDER} ? play(vm-num-i-have), 
+    init += play_callerid(${VM_MSG_SENDER}),
+    init += play(vm-tocallnum), 
+    init += ${IF(${VMU_DIALOUT}?play(vm-calldiffnum))}, 
+    init += play(vm-star-cancel)
+
+    init  = play(vm-nonumber),
+    init += ${IF(${VMU_DIALOUT}?play(vm-toenternumber))},
+    init += play(vm-star-cancel)
+
+;-----------------------------------------------------------;
+;
 ; Dialout Menu
+;
 ; In this menu, the user input pattern is used as phone 
 ; number to call. 
 
 [dialout_menu]
     init    = call(dialout_menu_instruction)
     default = call(dialout_menu_instruction)
-
-    _X. = dialout()
-        ; make a call
-    *   = return(1)
-        ; return to Main Menu
-    _#  = exit()
-        ; exit
-
-
-[dialout_menu_instruction]
+            ; play instructions
+    timeout = return(1)
+            ; on timeout return
+
+    _X. = dialout(${VM_MATCHED})
+        ; make a call to the matched pattern
+    *   = return(1) ; return to Main Menu
+    _#  = exit()    ; exit
+
+
+[dialout_menu_instruction]  ; play the dialout_menu instructions
     init  = play(vm-dialout), 
     init += return(1)
 
 ;-----------------------------------------------------------;
 ;
 ; Save To Folder Menu
+;
 ; By this menu user can store a message in another folder:
 ; the played audio file explain to users the folder related
 ; to each pattern. After changing or typing '*', user can 
@@ -257,16 +456,18 @@
 [save_to_folder_menu]
     init    = call(save_menu_instruction)
     default = call(save_menu_instruction)
-
-    0       = save_msg(INBOX), return(1)
-    1       = save_msg(Old), return(1)
-    2       = save_msg(Work), return(1)
-    3       = save_msg(Family), return(1)
-    4       = save_msg(Friends), return(1)
-    _#      = exit()   ; exit
-
-
-[save_menu_instruction]
+            ; play instructions
+
+    0  = save_into(INBOX), return(1) 
+    1  = save_into(Old), return(1)
+    2  = save_into(Work), return(1)
+    3  = save_into(Family), return(1)
+    4  = save_into(Friends), return(1)
+       ; save the selected message into a folder and return
+    _# = exit()   ; exit
+
+
+[save_menu_instruction] ; play the save_menu instruction
     init  = play(vm-savefolder), 
     init += play(vm-press), 
     init += play(digits/0), 
@@ -299,6 +500,7 @@
 ;-----------------------------------------------------------;
 ;
 ; Change Folder Menu
+;
 ; By this menu user can change his actual working folder: 
 ; the played audio file explain to users the folder related
 ; to each pattern. After changing or typing '*', user can 
@@ -307,20 +509,29 @@
 [change_to_folder_menu]
     init    = call(change_menu_instruction)
     default = call(change_menu_instruction)
+            ; play instructions
 
     0  = SET(VM_FOLDER=INBOX), jump(change_menu_exec)
     1  = SET(VM_FOLDER=Old), jump(change_menu_exec)
     2  = SET(VM_FOLDER=Work), jump(change_menu_exec)
     3  = SET(VM_FOLDER=Family), jump(change_menu_exec)
     4  = SET(VM_FOLDER=Friends), jump(change_menu_exec)
-    _# = return(1) ;return to Main Menu
+       ; select a folder and save it's name in VM_FOLDER, then 
+       ; go to Change Menu Exec to change the current folder
+    _# = return(1)  ; return to Main Menu
 
 
 [change_menu_exec]
-    init  = change_to(${VM_FOLDER}), return(1)
-
-
-[change_menu_instruction]
+    init  = change_to(${VM_FOLDER}),
+          ; set the VM_FOLDER as the current folder
+    init += SET(VM_MSGS=${VMCOUNT(${VM_MB},${VM_FOLDER})}), 
+          ; refresh the value of VM_MSGS, it conteins the number of
+          ; messages in the current folder 
+    init += return(1)
+          ; and return
+
+
+[change_menu_instruction]   ; play the change_menu instructions
     init  = play(vm-changeto), 
     init += play(vm-press), 
     init += play(digits/0), 
@@ -353,36 +564,92 @@
 ;-----------------------------------------------------------;
 ;
 ; Voicemail Menu Options
+;
 ; In this menu there are the voicemail manage operations as
 ; recording a welcome message or changing the password.
 
 [opts_menu]
     init    = call(opts_menu_instruction)
     default = call(opts_menu_instruction)
-
-    1  = record(unavailable)
-       ; record a unavailable message
-    2  = record(busy)
-       ; record a busy message
-    3  = record(name)
-       ; record a welcome message
-    4  = changepassword()
+            ; play instructions
+
+    1  = SET(VM_REC_GREET=unv), call(record_menu)
+       ; go to Record Menu to record a unavailable message
+    2  = SET(VM_REC_GREET=busy), call(record_menu)
+       ; go to Record Menu to record a busy message
+    3  = SET(VM_REC_GREET=name), call(record_menu)
+       ; go to Record Menu to record a greeting message
+    4  = SET(VM_REC_GREET=temp), call(manage_temp_menu)
+       ; go to Manage Temp Menu to manage the temporary 
+       ; greeting message
+    5  = change_password()
        ; change the user password
-    *  = return(1)
-       ; return to Main Menu
-    _# = exit()	; exit
-
-
-[opts_menu_instruction]
+    *  = return(1)  ; return to Main Menu
+    _# = exit() ; exit
+
+
+[opts_menu_instruction] ; play the opts_menu instructions
     init  = play(vm-options), 
     init += return(1)
 
+
+[manage_temp_menu]
+    init    = ${msg_exists(temp)} ? play(vm-tempgreeting2)
+            ; if the temp message exists, play instructions
+    init    = jump(record_menu)
+            ; if the temp message doesn't exists, go to Record Menu
+
+    default = ${msg_exists(temp)} ? play(vm-tempgreeting2)
+            ; if the temp message exists, play instructions
+    default = play(vm-tempgreeting)
+            ; play instructions
+
+    1  = call(record_greetings_menu)
+       ; go to Record Menu to record a temporary greeting

[... 5044 lines stripped ...]



More information about the svn-commits mailing list