[asterisk-commits] mmichelson: branch group/CCSS r214271 - in /team/group/CCSS: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 26 16:49:54 CDT 2009


Author: mmichelson
Date: Wed Aug 26 16:49:50 2009
New Revision: 214271

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214271
Log:
Some rearranging and fill out ast_cc_agent_init more.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=214271&r1=214270&r2=214271
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Aug 26 16:49:50 2009
@@ -548,10 +548,6 @@
 };
 
 struct ast_cc_agent {
-	/*! The type of the agent being used. Will be a string
-	 * such as "SIP" "ISDN" or "generic"
-	 */
-	const char *type;
 	/*! Which instance of the core state machine does this
 	 * agent pertain to?
 	 */
@@ -568,8 +564,7 @@
 	/*!
 	 * \brief Type of agent the callbacks belong to.
 	 * 
-	 * Identical to the type field of the corresponding
-	 * ast_cc_agent
+	 * Examples are "SIP" "ISDN" and "generic"
 	 */
 	const char *type;
 	/*!

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=214271&r1=214270&r2=214271
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Aug 26 16:49:50 2009
@@ -52,6 +52,21 @@
 static const unsigned int CCBS_AVAILABLE_TIMER_DEFAULT = 4800u;
 static const unsigned int CC_MAX_AGENTS_DEFAULT = 5u;
 static const unsigned int CC_MAX_MONITORS_DEFAULT = 5u;
+
+/* Generic agent callbacks */
+static void *cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
+static void cc_generic_agent_ack(struct ast_cc_agent *agent);
+static enum ast_device_state cc_generic_agent_status_request(struct ast_cc_agent *agent);
+static int cc_generic_agent_recall(struct ast_cc_agent *agent);
+static void cc_generic_agent_destructor(struct ast_cc_agent *agent);
+
+static struct ast_cc_agent_callbacks generic_agent_callbacks = {
+	.init = cc_generic_agent_init,
+	.ack = cc_generic_agent_ack,
+	.status_request = cc_generic_agent_status_request,
+	.recall = cc_generic_agent_recall,
+	.destructor = cc_generic_agent_destructor,
+};
 
 struct ast_cc_config_params *__ast_cc_config_params_init(const char *file, int line, const char *function)
 {
@@ -493,12 +508,35 @@
 	return pending_offer;
 }
 
-static struct ast_cc_agent *cc_agent_init(struct ast_channel *caller_chan) {
+static void check_callback_sanity(const struct ast_cc_agent_callbacks *callbacks)
+{
+	ast_assert(callbacks->init != NULL);
+	ast_assert(callbacks->ack != NULL);
+	ast_assert(callbacks->status_request != NULL);
+	ast_assert(callbacks->recall != NULL);
+	ast_assert(callbacks->destructor != NULL);
+}
+
+static struct ast_cc_agent *cc_agent_init(struct ast_channel *caller_chan, 
+		const int core_id) 
+{
 	struct ast_cc_agent *agent;
 
 	if (!(agent = ast_calloc(1, sizeof(*agent)))) {
 		return NULL;
 	}
+
+	agent->core_id = core_id;
+	/* XXX Obviously this will need to be revisited.
+	 * For now, I'm keeping it simple by using only generic
+	 * agents.
+	 */
+	agent->callbacks = &generic_agent_callbacks;
+	check_callback_sanity(agent->callbacks);
+	if (!(agent->private_data = agent->callbacks->init(agent, caller_chan))) {
+		ast_free(agent);
+		return NULL;
+	}
 	return agent;
 }
 
@@ -508,7 +546,8 @@
 	ast_free(core_instance->agent);
 }
 
-int ast_cc_core_init_instance(struct ast_channel *caller_chan, struct ast_cc_interface_tree *called_tree)
+int ast_cc_core_init_instance(struct ast_channel *caller_chan, 
+		struct ast_cc_interface_tree *called_tree)
 {
 	char *caller = ast_strdupa(caller_chan->name);
 	char *dash = strrchr(caller, '-');
@@ -536,7 +575,7 @@
 	}
 
 	core_instance->core_id = pending_offer->core_id;
-	if (!(core_instance->agent = cc_agent_init(caller_chan))) {
+	if (!(core_instance->agent = cc_agent_init(caller_chan, core_instance->core_id))) {
 		ao2_ref(pending_offer, -1);
 		ao2_ref(core_instance, -1);
 		return -1;
@@ -575,14 +614,6 @@
 	return;
 }
 
-static struct ast_cc_agent_callbacks generic_agent_callbacks = {
-	.init = cc_generic_agent_init,
-	.ack = cc_generic_agent_ack,
-	.status_request = cc_generic_agent_status_request,
-	.recall = cc_generic_agent_recall,
-	.destructor = cc_generic_agent_destructor,
-};
-
 int ast_cc_init(void)
 {
 	if (!(pending_cc_offers = ao2_container_alloc(CC_PENDING_OFFER_BUCKETS,




More information about the asterisk-commits mailing list