[asterisk-commits] qwell: branch qwell/dial_events r388927 - in /team/qwell/dial_events: apps/ i...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 16 08:28:53 CDT 2013


Author: qwell
Date: Thu May 16 08:28:52 2013
New Revision: 388927

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388927
Log:
First stab at adding dial events to app_queue.  Completely untested.

Modified:
    team/qwell/dial_events/apps/app_dial.c
    team/qwell/dial_events/apps/app_queue.c
    team/qwell/dial_events/include/asterisk/dial.h
    team/qwell/dial_events/main/dial.c

Modified: team/qwell/dial_events/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/dial_events/apps/app_dial.c?view=diff&rev=388927&r1=388926&r2=388927
==============================================================================
--- team/qwell/dial_events/apps/app_dial.c (original)
+++ team/qwell/dial_events/apps/app_dial.c Thu May 16 08:28:52 2013
@@ -67,6 +67,7 @@
 #include "asterisk/ccss.h"
 #include "asterisk/indications.h"
 #include "asterisk/framehook.h"
+#include "asterisk/dial.h"
 #include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
@@ -1034,22 +1035,6 @@
 	char status[256];
 };
 
-static const char *hangup_cause_to_dial_status(int hangup_cause)
-{
-	switch(hangup_cause) {
-	case AST_CAUSE_BUSY:
-		return "BUSY";
-	case AST_CAUSE_CONGESTION:
-		return "CONGESTION";
-	case AST_CAUSE_NO_ROUTE_DESTINATION:
-	case AST_CAUSE_UNREGISTERED:
-		return "CHANUNAVAIL";
-	case AST_CAUSE_NO_ANSWER:
-	default:
-		return "NOANSWER";
-	}
-}
-
 static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
 {
 	struct chanlist *outgoing;
@@ -1265,7 +1250,7 @@
 #ifdef HAVE_EPOLL
 				ast_poll_channel_del(in, c);
 #endif
-				ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
+				ast_channel_publish_dial(in, c, NULL, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 				ast_hangup(c);
 				c = o->chan = NULL;
 				ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1333,7 +1318,7 @@
 				case AST_CONTROL_BUSY:
 					ast_verb(3, "%s is busy\n", ast_channel_name(c));
 					ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
-					ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
+					ast_channel_publish_dial(in, c, NULL, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 					ast_hangup(c);
 					c = o->chan = NULL;
 					ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1342,7 +1327,7 @@
 				case AST_CONTROL_CONGESTION:
 					ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
 					ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
-					ast_channel_publish_dial(in, c, NULL, hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
+					ast_channel_publish_dial(in, c, NULL, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(c)));
 					ast_hangup(c);
 					c = o->chan = NULL;
 					ast_clear_flag64(o, DIAL_STILLGOING);

Modified: team/qwell/dial_events/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/dial_events/apps/app_queue.c?view=diff&rev=388927&r1=388926&r2=388927
==============================================================================
--- team/qwell/dial_events/apps/app_queue.c (original)
+++ team/qwell/dial_events/apps/app_queue.c Thu May 16 08:28:52 2013
@@ -106,6 +106,8 @@
 #include "asterisk/cel.h"
 #include "asterisk/data.h"
 #include "asterisk/term.h"
+#include "asterisk/dial.h"
+#include "asterisk/stasis_channels.h"
 
 /* Define, to debug reference counts on queues, without debugging reference counts on queue members */
 /* #define REF_DEBUG_ONLY_QUEUES */
@@ -3765,6 +3767,8 @@
 		ast_verb(3, "Called %s\n", tmp->interface);
 	}
 
+	ast_channel_publish_dial(qe->chan, tmp->chan, tmp->interface, NULL);
+
 	member_call_pending_clear(tmp->member);
 	return 1;
 }
@@ -4343,6 +4347,7 @@
 							/* This is our guy if someone answered. */
 							if (!peer) {
 								ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
+								ast_channel_publish_dial(qe->chan, o->chan, on, "ANSWER");
 								if (!o->block_connected_update) {
 									if (o->pending_connected_update) {
 										if (ast_channel_connected_line_sub(o->chan, in, &o->connected, 0) &&
@@ -4380,6 +4385,7 @@
 							do_hang(o);
 							endtime = (long) time(NULL);
 							endtime -= starttime;
+							ast_channel_publish_dial(qe->chan, o->chan, on, "BUSY");
 							rna(endtime * 1000, qe, on, membername, qe->parent->autopausebusy);
 							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart) {
@@ -4400,6 +4406,7 @@
 							}
 							endtime = (long) time(NULL);
 							endtime -= starttime;
+							ast_channel_publish_dial(qe->chan, o->chan, on, "CONGESTION");
 							rna(endtime * 1000, qe, on, membername, qe->parent->autopauseunavail);
 							do_hang(o);
 							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
@@ -4495,6 +4502,7 @@
 					ast_frfree(f);
 				} else { /* ast_read() returned NULL */
 					endtime = (long) time(NULL) - starttime;
+					ast_channel_publish_dial(qe->chan, o->chan, on, "NOANSWER");
 					rna(endtime * 1000, qe, on, membername, 1);
 					do_hang(o);
 					if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
@@ -4594,6 +4602,7 @@
  
 	if (!*to) {
 		for (o = start; o; o = o->call_next) {
+			ast_channel_publish_dial(qe->chan, o->chan, o->interface, "NOANSWER");
 			rna(orig, qe, o->interface, o->member->membername, 1);
 		}
 
@@ -5529,6 +5538,7 @@
 							queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
 							qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 				ast_autoservice_chan_hangup_peer(qe->chan, peer);
+				ast_channel_publish_dial(qe->chan, peer, member->interface, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(peer)));
 				ao2_ref(member, -1);
 				goto out;
 			} else if (ast_check_hangup(qe->chan)) {
@@ -5831,7 +5841,7 @@
 			}
 		}
 
-		if (qe->parent->eventwhencalled)
+		if (qe->parent->eventwhencalled) {
 			/*** DOCUMENTATION
 			<managerEventInstance>
 				<synopsis>Raised when an agent answers and is bridged to a member in the queue.</synopsis>
@@ -5863,6 +5873,10 @@
 					queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
 					(long) time(NULL) - qe->start, ast_channel_uniqueid(peer), (long)(orig - to > 0 ? (orig - to) / 1000 : 0),
 					qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
+		}
+
+		ast_channel_publish_dial(qe->chan, peer, member->interface, NULL);
+
 		ast_copy_string(oldcontext, ast_channel_context(qe->chan), sizeof(oldcontext));
 		ast_copy_string(oldexten, ast_channel_exten(qe->chan), sizeof(oldexten));
 	

Modified: team/qwell/dial_events/include/asterisk/dial.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/dial_events/include/asterisk/dial.h?view=diff&rev=388927&r1=388926&r2=388927
==============================================================================
--- team/qwell/dial_events/include/asterisk/dial.h (original)
+++ team/qwell/dial_events/include/asterisk/dial.h Thu May 16 08:28:52 2013
@@ -180,6 +180,11 @@
  */
 void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout);
 
+/*! \since 12
+ * \brief Convert a hangup cause to a publishable dial status
+ */
+const char *ast_hangup_cause_to_dial_status(int hangup_cause);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/qwell/dial_events/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/dial_events/main/dial.c?view=diff&rev=388927&r1=388926&r2=388927
==============================================================================
--- team/qwell/dial_events/main/dial.c (original)
+++ team/qwell/dial_events/main/dial.c Thu May 16 08:28:52 2013
@@ -577,9 +577,9 @@
 }
 
 /*! \since 12
- * \internal \brief Convert a hangup cause to a publishable dial status
- */
-static const char *hangup_cause_to_dial_status(int hangup_cause)
+ * \brief Convert a hangup cause to a publishable dial status
+ */
+const char *ast_hangup_cause_to_dial_status(int hangup_cause)
 {
 	switch(hangup_cause) {
 	case AST_CAUSE_BUSY:
@@ -688,7 +688,7 @@
 			}
 			if (chan)
 				ast_poll_channel_del(chan, channel->owner);
-			ast_channel_publish_dial(chan, who, channel->device, hangup_cause_to_dial_status(ast_channel_hangupcause(who)));
+			ast_channel_publish_dial(chan, who, channel->device, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(who)));
 			ast_hangup(who);
 			channel->owner = NULL;
 			continue;




More information about the asterisk-commits mailing list