[Freeswitch-svn] [commit] r6004 - in freeswitch/trunk: conf src/mod/applications/mod_voicemail

Freeswitch SVN anthm at freeswitch.org
Fri Oct 19 20:09:41 EDT 2007


Author: anthm
Date: Fri Oct 19 20:09:41 2007
New Revision: 6004

Modified:
   freeswitch/trunk/conf/voicemail.conf.xml
   freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c

Log:
add MODAPP-36

Modified: freeswitch/trunk/conf/voicemail.conf.xml
==============================================================================
--- freeswitch/trunk/conf/voicemail.conf.xml	(original)
+++ freeswitch/trunk/conf/voicemail.conf.xml	Fri Oct 19 20:09:41 2007
@@ -27,6 +27,7 @@
       <param name="restart-key" value="1"/>
       <param name="ff-key" value="6"/>
       <param name="rew-key" value="4"/>
+      <!--<param name="storage-dir" value="/tmp"/>-->
       <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
     </profile>
   </profiles>

Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	Fri Oct 19 20:09:41 2007
@@ -79,6 +79,7 @@
     char urgent_key[2];
     char file_ext[10];
     char *tone_spec;
+    char *storage_dir;
     uint32_t digit_timeout;
     uint32_t max_login_attempts;
     uint32_t max_record_len;
@@ -277,6 +278,7 @@
         char *urgent_key = "*";
         char *tone_spec = "%(1000, 0, 640)";
         char *file_ext = "wav";
+        char *storage_dir = "";
 
         switch_core_db_t *db;
         uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300;
@@ -324,6 +326,8 @@
                 rew_key = val;
             } else if (!strcasecmp(var, "urgent-key") && !switch_strlen_zero(val)) {
                 urgent_key = val;
+            } else if (!strcasecmp(var, "storage-dir") && !switch_strlen_zero(val)) {
+                storage_dir = val;
             } else if (!strcasecmp(var, "file-extension")) {
                 file_ext = val;
             } else if (!strcasecmp(var, "tone-spec")) {
@@ -437,6 +441,8 @@
             *profile->rew_key = *rew_key;
             *profile->urgent_key = *urgent_key;
 
+
+            profile->storage_dir = switch_core_strdup(globals.pool, storage_dir);
             profile->tone_spec = switch_core_strdup(globals.pool, tone_spec);
             switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext));
             switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, globals.pool);
@@ -972,6 +978,7 @@
 {
     vm_check_state_t vm_check_state = VM_CHECK_START;
     switch_channel_t *channel;
+    switch_caller_profile_t *caller_profile;
     vm_profile_t *profile;
     switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param;
     switch_status_t status;
@@ -1287,7 +1294,13 @@
 
                 if (!x_user) {
                     int ok = 1;
-                    char *xtra = switch_mprintf("mailbox=%s", myid);
+                    /* TRX added destination_number and caller_id_number from the session object
+                     * ideally switch_xml_* would do this for any curl request, but that can get tricky
+                     * since curl & the session object arent always present, I will eventually look at it 
+                     * and see what it would take to make it automagically do that
+                     */
+                    caller_profile = switch_channel_get_caller_profile(channel);
+                    char *xtra = switch_mprintf("mailbox=%s&destination_number=%s&caller_id_number=%s", myid,caller_profile->destination_number,caller_profile->caller_id_number);
                     
                     assert(xtra);
 
@@ -1344,14 +1357,21 @@
 
                 if (auth || !thepass || (thepass && mypass && !strcmp(thepass, mypass))) {
                     if (!dir_path) {
-                        dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
-                                                               SWITCH_PATH_SEPARATOR,
-                                                               SWITCH_PATH_SEPARATOR,
-                                                               profile->name,
-                                                               SWITCH_PATH_SEPARATOR,
-                                                               domain_name,
-                                                               SWITCH_PATH_SEPARATOR,
-                                                               myid);
+                        if(switch_strlen_zero(profile->storage_dir)) {
+                            dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
+                                                                   SWITCH_PATH_SEPARATOR,
+                                                                   SWITCH_PATH_SEPARATOR,
+                                                                   profile->name,
+                                                                   SWITCH_PATH_SEPARATOR,
+                                                                   domain_name,
+                                                                   SWITCH_PATH_SEPARATOR,
+                                                                   myid);
+                        } else {
+                            dir_path = switch_core_session_sprintf(session, "%s%s%s",
+                                                                   profile->storage_dir,
+                                                                   SWITCH_PATH_SEPARATOR,
+                                                                   myid);
+                        }
                         
                         
                         if (switch_dir_make_recursive(dir_path, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
@@ -1427,14 +1447,22 @@
     assert(channel != NULL);
     
     caller_profile = switch_channel_get_caller_profile(channel);
-    dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
-                                           SWITCH_PATH_SEPARATOR,
-                                           SWITCH_PATH_SEPARATOR,
-                                           profile->name,
-                                           SWITCH_PATH_SEPARATOR,
-                                           domain_name,
-                                           SWITCH_PATH_SEPARATOR,
-                                           id);
+    if(switch_strlen_zero(profile->storage_dir)) {
+        dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, 
+                                               SWITCH_PATH_SEPARATOR,
+                                               SWITCH_PATH_SEPARATOR,
+                                               profile->name,
+                                               SWITCH_PATH_SEPARATOR,
+                                               domain_name,
+                                               SWITCH_PATH_SEPARATOR,
+                                               id);
+    } else {
+        dir_path = switch_core_session_sprintf(session, "%s%s%s",
+                                               profile->storage_dir,
+                                               SWITCH_PATH_SEPARATOR,
+                                               id);
+    }
+
     if (switch_dir_make_recursive(dir_path, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s", dir_path);
         goto end;
@@ -1610,7 +1638,12 @@
 
     channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
-    
+
+    /* TRX this may not be required, every place that a directory is used above, a switch_dir_make_recursive() is called
+     * making this unneeded - the others are required since it involves making a directory for the user account, which
+     * may not exist until that first call, this however appears to be optional and while its 1 call at load time doesnt
+     * appear to do much
+     */
     if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s", SWITCH_GLOBAL_dirs.storage_dir);
         return;



More information about the Freeswitch-svn mailing list