make pager messages configurable (issue #4829)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6361 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
81f971522d
commit
77ffeda4e8
|
@ -343,6 +343,8 @@ static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64];
|
|||
|
||||
static char *emailbody = NULL;
|
||||
static char *emailsubject = NULL;
|
||||
static char *pagerbody = NULL;
|
||||
static char *pagersubject = NULL;
|
||||
static char fromstring[100];
|
||||
static char pagerfromstring[100];
|
||||
static char emailtitle[100];
|
||||
|
@ -1762,10 +1764,39 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char
|
|||
} else
|
||||
fprintf(p, "From: Asterisk PBX <%s>\n", who);
|
||||
fprintf(p, "To: %s\n", pager);
|
||||
fprintf(p, "Subject: New VM\n\n");
|
||||
if (pagersubject) {
|
||||
struct ast_channel *ast = ast_channel_alloc(0);
|
||||
if (ast) {
|
||||
char *passdata;
|
||||
int vmlen = strlen(pagersubject)*3 + 200;
|
||||
if ((passdata = alloca(vmlen))) {
|
||||
memset(passdata, 0, vmlen);
|
||||
prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
|
||||
pbx_substitute_variables_helper(ast,pagersubject,passdata,vmlen);
|
||||
fprintf(p, "Subject: %s\n\n",passdata);
|
||||
} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
|
||||
ast_channel_free(ast);
|
||||
} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
|
||||
} else
|
||||
fprintf(p, "Subject: New VM\n\n");
|
||||
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
|
||||
fprintf(p, "New %s long msg in box %s\n"
|
||||
"from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
|
||||
if (pagerbody) {
|
||||
struct ast_channel *ast = ast_channel_alloc(0);
|
||||
if (ast) {
|
||||
char *passdata;
|
||||
int vmlen = strlen(pagerbody)*3 + 200;
|
||||
if ((passdata = alloca(vmlen))) {
|
||||
memset(passdata, 0, vmlen);
|
||||
prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
|
||||
pbx_substitute_variables_helper(ast,pagerbody,passdata,vmlen);
|
||||
fprintf(p, "%s\n",passdata);
|
||||
} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
|
||||
ast_channel_free(ast);
|
||||
} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
|
||||
} else {
|
||||
fprintf(p, "New %s long msg in box %s\n"
|
||||
"from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
|
||||
}
|
||||
fclose(p);
|
||||
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
|
||||
ast_safe_system(tmp2);
|
||||
|
@ -5768,6 +5799,14 @@ static int load_config(void)
|
|||
free(emailsubject);
|
||||
emailsubject = NULL;
|
||||
}
|
||||
if (pagerbody) {
|
||||
free(pagerbody);
|
||||
pagerbody = NULL;
|
||||
}
|
||||
if (pagersubject) {
|
||||
free(pagersubject);
|
||||
pagersubject = NULL;
|
||||
}
|
||||
if ((s=ast_variable_retrieve(cfg, "general", "pbxskip")))
|
||||
ast_set2_flag((&globalflags), ast_true(s), VM_PBXSKIP);
|
||||
if ((s=ast_variable_retrieve(cfg, "general", "fromstring")))
|
||||
|
@ -5804,6 +5843,31 @@ static int load_config(void)
|
|||
|
||||
/* substitute strings \t and \n into the apropriate characters */
|
||||
tmpread = tmpwrite = emailbody;
|
||||
while ((tmpwrite = strchr(tmpread,'\\'))) {
|
||||
int len = strlen("\n");
|
||||
switch (tmpwrite[1]) {
|
||||
case 'n':
|
||||
strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
|
||||
strncpy(tmpwrite,"\n",len);
|
||||
break;
|
||||
case 't':
|
||||
strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
|
||||
strncpy(tmpwrite,"\t",len);
|
||||
break;
|
||||
default:
|
||||
ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n",tmpwrite[1]);
|
||||
}
|
||||
tmpread = tmpwrite+len;
|
||||
}
|
||||
}
|
||||
if ((s=ast_variable_retrieve(cfg, "general", "pagersubject")))
|
||||
pagersubject = strdup(s);
|
||||
if ((s=ast_variable_retrieve(cfg, "general", "pagerbody"))) {
|
||||
char *tmpread, *tmpwrite;
|
||||
pagerbody = strdup(s);
|
||||
|
||||
/* substitute strings \t and \n into the apropriate characters */
|
||||
tmpread = tmpwrite = pagerbody;
|
||||
while ((tmpwrite = strchr(tmpread,'\\'))) {
|
||||
int len = strlen("\n");
|
||||
switch (tmpwrite[1]) {
|
||||
|
|
|
@ -52,10 +52,7 @@ maxlogins=3
|
|||
; Permit finding entries for forward/compose from the directory
|
||||
;usedirectory=yes
|
||||
;
|
||||
;Change the From: string for pager messages
|
||||
;pagerfromstring=The Asterisk PBX
|
||||
;
|
||||
; Change the email body and/or subject, variables:
|
||||
; Change the from, body and/or subject, variables:
|
||||
; VM_NAME, VM_DUR, VM_MSGNUM, VM_MAILBOX, VM_CALLERID, VM_CIDNUM, VM_CIDNAME, VM_DATE
|
||||
;
|
||||
; Note: The emailbody config row can be up to 512 characters due to a limitation in
|
||||
|
@ -64,13 +61,19 @@ maxlogins=3
|
|||
; The following definition is very close to the default, but the default shows just
|
||||
; the CIDNAME, if it is not null, else just the CIDNUM, or "an unknown caller" if they are both null.
|
||||
;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}, so you might\nwant to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n
|
||||
;
|
||||
; You can also change the Pager From: string, the pager body and/or subject.
|
||||
; The above defined variables also can be used here
|
||||
;pagerfromstring=The Asterisk PBX
|
||||
;pagersubject=New VM
|
||||
;pagerbody=New ${VM_DUR} long msg in box ${VM_MAILBOX}\nfrom ${VM_CALLERID}, on ${VM_DATE}
|
||||
;
|
||||
; Set the date format on outgoing mails. Valid arguments can be found on the strftime(3) man page
|
||||
;
|
||||
; Default
|
||||
emaildateformat=%A, %B %d, %Y at %r
|
||||
; 24h date format
|
||||
;emaildateformat=%A, %d %B %Y at %H:%M:%S
|
||||
|
||||
;
|
||||
; You can override the default program to send e-mail if you wish, too
|
||||
;
|
||||
|
|
Reference in New Issue