[asterisk-commits] qwell: branch qwell/ccss_stasis r394516 - in /team/qwell/ccss_stasis: include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 16 16:53:56 CDT 2013


Author: qwell
Date: Tue Jul 16 16:53:54 2013
New Revision: 394516

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394516
Log:
Commit progress.  One message down.

Modified:
    team/qwell/ccss_stasis/include/asterisk/stasis_system.h
    team/qwell/ccss_stasis/main/ccss.c
    team/qwell/ccss_stasis/main/stasis_system.c

Modified: team/qwell/ccss_stasis/include/asterisk/stasis_system.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ccss_stasis/include/asterisk/stasis_system.h?view=diff&rev=394516&r1=394515&r2=394516
==============================================================================
--- team/qwell/ccss_stasis/include/asterisk/stasis_system.h (original)
+++ team/qwell/ccss_stasis/include/asterisk/stasis_system.h Tue Jul 16 16:53:54 2013
@@ -62,6 +62,12 @@
 struct stasis_message_type *ast_system_registry_type(void);
 
 /*!
+ * \brief A \ref stasis_message_type for CCSS Available messages.
+ * \since 12
+ */
+struct stasis_message_type *ast_cc_available_type(void);
+
+/*!
  * \brief Initialize the stasis system topic and message types
  * \retval 0 on success
  * \retval -1 on failure

Modified: team/qwell/ccss_stasis/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ccss_stasis/main/ccss.c?view=diff&rev=394516&r1=394515&r2=394516
==============================================================================
--- team/qwell/ccss_stasis/main/ccss.c (original)
+++ team/qwell/ccss_stasis/main/ccss.c Tue Jul 16 16:53:54 2013
@@ -52,6 +52,7 @@
 #include "asterisk/cli.h"
 #include "asterisk/manager.h"
 #include "asterisk/causes.h"
+#include "asterisk/stasis_system.h"
 
 /*** DOCUMENTATION
 	<application name="CallCompletionRequest" language="en_US">
@@ -1025,6 +1026,29 @@
 	}
 }
 
+static void cc_publish_available(int core_id, const char *callee, const char *service)
+{
+	RAII_VAR(struct ast_json *, avail, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+	avail = ast_json_pack("{s: s, s: i, s: s, s: s}",
+		"type", "ccavailable",
+		"core_id", core_id,
+		"callee", callee,
+		"service", service);
+
+	if (!(payload = ast_json_payload_create(avail))) {
+		return;
+	}
+
+	if (!(message = stasis_message_create(ast_cc_available_type(), payload))) {
+		return;
+	}
+
+	stasis_publish(ast_system_topic(), message);
+}
+
 struct cc_monitor_backend {
 	AST_LIST_ENTRY(cc_monitor_backend) next;
 	const struct ast_cc_monitor_callbacks *callbacks;
@@ -2262,12 +2286,7 @@
 
 	cc_extension_monitor_change_is_valid(core_instance, monitor->parent_id, monitor->interface->device_name, 0);
 
-	manager_event(EVENT_FLAG_CC, "CCAvailable",
-		"CoreID: %d\r\n"
-		"Callee: %s\r\n"
-		"Service: %s\r\n",
-		cc_interfaces->core_id, device_name, cc_service_to_string(cc_data->service)
-	);
+	cc_publish_available(cc_interfaces->core_id, device_name, cc_service_to_string(cc_data->service));
 
 	cc_unref(core_instance, "Done with core_instance after handling CC control frame");
 	cc_unref(monitor, "Unref reference from allocating monitor");

Modified: team/qwell/ccss_stasis/main/stasis_system.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ccss_stasis/main/stasis_system.c?view=diff&rev=394516&r1=394515&r2=394516
==============================================================================
--- team/qwell/ccss_stasis/main/stasis_system.c (original)
+++ team/qwell/ccss_stasis/main/stasis_system.c Tue Jul 16 16:53:54 2013
@@ -70,10 +70,14 @@
 static struct stasis_topic *system_topic;
 
 static struct ast_manager_event_blob *system_registry_to_ami(struct stasis_message *message);
+static struct ast_manager_event_blob *cc_available_to_ami(struct stasis_message *message);
 
 STASIS_MESSAGE_TYPE_DEFN(ast_network_change_type);
 STASIS_MESSAGE_TYPE_DEFN(ast_system_registry_type,
 	.to_ami = system_registry_to_ami,
+	);
+STASIS_MESSAGE_TYPE_DEFN(ast_cc_available_type,
+	.to_ami = cc_available_to_ami,
 	);
 
 void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause)
@@ -134,6 +138,24 @@
 		channeltype, username, domain, status, ast_str_buffer(cause_string));
 }
 
+static struct ast_manager_event_blob *cc_available_to_ami(struct stasis_message *message)
+{
+	struct ast_json_payload *payload = stasis_message_data(message);
+	int core_id;
+	const char *callee;
+	const char *service;
+
+	core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
+	callee = ast_json_string_get(ast_json_object_get(payload->json, "callee"));
+	service = ast_json_string_get(ast_json_object_get(payload->json, "service"));
+
+	return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCAvailable",
+		"CoreID: %d\r\n"
+		"Callee: %s\r\n"
+		"Service: %s\r\n",
+		core_id, callee, service);
+}
+
 struct stasis_topic *ast_system_topic(void)
 {
 	return system_topic;
@@ -146,6 +168,7 @@
 	system_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_network_change_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_system_registry_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(ast_cc_available_type);
 }
 
 /*! \brief Initialize the system level items for \ref stasis */
@@ -166,5 +189,9 @@
 		return -1;
 	}
 
+	if (STASIS_MESSAGE_TYPE_INIT(ast_cc_available_type) != 0) {
+		return -1;
+	}
+
 	return 0;
 }




More information about the asterisk-commits mailing list