aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-11 17:37:35 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-11 17:37:35 +0000
commitc729fc22e98dc349bf2bd09d1840a3ea7e7e609d (patch)
treedbb974795b256ad5a4a8333a113a5b6b0bd70f91
parentd11c0abe77a5c2de692643f4ac175d420cb448ba (diff)
Add pager stuff
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@829 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_voicemail.c44
-rwxr-xr-xconfigs/voicemail.conf.sample4
2 files changed, 45 insertions, 3 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 88f43b75e..50427e3a6 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -391,6 +391,45 @@ static int sendmail(char *srcemail, char *email, char *name, int msgnum, char *m
return 0;
}
+static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char *callerid, long duration)
+{
+ FILE *p;
+ char date[256];
+ char host[256];
+ char who[256];
+ char dur[256];
+ time_t t;
+ struct tm tm;
+ struct ast_config *cfg;
+ p = popen(SENDMAIL, "w");
+ cfg = ast_load(VOICEMAIL_CONFIG);
+
+ if (p) {
+ gethostname(host, sizeof(host));
+ if (strchr(srcemail, '@'))
+ strncpy(who, srcemail, sizeof(who)-1);
+ else {
+ snprintf(who, sizeof(who), "%s@%s", srcemail, host);
+ }
+ snprintf(dur, sizeof(dur), "%ld:%02ld", duration / 60, duration % 60);
+ time(&t);
+ localtime_r(&t,&tm);
+ strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
+ fprintf(p, "Date: %s\n", date);
+ fprintf(p, "From: Asterisk PBX <%s>\n", who);
+ fprintf(p, "To: %s\n", pager);
+ fprintf(p, "Subject: New voicemail\n\n");
+ strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
+ fprintf(p, "New %s long message in mailbox %s\n"
+ "from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
+ pclose(p);
+ } else {
+ ast_log(LOG_WARNING, "Unable to launch '%s'\n", SENDMAIL);
+ return -1;
+ }
+ return 0;
+}
+
static int get_date(char *s, int len)
{
struct tm tm;
@@ -436,7 +475,7 @@ static int invent_message(struct ast_channel *chan, char *ext, int busy, char *e
static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int busy, int unavail)
{
struct ast_config *cfg;
- char *copy, *name, *passwd, *email, *fmt, *fmts;
+ char *copy, *name, *passwd, *email, *pager, *fmt, *fmts;
char comment[256];
struct ast_filestream *writer=NULL, *others[MAX_OTHER_FORMATS];
char *sfmt[MAX_OTHER_FORMATS];
@@ -485,6 +524,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
passwd = strsep(&stringp, ",");
name = strsep(&stringp, ",");
email = strsep(&stringp, ",");
+ pager = strsep(&stringp, ",");
make_dir(dir, sizeof(dir), ext, "");
/* It's easier just to try to make it than to check for its existence */
if (mkdir(dir, 0700) && (errno != EEXIST))
@@ -712,6 +752,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
/* Send e-mail if applicable */
if (email)
sendmail(astemail, email, name, msgnum, ext, chan->callerid, fn, wavother ? "wav" : fmts, end - start);
+ if (pager)
+ sendpage(astemail, pager, msgnum, ext, chan->callerid, end - start);
}
} else {
if (msgnum < MAXMSG)
diff --git a/configs/voicemail.conf.sample b/configs/voicemail.conf.sample
index 1b76e1916..f88887ccc 100755
--- a/configs/voicemail.conf.sample
+++ b/configs/voicemail.conf.sample
@@ -18,9 +18,9 @@ attach=yes
skipms=3000
;
-; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>
+; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>
; if the e-mail is specified, a message will be sent when a message is
-; received, to the given mailbox.
+; received, to the given mailbox. If pager is specified, a message will be sent there as well.
;
[default]
1234 => 4242,Example Mailbox,root@localhost