[asterisk-commits] kmoore: branch kmoore/stasis-device_state r384474 - in /team/kmoore/stasis-de...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 1 11:55:27 CDT 2013


Author: kmoore
Date: Mon Apr  1 11:55:24 2013
New Revision: 384474

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384474
Log:
Address dlee's review

Modified:
    team/kmoore/stasis-device_state/apps/app_queue.c
    team/kmoore/stasis-device_state/include/asterisk/devicestate.h
    team/kmoore/stasis-device_state/main/ccss.c
    team/kmoore/stasis-device_state/main/devicestate.c
    team/kmoore/stasis-device_state/main/pbx.c
    team/kmoore/stasis-device_state/res/res_jabber.c
    team/kmoore/stasis-device_state/res/res_xmpp.c
    team/kmoore/stasis-device_state/tests/test_devicestate.c

Modified: team/kmoore/stasis-device_state/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/apps/app_queue.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/apps/app_queue.c (original)
+++ team/kmoore/stasis-device_state/apps/app_queue.c Mon Apr  1 11:55:24 2013
@@ -1736,7 +1736,7 @@
 static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
 {
 	struct ao2_iterator miter, qiter;
-	struct stasis_device_state *dev_state;
+	struct ast_device_state_message *dev_state;
 	struct member *m;
 	struct call_queue *q;
 	char interface[80], *slash_pos;
@@ -1744,7 +1744,7 @@
 	int found_member;		/* Found this member in this queue */
 	int avail = 0;			/* Found an available member in this queue */
 
-	if (stasis_device_state_type() != stasis_message_type(msg)) {
+	if (ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -9926,7 +9926,7 @@
 	res |= ast_custom_function_register(&queuememberpenalty_function);
 
 	/* in the following subscribe call, do I use DEVICE_STATE, or DEVICE_STATE_CHANGE? */
-	if (!(device_state_sub = stasis_subscribe(stasis_device_state_topic_all(), device_state_cb, NULL))) {
+	if (!(device_state_sub = stasis_subscribe(ast_device_state_topic_all(), device_state_cb, NULL))) {
 		res = -1;
 	}
 

Modified: team/kmoore/stasis-device_state/include/asterisk/devicestate.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/include/asterisk/devicestate.h?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/include/asterisk/devicestate.h (original)
+++ team/kmoore/stasis-device_state/include/asterisk/devicestate.h Mon Apr  1 11:55:24 2013
@@ -274,7 +274,7 @@
  * \brief The structure that contains device state
  * \since 12
  */
-struct stasis_device_state {
+struct ast_device_state_message {
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(cache_id);	/*!< A unique ID used for hashing */
 		AST_STRING_FIELD(device);	/*!< The name of the device */
@@ -290,7 +290,7 @@
  * \retval NULL if it has not been allocated
  * \since 12
  */
-struct stasis_topic *stasis_device_state_topic_all(void);
+struct stasis_topic *ast_device_state_topic_all(void);
 
 /*!
  * \brief Get the Stasis topic for device state messages for a specific device
@@ -299,7 +299,7 @@
  * \retval NULL if it failed to be found or allocated
  * \since 12
  */
-struct stasis_topic *stasis_device_state_topic(const char *device);
+struct stasis_topic *ast_device_state_topic(const char *device);
 
 /*!
  * \brief Get the Stasis caching topic for device state messages
@@ -307,7 +307,7 @@
  * \retval NULL if it has not been allocated
  * \since 12
  */
-struct stasis_caching_topic *stasis_device_state_topic_cached(void);
+struct stasis_caching_topic *ast_device_state_topic_cached(void);
 
 /*!
  * \brief Get the Stasis message type for device state messages
@@ -315,7 +315,7 @@
  * \retval NULL if it has not been allocated
  * \since 12
  */
-struct stasis_message_type *stasis_device_state_type(void);
+struct stasis_message_type *ast_device_state_message_type(void);
 
 /*!
  * \brief Initialize the device state core
@@ -334,8 +334,8 @@
  * \retval -1 Failure
  * \since 12
  */
-#define stasis_publish_device_state(device, state, cachable) \
-	stasis_publish_device_state_full(device, state, cachable, &ast_eid_default)
+#define ast_publish_device_state(device, state, cachable) \
+	ast_publish_device_state_full(device, state, cachable, &ast_eid_default)
 
 /*!
  * \brief Publish a device state update with EID
@@ -347,7 +347,7 @@
  * \retval -1 Failure
  * \since 12
  */
-int stasis_publish_device_state_full(
+int ast_publish_device_state_full(
 			const char *device,
 			enum ast_device_state state,
 			enum ast_devstate_cache cachable,

Modified: team/kmoore/stasis-device_state/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/main/ccss.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/main/ccss.c (original)
+++ team/kmoore/stasis-device_state/main/ccss.c Mon Apr  1 11:55:24 2013
@@ -1286,7 +1286,7 @@
 	ast_tech_to_upper(device_name);
 	generic_list->device_name = device_name;
 
-	device_specific_topic = stasis_device_state_topic(device_name);
+	device_specific_topic = ast_device_state_topic(device_name);
 	if (!device_specific_topic) {
 		return NULL;
 	}
@@ -1302,7 +1302,7 @@
 
 static int generic_monitor_devstate_tp_cb(void *data)
 {
-	RAII_VAR(struct stasis_device_state *, dev_state, data, ao2_cleanup);
+	RAII_VAR(struct ast_device_state_message *, dev_state, data, ao2_cleanup);
 	enum ast_device_state new_state = dev_state->state;
 	enum ast_device_state previous_state;
 	struct generic_monitor_instance_list *generic_list;
@@ -1348,8 +1348,8 @@
 	 * so that all monitor operations can be serialized. Locks?! We don't need
 	 * no steenkin' locks!
 	 */
-	struct stasis_device_state *dev_state;
-	if (stasis_device_state_type() != stasis_message_type(msg)) {
+	struct ast_device_state_message *dev_state;
+	if (ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -1359,10 +1359,11 @@
 		return;
 	}
 
+	ao2_t_ref(dev_state, +1, "Bumping dev_state ref for cc_core_taskprocessor");
 	if (ast_taskprocessor_push(cc_core_taskprocessor, generic_monitor_devstate_tp_cb, dev_state)) {
+		ao2_cleanup(dev_state);
 		return;
 	}
-	ao2_t_ref(dev_state, +1, "Bumping dev_state ref for cc_core_taskprocessor");
 }
 
 int ast_cc_available_timer_expire(const void *data)
@@ -2628,13 +2629,13 @@
 {
 	struct ast_cc_agent *agent = userdata;
 	enum ast_device_state new_state;
-	struct stasis_device_state *dev_state;
+	struct ast_device_state_message *dev_state;
 	struct cc_generic_agent_pvt *generic_pvt = agent->private_data;
 
 	if (stasis_subscription_final_message(sub, msg)) {
 		cc_unref(agent, "Done holding ref for subscription");
 		return;
-	} else if (stasis_device_state_type() != stasis_message_type(msg)) {
+	} else if (ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -2664,7 +2665,7 @@
 	ast_str_set(&str, 0, "Agent monitoring %s device state since it is busy\n",
 		agent->device_name);
 
-	device_specific_topic = stasis_device_state_topic(agent->device_name);
+	device_specific_topic = ast_device_state_topic(agent->device_name);
 	if (!device_specific_topic) {
 		return -1;
 	}

Modified: team/kmoore/stasis-device_state/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/main/devicestate.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/main/devicestate.c (original)
+++ team/kmoore/stasis-device_state/main/devicestate.c Mon Apr  1 11:55:24 2013
@@ -282,9 +282,9 @@
 static enum ast_device_state devstate_cached(const char *device)
 {
 	RAII_VAR(struct stasis_message *, cached_msg, NULL, ao2_cleanup);
-	struct stasis_device_state *device_state;
-
-	cached_msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), device);
+	struct ast_device_state_message *device_state;
+
+	cached_msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), device);
 	if (!cached_msg) {
 		return AST_DEVICE_UNKNOWN;
 	}
@@ -423,7 +423,7 @@
 
 	ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, ast_devstate2str(state));
 
-	stasis_publish_device_state(device, state, cachable);
+	ast_publish_device_state(device, state, cachable);
 }
 
 int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
@@ -447,7 +447,7 @@
 	 */
 
 	if (state != AST_DEVICE_UNKNOWN) {
-		stasis_publish_device_state(device, state, cachable);
+		ast_publish_device_state(device, state, cachable);
 	} else if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
@@ -525,7 +525,7 @@
 	struct stasis_message *msg = obj;
 	struct ast_devstate_aggregate *aggregate = arg;
 	char *device = data;
-	struct stasis_device_state *device_state = stasis_message_data(msg);
+	struct ast_device_state_message *device_state = stasis_message_data(msg);
 
 	if (!device_state->eid || strcmp(device, device_state->device)) {
 		/* ignore aggregate states and devices that don't match */
@@ -539,14 +539,14 @@
 
 static void device_state_dtor(void *obj)
 {
-	struct stasis_device_state *device_state = obj;
+	struct ast_device_state_message *device_state = obj;
 	ast_string_field_free_memory(device_state);
 	ast_free(device_state->eid);
 }
 
-static struct stasis_device_state *device_state_alloc(const char *device, enum ast_device_state state, enum ast_devstate_cache cachable, const struct ast_eid *eid)
-{
-	RAII_VAR(struct stasis_device_state *, new_device_state, ao2_alloc(sizeof(*new_device_state), device_state_dtor), ao2_cleanup);
+static struct ast_device_state_message *device_state_alloc(const char *device, enum ast_device_state state, enum ast_devstate_cache cachable, const struct ast_eid *eid)
+{
+	RAII_VAR(struct ast_device_state_message *, new_device_state, ao2_alloc(sizeof(*new_device_state), device_state_dtor), ao2_cleanup);
 
 	if (!new_device_state || ast_string_field_init(new_device_state, 256)) {
 		return NULL;
@@ -585,7 +585,7 @@
 
 	ast_devstate_aggregate_init(&aggregate);
 
-	cached = stasis_cache_dump(stasis_device_state_topic_cached(), NULL);
+	cached = stasis_cache_dump(ast_device_state_topic_cached(), NULL);
 
 	ao2_callback_data(cached, OBJ_NODATA, devstate_change_aggregator_cb, &aggregate, device);
 
@@ -595,9 +595,9 @@
 static int aggregate_state_changed(char *device, enum ast_device_state new_aggregate_state)
 {
 	RAII_VAR(struct stasis_message *, cached_aggregate_msg, NULL, ao2_cleanup);
-	struct stasis_device_state *cached_aggregate_device_state;
-
-	cached_aggregate_msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), device);
+	struct ast_device_state_message *cached_aggregate_device_state;
+
+	cached_aggregate_msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), device);
 	if (!cached_aggregate_msg) {
 		return 1;
 	}
@@ -613,9 +613,9 @@
 {
 	enum ast_device_state aggregate_state;
 	char *device;
-	struct stasis_device_state *device_state;
+	struct ast_device_state_message *device_state;
 	RAII_VAR(struct stasis_message *, new_aggregate_msg, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_device_state *, new_aggregate_state, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_device_state_message *, new_aggregate_state, NULL, ao2_cleanup);
 
 	if (stasis_cache_update_type() == stasis_message_type(msg)) {
 		struct stasis_cache_update *update = stasis_message_data(msg);
@@ -625,7 +625,7 @@
 		msg = update->new_snapshot;
 	}
 
-	if (stasis_device_state_type() != stasis_message_type(msg)) {
+	if (ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -660,7 +660,7 @@
 	ast_debug(1, "Aggregate state for device '%s' has changed to '%s'\n",
 		device, ast_devstate2str(aggregate_state));
 
-	stasis_publish_device_state_full(device, aggregate_state, device_state->cachable, NULL);
+	ast_publish_device_state_full(device, aggregate_state, device_state->cachable, NULL);
 }
 
 /*! \brief Initialize the device state engine in separate thread */
@@ -713,33 +713,33 @@
 	return agg->state;
 }
 
-struct stasis_topic *stasis_device_state_topic_all(void)
+struct stasis_topic *ast_device_state_topic_all(void)
 {
 	return device_state_topic_all;
 }
 
-struct stasis_caching_topic *stasis_device_state_topic_cached(void)
+struct stasis_caching_topic *ast_device_state_topic_cached(void)
 {
 	return device_state_topic_cached;
 }
 
-struct stasis_message_type *stasis_device_state_type(void)
+struct stasis_message_type *ast_device_state_message_type(void)
 {
 	return device_state_message_type;
 }
 
-struct stasis_topic *stasis_device_state_topic(const char *device)
+struct stasis_topic *ast_device_state_topic(const char *device)
 {
 	return stasis_topic_pool_get_topic(device_state_topic_pool, device);
 }
 
-int stasis_publish_device_state_full(
+int ast_publish_device_state_full(
 			const char *device,
 			enum ast_device_state state,
 			enum ast_devstate_cache cachable,
 			struct ast_eid *eid)
 {
-	RAII_VAR(struct stasis_device_state *, device_state, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_device_state_message *, device_state, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 	struct stasis_topic *device_specific_topic;
 
@@ -750,9 +750,9 @@
 		return -1;
 	}
 
-	message = stasis_message_create(stasis_device_state_type(), device_state);
-
-	device_specific_topic = stasis_device_state_topic(device);
+	message = stasis_message_create(ast_device_state_message_type(), device_state);
+
+	device_specific_topic = ast_device_state_topic(device);
 	if (!device_specific_topic) {
 		return -1;
 	}
@@ -763,8 +763,8 @@
 
 static const char *device_state_get_id(struct stasis_message *message)
 {
-	struct stasis_device_state *device_state;
-	if (stasis_device_state_type() != stasis_message_type(message)) {
+	struct ast_device_state_message *device_state;
+	if (ast_device_state_message_type() != stasis_message_type(message)) {
 		return NULL;
 	}
 
@@ -789,7 +789,7 @@
 
 int devstate_init(void)
 {
-	device_state_topic_all = stasis_topic_create("stasis_device_state_topic");
+	device_state_topic_all = stasis_topic_create("ast_device_state_topic");
 	if (!device_state_topic_all) {
 		return -1;
 	}
@@ -797,16 +797,16 @@
 	if (!device_state_topic_cached) {
 		return -1;
 	}
-	device_state_message_type = stasis_message_type_create("stasis_device_state");
+	device_state_message_type = stasis_message_type_create("ast_device_state_message");
 	if (!device_state_message_type) {
 		return -1;
 	}
-	device_state_topic_pool = stasis_topic_pool_create(stasis_device_state_topic_all());
+	device_state_topic_pool = stasis_topic_pool_create(ast_device_state_topic_all());
 	if (!device_state_topic_pool) {
 		return -1;
 	}
 
-	devstate_message_sub = stasis_subscribe(stasis_caching_get_topic(stasis_device_state_topic_cached()), devstate_change_collector_cb, NULL);
+	devstate_message_sub = stasis_subscribe(stasis_caching_get_topic(ast_device_state_topic_cached()), devstate_change_collector_cb, NULL);
 
 	if (!devstate_message_sub) {
 		ast_log(LOG_ERROR, "Failed to create subscription for the device state change collector\n");

Modified: team/kmoore/stasis-device_state/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/main/pbx.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/main/pbx.c (original)
+++ team/kmoore/stasis-device_state/main/pbx.c Mon Apr  1 11:55:24 2013
@@ -5243,7 +5243,7 @@
 
 static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
 {
-	struct stasis_device_state *dev_state;
+	struct ast_device_state_message *dev_state;
 	struct ast_hint *hint;
 	struct ast_str *hint_app;
 	struct ast_hintdevice *device;
@@ -5253,7 +5253,7 @@
 	char context_name[AST_MAX_CONTEXT];
 	char exten_name[AST_MAX_EXTENSION];
 
-	if (stasis_device_state_type() != stasis_message_type(msg)) {
+	if (ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -11814,7 +11814,7 @@
 	/* Register manager application */
 	ast_manager_register_xml_core("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan);
 
-	if (!(device_state_sub = stasis_subscribe(stasis_device_state_topic_all(), device_state_cb, NULL))) {
+	if (!(device_state_sub = stasis_subscribe(ast_device_state_topic_all(), device_state_cb, NULL))) {
 		return -1;
 	}
 

Modified: team/kmoore/stasis-device_state/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/res/res_jabber.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/res/res_jabber.c (original)
+++ team/kmoore/stasis-device_state/res/res_jabber.c Mon Apr  1 11:55:24 2013
@@ -3277,9 +3277,9 @@
 static void aji_devstate_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
 {
 	struct aji_client *client = data;
-	struct stasis_device_state *dev_state;
-
-	if (!stasis_subscription_is_subscribed(sub) || stasis_device_state_type() != stasis_message_type(msg)) {
+	struct ast_device_state_message *dev_state;
+
+	if (!stasis_subscription_is_subscribed(sub) || ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -3312,9 +3312,9 @@
 	}
 	if (!device_state_sub) {
 		RAII_VAR(struct ao2_container *, cached, NULL, ao2_cleanup);
-		device_state_sub = stasis_subscribe(stasis_device_state_topic_all(),
+		device_state_sub = stasis_subscribe(ast_device_state_topic_all(),
 			aji_devstate_cb, client);
-		cached = stasis_cache_dump(stasis_device_state_topic_cached(), NULL);
+		cached = stasis_cache_dump(ast_device_state_topic_cached(), NULL);
 		ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, client);
 	}
 
@@ -3359,7 +3359,7 @@
 		if ((cachable_str = iks_find_cdata(item, "cachable"))) {
 			sscanf(cachable_str, "%30d", &cachable);
 		}
-		stasis_publish_device_state_full(item_id,
+		ast_publish_device_state_full(item_id,
 						ast_devstate_val(device_state),
 						cachable == AST_DEVSTATE_CACHABLE ? AST_DEVSTATE_CACHABLE : AST_DEVSTATE_NOT_CACHABLE,
 						&pubsub_eid);

Modified: team/kmoore/stasis-device_state/res/res_xmpp.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/res/res_xmpp.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/res/res_xmpp.c (original)
+++ team/kmoore/stasis-device_state/res/res_xmpp.c Mon Apr  1 11:55:24 2013
@@ -1355,9 +1355,9 @@
 static void xmpp_pubsub_devstate_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
 {
 	struct ast_xmpp_client *client = data;
-	struct stasis_device_state *dev_state;
-
-	if (!stasis_subscription_is_subscribed(sub) || stasis_device_state_type() != stasis_message_type(msg)) {
+	struct ast_device_state_message *dev_state;
+
+	if (!stasis_subscription_is_subscribed(sub) || ast_device_state_message_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -1474,7 +1474,7 @@
 		if ((cachable_str = iks_find_cdata(item, "cachable"))) {
 			sscanf(cachable_str, "%30d", &cachable);
 		}
-		stasis_publish_device_state_full(item_id,
+		ast_publish_device_state_full(item_id,
 						ast_devstate_val(device_state),
 						cachable == AST_DEVSTATE_CACHABLE ? AST_DEVSTATE_CACHABLE : AST_DEVSTATE_NOT_CACHABLE,
 						&pubsub_eid);
@@ -1600,12 +1600,12 @@
 		return;
 	}
 
-	if (!(client->device_state_sub = stasis_subscribe(stasis_device_state_topic_all(), xmpp_pubsub_devstate_cb, client))) {
+	if (!(client->device_state_sub = stasis_subscribe(ast_device_state_topic_all(), xmpp_pubsub_devstate_cb, client))) {
 		client->mwi_sub = stasis_unsubscribe(client->mwi_sub);
 		return;
 	}
 
-	cached = stasis_cache_dump(stasis_device_state_topic_cached(), NULL);
+	cached = stasis_cache_dump(ast_device_state_topic_cached(), NULL);
 	ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, client);
 
 	xmpp_pubsub_subscribe(client, "device_state");

Modified: team/kmoore/stasis-device_state/tests/test_devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/tests/test_devicestate.c?view=diff&rev=384474&r1=384473&r2=384474
==============================================================================
--- team/kmoore/stasis-device_state/tests/test_devicestate.c (original)
+++ team/kmoore/stasis-device_state/tests/test_devicestate.c Mon Apr  1 11:55:24 2013
@@ -314,7 +314,7 @@
 	struct consumer *consumer = data;
 	RAII_VAR(struct consumer *, consumer_needs_cleanup, NULL, ao2_cleanup);
 	struct stasis_cache_update *cache_update = stasis_message_data(message);
-	struct stasis_device_state *device_state;
+	struct ast_device_state_message *device_state;
 	SCOPED_MUTEX(lock, &consumer->lock);
 
 	if (!cache_update->new_snapshot) {
@@ -378,15 +378,15 @@
 static int remove_device_states_cb(void *obj, void *arg, int flags)
 {
 	RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);
-	struct stasis_device_state *device_state = stasis_message_data(msg);
+	struct ast_device_state_message *device_state = stasis_message_data(msg);
 	if (strcmp(UNIT_TEST_DEVICE_IDENTIFIER, device_state->device)) {
 		msg = NULL;
 		return 0;
 	}
 
-	msg = stasis_cache_clear_create(stasis_device_state_type(), device_state->cache_id);
+	msg = stasis_cache_clear_create(ast_device_state_message_type(), device_state->cache_id);
 	/* topic guaranteed to have been created by this point */
-	stasis_publish(stasis_device_state_topic(device_state->device), msg);
+	stasis_publish(ast_device_state_topic(device_state->device), msg);
 	return 0;
 }
 
@@ -394,7 +394,7 @@
 {
 	RAII_VAR(struct ao2_container *, cache_dump, NULL, ao2_cleanup);
 	/* remove all device states created during this test */
-	cache_dump = stasis_cache_dump(stasis_device_state_topic_cached(), NULL);
+	cache_dump = stasis_cache_dump(ast_device_state_topic_cached(), NULL);
 	if (!cache_dump) {
 		return;
 	}
@@ -408,7 +408,7 @@
 	RAII_VAR(struct ast_eid *, foreign_eid, NULL, ast_free);
 	RAII_VAR(int, cleanup_cache, 0, cache_cleanup);
 	int res;
-	struct stasis_device_state *device_state;
+	struct ast_device_state_message *device_state;
 	struct stasis_message *msg;
 
 	switch (cmd) {
@@ -434,7 +434,7 @@
 	consumer = consumer_create();
 	ast_test_validate(test, NULL != consumer);
 
-	device_msg_router = stasis_message_router_create(stasis_caching_get_topic(stasis_device_state_topic_cached()));
+	device_msg_router = stasis_message_router_create(stasis_caching_get_topic(ast_device_state_topic_cached()));
 	ast_test_validate(test, NULL != device_msg_router);
 
 	ao2_ref(consumer, +1);
@@ -445,13 +445,13 @@
 	ast_test_validate(test, !res);
 
 	/* push local state */
-	stasis_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE);
+	ast_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE);
 
 	consumer_wait_for(consumer);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->state);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->aggregate_state);
 
-	msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), UNIT_TEST_DEVICE_IDENTIFIER);
+	msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER);
 	device_state = stasis_message_data(msg);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == device_state->state);
 	ao2_cleanup(msg);
@@ -460,39 +460,39 @@
 	/* push remote state */
 	/* this will not produce a new aggregate state message since the aggregate state does not change */
 	consumer->sig_on_non_aggregate_state = 1;
-	stasis_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
+	ast_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
 
 	consumer_wait_for(consumer);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->state);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == consumer->aggregate_state);
 
-	msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), UNIT_TEST_DEVICE_IDENTIFIER);
+	msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER);
 	device_state = stasis_message_data(msg);
 	ast_test_validate(test, AST_DEVICE_NOT_INUSE == device_state->state);
 	ao2_cleanup(msg);
 	msg = NULL;
 
 	/* push remote state different from local state */
-	stasis_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
+	ast_publish_device_state_full(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, foreign_eid);
 
 	consumer_wait_for(consumer);
 	ast_test_validate(test, AST_DEVICE_INUSE == consumer->state);
 	ast_test_validate(test, AST_DEVICE_INUSE == consumer->aggregate_state);
 
-	msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), UNIT_TEST_DEVICE_IDENTIFIER);
+	msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER);
 	device_state = stasis_message_data(msg);
 	ast_test_validate(test, AST_DEVICE_INUSE == device_state->state);
 	ao2_cleanup(msg);
 	msg = NULL;
 
 	/* push local state that will cause aggregated state different from local non-aggregate state */
-	stasis_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE);
+	ast_publish_device_state(UNIT_TEST_DEVICE_IDENTIFIER, AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE);
 
 	consumer_wait_for(consumer);
 	ast_test_validate(test, AST_DEVICE_RINGING == consumer->state);
 	ast_test_validate(test, AST_DEVICE_RINGINUSE == consumer->aggregate_state);
 
-	msg = stasis_cache_get(stasis_device_state_topic_cached(), stasis_device_state_type(), UNIT_TEST_DEVICE_IDENTIFIER);
+	msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), UNIT_TEST_DEVICE_IDENTIFIER);
 	device_state = stasis_message_data(msg);
 	ast_test_validate(test, AST_DEVICE_RINGINUSE == device_state->state);
 	ao2_cleanup(msg);




More information about the asterisk-commits mailing list