Merged revisions 167835 via svnmerge from

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

........
  r167835 | tilghman | 2009-01-08 15:32:45 -0600 (Thu, 08 Jan 2009) | 6 lines
  
  Textual changes, consistency in status variable naming, and other minor bugs.
  (closes issue #13943)
   Reported by: Marquis
   Patches: 
         minivm_trunk_fixes3.patch uploaded by Marquis (license 32)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@167836 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Tilghman Lesher 17 years ago
parent b205a18a8d
commit 361d76c1eb

@ -228,8 +228,8 @@ static char *descrip_minivm_record =
"MiniVM records audio file in configured format and forwards message to e-mail and pager.\n" "MiniVM records audio file in configured format and forwards message to e-mail and pager.\n"
"If there's no user account for that address, a temporary account will\n" "If there's no user account for that address, a temporary account will\n"
"be used with default options.\n" "be used with default options.\n"
"The recorded file name and path will be stored in MINIVM_FILENAME and the \n" "The recorded file name and path will be stored in MVM_FILENAME and the \n"
"duration of the message will be stored in MINIVM_DURATION\n" "duration of the message will be stored in MVM_DURATION\n"
"\nNote: If the caller hangs up after the recording, the only way to send\n" "\nNote: If the caller hangs up after the recording, the only way to send\n"
"the message and clean up is to execute in the \"h\" extension.\n" "the message and clean up is to execute in the \"h\" extension.\n"
"\nThe application will exit if any of the following DTMF digits are \n" "\nThe application will exit if any of the following DTMF digits are \n"
@ -237,7 +237,7 @@ static char *descrip_minivm_record =
" 0 - Jump to the 'o' extension in the current dialplan context.\n" " 0 - Jump to the 'o' extension in the current dialplan context.\n"
" * - Jump to the 'a' extension in the current dialplan context.\n" " * - Jump to the 'a' extension in the current dialplan context.\n"
"\n" "\n"
"Result is given in channel variable MINIVM_RECORD_STATUS\n" "Result is given in channel variable MVM_RECORD_STATUS\n"
" The possible values are: SUCCESS | USEREXIT | FAILED\n\n" " The possible values are: SUCCESS | USEREXIT | FAILED\n\n"
" Options:\n" " Options:\n"
" g(#) - Use the specified amount of gain when recording the voicemail\n" " g(#) - Use the specified amount of gain when recording the voicemail\n"
@ -252,7 +252,7 @@ static char *descrip_minivm_greet =
"Busy and unavailable messages can be choosen, but will be overridden if a temporary\n" "Busy and unavailable messages can be choosen, but will be overridden if a temporary\n"
"message exists for the account.\n" "message exists for the account.\n"
"\n" "\n"
"Result is given in channel variable MINIVM_GREET_STATUS\n" "Result is given in channel variable MVM_GREET_STATUS\n"
" The possible values are: SUCCESS | USEREXIT | FAILED\n\n" " The possible values are: SUCCESS | USEREXIT | FAILED\n\n"
" Options:\n" " Options:\n"
" b - Play the 'busy' greeting to the calling party.\n" " b - Play the 'busy' greeting to the calling party.\n"
@ -276,7 +276,7 @@ static char *descrip_minivm_notify =
"default pager template to send paging message (if the user account is configured with\n" "default pager template to send paging message (if the user account is configured with\n"
"a paging address.\n" "a paging address.\n"
"\n" "\n"
"Result is given in channel variable MINIVM_NOTIFY_STATUS\n" "Result is given in channel variable MVM_NOTIFY_STATUS\n"
" The possible values are: SUCCESS | FAILED\n" " The possible values are: SUCCESS | FAILED\n"
"\n"; "\n";
@ -286,7 +286,7 @@ static char *descrip_minivm_delete =
"This application is part of the Mini-Voicemail system, configured in minivm.conf.\n" "This application is part of the Mini-Voicemail system, configured in minivm.conf.\n"
"It deletes voicemail file set in MVM_FILENAME or given filename.\n" "It deletes voicemail file set in MVM_FILENAME or given filename.\n"
"\n" "\n"
"Result is given in channel variable MINIVM_DELETE_STATUS\n" "Result is given in channel variable MVM_DELETE_STATUS\n"
" The possible values are: SUCCESS | FAILED\n" " The possible values are: SUCCESS | FAILED\n"
" FAILED is set if the file does not exist or can't be deleted.\n" " FAILED is set if the file does not exist or can't be deleted.\n"
"\n"; "\n";
@ -304,7 +304,7 @@ static char *descrip_minivm_accmess =
" t Temporary (overrides busy and unavailable)\n" " t Temporary (overrides busy and unavailable)\n"
" n Account name\n" " n Account name\n"
"\n" "\n"
"Result is given in channel variable MINIVM_ACCMESS_STATUS\n" "Result is given in channel variable MVM_ACCMESS_STATUS\n"
" The possible values are: SUCCESS | FAILED\n" " The possible values are: SUCCESS | FAILED\n"
" FAILED is set if the file can't be created.\n" " FAILED is set if the file can't be created.\n"
"\n"; "\n";
@ -498,7 +498,7 @@ static int message_template_build(const char *name, struct ast_variable *var)
} }
while (var) { while (var) {
ast_debug(3, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name); ast_debug(3, "Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "fromaddress")) { if (!strcasecmp(var->name, "fromaddress")) {
ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress)); ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress));
} else if (!strcasecmp(var->name, "fromemail")) { } else if (!strcasecmp(var->name, "fromemail")) {
@ -815,7 +815,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern
ast_log(LOG_NOTICE, "No username or domain? \n"); ast_log(LOG_NOTICE, "No username or domain? \n");
return NULL; return NULL;
} }
ast_debug(3, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain); ast_debug(3, "Looking for voicemail user %s in domain %s\n", username, domain);
AST_LIST_LOCK(&minivm_accounts); AST_LIST_LOCK(&minivm_accounts);
AST_LIST_TRAVERSE(&minivm_accounts, cur, list) { AST_LIST_TRAVERSE(&minivm_accounts, cur, list) {
@ -826,7 +826,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern
AST_LIST_UNLOCK(&minivm_accounts); AST_LIST_UNLOCK(&minivm_accounts);
if (cur) { if (cur) {
ast_debug(3, "-_-_- Found account for %s@%s\n", username, domain); ast_debug(3, "Found account for %s@%s\n", username, domain);
vmu = cur; vmu = cur;
} else } else
@ -839,7 +839,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern
if (vmu) { if (vmu) {
ast_copy_string(vmu->username, username, sizeof(vmu->username)); ast_copy_string(vmu->username, username, sizeof(vmu->username));
ast_copy_string(vmu->domain, domain, sizeof(vmu->domain)); ast_copy_string(vmu->domain, domain, sizeof(vmu->domain));
ast_debug(1, "--- Created temporary account\n"); ast_debug(1, "Created temporary account\n");
} }
} }
@ -915,7 +915,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
return -1; return -1;
} }
ast_debug(3, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name); ast_debug(3, "Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
if (!strcmp(format, "wav49")) if (!strcmp(format, "wav49"))
format = "WAV"; format = "WAV";
@ -933,7 +933,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format); snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
ast_safe_system(tmpcmd); ast_safe_system(tmpcmd);
finalfilename = newtmp; finalfilename = newtmp;
ast_debug(3, "-- VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", filename, format, vmu->volgain, vmu->username); ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", filename, format, vmu->volgain, vmu->username);
} else { } else {
finalfilename = ast_strdupa(filename); finalfilename = ast_strdupa(filename);
} }
@ -942,7 +942,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format); snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format);
if (template->attachment) if (template->attachment)
ast_debug(1, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail); ast_debug(1, "Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail);
/* Make a temporary file instead of piping directly to sendmail, in case the mail /* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */ command hangs */
@ -953,7 +953,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
close(pfd); close(pfd);
pfd = -1; pfd = -1;
} }
ast_debug(1, "-_-_- Opening temp file for e-mail: %s\n", tmp); ast_debug(1, "Opening temp file for e-mail: %s\n", tmp);
} }
if (!p) { if (!p) {
ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp); ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp);
@ -1017,7 +1017,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
/* Allocate a buffer big enough for variable substitution */ /* Allocate a buffer big enough for variable substitution */
int vmlen = strlen(fromaddress) * 3 + 200; int vmlen = strlen(fromaddress) * 3 + 200;
ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress); ast_debug(4, "Fromaddress template: %s\n", fromaddress);
if ((passdata = alloca(vmlen))) { if ((passdata = alloca(vmlen))) {
pbx_substitute_variables_helper(ast, fromaddress, passdata, vmlen); pbx_substitute_variables_helper(ast, fromaddress, passdata, vmlen);
len_passdata = strlen(passdata) * 2 + 3; len_passdata = strlen(passdata) * 2 + 3;
@ -1029,7 +1029,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
return -1; return -1;
} }
} }
ast_debug(4, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata); ast_debug(4, "Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata);
fprintf(p, "Message-ID: <Asterisk-%d-%s-%d-%s>\n", (unsigned int)rand(), vmu->username, (int)getpid(), who); fprintf(p, "Message-ID: <Asterisk-%d-%s-%d-%s>\n", (unsigned int)rand(), vmu->username, (int)getpid(), who);
len_passdata = strlen(vmu->fullname) * 2 + 3; len_passdata = strlen(vmu->fullname) * 2 + 3;
@ -1051,11 +1051,11 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
return -1; return -1;
} }
ast_debug(4, "-_-_- Subject now: %s\n", pass_data); ast_debug(4, "Subject now: %s\n", pass_data);
} else { } else {
fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain); fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain);
ast_debug(1, "-_-_- Using default subject for this email \n"); ast_debug(1, "Using default subject for this email \n");
} }
@ -1090,7 +1090,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
/* Eww. We want formats to tell us their own MIME type */ /* Eww. We want formats to tell us their own MIME type */
if (template->attachment) { if (template->attachment) {
char *ctype = "audio/x-"; char *ctype = "audio/x-";
ast_debug(3, "-_-_- Attaching file to message: %s\n", fname); ast_debug(3, "Attaching file to message: %s\n", fname);
if (!strcasecmp(format, "ogg")) if (!strcasecmp(format, "ogg"))
ctype = "application/"; ctype = "application/";
@ -1107,7 +1107,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp);
ast_safe_system(tmp2); ast_safe_system(tmp2);
ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : ""); ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
ast_debug(3, "-_-_- Actual command used: %s\n", tmp2); ast_debug(3, "Actual command used: %s\n", tmp2);
if (ast) if (ast)
ast_channel_free(ast); ast_channel_free(ast);
return 0; return 0;
@ -1165,7 +1165,7 @@ static int invent_message(struct ast_channel *chan, char *domain, char *username
int res; int res;
char fn[PATH_MAX]; char fn[PATH_MAX];
ast_debug(2, "-_-_- Still preparing to play message ...\n"); ast_debug(2, "Still preparing to play message ...\n");
snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username); snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username);
@ -1180,10 +1180,10 @@ static int invent_message(struct ast_channel *chan, char *domain, char *username
int numericusername = 1; int numericusername = 1;
char *i = username; char *i = username;
ast_debug(2, "-_-_- No personal prompts. Using default prompt set for language\n"); ast_debug(2, "No personal prompts. Using default prompt set for language\n");
while (*i) { while (*i) {
ast_debug(2, "-_-_- Numeric? Checking %c\n", *i); ast_debug(2, "Numeric? Checking %c\n", *i);
if (!isdigit(*i)) { if (!isdigit(*i)) {
numericusername = FALSE; numericusername = FALSE;
break; break;
@ -1220,7 +1220,7 @@ static int vm_delete(char *file)
{ {
int res; int res;
ast_debug(1, "-_-_- Deleting voicemail file %s\n", file); ast_debug(1, "Deleting voicemail file %s\n", file);
res = unlink(file); /* Remove the meta data file */ res = unlink(file); /* Remove the meta data file */
res |= ast_filedelete(file, NULL); /* remove the media file */ res |= ast_filedelete(file, NULL); /* remove the media file */
@ -1254,6 +1254,11 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
while ((cmd >= 0) && (cmd != 't')) { while ((cmd >= 0) && (cmd != 't')) {
switch (cmd) { switch (cmd) {
case '1':
ast_verb(3, "Saving message as is\n");
ast_stream_and_wait(chan, "vm-msgsaved", "");
cmd = 't';
break;
case '2': case '2':
/* Review */ /* Review */
ast_verb(3, "Reviewing the message\n"); ast_verb(3, "Reviewing the message\n");
@ -1402,7 +1407,7 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename
if (!ast_strlen_zero(etemplate->locale)) { if (!ast_strlen_zero(etemplate->locale)) {
char *new_locale; char *new_locale;
ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale)); ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale));
ast_debug(2, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale); ast_debug(2, "Changing locale from %s to %s\n", oldlocale, etemplate->locale);
new_locale = setlocale(LC_TIME, etemplate->locale); new_locale = setlocale(LC_TIME, etemplate->locale);
if (new_locale == NULL) { if (new_locale == NULL) {
ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale); ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale);
@ -1419,9 +1424,9 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename
ast_channel_unlock(chan); ast_channel_unlock(chan);
if (ast_strlen_zero(counter)) { if (ast_strlen_zero(counter)) {
ast_debug(2, "-_-_- MVM_COUNTER not found\n"); ast_debug(2, "MVM_COUNTER not found\n");
} else { } else {
ast_debug(2, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter); ast_debug(2, "MVM_COUNTER found - will use it with value %s\n", counter);
} }
res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter); res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter);
@ -1478,7 +1483,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
if (!(vmu = find_account(domain, username, TRUE))) { if (!(vmu = find_account(domain, username, TRUE))) {
/* We could not find user, let's exit */ /* We could not find user, let's exit */
ast_log(LOG_ERROR, "Can't allocate temporary account for '%s@%s'\n", username, domain); ast_log(LOG_ERROR, "Can't allocate temporary account for '%s@%s'\n", username, domain);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
return 0; return 0;
} }
@ -1496,7 +1501,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
if (ast_strlen_zero(fmt)) { if (ast_strlen_zero(fmt)) {
ast_log(LOG_WARNING, "No format for saving voicemail? Default %s\n", default_vmformat); ast_log(LOG_WARNING, "No format for saving voicemail? Default %s\n", default_vmformat);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
return res; return res;
} }
msgnum = 0; msgnum = 0;
@ -1520,7 +1525,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
res = ast_streamfile(chan, "vm-mailboxfull", chan->language); res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
if (!res) if (!res)
res = ast_waitstream(chan, ""); res = ast_waitstream(chan, "");
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
return res; return res;
} }
@ -1577,14 +1582,14 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
fclose(txt); fclose(txt);
ast_filedelete(tmptxtfile, NULL); ast_filedelete(tmptxtfile, NULL);
unlink(tmptxtfile); unlink(tmptxtfile);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
return 0; return 0;
} }
fclose(txt); /* Close log file */ fclose(txt); /* Close log file */
if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n"); ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n");
unlink(tmptxtfile); unlink(tmptxtfile);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu); free_user(vmu);
return 0; return 0;
@ -1612,7 +1617,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu); free_user(vmu);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "SUCCESS"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS");
return res; return res;
} }
@ -1661,7 +1666,7 @@ static int minivm_notify_exec(struct ast_channel *chan, void *data)
if(!(vmu = find_account(domain, username, TRUE))) { if(!(vmu = find_account(domain, username, TRUE))) {
/* We could not find user, let's exit */ /* We could not find user, let's exit */
ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain); ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain);
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", "FAILED");
return -1; return -1;
} }
@ -1683,7 +1688,7 @@ static int minivm_notify_exec(struct ast_channel *chan, void *data)
res = notify_new_message(chan, template, vmu, filename, atoi(duration_string), format, chan->cid.cid_num, chan->cid.cid_name); res = notify_new_message(chan, template, vmu, filename, atoi(duration_string), format, chan->cid.cid_num, chan->cid.cid_name);
} }
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", res == 0 ? "SUCCESS" : "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", res == 0 ? "SUCCESS" : "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
@ -1743,10 +1748,10 @@ static int minivm_record_exec(struct ast_channel *chan, void *data)
if (res == ERROR_LOCK_PATH) { if (res == ERROR_LOCK_PATH) {
ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n"); ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
res = 0; res = 0;
} }
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "SUCCESS"); pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS");
return res; return res;
} }
@ -1765,7 +1770,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
int ouseexten = 0; int ouseexten = 0;
char tmp[PATH_MAX]; char tmp[PATH_MAX];
char dest[PATH_MAX]; char dest[PATH_MAX];
char prefile[PATH_MAX]; char prefile[PATH_MAX] = "";
char tempfile[PATH_MAX] = ""; char tempfile[PATH_MAX] = "";
char ext_context[256] = ""; char ext_context[256] = "";
char *domain; char *domain;
@ -1802,7 +1807,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument: %s\n", argv[0]); ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument: %s\n", argv[0]);
return -1; return -1;
} }
ast_debug(1, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain); ast_debug(1, "Trying to find configuration for user %s in domain %s\n", username, domain);
if (!(vmu = find_account(domain, username, TRUE))) { if (!(vmu = find_account(domain, username, TRUE))) {
ast_log(LOG_ERROR, "Could not allocate memory. \n"); ast_log(LOG_ERROR, "Could not allocate memory. \n");
@ -1834,7 +1839,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile); ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile);
ast_copy_string(prefile, tempfile, sizeof(prefile)); ast_copy_string(prefile, tempfile, sizeof(prefile));
} }
ast_debug(2, "-_-_- Preparing to play message ...\n"); ast_debug(2, "Preparing to play message ...\n");
/* Check current or macro-calling context for special extensions */ /* Check current or macro-calling context for special extensions */
if (ast_test_flag(vmu, MVM_OPERATOR)) { if (ast_test_flag(vmu, MVM_OPERATOR)) {
@ -1874,7 +1879,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
} }
if (res < 0) { if (res < 0) {
ast_debug(2, "Hang up during prefile playback\n"); ast_debug(2, "Hang up during prefile playback\n");
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu); free_user(vmu);
return -1; return -1;
@ -1906,7 +1911,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context)); ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
} }
chan->priority = 0; chan->priority = 0;
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "USEREXIT"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT");
res = 0; res = 0;
} else if (res == '0') { /* Check for a '0' here */ } else if (res == '0') { /* Check for a '0' here */
if(ouseexten || ousemacro) { if(ouseexten || ousemacro) {
@ -1919,14 +1924,14 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data)
} }
ast_play_and_wait(chan, "transfer"); ast_play_and_wait(chan, "transfer");
chan->priority = 0; chan->priority = 0;
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "USEREXIT"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT");
} }
res = 0; res = 0;
} else if (res < 0) { } else if (res < 0) {
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "FAILED");
res = -1; res = -1;
} else } else
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "SUCCESS"); pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "SUCCESS");
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu); free_user(vmu);
@ -1961,15 +1966,15 @@ static int minivm_delete_exec(struct ast_channel *chan, void *data)
if (ast_fileexists(filename, NULL, NULL) > 0) { if (ast_fileexists(filename, NULL, NULL) > 0) {
res = vm_delete(filename); res = vm_delete(filename);
if (res) { if (res) {
ast_debug(2, "-_-_- Can't delete file: %s\n", filename); ast_debug(2, "Can't delete file: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED");
} else { } else {
ast_debug(2, "-_-_- Deleted voicemail file :: %s \n", filename); ast_debug(2, "Deleted voicemail file :: %s \n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "SUCCESS"); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "SUCCESS");
} }
} else { } else {
ast_debug(2, "-_-_- Filename does not exist: %s\n", filename); ast_debug(2, "Filename does not exist: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED");
} }
return res; return res;
@ -2022,7 +2027,7 @@ static int minivm_accmess_exec(struct ast_channel *chan, void *data)
} }
if (error) { if (error) {
pbx_builtin_setvar_helper(chan, "MINIVM_ACCMESS_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "FAILED");
return -1; return -1;
} }
@ -2035,14 +2040,14 @@ static int minivm_accmess_exec(struct ast_channel *chan, void *data)
} }
if (ast_strlen_zero(domain) || ast_strlen_zero(username)) { if (ast_strlen_zero(domain) || ast_strlen_zero(username)) {
ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]); ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument 0 %s\n", argv[0]);
pbx_builtin_setvar_helper(chan, "MINIVM_ACCMESS_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_ACCMESS_STATUS", "FAILED");
return -1; return -1;
} }
if(!(vmu = find_account(domain, username, TRUE))) { if(!(vmu = find_account(domain, username, TRUE))) {
/* We could not find user, let's exit */ /* We could not find user, let's exit */
ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain); ast_log(LOG_WARNING, "Could not allocate temporary memory for '%s@%s'\n", username, domain);
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "FAILED"); pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", "FAILED");
return -1; return -1;
} }
@ -2056,10 +2061,10 @@ static int minivm_accmess_exec(struct ast_channel *chan, void *data)
prompt = "vm-rec-busy"; prompt = "vm-rec-busy";
} else if (ast_test_flag(&flags, OPT_UNAVAIL_GREETING)) { } else if (ast_test_flag(&flags, OPT_UNAVAIL_GREETING)) {
message = "unavailable"; message = "unavailable";
prompt = "vm-rec-unavail"; prompt = "vm-rec-unv";
} else if (ast_test_flag(&flags, OPT_TEMP_GREETING)) { } else if (ast_test_flag(&flags, OPT_TEMP_GREETING)) {
message = "temp"; message = "temp";
prompt = "vm-temp-greeting"; prompt = "vm-rec-temp";
} else if (ast_test_flag(&flags, OPT_NAME_GREETING)) { } else if (ast_test_flag(&flags, OPT_NAME_GREETING)) {
message = "greet"; message = "greet";
prompt = "vm-rec-name"; prompt = "vm-rec-name";
@ -2073,7 +2078,7 @@ static int minivm_accmess_exec(struct ast_channel *chan, void *data)
if(ast_test_flag(vmu, MVM_ALLOCED)) if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu); free_user(vmu);
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "SUCCESS"); pbx_builtin_setvar_helper(chan, "MVM_NOTIFY_STATUS", "SUCCESS");
/* Ok, we're ready to rock and roll. Return to dialplan */ /* Ok, we're ready to rock and roll. Return to dialplan */
return 0; return 0;
@ -2116,7 +2121,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime)
ast_debug(3, "...Configuring account %s\n", name); ast_debug(3, "...Configuring account %s\n", name);
while (var) { while (var) {
ast_debug(3, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name); ast_debug(3, "Configuring %s = \"%s\" for account %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "serveremail")) { if (!strcasecmp(var->name, "serveremail")) {
ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail)); ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail));
} else if (!strcasecmp(var->name, "email")) { } else if (!strcasecmp(var->name, "email")) {
@ -2402,13 +2407,13 @@ static int load_config(int reload)
return 0; return 0;
} }
ast_debug(2, "-_-_- Loaded configuration file, now parsing\n"); ast_debug(2, "Loaded configuration file, now parsing\n");
/* General settings */ /* General settings */
cat = ast_category_browse(cfg, NULL); cat = ast_category_browse(cfg, NULL);
while (cat) { while (cat) {
ast_debug(3, "-_-_- Found configuration section [%s]\n", cat); ast_debug(3, "Found configuration section [%s]\n", cat);
if (!strcasecmp(cat, "general")) { if (!strcasecmp(cat, "general")) {
/* Nothing right now */ /* Nothing right now */
error += apply_general_options(ast_variable_browse(cfg, cat)); error += apply_general_options(ast_variable_browse(cfg, cat));
@ -2484,7 +2489,7 @@ static int load_config(int reload)
if(!minivmlogfile) if(!minivmlogfile)
ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno)); ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno));
if (minivmlogfile) if (minivmlogfile)
ast_debug(3, "-_-_- Opened log file %s \n", global_logfile); ast_debug(3, "Opened log file %s \n", global_logfile);
} }
return 0; return 0;

Loading…
Cancel
Save