[svn-commits] branch bweschke/findme_followme r32498 - /team/bweschke/findme_followme/apps/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jun 6 00:09:56 MST 2006


Author: bweschke
Date: Tue Jun  6 02:09:55 2006
New Revision: 32498

URL: http://svn.digium.com/view/asterisk?rev=32498&view=rev
Log:
 Ready to be merged...


Modified:
    team/bweschke/findme_followme/apps/app_followme.c

Modified: team/bweschke/findme_followme/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_followme.c?rev=32498&r1=32497&r2=32498&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_followme.c (original)
+++ team/bweschke/findme_followme/apps/app_followme.c Tue Jun  6 02:09:55 2006
@@ -120,6 +120,7 @@
 	char plsholdprompt[AST_CONFIG_MAX_PATH];
 	char statusprompt[AST_CONFIG_MAX_PATH];
 	char sorryprompt[AST_CONFIG_MAX_PATH];
+	struct ast_flags followmeflags;
 };
 
 struct findme_user {
@@ -132,6 +133,18 @@
 	int cleared;
 	AST_LIST_ENTRY(findme_user) entry;	
 };
+
+enum {
+	FOLLOWMEFLAG_STATUSMSG = (1 << 0),
+	FOLLOWMEFLAG_RECORDNAME = (1 << 1),
+	FOLLOWMEFLAG_UNREACHABLEMSG = (1 << 2)
+};
+
+AST_APP_OPTIONS(followme_opts, {
+	AST_APP_OPTION('s', FOLLOWMEFLAG_STATUSMSG ),
+	AST_APP_OPTION('a', FOLLOWMEFLAG_RECORDNAME ),
+	AST_APP_OPTION('n', FOLLOWMEFLAG_UNREACHABLEMSG ),
+});
 
 static int ynlongest = 0;
 static char toast[80];
@@ -376,9 +389,9 @@
 							numorder = 0;
 						timeout = atoi(timeoutstr);
 						if (timeout < 0) 
-							timeout = 12;
+							timeout = 25;
 					} else {
-						timeout = 12;
+						timeout = 25;
 						numorder = 0;
 					}
 
@@ -503,15 +516,27 @@
 					if (tmpuser->digts && (tmpuser->digts > featuredigittimeout)) {
 						if (option_verbose > 2)
 							ast_verbose(VERBOSE_PREFIX_3 "We've been waiting for digits longer than we should have.\n");
-						tmpuser->state = 1;
-						tmpuser->digts = 0;
-						if (!ast_streamfile(tmpuser->ochan, callfromname, tmpuser->ochan->language)) {
-							ast_sched_runq(tmpuser->ochan->sched);
+						if (!ast_strlen_zero(namerecloc)) {
+							tmpuser->state = 1;
+							tmpuser->digts = 0;
+							if (!ast_streamfile(tmpuser->ochan, callfromname, tmpuser->ochan->language)) {
+								ast_sched_runq(tmpuser->ochan->sched);
+							} else {
+								ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
+								free(to);
+								return NULL;
+							}							
 						} else {
-							ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
-							free(to);
-							return NULL;
-						}							
+							tmpuser->state = 2;
+							tmpuser->digts = 0;
+							if (!ast_streamfile(tmpuser->ochan, tpargs->norecordingprompt, tmpuser->ochan->language))
+								ast_sched_runq(tmpuser->ochan->sched);
+							else {
+								ast_log(LOG_WARNING, "Unable to playback %s.\n", tpargs->norecordingprompt);
+								free(to);
+								return NULL;
+							}
+						}
 					}
 					if (tmpuser->ochan->stream) {
 						ast_sched_runq(tmpuser->ochan->sched);
@@ -601,7 +626,6 @@
 							}
 							break;
 						case AST_CONTROL_ANSWER:
-							/* This is our guy if someone answered. */
 							if (option_verbose > 2)
 								ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", winner->name, caller->name);
 							/* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
@@ -610,14 +634,25 @@
 							if (option_verbose > 2)
 								ast_verbose( VERBOSE_PREFIX_3 "Starting playback of %s\n", callfromname);
 							if (dg > 0) {
-								if (!ast_streamfile(winner, callfromname, winner->language)) {
-									ast_sched_runq(winner->sched);
-									tmpuser->state = 1;
-								} else {
-									ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
-									free(to);
-									return NULL;
-								}							
+								if (!ast_strlen_zero(namerecloc)) {
+									if (!ast_streamfile(winner, callfromname, winner->language)) {
+										ast_sched_runq(winner->sched);
+										tmpuser->state = 1;
+									} else {
+										ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
+										free(to);
+										return NULL;
+									}				
+								} else {			
+									tmpuser->state = 2;
+									if (!ast_streamfile(tmpuser->ochan, tpargs->norecordingprompt, tmpuser->ochan->language))
+										ast_sched_runq(tmpuser->ochan->sched);
+									else {
+										ast_log(LOG_WARNING, "Unable to playback %s.\n", tpargs->norecordingprompt);
+										free(to);
+										return NULL;
+									}
+								}
 							}
 							break;
 						case AST_CONTROL_BUSY:
@@ -905,6 +940,7 @@
 	
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(followmeid);
+		AST_APP_ARG(options);
 	);
 	
 	if (!(argstr = ast_strdupa((char *)data))) {
@@ -921,7 +957,7 @@
 
 	AST_STANDARD_APP_ARGS(args, argstr);
 
-	if (!ast_strlen_zero(args.followmeid) && (option_debug > 2)) 
+	if (!ast_strlen_zero(args.followmeid)) 
 	
 			AST_LIST_LOCK(&followmes);
 			AST_LIST_TRAVERSE(&followmes, f, entry) {
@@ -941,6 +977,11 @@
 			{
 	
 				/* XXX TODO: Reinsert the db check value to see whether or not follow-me is on or off */
+
+
+				if (args.options) {
+					ast_app_parse_options(followme_opts, &targs.followmeflags, NULL, args.options);
+				}
 
 				/* Lock the profile lock and copy out everything we need to run with before unlocking it again */
 				ast_mutex_lock(&f->lock);
@@ -963,10 +1004,21 @@
 				}
 				ast_mutex_unlock(&f->lock);
 
+				if (targs.followmeflags.flags & FOLLOWMEFLAG_STATUSMSG) 
+					ast_stream_and_wait(chan, targs.statusprompt, chan->language, "");
+
 				snprintf(namerecloc,sizeof(namerecloc),"%s/followme.%s",ast_config_AST_SPOOL_DIR,chan->uniqueid);
 				duration = 5;
-				if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, 128, 0, NULL) < 0)
-					goto outrun;
+
+				if (targs.followmeflags.flags & FOLLOWMEFLAG_RECORDNAME) 
+					if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, 128, 0, NULL) < 0)
+						goto outrun;
+
+				/* The following call looks like we're going to playback the file, but we're actually	*/
+				/* just checking to see if we *can* play it. 						*/
+				if (ast_streamfile(chan, namerecloc, chan->language))
+					ast_copy_string(namerecloc, "", sizeof(namerecloc));					
+
 				if (ast_streamfile(chan, targs.plsholdprompt, chan->language))
 					goto outrun;
 				if (ast_waitstream(chan, "") < 0)
@@ -990,10 +1042,14 @@
 				}
 				AST_LIST_TRAVERSE_SAFE_END
 	
-				unlink(namerecloc);	
+				if (!ast_strlen_zero(namerecloc))
+					unlink(namerecloc);	
+
 				if (targs.status != 100)
 				{
 					ast_moh_stop(chan);
+					if (targs.followmeflags.flags & FOLLOWMEFLAG_UNREACHABLEMSG) 
+						ast_stream_and_wait(chan, targs.sorryprompt, chan->language, "");
 					res = 0;
 				}
 				else



More information about the svn-commits mailing list