[asterisk-commits] qwell: trunk r100676 - in /trunk: ./ apps/app_voicemail.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 28 15:02:12 CST 2008
Author: qwell
Date: Mon Jan 28 15:02:11 2008
New Revision: 100676
URL: http://svn.digium.com/view/asterisk?view=rev&rev=100676
Log:
Merged revisions 100672 via svnmerge from
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)
........
Modified:
trunk/ (props changed)
trunk/apps/app_voicemail.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=100676&r1=100675&r2=100676
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Mon Jan 28 15:02:11 2008
@@ -2244,36 +2244,55 @@
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);
-
- if ((res = create_dirpath(dest, sizeof(dest), context, ext, ""))) {
+ snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->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 @@
/* 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);
- }
- DISPOSE(prefile, -1);
+ res = invent_message(chan, vmu, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
+ }
if (res < 0) {
ast_debug(1, "Hang up during prefile playback\n");
free_user(vmu);
More information about the asterisk-commits
mailing list