[asterisk-commits] qwell: branch qwell/dial_events r388965 - /team/qwell/dial_events/apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 17 11:58:35 CDT 2013


Author: qwell
Date: Fri May 17 11:58:31 2013
New Revision: 388965

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388965
Log:
Add some missing events.  Fix events in app_dial, on the forward case.

Modified:
    team/qwell/dial_events/apps/app_dial.c
    team/qwell/dial_events/apps/app_queue.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=388965&r1=388964&r2=388965
==============================================================================
--- team/qwell/dial_events/apps/app_dial.c (original)
+++ team/qwell/dial_events/apps/app_dial.c Fri May 17 11:58:31 2013
@@ -1014,9 +1014,15 @@
 			num->nochan++;
 		} else {
 			ast_channel_lock_both(c, in);
-			ast_channel_publish_dial(c, in, stuff, NULL);
+			ast_channel_publish_dial(in, c, stuff, NULL);
 			ast_channel_unlock(in);
 			ast_channel_unlock(c);
+
+			ast_channel_lock_both(original, in);
+			ast_channel_publish_dial(in, original, NULL, "CANCEL");
+			ast_channel_unlock(in);
+			ast_channel_unlock(original);
+
 			/* Hangup the original channel now, in case we needed it */
 			ast_hangup(original);
 		}

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=388965&r1=388964&r2=388965
==============================================================================
--- team/qwell/dial_events/apps/app_queue.c (original)
+++ team/qwell/dial_events/apps/app_queue.c Fri May 17 11:58:31 2013
@@ -3329,8 +3329,19 @@
 	ast_free(doomed);
 }
 
+static void publish_dial_end_event(struct ast_channel *in, struct callattempt *outgoing, struct ast_channel *exception, const char *status)
+{
+	struct callattempt *cur;
+
+	for (cur = outgoing; cur; cur = cur->q_next) {
+                if (cur->chan && cur->chan != exception) {
+			ast_channel_publish_dial(in, cur->chan, NULL, status);
+                }
+        }
+}
+
 /*! \brief Hang up a list of outgoing calls */
-static void hangupcalls(struct callattempt *outgoing, struct ast_channel *exception, int cancel_answered_elsewhere)
+static void hangupcalls(struct queue_ent *qe, struct callattempt *outgoing, struct ast_channel *exception, int cancel_answered_elsewhere)
 {
 	struct callattempt *oo;
 
@@ -3341,6 +3352,7 @@
 			if (exception || cancel_answered_elsewhere) {
 				ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE);
 			}
+			ast_channel_publish_dial(qe->chan, outgoing->chan, outgoing->interface, "CANCEL");
 			ast_hangup(outgoing->chan);
 		}
 		oo = outgoing;
@@ -3711,10 +3723,10 @@
 		return 0;
 	}
 
+	ast_channel_lock_both(tmp->chan, qe->chan);
+
 	if (qe->parent->eventwhencalled) {
 		char vars[2048];
-
-		ast_channel_lock_both(tmp->chan, qe->chan);
 
 		/*** DOCUMENTATION
 		<managerEventInstance>
@@ -3760,14 +3772,14 @@
 			S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"),
 			ast_channel_context(qe->chan), ast_channel_exten(qe->chan), ast_channel_priority(qe->chan), ast_channel_uniqueid(qe->chan),
 			qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
-
-		ast_channel_unlock(tmp->chan);
-		ast_channel_unlock(qe->chan);
-
-		ast_verb(3, "Called %s\n", tmp->interface);
 	}
 
 	ast_channel_publish_dial(qe->chan, tmp->chan, tmp->interface, NULL);
+
+	ast_channel_unlock(tmp->chan);
+	ast_channel_unlock(qe->chan);
+
+	ast_verb(3, "Called %s\n", tmp->interface);
 
 	member_call_pending_clear(tmp->member);
 	return 1;
@@ -4335,6 +4347,15 @@
 							numnochan++;
 						}
 					}
+					ast_channel_lock_both(qe->chan, o->chan);
+					ast_channel_publish_dial(qe->chan, o->chan, stuff, NULL);
+					ast_channel_unlock(o->chan);
+					ast_channel_unlock(qe->chan);
+
+					ast_channel_lock_both(qe->chan, original);
+					ast_channel_publish_dial(qe->chan, original, NULL, "CANCEL");
+					ast_channel_unlock(original);
+					ast_channel_unlock(qe->chan);
 					/* Hangup the original channel now, in case we needed it */
 					ast_hangup(winner);
 					continue;
@@ -4348,6 +4369,7 @@
 							if (!peer) {
 								ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
 								ast_channel_publish_dial(qe->chan, o->chan, on, "ANSWER");
+								publish_dial_end_event(qe->chan, outgoing, o->chan, "CANCEL");
 								if (!o->block_connected_update) {
 									if (o->pending_connected_update) {
 										if (ast_channel_connected_line_sub(o->chan, in, &o->connected, 0) &&
@@ -4382,10 +4404,10 @@
 							if (ast_channel_cdr(in)) {
 								ast_cdr_busy(ast_channel_cdr(in));
 							}
+							ast_channel_publish_dial(qe->chan, o->chan, on, "BUSY");
 							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) {
@@ -4404,9 +4426,9 @@
 							if (ast_channel_cdr(in)) {
 								ast_cdr_failed(ast_channel_cdr(in));
 							}
+							ast_channel_publish_dial(qe->chan, o->chan, on, "CONGESTION");
 							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) {
@@ -4524,6 +4546,7 @@
 			if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
 				/* Got hung up */
 				*to = -1;
+				publish_dial_end_event(in, outgoing, NULL, "CANCEL");
 				if (f) {
 					if (f->data.uint32) {
 						ast_channel_hangupcause_set(in, f->data.uint32);
@@ -4536,6 +4559,7 @@
 			if ((f->frametype == AST_FRAME_DTMF) && caller_disconnect && (f->subclass.integer == '*')) {
 				ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
 				*to = 0;
+				publish_dial_end_event(in, outgoing, NULL, "EXITCONTEXT");
 				ast_frfree(f);
 				if (ast_channel_cdr(in) && ast_channel_state(in) != AST_STATE_UP) {
 					ast_cdr_noanswer(ast_channel_cdr(in));
@@ -4545,6 +4569,7 @@
 			if ((f->frametype == AST_FRAME_DTMF) && valid_exit(qe, f->subclass.integer)) {
 				ast_verb(3, "User pressed digit: %c\n", f->subclass.integer);
 				*to = 0;
+				publish_dial_end_event(in, outgoing, NULL, "CANCEL");
 				*digit = f->subclass.integer;
 				ast_frfree(f);
 				if (ast_channel_cdr(in) && ast_channel_state(in) != AST_STATE_UP) {
@@ -4602,10 +4627,10 @@
  
 	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);
 		}
 
+		publish_dial_end_event(qe->chan, outgoing, NULL, "NOANSWER");
 		if (ast_channel_cdr(in)
 			&& ast_channel_state(in) != AST_STATE_UP
 			&& (!*to || ast_check_hangup(in))) {
@@ -5469,7 +5494,7 @@
 		member = lpeer->member;
 		/* Increment the refcount for this member, since we're going to be using it for awhile in here. */
 		ao2_ref(member, 1);
-		hangupcalls(outgoing, peer, qe->cancel_answered_elsewhere);
+		hangupcalls(qe, outgoing, peer, qe->cancel_answered_elsewhere);
 		outgoing = NULL;
 		if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) {
 			int res2;
@@ -5512,7 +5537,7 @@
 				/* Agent must have hung up */
 				ast_log(LOG_WARNING, "Agent on %s hungup on the customer.\n", ast_channel_name(peer));
 				ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "AGENTDUMP", "%s", "");
-				if (qe->parent->eventwhencalled)
+				if (qe->parent->eventwhencalled) {
 					/*** DOCUMENTATION
 					<managerEventInstance>
 						<synopsis>Raised when an agent hangs up on a member in the queue.</synopsis>
@@ -5537,8 +5562,9 @@
 							"%s",
 							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_channel_publish_dial(qe->chan, peer, member->interface, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(peer)));
 				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)) {
@@ -5546,6 +5572,7 @@
 				ast_log(LOG_NOTICE, "Caller was about to talk to agent on %s but the caller hungup.\n", ast_channel_name(peer));
 				ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start);
 				record_abandoned(qe);
+				ast_channel_publish_dial(qe->chan, peer, member->interface, ast_hangup_cause_to_dial_status(ast_channel_hangupcause(peer)));
 				ast_autoservice_chan_hangup_peer(qe->chan, peer);
 				ao2_ref(member, -1);
 				return -1;
@@ -5875,8 +5902,6 @@
 					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));
 	
@@ -5957,7 +5982,7 @@
 		ao2_ref(member, -1);
 	}
 out:
-	hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere);
+	hangupcalls(qe, outgoing, NULL, qe->cancel_answered_elsewhere);
 
 	return res;
 }




More information about the asterisk-commits mailing list