aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2000-01-02 20:59:00 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2000-01-02 20:59:00 +0000
commit999d3524e27900ec85d461f644d0e2fde138fca4 (patch)
tree53bb1d4c35295fea70d6179bfa71cd1e10d402df /apps/app_voicemail.c
parent2137f5008cf14c94312348e272f9b38df43233e1 (diff)
Version 0.1.2 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@152 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rwxr-xr-xapps/app_voicemail.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index f2893b3f6..8fc6f500f 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -141,7 +141,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
struct ast_config *cfg;
char *copy, *name, *passwd, *email, *dir, *fmt, *fmts, *fn=NULL;
char comment[256];
- struct ast_filestream *writer, *others[MAX_OTHER_FORMATS];
+ struct ast_filestream *writer=NULL, *others[MAX_OTHER_FORMATS];
char *sfmt[MAX_OTHER_FORMATS];
int res = -1, fmtcnt=0, x;
int msgnum;
@@ -182,8 +182,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
snprintf(comment, sizeof(comment), "Voicemail from %s to %s (%s) on %s\n",
(chan->callerid ? chan->callerid : "Unknown"),
name, ext, chan->name);
+ if (ast_fileexists(fn, NULL) > 0) {
+ msgnum++;
+ continue;
+ }
writer = ast_writefile(fn, fmt, comment, O_EXCL, 1 /* check for other formats */, 0700);
- if (!writer && (errno != EEXIST))
+ if (!writer)
break;
msgnum++;
} while(!writer && (msgnum < MAXMSG));
@@ -221,9 +225,14 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
if (f->frametype == AST_FRAME_VOICE) {
/* Write the primary format */
res = ast_writestream(writer, f);
+ if (res) {
+ ast_log(LOG_WARNING, "Error writing primary frame\n");
+ break;
+ }
/* And each of the others */
- for (x=0;x<fmtcnt;x++)
+ for (x=0;x<fmtcnt;x++) {
res |= ast_writestream(others[x], f);
+ }
ast_frfree(f);
/* Exit on any error */
if (res) {
@@ -314,20 +323,30 @@ static int vm_execmain(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "No voicemail configuration\n");
goto out;
}
- if (ast_streamfile(chan, "vm-login"))
+ if (ast_streamfile(chan, "vm-login")) {
+ ast_log(LOG_WARNING, "Couldn't stream login file\n");
goto out;
+ }
do {
/* Prompt for, and read in the username */
- if (ast_readstring(chan, username, sizeof(username), 2000, 5000, "#"))
+ if (ast_readstring(chan, username, sizeof(username), 2000, 5000, "#")) {
+ ast_log(LOG_WARNING, "Couldn't read username\n");
goto out;
+ }
if (!strlen(username)) {
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "Username not entered\n");
res = 0;
goto out;
}
- if (ast_streamfile(chan, "vm-password"))
+ if (ast_streamfile(chan, "vm-password")) {
+ ast_log(LOG_WARNING, "Unable to stream password file\n");
goto out;
- if (ast_readstring(chan, password, sizeof(password), 2000, 5000, "#"))
+ }
+ if (ast_readstring(chan, password, sizeof(password), 2000, 5000, "#")) {
+ ast_log(LOG_WARNING, "Unable to read password\n");
goto out;
+ }
copy = ast_variable_retrieve(cfg, NULL, username);
if (copy) {
copy = strdup(copy);