[Asterisk-cvs] asterisk pbx.c,1.268,1.269

kpfleming kpfleming
Mon Aug 29 19:52:10 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv14716

Modified Files:
	pbx.c 
Log Message:
massive upgrade to SUBSCRIBE, device state and messaging support (issue #3644)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.268
retrieving revision 1.269
diff -u -d -r1.268 -r1.269
--- pbx.c	29 Aug 2005 22:03:37 -0000	1.268
+++ pbx.c	29 Aug 2005 23:53:29 -0000	1.269
@@ -1731,7 +1731,7 @@
 	char *cur, *rest;
 	int res = -1;
 	int allunavailable = 1, allbusy = 1, allfree = 1;
-	int busy = 0;
+	int busy = 0, inuse = 0, ring = 0;
 
 	if (!e)
 		return -1;
@@ -1742,7 +1742,7 @@
 	do {
 		rest = strchr(cur, '&');
 		if (rest) {
-	    		*rest = 0;
+			*rest = 0;
 			rest++;
 		}
 	
@@ -1753,7 +1753,15 @@
 			allbusy = 0;
 			break;
 		case AST_DEVICE_INUSE:
-			return AST_EXTENSION_INUSE;
+			inuse = 1;
+			allunavailable = 0;
+			allfree = 0;
+			break;
+		case AST_DEVICE_RINGING:
+			ring = 1;
+			allunavailable = 0;
+			allfree = 0;
+			break;
 		case AST_DEVICE_BUSY:
 			allunavailable = 0;
 			allfree = 0;
@@ -1772,7 +1780,13 @@
 		cur = rest;
 	} while (cur);
 
-	if (allfree)			
+	if (!inuse && ring)
+		return AST_EXTENSION_RINGING;
+	if (inuse && ring)
+		return (AST_EXTENSION_INUSE | AST_EXTENSION_RINGING);
+	if (inuse)
+		return AST_EXTENSION_INUSE;
+	if (allfree)
 		return AST_EXTENSION_NOT_INUSE;
 	if (allbusy)		
 		return AST_EXTENSION_BUSY;
@@ -1784,6 +1798,18 @@
 	return AST_EXTENSION_NOT_INUSE;
 }
 
+/*--- ast_extension_state2str: Return extension_state as string */
+const char *ast_extension_state2str(int extension_state)
+{
+	int i;
+
+	for (i = 0; (i < (sizeof(extension_states) / sizeof(extension_states[0]))); i++) {
+		if (extension_states[i].extension_state == extension_state) {
+			return extension_states[i].text;
+		}
+	}
+	return "Unknown";	
+}
 
 /*--- ast_extension_state: Check extension state for an extension by using hint */
 int ast_extension_state(struct ast_channel *c, char *context, char *exten)




More information about the svn-commits mailing list