[Asterisk-cvs] asterisk channel.c,1.143,1.144

markster at lists.digium.com markster at lists.digium.com
Tue Oct 26 18:22:19 CDT 2004


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

Modified Files:
	channel.c 
Log Message:
Pass concept of status back, permit "leaveempty" to work with static agents who are not loggedon (bug #2719)


Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- channel.c	24 Oct 2004 02:53:24 -0000	1.143
+++ channel.c	26 Oct 2004 22:25:42 -0000	1.144
@@ -65,7 +65,7 @@
 	char type[80];
 	char description[80];
 	int capabilities;
-	struct ast_channel * (*requester)(const char *type, int format, void *data);
+	struct ast_channel * (*requester)(const char *type, int format, void *data, int *cause);
 	int (*devicestate)(void *data);
 	struct chanlist *next;
 } *backends = NULL;
@@ -154,13 +154,13 @@
 }
 
 int ast_channel_register(const char *type, const char *description, int capabilities,
-		struct ast_channel *(*requester)(const char *type, int format, void *data))
+		struct ast_channel *(*requester)(const char *type, int format, void *data, int *cause))
 {
 	return ast_channel_register_ex(type, description, capabilities, requester, NULL);
 }
 
 int ast_channel_register_ex(const char *type, const char *description, int capabilities,
-		struct ast_channel *(*requester)(const char *type, int format, void *data),
+		struct ast_channel *(*requester)(const char *type, int format, void *data, int *cause),
 		int (*devicestate)(void *data))
 {
 	struct chanlist *chan, *last=NULL;
@@ -1751,11 +1751,12 @@
 struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
 {
 	int state = 0;
+	int cause = 0;
 	struct ast_channel *chan;
 	struct ast_frame *f;
 	int res = 0;
 	char *variable;
-	chan = ast_request(type, format, data);
+	chan = ast_request(type, format, data, &cause);
 	if (chan) {
 		if (oh) {
 			char *tmp, *var;
@@ -1815,9 +1816,18 @@
 				ast_frfree(f);
 			}
 		} else
-			ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
-	} else
+			ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
+	} else {
 		ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
+		switch(cause) {
+		case AST_CAUSE_BUSY:
+			state = AST_CONTROL_BUSY;
+			break;
+		case AST_CAUSE_CONGESTION:
+			state = AST_CONTROL_CONGESTION;
+			break;
+		}
+	}
 	if (chan) {
 		/* Final fixups */
 		if (oh) {
@@ -1861,13 +1871,17 @@
 	return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL);
 }
 
-struct ast_channel *ast_request(const char *type, int format, void *data)
+struct ast_channel *ast_request(const char *type, int format, void *data, int *cause)
 {
 	struct chanlist *chan;
 	struct ast_channel *c = NULL;
 	int capabilities;
 	int fmt;
 	int res;
+	int foo;
+	if (!cause)
+		cause = &foo;
+	*cause = AST_CAUSE_NOTDEFINED;
 	if (ast_mutex_lock(&chlock)) {
 		ast_log(LOG_WARNING, "Unable to lock channel list\n");
 		return NULL;
@@ -1885,7 +1899,7 @@
 			}
 			ast_mutex_unlock(&chlock);
 			if (chan->requester)
-				c = chan->requester(type, capabilities, data);
+				c = chan->requester(type, capabilities, data, cause);
 			if (c) {
 				if (c->_state == AST_STATE_DOWN) {
 					manager_event(EVENT_FLAG_CALL, "Newchannel",
@@ -1901,8 +1915,10 @@
 		}
 		chan = chan->next;
 	}
-	if (!chan)
+	if (!chan) {
 		ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type);
+		*cause = AST_CAUSE_NOSUCHDRIVER;
+	}
 	ast_mutex_unlock(&chlock);
 	return c;
 }




More information about the svn-commits mailing list