--- app_minivm.c.orig 2008-11-25 16:01:28.000000000 -0500 +++ app_minivm.c.new 2008-11-25 17:51:06.000000000 -0500 @@ -207,10 +207,10 @@ his application is part of the Mini-Voicemail system, configured in minivm.conf MiniVM records audio file in configured format and forwards message to e-mail and pager. If there's no user account for that address, a temporary account will be used with default options. - The recorded file name and path will be stored in MINIVM_FILENAME and the duration of the message will be stored in MINIVM_DURATION + The recorded file name and path will be stored in MVM_FILENAME and the duration of the message will be stored in MVM_DURATION Note: If the caller hangs up after the recording, the only way to send the message and clean up is to execute in the h extension. The application will exit if any of the following DTMF digits are received and the requested extension exist in the current context. - + This is the status of the record operation @@ -252,7 +252,7 @@ MinivmGreet() plays default prompts or user specific prompts for an account. Busy and unavailable messages can be choosen, but will be overridden if a temporary message exists for the account. - + This is the status of the greeting playback. @@ -289,7 +289,7 @@ If the channel variable MVM_COUNTER is set, this will be used in the message file name and available in the template for the message. 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. - + This is the status of the notification attempt @@ -311,7 +311,7 @@ This application is part of the Mini-Voicemail system, configured in minivm.conf. It deletes voicemail file set in MVM_FILENAME or given filename. - + This is the status of the delete operation. @@ -355,7 +355,7 @@ Use this application to record account specific audio/video messages for busy, unavailable and temporary messages. Account specific directories will be created if they do not exist. - + This is the result of the attempt to record the specified greeting. FAILED is set if the file can't be created. @@ -461,8 +461,8 @@ "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" "be used with default options.\n" - "The recorded file name and path will be stored in MINIVM_FILENAME and the \n" - "duration of the message will be stored in MINIVM_DURATION\n" + "The recorded file name and path will be stored in MVM_FILENAME and the \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" "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" @@ -470,7 +470,7 @@ " 0 - Jump to the 'o' extension in the current dialplan context.\n" " * - Jump to the 'a' extension in the current dialplan context.\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" " Options:\n" " g(#) - Use the specified amount of gain when recording the voicemail\n" @@ -669,7 +669,7 @@ } 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")) { ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress)); } else if (!strcasecmp(var->name, "fromemail")) { @@ -986,7 +986,7 @@ ast_log(LOG_NOTICE, "No username or domain? \n"); 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_TRAVERSE(&minivm_accounts, cur, list) { @@ -997,7 +997,7 @@ AST_LIST_UNLOCK(&minivm_accounts); 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; } else @@ -1010,7 +1010,7 @@ if (vmu) { ast_copy_string(vmu->username, username, sizeof(vmu->username)); ast_copy_string(vmu->domain, domain, sizeof(vmu->domain)); - ast_debug(1, "--- Created temporary account\n"); + ast_debug(1, "Created temporary account\n"); } } @@ -1086,7 +1086,7 @@ 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")) format = "WAV"; @@ -1104,7 +1104,7 @@ snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format); ast_safe_system(tmpcmd); 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 { finalfilename = ast_strdupa(filename); } @@ -1113,7 +1113,7 @@ snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format); 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 command hangs */ @@ -1124,7 +1124,7 @@ close(pfd); 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) { ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp); @@ -1188,7 +1188,7 @@ /* Allocate a buffer big enough for variable substitution */ 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))) { pbx_substitute_variables_helper(ast, fromaddress, passdata, vmlen); len_passdata = strlen(passdata) * 2 + 3; @@ -1200,7 +1200,7 @@ 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: \n", (unsigned int)rand(), vmu->username, (int)getpid(), who); len_passdata = strlen(vmu->fullname) * 2 + 3; @@ -1222,11 +1222,11 @@ return -1; } - ast_debug(4, "-_-_- Subject now: %s\n", pass_data); + ast_debug(4, "Subject now: %s\n", pass_data); } else { 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"); } @@ -1261,7 +1261,7 @@ /* Eww. We want formats to tell us their own MIME type */ if (template->attachment) { 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")) ctype = "application/"; @@ -1278,7 +1278,7 @@ snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp); 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(3, "-_-_- Actual command used: %s\n", tmp2); + ast_debug(3, "Actual command used: %s\n", tmp2); if (ast) ast_channel_free(ast); return 0; @@ -1336,7 +1336,7 @@ int res; 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); @@ -1351,10 +1351,10 @@ int numericusername = 1; 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) { - ast_debug(2, "-_-_- Numeric? Checking %c\n", *i); + ast_debug(2, "Numeric? Checking %c\n", *i); if (!isdigit(*i)) { numericusername = FALSE; break; @@ -1391,7 +1391,7 @@ { 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 |= ast_filedelete(file, NULL); /* remove the media file */ @@ -1425,6 +1425,11 @@ while ((cmd >= 0) && (cmd != 't')) { switch (cmd) { + case '1': + ast_verb(3, "Saving message as is\n"); + ast_stream_and_wait(chan, "vm-msgsaved", ""); + cmd = 't'; + break; case '2': /* Review */ ast_verb(3, "Reviewing the message\n"); @@ -1573,7 +1578,7 @@ if (!ast_strlen_zero(etemplate->locale)) { char *new_locale; 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); if (new_locale == NULL) { ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale); @@ -1590,9 +1595,9 @@ ast_channel_unlock(chan); if (ast_strlen_zero(counter)) { - ast_debug(2, "-_-_- MVM_COUNTER not found\n"); + ast_debug(2, "MVM_COUNTER not found\n"); } 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); @@ -1649,7 +1654,7 @@ if (!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ 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; } @@ -1667,7 +1672,7 @@ if (ast_strlen_zero(fmt)) { 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; } msgnum = 0; @@ -1691,7 +1696,7 @@ res = ast_streamfile(chan, "vm-mailboxfull", chan->language); if (!res) res = ast_waitstream(chan, ""); - pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); + pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return res; } @@ -1748,14 +1753,14 @@ fclose(txt); ast_filedelete(tmptxtfile, NULL); unlink(tmptxtfile); - pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); + pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED"); return 0; } fclose(txt); /* Close log file */ 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"); 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)) free_user(vmu); return 0; @@ -1783,7 +1788,7 @@ if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); - pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "SUCCESS"); + pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS"); return res; } @@ -1900,7 +1905,7 @@ if(!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ 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; } @@ -1922,7 +1927,7 @@ 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)) @@ -1982,10 +1987,10 @@ if (res == ERROR_LOCK_PATH) { 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; } - pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "SUCCESS"); + pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "SUCCESS"); return res; } @@ -2004,7 +2009,7 @@ int ouseexten = 0; char tmp[PATH_MAX]; char dest[PATH_MAX]; - char prefile[PATH_MAX]; + char prefile[PATH_MAX] = ""; char tempfile[PATH_MAX] = ""; char ext_context[256] = ""; char *domain; @@ -2041,7 +2046,7 @@ ast_log(LOG_ERROR, "Need username@domain as argument. Sorry. Argument: %s\n", argv[0]); 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))) { ast_log(LOG_ERROR, "Could not allocate memory. \n"); @@ -2073,7 +2078,7 @@ ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile); 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 */ if (ast_test_flag(vmu, MVM_OPERATOR)) { @@ -2113,7 +2118,7 @@ } if (res < 0) { 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)) free_user(vmu); return -1; @@ -2145,7 +2150,7 @@ ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context)); } chan->priority = 0; - pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "USEREXIT"); + pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT"); res = 0; } else if (res == '0') { /* Check for a '0' here */ if(ouseexten || ousemacro) { @@ -2158,14 +2163,14 @@ } ast_play_and_wait(chan, "transfer"); chan->priority = 0; - pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "USEREXIT"); + pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT"); } 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; } 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)) free_user(vmu); @@ -2200,15 +2205,15 @@ if (ast_fileexists(filename, NULL, NULL) > 0) { res = vm_delete(filename); if (res) { - ast_debug(2, "-_-_- Can't delete file: %s\n", filename); - pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); + ast_debug(2, "Can't delete file: %s\n", filename); + pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED"); } else { - ast_debug(2, "-_-_- Deleted voicemail file :: %s \n", filename); - pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "SUCCESS"); + ast_debug(2, "Deleted voicemail file :: %s \n", filename); + pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "SUCCESS"); } } else { - ast_debug(2, "-_-_- Filename does not exist: %s\n", filename); - pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); + ast_debug(2, "Filename does not exist: %s\n", filename); + pbx_builtin_setvar_helper(chan, "MVM_DELETE_STATUS", "FAILED"); } return res; @@ -2279,7 +2284,7 @@ if(!(vmu = find_account(domain, username, TRUE))) { /* We could not find user, let's exit */ 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; } @@ -2293,10 +2298,10 @@ prompt = "vm-rec-busy"; } else if (ast_test_flag(&flags, OPT_UNAVAIL_GREETING)) { message = "unavailable"; - prompt = "vm-rec-unavail"; + prompt = "vm-rec-unv"; } else if (ast_test_flag(&flags, OPT_TEMP_GREETING)) { message = "temp"; - prompt = "vm-temp-greeting"; + prompt = "vm-rec-temp"; } else if (ast_test_flag(&flags, OPT_NAME_GREETING)) { message = "greet"; prompt = "vm-rec-name"; @@ -2353,7 +2358,7 @@ ast_debug(3, "...Configuring account %s\n", name); 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")) { ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail)); } else if (!strcasecmp(var->name, "email")) { @@ -2406,7 +2411,7 @@ 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; } @@ -2643,13 +2648,13 @@ return 0; } - ast_debug(2, "-_-_- Loaded configuration file, now parsing\n"); + ast_debug(2, "Loaded configuration file, now parsing\n"); /* General settings */ cat = ast_category_browse(cfg, NULL); while (cat) { - ast_debug(3, "-_-_- Found configuration section [%s]\n", cat); + ast_debug(3, "Found configuration section [%s]\n", cat); if (!strcasecmp(cat, "general")) { /* Nothing right now */ error += apply_general_options(ast_variable_browse(cfg, cat)); @@ -2725,7 +2730,7 @@ if(!minivmlogfile) ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno)); if (minivmlogfile) - ast_debug(3, "-_-_- Opened log file %s \n", global_logfile); + ast_debug(3, "Opened log file %s \n", global_logfile); } return 0;