[asterisk-commits] qwell: branch mjordan/ami-refactoring r387804 - /team/mjordan/ami-refactoring...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 7 13:13:38 CDT 2013
Author: qwell
Date: Tue May 7 13:13:35 2013
New Revision: 387804
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387804
Log:
Fix a merge issue.
Modified:
team/mjordan/ami-refactoring/main/asterisk.c
Modified: team/mjordan/ami-refactoring/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/ami-refactoring/main/asterisk.c?view=diff&rev=387804&r1=387803&r2=387804
==============================================================================
--- team/mjordan/ami-refactoring/main/asterisk.c (original)
+++ team/mjordan/ami-refactoring/main/asterisk.c Tue May 7 13:13:35 2013
@@ -551,98 +551,6 @@
}
}
-struct stasis_topic *ast_system_topic(void)
-{
- return system_topic;
-}
-
-struct stasis_message_type *ast_network_change_type(void)
-{
- return network_change_type;
-}
-
-struct stasis_message_type *ast_system_status_type(void)
-{
- return system_status_type;
-}
-/*! \brief Cleanup the \ref stasis system level items */
-
-static void stasis_system_topic_cleanup(void)
-{
- ao2_cleanup(system_topic);
- system_topic = NULL;
- ao2_cleanup(network_change_type);
- network_change_type = NULL;
- ao2_cleanup(system_status_type);
- system_status_type = NULL;
-}
-
-/*! \brief Initialize the system level items for \ref stasis */
-static int stasis_system_topic_init(void)
-{
- ast_register_atexit(stasis_system_topic_cleanup);
-
- system_topic = stasis_topic_create("ast_system");
- if (!system_topic) {
- return 1;
- }
-
- network_change_type = stasis_message_type_create("network_change");
- if (!network_change_type) {
- return -1;
- }
-
- system_status_type = stasis_message_type_create("system_status");
- if (!system_status_type) {
- return -1;
- }
- return 0;
-}
-
-/*!
- * \brief Publish a \ref system_status_type message over \ref stasis
- *
- * \note The JSON object must contain a 'type' field
- *
- * \param payload The JSON payload to send with the message
- */
-static void publish_system_message(struct ast_json *obj)
-{
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
- RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
- struct ast_json *type;
-
- if (!obj) {
- return;
- }
-
- type = ast_json_object_get(obj, "type");
- if (type == NULL) {
- ast_log(LOG_ERROR, "Invalid JSON for system message; missing type field\n");
- return;
- }
-
- payload = ast_json_payload_create(obj);
- if (!payload) {
- return;
- }
-
- message = stasis_message_create(ast_system_status_type(), payload);
- if (!message) {
- return;
- }
- stasis_publish(ast_system_topic(), message);
-}
-
-static void publish_fully_booted(void)
-{
- RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
-
- json_object = ast_json_pack("s: s",
- "type", "fullybooted");
- publish_system_message(json_object);
-}
-
/*! \brief Give an overview of core settings */
static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -1168,13 +1076,20 @@
return network_change_type;
}
+struct stasis_message_type *ast_system_status_type(void)
+{
+ return system_status_type;
+}
+
/*! \brief Cleanup the \ref stasis system level items */
static void stasis_system_topic_cleanup(void)
{
- ao2_ref(system_topic, -1);
+ ao2_cleanup(system_topic);
system_topic = NULL;
- ao2_ref(network_change_type, -1);
+ ao2_cleanup(network_change_type);
network_change_type = NULL;
+ ao2_cleanup(system_status_type);
+ system_status_type = NULL;
}
/*! \brief Initialize the system level items for \ref stasis */
@@ -1191,7 +1106,56 @@
if (!network_change_type) {
return -1;
}
+
+ system_status_type = stasis_message_type_create("system_status");
+ if (!system_status_type) {
+ return -1;
+ }
return 0;
+}
+
+/*!
+ * \brief Publish a \ref system_status_type message over \ref stasis
+ *
+ * \note The JSON object must contain a 'type' field
+ *
+ * \param payload The JSON payload to send with the message
+ */
+static void publish_system_message(struct ast_json *obj)
+{
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
+ struct ast_json *type;
+
+ if (!obj) {
+ return;
+ }
+
+ type = ast_json_object_get(obj, "type");
+ if (type == NULL) {
+ ast_log(LOG_ERROR, "Invalid JSON for system message; missing type field\n");
+ return;
+ }
+
+ payload = ast_json_payload_create(obj);
+ if (!payload) {
+ return;
+ }
+
+ message = stasis_message_create(ast_system_status_type(), payload);
+ if (!message) {
+ return;
+ }
+ stasis_publish(ast_system_topic(), message);
+}
+
+static void publish_fully_booted(void)
+{
+ RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+
+ json_object = ast_json_pack("s: s",
+ "type", "fullybooted");
+ publish_system_message(json_object);
}
static void ast_run_atexits(void)
More information about the asterisk-commits
mailing list