[Asterisk-cvs] asterisk/apps app_voicemail.c,1.53,1.54
markster at lists.digium.com
markster at lists.digium.com
Mon Jan 26 18:45:46 CST 2004
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv3813/apps
Modified Files:
app_voicemail.c
Log Message:
Character set fixes, and add "mailcmd" option (bug #472)
Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- app_voicemail.c 13 Jan 2004 00:35:45 -0000 1.53
+++ app_voicemail.c 27 Jan 2004 00:37:47 -0000 1.54
@@ -67,6 +67,8 @@
#define VOICEMAIL_CONFIG "voicemail.conf"
#define ASTERISK_USERNAME "asterisk"
+/* Default mail command to mail voicemail. Change it with the
+ mailcmd= command in voicemail.conf */
#define SENDMAIL "/usr/sbin/sendmail -t"
#define INTRO "vm-intro"
@@ -91,6 +93,7 @@
unsigned char iobuf[BASEMAXINLINE];
};
+/* Structure for linked list of users */
struct ast_vm_user {
char context[80];
char mailbox[80];
@@ -99,6 +102,7 @@
char email[80];
char pager[80];
char serveremail[80];
+ char mailcmd[160]; /* Configurable mail command */
char zonetag[80];
int attach;
int alloced;
@@ -183,6 +187,8 @@
static int maxsilence;
static int silencethreshold = 128;
static char serveremail[80];
+static char mailcmd[160]; /* Configurable mail cmd */
+
static char vmfmts[80];
static int vmmaxmessage;
static int maxgreet;
@@ -194,6 +200,7 @@
static char fromstring[100];
static char emailtitle[100];
+
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@@ -382,6 +389,7 @@
#endif /* Postgres */
#ifndef USESQLVM
+
static struct ast_vm_user *find_user(struct ast_vm_user *ivm, char *context, char *mailbox)
{
/* This function could be made to generate one from a database, too */
@@ -675,7 +683,7 @@
if (!strcmp(format, "wav49"))
format = "WAV";
ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, attach_voicemail);
- p = popen(SENDMAIL, "w");
+ p = popen(mailcmd, "w");
if (p) {
gethostname(host, sizeof(host));
if (strchr(srcemail, '@'))
@@ -733,7 +741,7 @@
fprintf(p, "--%s\n", bound);
}
- fprintf(p, "Content-Type: TEXT/PLAIN; charset=US-ASCII\n\n");
+ fprintf(p, "Content-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: 8bit\n");
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
if (emailbody) {
struct ast_channel *ast = ast_channel_alloc(0);
@@ -764,7 +772,7 @@
if (attach_user_voicemail) {
fprintf(p, "--%s\n", bound);
fprintf(p, "Content-Type: audio/x-%s; name=\"msg%04d.%s\"\n", format, msgnum, format);
- fprintf(p, "Content-Transfer-Encoding: BASE64\n");
+ 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);
@@ -773,8 +781,9 @@
fprintf(p, "\n\n--%s--\n.\n", bound);
}
pclose(p);
+ ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd);
} else {
- ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
+ ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
return -1;
}
return 0;
@@ -790,7 +799,7 @@
time_t t;
struct tm tm;
struct vm_zone *the_zone = NULL;
- p = popen(SENDMAIL, "w");
+ p = popen(mailcmd, "w");
if (p) {
gethostname(host, sizeof(host));
@@ -830,8 +839,9 @@
fprintf(p, "New %s long msg in box %s\n"
"from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
pclose(p);
+ ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", who, mailcmd);
} else {
- ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
+ ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
return -1;
}
return 0;
@@ -3145,6 +3155,7 @@
char *thresholdstr;
char *fmt;
char *astemail;
+ char *astmailcmd = SENDMAIL;
char *s;
int x;
@@ -3168,10 +3179,18 @@
usersl = NULL;
if (cfg) {
/* General settings */
+
+ /* Attach voice message to mail message ? */
attach_voicemail = 1;
if (!(astattach = ast_variable_retrieve(cfg, "general", "attach")))
astattach = "yes";
attach_voicemail = ast_true(astattach);
+
+ /* Mail command */
+ strncpy(mailcmd, SENDMAIL, sizeof(mailcmd) - 1); /* Default */
+ if ((astmailcmd = ast_variable_retrieve(cfg, "general", "mailcmd")))
+ strncpy(mailcmd, astmailcmd, sizeof(mailcmd) - 1); /* User setting */
+
maxsilence = 0;
if ((silencestr = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
maxsilence = atoi(silencestr);
@@ -3179,6 +3198,8 @@
maxsilence *= 1000;
}
+
+ /* Silence treshold */
silencethreshold = 256;
if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold")))
silencethreshold = atoi(thresholdstr);
More information about the svn-commits
mailing list