[Asterisk-Dev] Voicemail Envelope (cid, date/time playback)
Brad Bergman
bradley at bergman.ca
Fri Jun 27 02:48:58 MST 2003
Inspired by Tilghman Lesher's "Patch for voicemail date/time" and the
voicemail details that can be displayed on an ADSI phone, I thought I'd
see what I could do about an audible message envelope feature--something
that's commonly available on various voicemail systems. Not being a
programmer, I'd hesitate to call this a patch, more something worth (if
anything) a look, and I thought I'd see if anyone has any thoughts.
A couple of obvious deficiencies: it relies on the precious spare '3' key
to trigger the envelope playback, the envelope can't be interrupted by any
DTMF sequence, and it uses voice prompts that don't exist... other than
that it seems to me to work okay.
diff -rcs app_voicemail2.c app_voicemail2.c.bwb
*** app_voicemail2.c 2003-06-27 03:14:43.000000000 -0600
--- app_voicemail2.c.bwb 2003-06-27 03:14:30.000000000 -0600
***************
*** 1999,2004 ****
--- 1999,2006 ----
if (!res)
res = play_and_wait(chan, "vm-toforward");
if (!res)
+ res = play_and_wait(chan, "vm-getenvelope");
+ if (!res)
res = play_and_wait(chan, "vm-savemessage");
}
}
***************
*** 2277,2282 ****
--- 2279,2289 ----
cmd = play_and_wait(chan, "vm-messages");
vms.starting = 1;
break;
+
+ case '3':
+ cmd = message_envelope(chan, vms.fn);
+ break;
+
case '4':
if (vms.curmsg) {
vms.curmsg--;
***************
*** 2613,2618 ****
--- 2620,2695 ----
}
}
+
+ static int message_envelope(struct ast_channel *chan, char *fn)
+ {
+ int res = 0;
+ char filename[256], buf[256];
+ char cid[256];
+ char *name, *num;
+ char datetime[21]="";
+ char *val;
+ FILE *f;
+
+ time_t t;
+ /* Get envelope info */
+
+ snprintf(filename, sizeof(filename), "%s.txt", fn);
+
+ f = fopen(filename, "r");
+
+ if (f) {
+
+ while(!feof(f)) {
+ fgets(buf, sizeof(buf), f);
+ if (!feof(f)) {
+ char *stringp = NULL;
+ stringp=buf;
+ strsep(&stringp, "=");
+ val = strsep(&stringp, "=");
+ if (val && strlen(val)) {
+ if (!strcmp(buf, "callerid"))
+
+ strncpy(cid, val,
sizeof(cid) -1);
+ if (!strcmp(buf, "origtime"))
+ strncpy(datetime, val,
sizeof(datetime) - 1);
+ }
+ }
+ }
+ fclose(f);
+
+ /* Read calling party number */
+
+ if (strlen(cid)) {
+ ast_streamfile(chan, "vm-from", chan->language);
+ ast_waitstream(chan, "");
+ ast_callerid_parse(cid, &name, &num);
+ ast_say_digit_str(chan, num, "", chan->language);
+
+
+ } else {
+ ast_streamfile(chan, "unknown-caller", chan->language);
+ ast_waitstream(chan, "");
+ }
+
+ /* Read date */
+
+ ast_streamfile(chan, "vm-received", chan->language);
+ ast_waitstream(chan, "");
+
+ sscanf(datetime,"%i",&t);
+
+ res = ast_say_datetime(chan, t, "", chan->language);
+
+ return res;
+
+ }
+
+
+ return res;
+ }
+
+
int reload(void)
{
return(load_config());
More information about the asterisk-dev
mailing list