--- app_minivm.c 2008-12-05 11:10:38.000000000 -0500 +++ app_minivm.c.new 2008-12-05 11:08:02.000000000 -0500 @@ -208,13 +208,13 @@ This 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 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 @@ -256,7 +256,7 @@ 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. @@ -296,7 +296,7 @@ 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 @@ -317,7 +317,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. @@ -362,7 +362,7 @@ 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. @@ -644,7 +644,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")) { @@ -961,7 +961,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) { @@ -972,7 +972,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 @@ -985,7 +985,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"); } } @@ -1061,7 +1061,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"; @@ -1079,7 +1079,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); } @@ -1088,7 +1088,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 */ @@ -1099,7 +1099,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); @@ -1163,7 +1163,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; @@ -1175,7 +1175,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; @@ -1197,11 +1197,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"); } @@ -1236,7 +1236,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/"; @@ -1253,7 +1253,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; @@ -1311,7 +1311,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); @@ -1326,10 +1326,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; @@ -1366,7 +1366,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 */ @@ -1400,6 +1400,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"); @@ -1548,7 +1553,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); @@ -1565,9 +1570,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); @@ -1624,7 +1629,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; } @@ -1642,7 +1647,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; @@ -1666,7 +1671,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; } @@ -1723,14 +1728,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; @@ -1758,7 +1763,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; } @@ -1875,7 +1880,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; } @@ -1897,7 +1902,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)) @@ -1957,10 +1962,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; } @@ -1979,7 +1984,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; @@ -2016,7 +2021,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"); @@ -2048,7 +2053,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)) { @@ -2088,7 +2093,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; @@ -2120,7 +2125,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) { @@ -2133,14 +2138,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); @@ -2175,15 +2180,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; @@ -2254,7 +2259,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; } @@ -2268,10 +2273,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"; @@ -2328,7 +2333,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")) { @@ -2381,7 +2386,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; } @@ -2618,13 +2623,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)); @@ -2700,7 +2705,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;