Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 211346) +++ apps/app_voicemail.c (working copy) @@ -387,6 +387,8 @@ static char externnotify[160]; static char vmfmts[80]; +static char archive[256]; +static int volgain; static int vmminmessage; static int vmmaxmessage; static int maxgreet; @@ -1680,6 +1682,8 @@ char dur[PATH_MAX]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[PATH_MAX]; + char newtmp[256]; + char tmpcmd[256]; time_t t; struct tm tm; struct vm_zone *the_zone = NULL; @@ -1815,9 +1819,18 @@ char *ctype = "audio/x-"; if (!strcasecmp(format, "ogg")) ctype = "application/"; - + char *ctypeformat = format; + snprintf(newtmp, sizeof(newtmp), "%s/%s-XXXXXX", archive, mailbox); + mkstemp(newtmp); + ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp); + if (volgain) { + snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %d %s.%s %s.%s", volgain, attach, format, newtmp, format); + ast_safe_system(tmpcmd); + attach = newtmp; + ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %d - Mailbox: %s\n", attach, format, volgain, mailbox); + } fprintf(p, "--%s\n", bound); - fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, format, msgnum, format); + fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, ctypeformat, msgnum, format); fprintf(p, "Content-Transfer-Encoding: base64\n"); fprintf(p, "Content-Description: Voicemail sound attachment.\n"); fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"\n\n", msgnum, format); @@ -1825,6 +1838,8 @@ snprintf(fname, sizeof(fname), "%s.%s", attach, format); base_encode(fname, p); fprintf(p, "\n\n--%s--\n.\n", bound); + snprintf(tmpcmd, sizeof(tmpcmd), "rm -f %s", newtmp); + ast_safe_system(tmpcmd); } fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); @@ -5966,6 +5981,8 @@ char *exitcxt = NULL; char *extpc; char *emaildateformatstr; + char *volgainstr; + char *archivestr; int x; int tmpadsi[4]; @@ -6002,6 +6019,18 @@ astsearch = "no"; ast_set2_flag((&globalflags), ast_true(astsearch), VM_SEARCH); + if (!(volgainstr = ast_variable_retrieve(cfg, "general", "volgain"))) { + volgain = 0; + } else { + volgain = atoi(volgainstr); + } + + if (!(archivestr = ast_variable_retrieve(cfg, "general", "archivedir"))) { + snprintf(archive, sizeof(archive), "/tmp"); + } else { + strcpy(archive, archivestr); + } + #ifdef USE_ODBC_STORAGE strcpy(odbc_database, "asterisk"); if ((thresholdstr = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {