Merged revisions 193870 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r193870 | tilghman | 2009-05-12 12:29:33 -0500 (Tue, 12 May 2009) | 2 lines
  
  Convert a THREADSTORAGE object into a simple malloc'd object (as suggested by Russell on -dev)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@193871 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Tilghman Lesher 16 years ago
parent 0569b32ac0
commit b9d140e943

@ -227,8 +227,6 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
#define ERROR_MAILBOX_FULL -200
AST_THREADSTORAGE(voicemail_extension_list);
enum {
NEW_FOLDER,
OLD_FOLDER,
@ -4292,7 +4290,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
char *context;
char ecodes[17] = "#";
char *tmpptr;
struct ast_str *tmp = ast_str_thread_get(&voicemail_extension_list, 16);
struct ast_str *tmp = ast_str_create(16);
struct ast_vm_user *vmu;
struct ast_vm_user svm;
const char *category = NULL, *code, *alldtmf = "0123456789ABCD*#";
@ -4306,8 +4304,9 @@ static int has_voicemail(const char *mailbox, const char *folder)
tmpptr = strchr(ext, '&');
}
if (tmpptr)
if (tmpptr) {
*tmpptr++ = '\0';
}
category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY");
@ -4315,13 +4314,15 @@ static int has_voicemail(const char *mailbox, const char *folder)
if (!(vmu = find_user(&svm, context, ext))) {
ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
ast_free(tmp);
return res;
}
/* Setup pre-file if appropriate */
if (strcmp(vmu->context, "default"))
if (strcmp(vmu->context, "default")) {
snprintf(ext_context, sizeof(ext_context), "%s@%s", ext, vmu->context);
else
} else {
ast_copy_string(ext_context, vmu->mailbox, sizeof(ext_context));
}
if (ast_test_flag(options, OPT_BUSY_GREETING)) {
snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, ext);
} else if (ast_test_flag(options, OPT_UNAVAIL_GREETING)) {
@ -4330,11 +4331,13 @@ static int has_voicemail(const char *mailbox, const char *folder)
snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext);
if ((res = create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, ext, "tmp"))) {
ast_log(LOG_WARNING, "Failed to make directory (%s)\n", tempfile);
ast_free(tmp);
return -1;
}
RETRIEVE(tempfile, -1, vmu->mailbox, vmu->context);
if (ast_fileexists(tempfile, NULL, NULL) > 0)
if (ast_fileexists(tempfile, NULL, NULL) > 0) {
ast_copy_string(prefile, tempfile, sizeof(prefile));
}
DISPOSE(tempfile, -1);
/* It's easier just to try to make it than to check for its existence */
create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX");
@ -4356,11 +4359,12 @@ static int has_voicemail(const char *mailbox, const char *folder)
}
if (!ast_strlen_zero(vmu->exit)) {
if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num))
if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num)) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
} else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num))
}
} else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num)) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
} else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
}
@ -4369,10 +4373,11 @@ static int has_voicemail(const char *mailbox, const char *folder)
for (code = alldtmf; *code; code++) {
char e[2] = "";
e[0] = *code;
if (strchr(ecodes, e[0]) == NULL && ast_canmatch_extension(chan, chan->context, e, 1, chan->cid.cid_num))
if (strchr(ecodes, e[0]) == NULL && ast_canmatch_extension(chan, chan->context, e, 1, chan->cid.cid_num)) {
strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1);
}
}
}
/* Play the beginning intro if desired */
if (!ast_strlen_zero(prefile)) {
@ -4386,6 +4391,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
ast_debug(1, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
ast_free(tmp);
return -1;
}
}
@ -4401,10 +4407,11 @@ static int has_voicemail(const char *mailbox, const char *folder)
res = 0;
}
}
if (res > 0)
if (res > 0) {
ast_stopstream(chan);
}
/* Check for a '*' here in case the caller wants to escape from voicemail to something
other than the operator -- an automated attendant or mailbox login for example */
* other than the operator -- an automated attendant or mailbox login for example */
if (res == '*') {
chan->exten[0] = 'a';
chan->exten[1] = '\0';
@ -4416,6 +4423,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
chan->priority = 0;
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
ast_free(tmp);
return 0;
}
@ -4435,13 +4443,15 @@ static int has_voicemail(const char *mailbox, const char *folder)
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
}
ast_free(tmp);
return 0;
}
/* Allow all other digits to exit Voicemail and return to the dialplan */
if (ast_test_flag(options, OPT_DTMFEXIT) && res > 0) {
if (!ast_strlen_zero(options->exitcontext))
if (!ast_strlen_zero(options->exitcontext)) {
ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context));
}
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
return res;
@ -4450,6 +4460,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
if (res < 0) {
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
ast_free(tmp);
return -1;
}
/* The meat of recording the message... All the announcements and beeps have been played*/
@ -4463,6 +4474,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
res = inboxcount(ext_context, &newmsgs, &oldmsgs);
if (res < 0) {
ast_log(LOG_NOTICE, "Can not leave voicemail, unable to count messages\n");
ast_free(tmp);
return -1;
}
if (!(vms = get_vm_state_by_mailbox(ext, 0))) {
@ -4472,6 +4484,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
*/
if (!(vms = create_vm_state_from_user(vmu))) {
ast_log(LOG_ERROR, "Couldn't allocate necessary space\n");
ast_free(tmp);
return -1;
}
}
@ -4489,6 +4502,7 @@ static int has_voicemail(const char *mailbox, const char *folder)
if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) {
ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
ast_play_and_wait(chan, "vm-mailboxfull");
ast_free(tmp);
return -1;
}
@ -4496,13 +4510,15 @@ static int has_voicemail(const char *mailbox, const char *folder)
if (msgnum >= vmu->maxmsg) {
ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg);
ast_play_and_wait(chan, "vm-mailboxfull");
ast_free(tmp);
return -1;
}
#else
if (count_messages(vmu, dir) >= vmu->maxmsg) {
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
if (!res)
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;
@ -4514,8 +4530,9 @@ static int has_voicemail(const char *mailbox, const char *folder)
chmod(tmptxtfile, VOICEMAIL_FILE_MODE & ~my_umask);
if (txtdes < 0) {
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
if (!res)
if (!res) {
res = ast_waitstream(chan, "");
}
ast_log(LOG_ERROR, "Unable to create message file: %s\n", strerror(errno));
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
goto leave_vm_out;
@ -4563,8 +4580,9 @@ static int has_voicemail(const char *mailbox, const char *folder)
ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"),
date, (long)time(NULL),
category ? category : "");
} else
} else {
ast_log(LOG_WARNING, "Error opening text file for output\n");
}
res = play_record_review(chan, NULL, tmptxtfile, vmu->maxsecs, fmt, 1, vmu, &duration, NULL, options->record_gain, vms);
if (txt) {
@ -4612,8 +4630,9 @@ static int has_voicemail(const char *mailbox, const char *folder)
/* Properly set permissions on voicemail text descriptor file.
Unfortunately mkstemp() makes this file 0600 on most unix systems. */
if (chmod(txtfile, VOICEMAIL_FILE_MODE) < 0)
if (chmod(txtfile, VOICEMAIL_FILE_MODE) < 0) {
ast_log(LOG_ERROR, "Couldn't set permissions on voicemail text file %s: %s", txtfile, strerror(errno));
}
ast_unlock_path(dir);
if (ast_check_realtime("voicemail_data")) {
@ -4658,19 +4677,23 @@ static int has_voicemail(const char *mailbox, const char *folder)
}
if (res == '0') {
goto transfer;
} else if (res > 0)
} else if (res > 0) {
res = 0;
}
if (duration < vmminsecs)
if (duration < vmminsecs) {
/* 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
} else {
pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
} else
}
} else {
ast_log(LOG_WARNING, "No format for saving voicemail?\n");
}
leave_vm_out:
free_user(vmu);
ast_free(tmp);
return res;
}

Loading…
Cancel
Save