[svn-commits] rmudgett: branch rmudgett/bridge_phase r393360 - in /team/rmudgett/bridge_pha...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 1 16:22:45 CDT 2013


Author: rmudgett
Date: Mon Jul  1 16:22:43 2013
New Revision: 393360

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393360
Log:
Make AgentLogin/AgentLogoff stasis message types public so app_queue can subscribe to them.

Modified:
    team/rmudgett/bridge_phase/apps/app_agent_pool.c
    team/rmudgett/bridge_phase/include/asterisk/stasis_channels.h
    team/rmudgett/bridge_phase/main/stasis_channels.c

Modified: team/rmudgett/bridge_phase/apps/app_agent_pool.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/apps/app_agent_pool.c?view=diff&rev=393360&r1=393359&r2=393360
==============================================================================
--- team/rmudgett/bridge_phase/apps/app_agent_pool.c (original)
+++ team/rmudgett/bridge_phase/apps/app_agent_pool.c Mon Jul  1 16:22:43 2013
@@ -179,35 +179,6 @@
 			<para>Sets an agent as no longer logged in.</para>
 		</description>
 	</manager>
-	<managerEvent language="en_US" name="AgentLogin">
-		<managerEventInstance class="EVENT_FLAG_AGENT">
-			<synopsis>Raised when an Agent has logged in.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-				<parameter name="Agent">
-					<para>The name of the agent.</para>
-				</parameter>
-			</syntax>
-			<see-also>
-				<ref type="application">AgentLogin</ref>
-				<ref type="managerEvent">Agentlogoff</ref>
-			</see-also>
-		</managerEventInstance>
-	</managerEvent>
-	<managerEvent language="en_US" name="AgentLogoff">
-		<managerEventInstance class="EVENT_FLAG_AGENT">
-			<synopsis>Raised when an Agent has logged off.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentLogin']/managerEventInstance/syntax/parameter)" />
-				<parameter name="Logintime">
-					<para>The number of seconds the agent was logged in.</para>
-				</parameter>
-			</syntax>
-			<see-also>
-				<ref type="managerEvent">AgentLogin</ref>
-			</see-also>
-		</managerEventInstance>
-	</managerEvent>
  ***/
 
 /* ------------------------------------------------------------------- */
@@ -1308,28 +1279,6 @@
 	return 0;
 }
 
-static struct ast_manager_event_blob *login_to_ami(struct stasis_message *msg)
-{
-	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
-	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
-	struct ast_channel_blob *obj = stasis_message_data(msg);
-	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
-
-	channel_string = ast_manager_build_channel_state_string(obj->snapshot);
-	if (!channel_string) {
-		return NULL;
-	}
-
-	return ast_manager_event_blob_create(EVENT_FLAG_AGENT, "AgentLogin",
-		"%s"
-		"Agent: %s\r\n",
-		ast_str_buffer(channel_string), agent);
-}
-
-STASIS_MESSAGE_TYPE_DEFN_LOCAL(login_type,
-	.to_ami = login_to_ami,
-	);
-
 static void send_agent_login(struct ast_channel *chan, const char *agent)
 {
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
@@ -1342,32 +1291,8 @@
 		return;
 	}
 
-	ast_channel_publish_blob(chan, login_type(), blob);
-}
-
-static struct ast_manager_event_blob *logoff_to_ami(struct stasis_message *msg)
-{
-	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
-	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
-	struct ast_channel_blob *obj = stasis_message_data(msg);
-	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
-	long logintime = ast_json_integer_get(ast_json_object_get(obj->blob, "logintime"));
-
-	channel_string = ast_manager_build_channel_state_string(obj->snapshot);
-	if (!channel_string) {
-		return NULL;
-	}
-
-	return ast_manager_event_blob_create(EVENT_FLAG_AGENT, "AgentLogoff",
-		"%s"
-		"Agent: %s\r\n"
-		"Logintime: %ld\r\n",
-		ast_str_buffer(channel_string), agent, logintime);
-}
-
-STASIS_MESSAGE_TYPE_DEFN_LOCAL(logoff_type,
-	.to_ami = logoff_to_ami,
-	);
+	ast_channel_publish_blob(chan, ast_channel_agent_login_type(), blob);
+}
 
 static void send_agent_logoff(struct ast_channel *chan, const char *agent, long logintime)
 {
@@ -1382,7 +1307,7 @@
 		return;
 	}
 
-	ast_channel_publish_blob(chan, logoff_type(), blob);
+	ast_channel_publish_blob(chan, ast_channel_agent_logoff_type(), blob);
 }
 
 /*!
@@ -2459,39 +2384,22 @@
 	destroy_config();
 	ao2_ref(agents, -1);
 	agents = NULL;
-
-	STASIS_MESSAGE_TYPE_CLEANUP(login_type);
-	STASIS_MESSAGE_TYPE_CLEANUP(logoff_type);
 	return 0;
 }
 
 static int load_module(void)
 {
 	int res = 0;
-
-/* BUGBUG need to make these message types public so app_queue can subscribe to them for its log. */
-	if (STASIS_MESSAGE_TYPE_INIT(login_type)) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
-
-	if (STASIS_MESSAGE_TYPE_INIT(logoff_type)) {
-		STASIS_MESSAGE_TYPE_CLEANUP(login_type);
-		return AST_MODULE_LOAD_FAILURE;
-	}
 
 	agents = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_MUTEX,
 		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, agent_pvt_sort_cmp, agent_pvt_cmp);
 	if (!agents) {
-		STASIS_MESSAGE_TYPE_CLEANUP(login_type);
-		STASIS_MESSAGE_TYPE_CLEANUP(logoff_type);
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	if (load_config()) {
 		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
 		ao2_ref(agents, -1);
 		agents = NULL;
-		STASIS_MESSAGE_TYPE_CLEANUP(login_type);
-		STASIS_MESSAGE_TYPE_CLEANUP(logoff_type);
 		return AST_MODULE_LOAD_DECLINE;
 	}
 

Modified: team/rmudgett/bridge_phase/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/stasis_channels.h?view=diff&rev=393360&r1=393359&r2=393360
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/stasis_channels.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/stasis_channels.h Mon Jul  1 16:22:43 2013
@@ -422,6 +422,22 @@
 struct stasis_message_type *ast_channel_monitor_stop_type(void);
 
 /*!
+ * \since 12.0.0
+ * \brief Message type for agent login on a channel
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_agent_login_type(void);
+
+/*!
+ * \since 12.0.0
+ * \brief Message type for agent logoff on a channel
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_channel_agent_logoff_type(void);
+
+/*!
  * \since 12
  * \brief Message type for starting music on hold on a channel
  *

Modified: team/rmudgett/bridge_phase/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/stasis_channels.c?view=diff&rev=393360&r1=393359&r2=393360
==============================================================================
--- team/rmudgett/bridge_phase/main/stasis_channels.c (original)
+++ team/rmudgett/bridge_phase/main/stasis_channels.c Mon Jul  1 16:22:43 2013
@@ -50,6 +50,35 @@
 					<para>The new value of the variable.</para>
 				</parameter>
 			</syntax>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="AgentLogin">
+		<managerEventInstance class="EVENT_FLAG_AGENT">
+			<synopsis>Raised when an Agent has logged in.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Agent">
+					<para>The name of the agent.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="application">AgentLogin</ref>
+				<ref type="managerEvent">Agentlogoff</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="AgentLogoff">
+		<managerEventInstance class="EVENT_FLAG_AGENT">
+			<synopsis>Raised when an Agent has logged off.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentLogin']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Logintime">
+					<para>The number of seconds the agent was logged in.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="managerEvent">AgentLogin</ref>
+			</see-also>
 		</managerEventInstance>
 	</managerEvent>
 ***/
@@ -587,6 +616,44 @@
 		"Variable: %s\r\n"
 		"Value: %s\r\n",
 		ast_str_buffer(channel_event_string), variable, value);
+}
+
+static struct ast_manager_event_blob *agent_login_to_ami(struct stasis_message *msg)
+{
+	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
+	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
+	struct ast_channel_blob *obj = stasis_message_data(msg);
+	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
+
+	channel_string = ast_manager_build_channel_state_string(obj->snapshot);
+	if (!channel_string) {
+		return NULL;
+	}
+
+	return ast_manager_event_blob_create(EVENT_FLAG_AGENT, "AgentLogin",
+		"%s"
+		"Agent: %s\r\n",
+		ast_str_buffer(channel_string), agent);
+}
+
+static struct ast_manager_event_blob *agent_logoff_to_ami(struct stasis_message *msg)
+{
+	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
+	RAII_VAR(struct ast_str *, party_string, ast_str_create(256), ast_free);
+	struct ast_channel_blob *obj = stasis_message_data(msg);
+	const char *agent = ast_json_string_get(ast_json_object_get(obj->blob, "agent"));
+	long logintime = ast_json_integer_get(ast_json_object_get(obj->blob, "logintime"));
+
+	channel_string = ast_manager_build_channel_state_string(obj->snapshot);
+	if (!channel_string) {
+		return NULL;
+	}
+
+	return ast_manager_event_blob_create(EVENT_FLAG_AGENT, "AgentLogoff",
+		"%s"
+		"Agent: %s\r\n"
+		"Logintime: %ld\r\n",
+		ast_str_buffer(channel_string), agent, logintime);
 }
 
 void ast_publish_channel_state(struct ast_channel *chan)
@@ -697,6 +764,12 @@
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_moh_stop_type);
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_monitor_start_type);
 STASIS_MESSAGE_TYPE_DEFN(ast_channel_monitor_stop_type);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_agent_login_type,
+	.to_ami = agent_login_to_ami,
+	);
+STASIS_MESSAGE_TYPE_DEFN(ast_channel_agent_logoff_type,
+	.to_ami = agent_logoff_to_ami,
+	);
 
 /*! @} */
 
@@ -723,6 +796,8 @@
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_moh_stop_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_start_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_stop_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_agent_login_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_agent_logoff_type);
 }
 
 void ast_stasis_channels_init(void)
@@ -746,6 +821,8 @@
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_stop_type);
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_start_type);
 	STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_stop_type);
+	STASIS_MESSAGE_TYPE_INIT(ast_channel_agent_login_type);
+	STASIS_MESSAGE_TYPE_INIT(ast_channel_agent_logoff_type);
 
 	channel_topic_all = stasis_topic_create("ast_channel_topic_all");
 	channel_topic_all_cached = stasis_caching_topic_create(channel_topic_all, channel_snapshot_get_id);




More information about the svn-commits mailing list