]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 100672 via svnmerge from
authorJason Parker <jparker@digium.com>
Mon, 28 Jan 2008 21:02:11 +0000 (21:02 +0000)
committerJason Parker <jparker@digium.com>
Mon, 28 Jan 2008 21:02:11 +0000 (21:02 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

(closes issue #11795)
........
r100672 | qwell | 2008-01-28 14:42:43 -0600 (Mon, 28 Jan 2008) | 7 lines

When using ODBC_STORAGE, make sure we put greeting files into the database like we do with the others.

Issue #11795
Reported by: dimas
Patches:
      vmgreet.patch uploaded by dimas (license 88)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@100676 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 4faef707dff22e55a5cea4a7a2d56ca61ee8c176..ad1f0a23acf8b1e670edfc6569b723ff0afc1923 100644 (file)
@@ -2244,36 +2244,55 @@ static int get_date(char *s, int len)
        return ast_strftime(s, len, "%a %b %e %r UTC %Y", &tm);
 }
 
-static int invent_message(struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
+static int play_greeting(struct ast_channel *chan, struct ast_vm_user *vmu, char *filename, char *ecodes)
+{
+       int res = -2;
+       
+#ifdef ODBC_STORAGE
+       int success = 
+#endif
+       RETRIEVE(filename, -1, vmu->mailbox, vmu->context);
+       if (ast_fileexists(filename, NULL, NULL) > 0) {
+               res = ast_streamfile(chan, filename, chan->language);
+               if (res > -1) 
+                       res = ast_waitstream(chan, ecodes);
+#ifdef ODBC_STORAGE
+               if (success == -1) {
+                       /* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */
+                       ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n");
+                       store_file(filename, vmu->mailbox, vmu->context, -1);
+               }
+#endif
+       }
+       DISPOSE(filename, -1);
+
+       return res;
+}
+
+static int invent_message(struct ast_channel *chan, struct ast_vm_user *vmu, char *ext, int busy, char *ecodes)
 {
        int res;
        char fn[PATH_MAX];
        char dest[PATH_MAX];
 
-       snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
+       snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, ext);
 
-       if ((res = create_dirpath(dest, sizeof(dest), context, ext, ""))) {
+       if ((res = create_dirpath(dest, sizeof(dest), vmu->context, ext, ""))) {
                ast_log(LOG_WARNING, "Failed to make directory(%s)\n", fn);
                return -1;
        }
 
-       RETRIEVE(fn, -1, ext, context);
-       if (ast_fileexists(fn, NULL, NULL) > 0) {
-               res = ast_stream_and_wait(chan, fn, ecodes);
-               if (res) {
-                       DISPOSE(fn, -1);
-                       return res;
-               }
-       } else {
-               /* Dispose just in case */
-               DISPOSE(fn, -1);
+       res = play_greeting(chan, vmu, fn, ecodes);
+       if (res == -2) {
+               /* File did not exist */
                res = ast_stream_and_wait(chan, "vm-theperson", ecodes);
                if (res)
                        return res;
                res = ast_say_digit_str(chan, ext, ecodes, chan->language);
-               if (res)
-                       return res;
        }
+       if (res)
+               return res;
+
        res = ast_stream_and_wait(chan, busy ? "vm-isonphone" : "vm-isunavail", ecodes);
        return res;
 }
@@ -3100,25 +3119,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
 
        /* Play the beginning intro if desired */
        if (!ast_strlen_zero(prefile)) {
-#ifdef ODBC_STORAGE
-               int success = 
-#endif
-                       RETRIEVE(prefile, -1, ext, context);
-               if (ast_fileexists(prefile, NULL, NULL) > 0) {
-                       if (ast_streamfile(chan, prefile, chan->language) > -1) 
-                               res = ast_waitstream(chan, ecodes);
-#ifdef ODBC_STORAGE
-                       if (success == -1) {
-                               /* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */
-                               ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n");
-                               store_file(prefile, vmu->mailbox, vmu->context, -1);
-                       }
-#endif
-               } else {
+               res = play_greeting(chan, vmu, prefile, ecodes);
+               if (res == -2) {
+                       /* The file did not exist */
                        ast_debug(1, "%s doesn't exist, doing what we can\n", prefile);
-                       res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
+                       res = invent_message(chan, vmu, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
                }
-               DISPOSE(prefile, -1);
                if (res < 0) {
                        ast_debug(1, "Hang up during prefile playback\n");
                        free_user(vmu);