Subject: [Asterisk-Users] new application Dialtone() Date: Wed, 4 Jun 2003 16:16:49 -0700 From: "Surfer Dude" Reply-To: asterisk-users@lists.digium.com Organization: Swell, Inc. To: Hello, I created a new application for myself called Dialtone() by modifing res/res_indications.c file. It can be used as such: exten => s,4,Dialtone(30|${CALLERIDNUM}) exten => s,5,Playback(time-exceeded) exten => s,6,Goto(s|1) It will stutter if you have new voicemail and you have passed the mailbox number as I did above. It will stop dialtone the moment you press a key or the timeout (in seconds) has occured. This is my first stab at asterisk so I am not 100% that this is where the code should live. If there is someone out there that wants to add it to (*) then please feel free. I can send you the whole file if you need. I needed this application because I need to set immediate=yes so that I can set some variables when the phone is picked up. Thanks, Jason [root@zapata res]# cvs diff res_indications.c Index: res_indications.c =================================================================== RCS file: /usr/cvsroot/asterisk/res/res_indications.c,v retrieving revision 1.2 diff -r1.2 res_indications.c 31a32,33 > #include > #include 212a215,263 > * Dialtone > */ > static int handle_dialtone(struct ast_channel *chan, void *data) > { > struct tone_zone_sound *ts; > int res; > char tmp[256]; > char *stringp, *mailbox, *stimeout; > int timeout; > > stringp = mailbox = stimeout = NULL; > timeout = 10000; > > strncpy(tmp, data, sizeof(tmp)-1), > stringp = tmp; > > stimeout = strsep(&stringp, "|"); > if(stimeout && stimeout[0]) { > mailbox = strsep(&stringp, "|"); > timeout = atoi(stimeout) * 1000; > } > > > if(mailbox && ast_app_has_voicemail(mailbox)) { > ts = ast_get_indication_tone(chan->zone, "dialrecall"); > if (option_verbose > 2) > ast_verbose(VERBOSE_PREFIX_3 "Dialtone: playing dialrecall for %d mili seconds\n", timeout); > } else { > ts = ast_get_indication_tone(chan->zone, "dial"); > if (option_verbose > 2) > ast_verbose(VERBOSE_PREFIX_3 "Dialtone: playing dial for %d mili seconds\n", timeout); > } > > ast_playtones_stop(chan); > res = ast_playtones_start(chan, 0, ts->data, 0); > > if (res) > ast_log(LOG_NOTICE,"Unable to start playtones\n"); > > if (!res) { > res = ast_waitfordigit(chan, (const int) timeout); > ast_playtones_stop(chan); > } > > return 0; > } > > > /* 380a432,440 > ast_register_application( > "Dialtone", > handle_dialtone, > "Play a dialtone while awaiting extension", > " Dialtone([timeout[|mailbox]]): Plays a dialtone, including an initial stutter\n" > "on new voicemail, if optional mailbox is specified, while simultaneously waiting\n" > "for the user to begin typing an extension or the timeout occurs. Timeout parameter\n" > "is in seconds. Default timeout is 60 seconds. Returns 0\n" > ); _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users