mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 20:38:59 +00:00 
			
		
		
		
	Add n+101 jump if file does not exist (bug #2722)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4099 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		@@ -35,7 +35,7 @@ static char *descrip =
 | 
				
			|||||||
"  be included following a pipe symbol.  You can use * and # to rewind and\n"
 | 
					"  be included following a pipe symbol.  You can use * and # to rewind and\n"
 | 
				
			||||||
"  fast forward the playback specified. If 'stopchar' is added the file will\n"
 | 
					"  fast forward the playback specified. If 'stopchar' is added the file will\n"
 | 
				
			||||||
"  terminate playback when 'stopchar' is pressed. Returns -1 if the channel\n"
 | 
					"  terminate playback when 'stopchar' is pressed. Returns -1 if the channel\n"
 | 
				
			||||||
"  was hung up, or if the file does not exist. Returns 0 otherwise.\n\n"
 | 
					"  was hung up. if the file does not exist jumps to n+101 if it present.\n\n"
 | 
				
			||||||
"  Example:  exten => 1234,1,ControlPlayback(file|4000|*|#|1|0)\n\n";
 | 
					"  Example:  exten => 1234,1,ControlPlayback(file|4000|*|#|1|0)\n\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
STANDARD_LOCAL_USER;
 | 
					STANDARD_LOCAL_USER;
 | 
				
			||||||
@@ -55,6 +55,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
 | 
				
			|||||||
	char tmp[256];
 | 
						char tmp[256];
 | 
				
			||||||
	char *skip = NULL, *fwd = NULL, *rev = NULL, *stop = NULL, *pause = NULL, *file = NULL;
 | 
						char *skip = NULL, *fwd = NULL, *rev = NULL, *stop = NULL, *pause = NULL, *file = NULL;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!data || ast_strlen_zero((char *)data)) {
 | 
						if (!data || ast_strlen_zero((char *)data)) {
 | 
				
			||||||
		ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
 | 
							ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
@@ -111,6 +112,11 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
 | 
				
			|||||||
	if(stop && strchr(stop, res)) 
 | 
						if(stop && strchr(stop, res)) 
 | 
				
			||||||
		res = 0;
 | 
							res = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(res < 0) {
 | 
				
			||||||
 | 
							if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
 | 
				
			||||||
 | 
					            chan->priority+=100;
 | 
				
			||||||
 | 
							res = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,8 +36,8 @@ static char *descrip =
 | 
				
			|||||||
"specified, the application will return immediately should the channel not be\n"
 | 
					"specified, the application will return immediately should the channel not be\n"
 | 
				
			||||||
"off hook.  Otherwise, unless 'noanswer' is specified, the channel channel will\n"
 | 
					"off hook.  Otherwise, unless 'noanswer' is specified, the channel channel will\n"
 | 
				
			||||||
"be answered before the sound is played. Not all channels support playing\n"
 | 
					"be answered before the sound is played. Not all channels support playing\n"
 | 
				
			||||||
"messages while still hook. Returns -1 if the channel was hung up, or if the\n"
 | 
					"messages while still hook. Returns -1 if the channel was hung up.  If the\n"
 | 
				
			||||||
"file does not exist. Returns 0 otherwise.\n";
 | 
					"file does not exist, will jump to priority n+101 if present.\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
STANDARD_LOCAL_USER;
 | 
					STANDARD_LOCAL_USER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -81,6 +81,8 @@ static int playback_exec(struct ast_channel *chan, void *data)
 | 
				
			|||||||
			res = ast_waitstream(chan, "");
 | 
								res = ast_waitstream(chan, "");
 | 
				
			||||||
		else {
 | 
							else {
 | 
				
			||||||
			ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
 | 
								ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
 | 
				
			||||||
 | 
								if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
 | 
				
			||||||
 | 
									chan->priority+=100;
 | 
				
			||||||
			res = 0;
 | 
								res = 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ast_stopstream(chan);
 | 
							ast_stopstream(chan);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user