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/trunk@167835 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Tilghman Lesher 17 years ago
parent 454241dd58
commit 31a3307245

@ -208,13 +208,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<para>This application is part of the Mini-Voicemail system, configured in <filename>minivm.conf</filename></para> <para>This application is part of the Mini-Voicemail system, configured in <filename>minivm.conf</filename></para>
<para>MiniVM records audio file in configured format and forwards message to e-mail and pager.</para> <para>MiniVM records audio file in configured format and forwards message to e-mail and pager.</para>
<para>If there's no user account for that address, a temporary account will be used with default options.</para> <para>If there's no user account for that address, a temporary account will be used with default options.</para>
<para>The recorded file name and path will be stored in <variable>MINIVM_FILENAME</variable> and the duration <para>The recorded file name and path will be stored in <variable>MVM_FILENAME</variable> and the duration
of the message will be stored in <variable>MINIVM_DURATION</variable></para> of the message will be stored in <variable>MVM_DURATION</variable></para>
<note><para>If the caller hangs up after the recording, the only way to send the message and clean up is to <note><para>If the caller hangs up after the recording, the only way to send the message and clean up is to
execute in the <literal>h</literal> extension. The application will exit if any of the following DTMF digits execute in the <literal>h</literal> extension. The application will exit if any of the following DTMF digits
are received and the requested extension exist in the current context.</para></note> are received and the requested extension exist in the current context.</para></note>
<variablelist> <variablelist>
<variable name="MINIVM_RECORD_STATUS"> <variable name="MVM_RECORD_STATUS">
<para>This is the status of the record operation</para> <para>This is the status of the record operation</para>
<value name="SUCCESS" /> <value name="SUCCESS" />
<value name="USEREXIT" /> <value name="USEREXIT" />
@ -256,7 +256,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<para>Busy and unavailable messages can be choosen, but will be overridden if a temporary <para>Busy and unavailable messages can be choosen, but will be overridden if a temporary
message exists for the account.</para> message exists for the account.</para>
<variablelist> <variablelist>
<variable name="MINIVM_GREET_STATUS"> <variable name="MVM_GREET_STATUS">
<para>This is the status of the greeting playback.</para> <para>This is the status of the greeting playback.</para>
<value name="SUCCESS" /> <value name="SUCCESS" />
<value name="USEREXIT" /> <value name="USEREXIT" />
@ -296,7 +296,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<para>If no template is given, the default email template will be used to send email and default pager <para>If no template is given, the default email template will be used to send email and default pager
template to send paging message (if the user account is configured with a paging address.</para> template to send paging message (if the user account is configured with a paging address.</para>
<variablelist> <variablelist>
<variable name="MINIVM_NOTIFY_STATUS"> <variable name="MVM_NOTIFY_STATUS">
<para>This is the status of the notification attempt</para> <para>This is the status of the notification attempt</para>
<value name="SUCCESS" /> <value name="SUCCESS" />
<value name="FAILED" /> <value name="FAILED" />
@ -317,7 +317,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<para>This application is part of the Mini-Voicemail system, configured in <filename>minivm.conf</filename>.</para> <para>This application is part of the Mini-Voicemail system, configured in <filename>minivm.conf</filename>.</para>
<para>It deletes voicemail file set in MVM_FILENAME or given filename.</para> <para>It deletes voicemail file set in MVM_FILENAME or given filename.</para>
<variablelist> <variablelist>
<variable name="MINIVM_DELETE_STATUS"> <variable name="MVM_DELETE_STATUS">
<para>This is the status of the delete operation.</para> <para>This is the status of the delete operation.</para>
<value name="SUCCESS" /> <value name="SUCCESS" />
<value name="FAILED" /> <value name="FAILED" />
@ -362,7 +362,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
and temporary messages.</para> and temporary messages.</para>
<para>Account specific directories will be created if they do not exist.</para> <para>Account specific directories will be created if they do not exist.</para>
<variablelist> <variablelist>
<variable name="MINIVM_ACCMESS_STATUS"> <variable name="MVM_ACCMESS_STATUS">
<para>This is the result of the attempt to record the specified greeting.</para> <para>This is the result of the attempt to record the specified greeting.</para>
<para><literal>FAILED</literal> is set if the file can't be created.</para> <para><literal>FAILED</literal> is set if the file can't be created.</para>
<value name="SUCCESS" /> <value name="SUCCESS" />
@ -644,7 +644,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")) {
@ -961,7 +961,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) {
@ -972,7 +972,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
@ -985,7 +985,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");
} }
} }
@ -1061,7 +1061,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";
@ -1079,7 +1079,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);
} }
@ -1088,7 +1088,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 */
@ -1099,7 +1099,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);
@ -1163,7 +1163,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;
@ -1175,7 +1175,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;
@ -1197,11 +1197,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");
} }
@ -1236,7 +1236,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/";
@ -1253,7 +1253,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;
@ -1311,7 +1311,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);
@ -1326,10 +1326,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;
@ -1366,7 +1366,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 */
@ -1400,6 +1400,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");
@ -1548,7 +1553,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);
@ -1565,9 +1570,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);
@ -1624,7 +1629,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;
} }
@ -1642,7 +1647,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;
@ -1666,7 +1671,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;
} }
@ -1723,14 +1728,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;
@ -1758,7 +1763,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;
} }
@ -1875,7 +1880,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;
} }
@ -1897,7 +1902,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))
@ -1957,10 +1962,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;
} }
@ -1979,7 +1984,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;
@ -2016,7 +2021,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");
@ -2048,7 +2053,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)) {
@ -2088,7 +2093,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;
@ -2120,7 +2125,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) {
@ -2133,14 +2138,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);
@ -2175,15 +2180,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;
@ -2256,7 +2261,7 @@ static int minivm_accmess_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;
} }
@ -2270,10 +2275,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";
@ -2330,7 +2335,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")) {
@ -2383,7 +2388,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime)
global_stats.voicemailaccounts++; global_stats.voicemailaccounts++;
ast_debug(2, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : ""); ast_debug(2, "MVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : "");
return 0; return 0;
} }
@ -2620,13 +2625,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));
@ -2702,7 +2707,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