Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 24050) +++ apps/app_voicemail.c (working copy) @@ -399,6 +399,8 @@ static struct ast_smdi_interface *smdi_iface = NULL; #endif static char vmfmts[80]; +static char archive[256]; +static int volgain; static int vmminmessage; static int vmmaxmessage; static int maxgreet; @@ -1691,6 +1693,8 @@ char dur[256]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[256]; + char newtmp[256]; + char tmpcmd[256]; struct tm tm; if (vmu && ast_strlen_zero(vmu->email)) { @@ -1793,9 +1797,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); @@ -1803,6 +1816,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); @@ -5959,6 +5974,8 @@ char *exitcxt = NULL; char *extpc; char *emaildateformatstr; + char *volgainstr; + char *archivestr; int x; int tmpadsi[4]; @@ -5989,6 +6006,16 @@ 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"))) {