mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
automerge commit
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@27677 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2364,17 +2364,17 @@ struct leave_vm_options {
|
|||||||
|
|
||||||
static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options)
|
static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options)
|
||||||
{
|
{
|
||||||
char tmptxtfile[256], txtfile[256];
|
char txtfile[256], tmptxtfile[256];
|
||||||
char callerid[256];
|
char callerid[256];
|
||||||
FILE *txt;
|
FILE *txt;
|
||||||
int res = 0;
|
int res = 0, txtdes;
|
||||||
int msgnum;
|
int msgnum;
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
int ausemacro = 0;
|
int ausemacro = 0;
|
||||||
int ousemacro = 0;
|
int ousemacro = 0;
|
||||||
int ouseexten = 0;
|
int ouseexten = 0;
|
||||||
char date[256];
|
char date[256];
|
||||||
char dir[256];
|
char dir[256], tmpdir[260];
|
||||||
char fn[256];
|
char fn[256];
|
||||||
char prefile[256]="";
|
char prefile[256]="";
|
||||||
char tempfile[256]="";
|
char tempfile[256]="";
|
||||||
@@ -2429,6 +2429,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
DISPOSE(tempfile, -1);
|
DISPOSE(tempfile, -1);
|
||||||
/* It's easier just to try to make it than to check for its existence */
|
/* It's easier just to try to make it than to check for its existence */
|
||||||
create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX");
|
create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX");
|
||||||
|
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, ext, "tmp");
|
||||||
|
|
||||||
/* Check current or macro-calling context for special extensions */
|
/* Check current or macro-calling context for special extensions */
|
||||||
if (ast_test_flag(vmu, VM_OPERATOR)) {
|
if (ast_test_flag(vmu, VM_OPERATOR)) {
|
||||||
@@ -2535,22 +2536,25 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
if (!ast_strlen_zero(fmt)) {
|
if (!ast_strlen_zero(fmt)) {
|
||||||
msgnum = 0;
|
msgnum = 0;
|
||||||
|
|
||||||
if (vm_lock_path(dir)) {
|
if (count_messages(vmu, dir) >= vmu->maxmsg) {
|
||||||
free_user(vmu);
|
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
|
||||||
return ERROR_LOCK_PATH;
|
if (!res)
|
||||||
|
res = ast_waitstream(chan, "");
|
||||||
|
ast_log(LOG_WARNING, "No more messages possible\n");
|
||||||
|
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
||||||
|
goto leave_vm_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
snprintf(tmptxtfile, sizeof(tmptxtfile), "%s/XXXXXX", tmpdir);
|
||||||
* This operation can be very expensive if done say over NFS or if the mailbox has 100+ messages
|
txtdes = mkstemp(tmptxtfile);
|
||||||
* in the mailbox. So we should get this first so we don't cut off the first few seconds of the
|
if (txtdes < 0) {
|
||||||
* message.
|
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
|
||||||
*/
|
if (!res)
|
||||||
do {
|
res = ast_waitstream(chan, "");
|
||||||
make_file(fn, sizeof(fn), dir, msgnum);
|
ast_log(LOG_ERROR, "Unable to create message file: %s\n", strerror(errno));
|
||||||
if (!EXISTS(dir,msgnum,fn,chan->language))
|
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
||||||
break;
|
goto leave_vm_out;
|
||||||
msgnum++;
|
}
|
||||||
} while (msgnum < vmu->maxmsg);
|
|
||||||
|
|
||||||
/* Now play the beep once we have the message number for our next message. */
|
/* Now play the beep once we have the message number for our next message. */
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
@@ -2559,14 +2563,9 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
if (!res)
|
if (!res)
|
||||||
res = ast_waitstream(chan, "");
|
res = ast_waitstream(chan, "");
|
||||||
}
|
}
|
||||||
if (msgnum < vmu->maxmsg) {
|
|
||||||
/* assign a variable with the name of the voicemail file */
|
|
||||||
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
|
|
||||||
|
|
||||||
/* Store information */
|
/* Store information */
|
||||||
snprintf(txtfile, sizeof(txtfile), "%s.txt", fn);
|
txt = fdopen(txtdes, "w+");
|
||||||
snprintf(tmptxtfile, sizeof(tmptxtfile), "%s.txt.tmp", fn);
|
|
||||||
txt = fopen(tmptxtfile, "w+");
|
|
||||||
if (txt) {
|
if (txt) {
|
||||||
get_date(date, sizeof(date));
|
get_date(date, sizeof(date));
|
||||||
fprintf(txt,
|
fprintf(txt,
|
||||||
@@ -2595,35 +2594,38 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
category ? category : "");
|
category ? category : "");
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Error opening text file for output\n");
|
ast_log(LOG_WARNING, "Error opening text file for output\n");
|
||||||
res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir, options->record_gain);
|
res = play_record_review(chan, NULL, tmptxtfile, vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain);
|
||||||
if (res == '0') {
|
|
||||||
if (txt && EXISTS(dir,msgnum,fn,chan->language)) {
|
|
||||||
fclose(txt);
|
|
||||||
rename(tmptxtfile, txtfile);
|
|
||||||
} else if (txt && !EXISTS(dir,msgnum,fn,chan->language)) {
|
|
||||||
if (option_debug)
|
|
||||||
ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
|
|
||||||
fclose(txt);
|
|
||||||
unlink(tmptxtfile);
|
|
||||||
}
|
|
||||||
goto transfer;
|
|
||||||
}
|
|
||||||
if (res > 0)
|
|
||||||
res = 0;
|
|
||||||
if (txt) {
|
|
||||||
fprintf(txt, "duration=%d\n", duration);
|
|
||||||
fclose(txt);
|
|
||||||
rename(tmptxtfile, txtfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (txt) {
|
||||||
if (duration < vmminmessage) {
|
if (duration < vmminmessage) {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "Recording was %d seconds long but needs to be at least %d - abandoning\n", duration, vmminmessage);
|
ast_verbose( VERBOSE_PREFIX_3 "Recording was %d seconds long but needs to be at least %d - abandoning\n", duration, vmminmessage);
|
||||||
DELETE(dir,msgnum,fn);
|
DELETE(dir,msgnum,fn);
|
||||||
/* XXX We should really give a prompt too short/option start again, with leave_vm_out called only after a timeout XXX */
|
} else {
|
||||||
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
fprintf(txt, "duration=%d\n", duration);
|
||||||
goto leave_vm_out;
|
fclose(txt);
|
||||||
|
if (vm_lock_path(dir)) {
|
||||||
|
ast_log(LOG_ERROR, "Couldn't lock directory %s. Voicemail will be lost.\n", dir);
|
||||||
|
/* Delete files */
|
||||||
|
ast_filedelete(tmptxtfile, NULL);
|
||||||
|
unlink(tmptxtfile);
|
||||||
|
} else {
|
||||||
|
for (;;) {
|
||||||
|
make_file(fn, sizeof(fn), dir, msgnum);
|
||||||
|
if (!EXISTS(dir, msgnum, fn, NULL))
|
||||||
|
break;
|
||||||
|
msgnum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* assign a variable with the name of the voicemail file */
|
||||||
|
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
|
||||||
|
|
||||||
|
snprintf(txtfile, sizeof(txtfile), "%s.txt", fn);
|
||||||
|
ast_filerename(tmptxtfile, fn, NULL);
|
||||||
|
rename(tmptxtfile, txtfile);
|
||||||
|
|
||||||
|
ast_unlock_path(dir);
|
||||||
|
|
||||||
/* Are there to be more recipients of this message? */
|
/* Are there to be more recipients of this message? */
|
||||||
while (tmpptr) {
|
while (tmpptr) {
|
||||||
struct ast_vm_user recipu, *recip;
|
struct ast_vm_user recipu, *recip;
|
||||||
@@ -2645,15 +2647,20 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
|
notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
|
||||||
DISPOSE(dir, msgnum);
|
DISPOSE(dir, msgnum);
|
||||||
}
|
}
|
||||||
pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
|
|
||||||
} else {
|
|
||||||
ast_unlock_path(dir);
|
|
||||||
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
|
|
||||||
if (!res)
|
|
||||||
res = ast_waitstream(chan, "");
|
|
||||||
ast_log(LOG_WARNING, "No more messages possible\n");
|
|
||||||
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == '0') {
|
||||||
|
goto transfer;
|
||||||
|
} else if (res > 0)
|
||||||
|
res = 0;
|
||||||
|
|
||||||
|
if (duration < vmminmessage)
|
||||||
|
/* XXX We should really give a prompt too short/option start again, with leave_vm_out called only after a timeout XXX */
|
||||||
|
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
|
||||||
|
else
|
||||||
|
pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "No format for saving voicemail?\n");
|
ast_log(LOG_WARNING, "No format for saving voicemail?\n");
|
||||||
leave_vm_out:
|
leave_vm_out:
|
||||||
|
Reference in New Issue
Block a user