[asterisk-commits] murf: trunk r52086 - in /trunk: UPGRADE.txt apps/app_chanisavail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 24 13:35:55 MST 2007


Author: murf
Date: Wed Jan 24 14:35:54 2007
New Revision: 52086

URL: http://svn.digium.com/view/asterisk?view=rev&rev=52086
Log:
As per bug 8859 (Add option to revert old ChanIsAvail() with 's' option behavior), this update makes the 't' option available, which calls ast_parse_device_state instead of ast_device_state. This option will not dive into the channel driver to find the status of the device (which could be good if sip devicestate isn't returning full status, for various reasons).

Modified:
    trunk/UPGRADE.txt
    trunk/apps/app_chanisavail.c

Modified: trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/trunk/UPGRADE.txt?view=diff&rev=52086&r1=52085&r2=52086
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Wed Jan 24 14:35:54 2007
@@ -31,3 +31,6 @@
   to make them more distinguishable from 'maxmsgs', which sets folder
   size.  The old variables will continue to work in this version, albeit
   with a deprecation warning.
+* ChanIsAvail() now has a 't' option, which allows the specified device
+  to be queried for state without consulting the channel drivers. This
+  performs mostly a 'ChanExists' sort of function.

Modified: trunk/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanisavail.c?view=diff&rev=52086&r1=52085&r2=52086
==============================================================================
--- trunk/apps/app_chanisavail.c (original)
+++ trunk/apps/app_chanisavail.c Wed Jan 24 14:35:54 2007
@@ -61,12 +61,14 @@
 "  ${AVAILSTATUS}   - the status code for the available channel\n"
 "  Options:\n"
 "    s - Consider the channel unavailable if the channel is in use at all\n"
+"    t - Simply checks if specified channels exist in the channel list\n"
+"        (implies option s) \n"
 "    j - Support jumping to priority n+101 if no channel is available\n";
 
 
 static int chanavail_exec(struct ast_channel *chan, void *data)
 {
-	int res=-1, inuse=-1, option_state=0, priority_jump=0;
+	int res=-1, inuse=-1, option_state=0, priority_jump=0, string_compare=0;
 	int status;
 	struct ast_module_user *u;
 	char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur;
@@ -90,6 +92,8 @@
 	if (args.options) {
 		if (strchr(args.options, 's'))
 			option_state = 1;
+		if (strchr(args.options, 't'))
+			string_compare = 1;
 		if (strchr(args.options, 'j'))
 			priority_jump = 1;
 	}
@@ -113,7 +117,13 @@
 			*number = '\0';
 			number++;
 			
-			if (option_state) {
+			if (string_compare) {
+				/* ast_parse_device_state checks for "SIP/1234" as a channel name. 
+				   ast_device_state will ask the SIP driver for the channel state. */
+
+				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
+				status = inuse = ast_parse_device_state(trychan);
+			} else if (option_state) {
 				/* If the pbx says in use then don't bother trying further.
 				   This is to permit testing if someone's on a call, even if the 
 	 			   channel can permit more calls (ie callwaiting, sip calls, etc).  */



More information about the asterisk-commits mailing list