[svn-commits] kmoore: branch kmoore/cel_cleanup r392107 - in /team/kmoore/cel_cleanup: apps...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 17 16:13:03 CDT 2013


Author: kmoore
Date: Mon Jun 17 16:13:02 2013
New Revision: 392107

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392107
Log:
Initial swing at moving call forward notices into dial messages

Modified:
    team/kmoore/cel_cleanup/apps/app_dial.c
    team/kmoore/cel_cleanup/apps/app_queue.c
    team/kmoore/cel_cleanup/include/asterisk/stasis_channels.h
    team/kmoore/cel_cleanup/main/cdr.c
    team/kmoore/cel_cleanup/main/cel.c
    team/kmoore/cel_cleanup/main/manager_channels.c
    team/kmoore/cel_cleanup/main/stasis_channels.c

Modified: team/kmoore/cel_cleanup/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/apps/app_dial.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/apps/app_dial.c (original)
+++ team/kmoore/cel_cleanup/apps/app_dial.c Mon Jun 17 16:13:02 2013
@@ -859,8 +859,6 @@
 		ast_clear_flag64(o, OPT_IGNORE_CONNECTEDLINE);
 	}
 
-	ast_cel_report_event(in, AST_CEL_FORWARD, NULL, ast_channel_call_forward(c), NULL);
-
 	/* Before processing channel, go ahead and check for forwarding */
 	ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", ast_channel_name(in), tech, stuff, ast_channel_name(c));
 	/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
@@ -1004,6 +1002,7 @@
 			ast_channel_unlock(c);
 
 			ast_channel_lock_both(original, in);
+			ast_channel_publish_dial_forward(in, original, ast_channel_call_forward(c));
 			ast_channel_publish_dial(in, original, NULL, "CANCEL");
 			ast_channel_unlock(in);
 			ast_channel_unlock(original);

Modified: team/kmoore/cel_cleanup/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/apps/app_queue.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/apps/app_queue.c (original)
+++ team/kmoore/cel_cleanup/apps/app_queue.c Mon Jun 17 16:13:02 2013
@@ -4449,8 +4449,6 @@
 						o->block_connected_update = 0;
 					}
 
-					ast_cel_report_event(in, AST_CEL_FORWARD, NULL, ast_channel_call_forward(o->chan), NULL);
-
 					ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", inchan_name, tech, stuff, ochan_name);
 					/* Setup parameters */
 					o->chan = ast_request(tech, ast_channel_nativeformats(in), in, stuff, &status);
@@ -4544,6 +4542,7 @@
 					ast_channel_unlock(qe->chan);
 
 					ast_channel_lock_both(qe->chan, original);
+					ast_channel_publish_dial_forward(qe->chan, original, ast_channel_call_forward(original));
 					ast_channel_publish_dial(qe->chan, original, NULL, "CANCEL");
 					ast_channel_unlock(original);
 					ast_channel_unlock(qe->chan);

Modified: team/kmoore/cel_cleanup/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/include/asterisk/stasis_channels.h?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/include/asterisk/stasis_channels.h (original)
+++ team/kmoore/cel_cleanup/include/asterisk/stasis_channels.h Mon Jun 17 16:13:02 2013
@@ -456,6 +456,20 @@
 
 /*!
  * \since 12
+ * \brief Publish in the \ref ast_channel_topic or \ref ast_channel_topic_all
+ * topics a stasis message for the channels involved in a dial operation that
+ * is forwarded.
+ *
+ * \param caller The channel performing the dial operation
+ * \param peer The channel being dialed
+ * \param forward The call forward string provided by the dialed channel
+ */
+void ast_channel_publish_dial_forward(struct ast_channel *caller,
+		struct ast_channel *peer,
+		const char *forward);
+
+/*!
+ * \since 12
  * \brief Publish in the \ref ast_channel_topic a \ref ast_channel_snapshot
  * message indicating a change in channel state
  *

Modified: team/kmoore/cel_cleanup/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/main/cdr.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/main/cdr.c (original)
+++ team/kmoore/cel_cleanup/main/cdr.c Mon Jun 17 16:13:02 2013
@@ -1692,6 +1692,7 @@
 	struct cdr_object_snapshot *party_b;
 	struct cdr_object *it_cdr;
 	struct ast_json *dial_status_blob;
+	struct ast_json *dial_forward_blob;
 	const char *dial_status = NULL;
 	int res = 1;
 
@@ -1706,6 +1707,11 @@
 	dial_status_blob = ast_json_object_get(ast_multi_channel_blob_get_json(payload), "dialstatus");
 	if (dial_status_blob) {
 		dial_status = ast_json_string_get(dial_status_blob);
+	}
+
+	dial_forward_blob = ast_json_object_get(ast_multi_channel_blob_get_json(payload), "forward");
+	if (dial_forward_blob && !ast_strlen_zero(ast_json_string_get(dial_forward_blob))) {
+		return;
 	}
 
 	/* Figure out who is running this show */

Modified: team/kmoore/cel_cleanup/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/main/cel.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/main/cel.c (original)
+++ team/kmoore/cel_cleanup/main/cel.c Mon Jun 17 16:13:02 2013
@@ -1047,14 +1047,14 @@
 	return ao2_find(cel_dialstatus_store, uniqueid, OBJ_KEY | OBJ_UNLINK);
 }
 
-static const char *get_caller_dialstatus(struct ast_multi_channel_blob *blob)
+static const char *get_blob_variable(struct ast_multi_channel_blob *blob, const char *varname)
 {
 	struct ast_json *json = ast_multi_channel_blob_get_json(blob);
 	if (!json) {
 		return NULL;
 	}
 
-	json = ast_json_object_get(json, "dialstatus");
+	json = ast_json_object_get(json, varname);
 	if (!json) {
 		return NULL;
 	}
@@ -1087,8 +1087,8 @@
 		RAII_VAR(struct ast_str *, extra_str, ast_str_create(128), ast_free);
 		RAII_VAR(struct ast_multi_channel_blob *, blob, get_dialstatus_blob(new_snapshot->uniqueid), ao2_cleanup);
 		const char *dialstatus = "";
-		if (blob && !ast_strlen_zero(get_caller_dialstatus(blob))) {
-			dialstatus = get_caller_dialstatus(blob);
+		if (blob && !ast_strlen_zero(get_blob_variable(blob, "dialstatus"))) {
+			dialstatus = get_blob_variable(blob, "dialstatus");
 		}
 		ast_str_set(&extra_str, 0, "%d,%s,%s",
 			new_snapshot->hangupcause,
@@ -1399,7 +1399,17 @@
 		return;
 	}
 
-	if (ast_strlen_zero(get_caller_dialstatus(blob))) {
+	if (!ast_strlen_zero(get_blob_variable(blob, "forward"))) {
+		struct ast_channel_snapshot *caller = ast_multi_channel_blob_get_channel(blob, "caller");
+		if (!caller) {
+			return;
+		}
+
+		report_event_snapshot(caller, AST_CEL_FORWARD, NULL, get_blob_variable(blob, "forward"), NULL);
+		return;
+	}
+
+	if (ast_strlen_zero(get_blob_variable(blob, "dialstatus"))) {
 		return;
 	}
 

Modified: team/kmoore/cel_cleanup/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/main/manager_channels.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/main/manager_channels.c (original)
+++ team/kmoore/cel_cleanup/main/manager_channels.c Mon Jun 17 16:13:02 2013
@@ -1150,6 +1150,7 @@
 	struct ast_multi_channel_blob *obj = stasis_message_data(message);
 	const char *dialstatus;
 	const char *dialstring;
+	const char *forward;
 	struct ast_channel_snapshot *caller;
 	struct ast_channel_snapshot *peer;
 	RAII_VAR(struct ast_str *, caller_event_string, NULL, ast_free);
@@ -1171,7 +1172,13 @@
 
 	dialstatus = ast_json_string_get(ast_json_object_get(ast_multi_channel_blob_get_json(obj), "dialstatus"));
 	dialstring = ast_json_string_get(ast_json_object_get(ast_multi_channel_blob_get_json(obj), "dialstring"));
-	if (ast_strlen_zero(dialstatus)) {
+	forward = ast_json_string_get(ast_json_object_get(ast_multi_channel_blob_get_json(obj), "forward"));
+	if (!ast_strlen_zero(forward)) {
+		/* Handle forward during dialing */
+		return;
+	}
+	
+	if (!ast_strlen_zero(dialstring)) {
 		manager_event(EVENT_FLAG_CALL, "DialBegin",
 				"%s"
 				"%s"
@@ -1179,7 +1186,10 @@
 				caller_event_string ? ast_str_buffer(caller_event_string) : "",
 				ast_str_buffer(peer_event_string),
 				S_OR(dialstring, "unknown"));
-	} else {
+		return;
+	}
+	
+	if (!ast_strlen_zero(dialstatus)) {
 		manager_event(EVENT_FLAG_CALL, "DialEnd",
 				"%s"
 				"%s"
@@ -1187,8 +1197,8 @@
 				caller_event_string ? ast_str_buffer(caller_event_string) : "",
 				ast_str_buffer(peer_event_string),
 				S_OR(dialstatus, "unknown"));
-	}
-
+		return;
+	}
 }
 
 static void channel_hold_cb(void *data, struct stasis_subscription *sub,

Modified: team/kmoore/cel_cleanup/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/main/stasis_channels.c?view=diff&rev=392107&r1=392106&r2=392107
==============================================================================
--- team/kmoore/cel_cleanup/main/stasis_channels.c (original)
+++ team/kmoore/cel_cleanup/main/stasis_channels.c Mon Jun 17 16:13:02 2013
@@ -210,7 +210,8 @@
 	ast_json_unref(event->blob);
 }
 
-void ast_channel_publish_dial(struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
+static void publish_dial_full(struct ast_channel *caller, struct ast_channel *peer,
+	const char *dialstring, const char *dialstatus, const char *forward)
 {
 	RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
@@ -219,8 +220,9 @@
 	RAII_VAR(struct ast_channel_snapshot *, peer_snapshot, NULL, ao2_cleanup);
 
 	ast_assert(peer != NULL);
-	blob = ast_json_pack("{s: s, s: s}",
+	blob = ast_json_pack("{s: s, s: s, s: s}",
 			     "dialstatus", S_OR(dialstatus, ""),
+			     "forward", S_OR(forward, ""),
 			     "dialstring", S_OR(dialstring, ""));
 	if (!blob) {
 		return;
@@ -250,6 +252,18 @@
 	}
 
 	publish_message_for_channel_topics(msg, caller);
+}
+
+void ast_channel_publish_dial(struct ast_channel *caller, struct ast_channel *peer,
+	const char *dialstring, const char *dialstatus)
+{
+	publish_dial_full(caller, peer, dialstring, dialstatus, NULL);
+}
+
+void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_channel *peer,
+	const char *forward)
+{
+	publish_dial_full(caller, peer, NULL, NULL, forward);
 }
 
 static struct stasis_message *create_channel_blob_message(struct ast_channel_snapshot *snapshot,




More information about the svn-commits mailing list