[Asterisk-cvs] asterisk/channels chan_agent.c, 1.87, 1.88 chan_alsa.c, 1.28, 1.29 chan_h323.c, 1.84, 1.85 chan_iax2.c, 1.212, 1.213 chan_local.c, 1.36, 1.37 chan_mgcp.c, 1.88, 1.89 chan_modem.c, 1.31, 1.32 chan_nbs.c, 1.11, 1.12 chan_oss.c, 1.36, 1.37 chan_phone.c, 1.35, 1.36 chan_sip.c, 1.543, 1.544 chan_skinny.c, 1.58, 1.59 chan_vpb.c, 1.43, 1.44 chan_zap.c, 1.365, 1.366

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


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

Modified Files:
	chan_agent.c chan_alsa.c chan_h323.c chan_iax2.c chan_local.c 
	chan_mgcp.c chan_modem.c chan_nbs.c chan_oss.c chan_phone.c 
	chan_sip.c chan_skinny.c chan_vpb.c chan_zap.c 
Log Message:
Pass concept of status back, permit "leaveempty" to work with static agents who are not loggedon (bug #2719)


Index: chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- chan_agent.c	24 Oct 2004 18:02:32 -0000	1.87
+++ chan_agent.c	26 Oct 2004 22:25:43 -0000	1.88
@@ -34,6 +34,7 @@
 #include <asterisk/manager.h>
 #include <asterisk/features.h>
 #include <asterisk/utils.h>
+#include <asterisk/causes.h>
 #include <sys/socket.h>
 #include <errno.h>
 #include <unistd.h>
@@ -1051,7 +1052,7 @@
 	return res;
 }
 
-static struct ast_channel *agent_request(const char *type, int format, void *data)
+static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause)
 {
 	struct agent_pvt *p;
 	struct ast_channel *chan = NULL;
@@ -1113,7 +1114,7 @@
 						chan = agent_new(p, AST_STATE_DOWN);
 					} else if (!p->owner && !ast_strlen_zero(p->loginchan)) {
 						/* Adjustable agent */
-						p->chan = ast_request("Local", format, p->loginchan);
+						p->chan = ast_request("Local", format, p->loginchan, cause);
 						if (p->chan)
 							chan = agent_new(p, AST_STATE_DOWN);
 					}
@@ -1142,6 +1143,10 @@
 		} else
 			ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
 	}
+	if (hasagent)
+		*cause = AST_CAUSE_BUSY;
+	else
+		*cause = AST_CAUSE_UNREGISTERED;
 	ast_mutex_unlock(&agentlock);
 	return chan;
 }

Index: chan_alsa.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- chan_alsa.c	3 Oct 2004 04:19:58 -0000	1.28
+++ chan_alsa.c	26 Oct 2004 22:25:43 -0000	1.29
@@ -19,6 +19,7 @@
 #include <asterisk/config.h>
 #include <asterisk/cli.h>
 #include <asterisk/utils.h>
+#include <asterisk/causes.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -753,7 +754,7 @@
 	return tmp;
 }
 
-static struct ast_channel *alsa_request(const char *type, int format, void *data)
+static struct ast_channel *alsa_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat = format;
 	struct ast_channel *tmp=NULL;
@@ -765,6 +766,7 @@
 	ast_mutex_lock(&alsalock);
 	if (alsa.owner) {
 		ast_log(LOG_NOTICE, "Already have a call on the ALSA channel\n");
+		*cause = AST_CAUSE_BUSY;
 	} else {
 		tmp= alsa_new(&alsa, AST_STATE_DOWN);
 		if (!tmp) {

Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- chan_h323.c	22 Oct 2004 19:02:43 -0000	1.84
+++ chan_h323.c	26 Oct 2004 22:25:43 -0000	1.85
@@ -66,6 +66,7 @@
 #include <asterisk/callerid.h>
 #include <asterisk/cli.h>
 #include <asterisk/dsp.h>
+#include <asterisk/causes.h>
 #ifdef __cplusplus
 }
 #endif
@@ -948,7 +949,7 @@
 		return 0;
 	}
 }
-static struct ast_channel *oh323_request(const char *type, int format, void *data)
+static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct oh323_pvt *pvt;

Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -d -r1.212 -r1.213
--- chan_iax2.c	24 Oct 2004 06:44:36 -0000	1.212
+++ chan_iax2.c	26 Oct 2004 22:25:43 -0000	1.213
@@ -35,6 +35,7 @@
 #include <asterisk/musiconhold.h>
 #include <asterisk/features.h>
 #include <asterisk/utils.h>
+#include <asterisk/causes.h>
 #include <sys/mman.h>
 #include <arpa/inet.h>
 #include <dirent.h>
@@ -6208,7 +6209,7 @@
 	}
 }
 
-static struct ast_channel *iax2_request(const char *type, int format, void *data)
+static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause)
 {
 	int callno;
 	int res;
@@ -6248,6 +6249,7 @@
 
 	/* Populate our address from the given */
 	if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, &notransfer, &usejitterbuf, NULL, 0, NULL, 0, &found, NULL)) {
+		*cause = AST_CAUSE_UNREGISTERED;
 		return NULL;
 	}
 	if (portno) {
@@ -6256,6 +6258,7 @@
 	callno = find_callno(0, 0, &sin, NEW_FORCE, 1);
 	if (callno < 1) {
 		ast_log(LOG_WARNING, "Unable to create call\n");
+		*cause = AST_CAUSE_CONGESTION;
 		return NULL;
 	}
 	ast_mutex_lock(&iaxsl[callno]);

Index: chan_local.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_local.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- chan_local.c	26 Oct 2004 03:01:52 -0000	1.36
+++ chan_local.c	26 Oct 2004 22:25:43 -0000	1.37
@@ -462,7 +462,7 @@
 }
 
 
-static struct ast_channel *local_request(const char *type, int format, void *data)
+static struct ast_channel *local_request(const char *type, int format, void *data, int *cause)
 {
 	struct local_pvt *p;
 	struct ast_channel *chan = NULL;

Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- chan_mgcp.c	26 Oct 2004 02:57:18 -0000	1.88
+++ chan_mgcp.c	26 Oct 2004 22:25:43 -0000	1.89
@@ -72,6 +72,7 @@
 #include <asterisk/app.h>
 #include <asterisk/musiconhold.h>
 #include <asterisk/utils.h>
+#include <asterisk/causes.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
@@ -3342,7 +3343,7 @@
 	return 0;
 }
 
-static struct ast_channel *mgcp_request(const char *type, int format, void *data)
+static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct mgcp_subchannel *sub;
@@ -3364,6 +3365,7 @@
 	sub = find_subchannel(tmp, 0, NULL);
 	if (!sub) {
 		ast_log(LOG_WARNING, "Unable to find MGCP endpoint '%s'\n", tmp);
+		*cause = AST_CAUSE_UNREGISTERED;
 		return NULL;
 	}
 	
@@ -3383,6 +3385,7 @@
                  transmit_notify_request(sub,"L/vmwi(-)");
              }
          }
+		*cause = AST_CAUSE_BUSY;
 		return NULL;
     }
 	tmpc = mgcp_new(sub->owner ? sub->next : sub, AST_STATE_DOWN);

Index: chan_modem.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_modem.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- chan_modem.c	23 Oct 2004 11:50:04 -0000	1.31
+++ chan_modem.c	26 Oct 2004 22:25:43 -0000	1.32
@@ -773,7 +773,7 @@
 	return tmp;
 }
 
-static struct ast_channel *modem_request(const char *type, int format, void *data)
+static struct ast_channel *modem_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct ast_modem_pvt *p;

Index: chan_nbs.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_nbs.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- chan_nbs.c	3 Oct 2004 04:19:58 -0000	1.11
+++ chan_nbs.c	26 Oct 2004 22:25:43 -0000	1.12
@@ -232,7 +232,7 @@
 }
 
 
-static struct ast_channel *nbs_request(const char *type, int format, void *data)
+static struct ast_channel *nbs_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct nbs_pvt *p;

Index: chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- chan_oss.c	23 Oct 2004 12:19:47 -0000	1.36
+++ chan_oss.c	26 Oct 2004 22:25:43 -0000	1.37
@@ -26,6 +26,7 @@
 #include <asterisk/config.h>
 #include <asterisk/cli.h>
 #include <asterisk/utils.h>
+#include <asterisk/causes.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -745,7 +746,7 @@
 	return tmp;
 }
 
-static struct ast_channel *oss_request(const char *type, int format, void *data)
+static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat = format;
 	struct ast_channel *tmp;
@@ -756,6 +757,7 @@
 	}
 	if (oss.owner) {
 		ast_log(LOG_NOTICE, "Already have a call on the OSS channel\n");
+		*cause = AST_CAUSE_BUSY;
 		return NULL;
 	}
 	tmp= oss_new(&oss, AST_STATE_DOWN);

Index: chan_phone.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_phone.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- chan_phone.c	3 Oct 2004 04:19:58 -0000	1.35
+++ chan_phone.c	26 Oct 2004 22:25:43 -0000	1.36
@@ -23,6 +23,7 @@
 #include <asterisk/options.h>
 #include <asterisk/utils.h>
 #include <asterisk/callerid.h>
+#include <asterisk/causes.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <errno.h>
@@ -1023,7 +1024,7 @@
 	return tmp;
 }
 
-static struct ast_channel *phone_request(const char *type, int format, void *data)
+static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct phone_pvt *p;
@@ -1047,7 +1048,8 @@
 			if (!p->owner) {
 				tmp = phone_new(p, AST_STATE_DOWN, p->context);
 				break;
-			}
+			} else
+				*cause = AST_CAUSE_BUSY;
 		}
 		p = p->next;
 	}

Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.543
retrieving revision 1.544
diff -u -d -r1.543 -r1.544
--- chan_sip.c	23 Oct 2004 12:19:47 -0000	1.543
+++ chan_sip.c	26 Oct 2004 22:25:43 -0000	1.544
@@ -7946,7 +7946,7 @@
 
 /*--- sip_request: PBX interface function -build SIP pvt structure ---*/
 /* SIP calls initiated by the PBX arrive here */
-static struct ast_channel *sip_request(const char *type, int format, void *data)
+static struct ast_channel *sip_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct sip_pvt *p;
@@ -7990,6 +7990,7 @@
 	p->capability = global_capability;
 
 	if (create_addr(p, host)) {
+		*cause = AST_CAUSE_UNREGISTERED;
 		sip_destroy(p);
 		return NULL;
 	}

Index: chan_skinny.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- chan_skinny.c	23 Oct 2004 12:19:47 -0000	1.58
+++ chan_skinny.c	26 Oct 2004 22:25:43 -0000	1.59
@@ -2489,7 +2489,7 @@
 	return 0;
 }
 
-static struct ast_channel *skinny_request(const char *type, int format, void *data)
+static struct ast_channel *skinny_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	struct skinny_subchannel *sub;

Index: chan_vpb.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- chan_vpb.c	21 Oct 2004 05:03:00 -0000	1.43
+++ chan_vpb.c	26 Oct 2004 22:25:43 -0000	1.44
@@ -2115,7 +2115,7 @@
 	return tmp;
 }
 
-static struct ast_channel *vpb_request(const char *type, int format, void *data) 
+static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause) 
 {
 	int oldformat;
 	struct vpb_pvt *p;

Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.365
retrieving revision 1.366
diff -u -d -r1.365 -r1.366
--- chan_zap.c	26 Oct 2004 02:57:18 -0000	1.365
+++ chan_zap.c	26 Oct 2004 22:25:43 -0000	1.366
@@ -6732,7 +6732,7 @@
 }
 #endif
 
-static struct ast_channel *zt_request(const char *type, int format, void *data)
+static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause)
 {
 	int oldformat;
 	int groupmatch = 0;
@@ -6945,21 +6945,8 @@
 	}
 	ast_mutex_unlock(lock);
 	restart_monitor();
-	if (!tmp) {
-		if (busy && (channelmatch != CHAN_PSEUDO)) {
-			tmp = zt_request("Zap", format, "pseudo");
-			if (tmp) {
-				char newname[80];
-				ast_mutex_lock(&tmp->lock);
-				snprintf(newname, sizeof(newname), "Zap/%s-busy-%d", (char *)data, rand());
-				ast_change_name(tmp, newname);
-				ast_setstate(tmp, AST_STATE_BUSY);
-				ast_mutex_unlock(&tmp->lock);
-			}
-		} else if (busy) {
-			ast_log(LOG_WARNING, "Whoa, the pseudo was busy somehow!\n");
-		}
-	}
+	if (callwait || (!tmp && busy))
+		*cause = AST_CAUSE_BUSY;
 	return tmp;
 }
 
@@ -7200,6 +7187,7 @@
 	time_t t;
 	int i, which=-1;
 	int numdchans;
+	int cause=0;
 	struct zt_pvt *crv;
 	pthread_t threadid;
 	pthread_attr_t attr;
@@ -7277,7 +7265,7 @@
 				    (tv.tv_usec - lastidle.tv_usec) / 1000) > 1000) {
 					/* Don't create a new idle call more than once per second */
 					snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial);
-					idle = zt_request("Zap", AST_FORMAT_ULAW, idlen);
+					idle = zt_request("Zap", AST_FORMAT_ULAW, idlen, &cause);
 					if (idle) {
 						pri->pvts[nextidle]->isidlecall = 1;
 						if (ast_pthread_create(&p, NULL, do_idle_thread, idle)) {




More information about the svn-commits mailing list