[asterisk-commits] mmichelson: branch group/CCSS r227051 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 2 17:03:37 CST 2009


Author: mmichelson
Date: Mon Nov  2 17:03:32 2009
New Revision: 227051

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227051
Log:
Fix compilation through rearrangement.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=227051&r1=227050&r2=227051
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Mon Nov  2 17:03:32 2009
@@ -1368,38 +1368,6 @@
 	.duplicate = dialed_cc_interfaces_duplicate,
 	.destroy = dialed_cc_interfaces_destroy,
 };
-
-/*!
- * \brief Routine to set the ignore flag on all CC datastores
- *
- * When we determine that further calls to Dial in a particular thread should
- * not pay attention to any new CC offers, we set this flag as an indicator.
- *
- * The same also applies for recall purposes. If a call is forwarded or a second
- * Dial is invoked, then the target cannot be a purposeful target of a CC recall.
- *
- * \param chan The calling channel with teh dial_cc_interfaaces datastore on it
- * \return void
- */
-void ast_ignore_cc(struct ast_channel *chan)
-{
-	struct ast_datastore *cc_datastore;
-	struct ast_datastore *cc_recall_datastore;
-	struct dialed_cc_interfaces *cc_interfaces;
-	struct cc_recall_ds_data *recall_cc_data;
-
-	ast_channel_lock(chan);
-	if ((cc_datastore = ast_channel_datastore_find(chan, &dialed_cc_interfaces_info, NULL))) {
-		cc_interfaces = cc_datastore->data;
-		cc_interfaces->done = 1;
-	}
-
-	if ((cc_recall_datastore = ast_channel_datastore_find(chan, &recall_ds_info, NULL))) {
-		recall_cc_data = cc_recall_datastore->data;
-		recall_cc_data->done = 1;
-	}
-	ast_channel_unlock(chan);
-}
 
 void ast_cc_set_extension_dialable_name(struct ast_channel *chan, const char * const dialable_name)
 {
@@ -2599,229 +2567,6 @@
 	return ast_taskprocessor_push(cc_core_taskprocessor, cc_do_state_change, args);
 }
 
-int ast_cc_offer(struct ast_channel *caller_chan)
-{
-	int core_id;
-	int res = -1;
-	struct ast_datastore *datastore;
-	struct dialed_cc_interfaces *cc_interfaces;
-	char cc_is_offerable;
-	
-	ast_channel_lock(caller_chan);
-	if (!(datastore = ast_channel_datastore_find(caller_chan, &dialed_cc_interfaces_info, NULL))) {
-		ast_channel_unlock(caller_chan);
-		return res;
-	}
-
-	cc_interfaces = datastore->data;
-	cc_is_offerable = cc_interfaces->cc_is_offerable;
-	core_id = cc_interfaces->core_id;
-	ast_channel_unlock(caller_chan);
-
-	if (cc_is_offerable) {
-		res = cc_request_state_change(CC_CALLER_OFFERED, core_id, "Offer CC to caller");
-	}
-	return res;
-}
-
-int ast_cc_accept_request(int core_id, const char * const debug)
-{
-	return cc_request_state_change(CC_CALLER_REQUESTED, core_id, debug);
-}
-
-int ast_cc_request_acknowledged(int core_id, const char * const debug)
-{
-	return cc_request_state_change(CC_ACTIVE, core_id, debug);
-}
-
-int ast_cc_callee_available(struct ast_cc_monitor *monitor) {
-	return ast_taskprocessor_push(cc_core_taskprocessor, cc_devstate_change,
-			cc_ref(monitor, "Bump reference count until cc_devstate_change executes"));
-}
-
-int ast_cc_caller_busy(int core_id, const char * debug)
-{
-	return cc_request_state_change(CC_CALLER_BUSY, core_id, debug);
-}
-
-int ast_cc_caller_available(int core_id, const char * const debug)
-{
-	return cc_request_state_change(CC_ACTIVE, core_id, debug);
-}
-
-int ast_cc_recalling(int core_id, const char * const debug)
-{
-	return cc_request_state_change(CC_RECALLING, core_id, debug);
-}
-
-int ast_cc_completed(struct ast_channel *chan, const char * const debug)
-{
-	struct ast_datastore *recall_datastore;
-	struct cc_recall_ds_data *recall_data;
-	int core_id;
-
-	ast_channel_lock(chan);
-	if (!(recall_datastore = ast_channel_datastore_find(chan, &recall_ds_info, NULL))) {
-		/* Silly! Why did you call this function if there's no recall DS? */
-		ast_channel_unlock(chan);
-		return -1;
-	}
-	recall_data = recall_datastore->data;
-	if (recall_data->nested || recall_data->done) {
-		/* If this is being called from a nested Dial, it is too
-		 * early to determine if the recall has actually completed.
-		 * The outermost dial is the only one with the authority to
-		 * declare the recall to be complete.
-		 *
-		 * Similarly, if this function has been called when the 
-		 * recall has progressed beyond the first dial, this is not
-		 * a legitimate time to declare the recall to be done. In fact,
-		 * that should have been done already.
-		 */
-		ast_channel_unlock(chan);
-		return -1;
-	}
-
-	core_id = recall_data->core_id;
-	ast_channel_unlock(chan);
-	return cc_request_state_change(CC_COMPLETE, core_id, debug);
-}
-
-int ast_cc_failed(int core_id, const char * const debug)
-{
-	return cc_request_state_change(CC_FAILED, core_id, debug);
-}
-
-static int cc_status_request(void *data)
-{
-	struct cc_core_instance *core_instance= data;
-	int res;
-
-	res = core_instance->agent->callbacks->status_request(core_instance->agent);
-	cc_unref(core_instance, "Status request finished. Unref core instance");
-	return res;
-}
-
-int ast_cc_status_request(int core_id)
-{
-	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
-
-	if (!core_instance) {
-		return -1;
-	}
-
-	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_request,
-			cc_ref(core_instance, "Ref core instance for status request callback"));
-}
-
-struct cc_status_response_args {
-	enum ast_device_state devstate;
-	struct cc_core_instance *core_instance;
-};
-
-static int cc_status_response(void *data)
-{
-	struct cc_status_response_args *args;
-	struct cc_core_instance *core_instance = args->core_instance;
-	enum ast_device_state devstate = args->devstate;
-	int res;
-
-	res = core_instance->monitor->callbacks->status_response(core_instance->monitor, core_instance->core_id, devstate);
-	cc_unref(core_instance, "Status response finished. Unref core instance");
-	return res;
-}
-
-int ast_cc_status_response(int core_id, enum ast_device_state devstate)
-{
-	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
-
-	if (!core_instance || !core_instance->monitor) {
-		return -1;
-	}
-
-	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_response,
-			cc_ref(core_instance, "Ref core instance for status response callback"));
-}
-
-static char *ccreq_app = "CallCompletionRequest";
-
-static int ccreq_exec(struct ast_channel *chan, const char *data)
-{
-	struct cc_core_instance *core_instance;
-	char interface[AST_CHANNEL_NAME];
-	unsigned long match_flags;
-	int res;
-
-	ast_channel_get_device_name(chan, interface, sizeof(interface));
-
-	match_flags = MATCH_NO_MONITOR;
-	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionRequest"))) {
-		ast_log_dynamic_level(cc_logger_level, "Couldn't find a core instance for caller %s\n", interface);
-		return -1;
-	}
-
-	ast_log_dynamic_level(cc_logger_level, "Found core_instance with core_id %d\n", core_instance->core_id);
-
-	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
-		ast_log_dynamic_level(cc_logger_level, "CallCompletionRequest is only for generic agent types.\n");
-		cc_unref(core_instance, "Unref core_instance since CallCompletionRequest was called with native agent");
-		return -1;
-	}
-
-	if (!ast_cc_request_is_within_limits()) {
-		ast_log_dynamic_level(cc_logger_level, "CallCompletionRequest failed. Too many requests in the system\n");
-		ast_cc_failed(core_instance->core_id, "Too many CC requests\n");
-		return -1;
-	}
-
-	res = ast_cc_accept_request(core_instance->core_id, "CallCompletionRequest called");
-	cc_unref(core_instance, "Done with CallCompletionRequest");
-	return res;
-}
-
-static char *cccancel_app = "CallCompletionCancel";
-
-static int cccancel_exec(struct ast_channel *chan, const char *data)
-{
-	struct cc_core_instance *core_instance;
-	char interface[AST_CHANNEL_NAME];
-	unsigned long match_flags;
-	int res;
-
-	ast_channel_get_device_name(chan, interface, sizeof(interface));
-
-	match_flags = MATCH_MONITOR;
-	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionCancel"))) {
-		ast_log(LOG_WARNING, "Cannot find CC transaction to cancel for caller %s\n", interface);
-		return -1;
-	}
-
-	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
-		ast_log(LOG_WARNING, "CallCompletionCancel may only be used for calles with a generic agent\n");
-		cc_unref(core_instance, "Unref core instance found during CallCompletionCancel");
-		return -1;
-	}
-	res = ast_cc_failed(core_instance->core_id, "Call completion request Cancelled");
-	cc_unref(core_instance, "Unref core instance found during CallCompletionCancel");
-	return res;
-}
-
-
-int ast_cc_monitor_count(const char * const name, const char * const type)
-{
-	struct ast_cc_monitor *monitor;
-	int retval = 0;
-
-	if (!(monitor = find_monitor(name, type))) {
-		/* Can't find it, so there must not be any outstanding requests for it */
-		return 0;
-	}
-
-	retval = monitor->num_requests;
-	cc_unref(monitor, "Unref from ao2_find");
-	return retval;
-}
-
 struct cc_recall_ds_data {
 	int core_id;
 	char done;
@@ -3007,6 +2752,261 @@
 	ast_free(var_value);
 	return 0;
 }
+/*!
+ * \brief Routine to set the ignore flag on all CC datastores
+ *
+ * When we determine that further calls to Dial in a particular thread should
+ * not pay attention to any new CC offers, we set this flag as an indicator.
+ *
+ * The same also applies for recall purposes. If a call is forwarded or a second
+ * Dial is invoked, then the target cannot be a purposeful target of a CC recall.
+ *
+ * \param chan The calling channel with teh dial_cc_interfaaces datastore on it
+ * \return void
+ */
+void ast_ignore_cc(struct ast_channel *chan)
+{
+	struct ast_datastore *cc_datastore;
+	struct ast_datastore *cc_recall_datastore;
+	struct dialed_cc_interfaces *cc_interfaces;
+	struct cc_recall_ds_data *recall_cc_data;
+
+	ast_channel_lock(chan);
+	if ((cc_datastore = ast_channel_datastore_find(chan, &dialed_cc_interfaces_info, NULL))) {
+		cc_interfaces = cc_datastore->data;
+		cc_interfaces->done = 1;
+	}
+
+	if ((cc_recall_datastore = ast_channel_datastore_find(chan, &recall_ds_info, NULL))) {
+		recall_cc_data = cc_recall_datastore->data;
+		recall_cc_data->done = 1;
+	}
+	ast_channel_unlock(chan);
+}
+
+int ast_cc_offer(struct ast_channel *caller_chan)
+{
+	int core_id;
+	int res = -1;
+	struct ast_datastore *datastore;
+	struct dialed_cc_interfaces *cc_interfaces;
+	char cc_is_offerable;
+	
+	ast_channel_lock(caller_chan);
+	if (!(datastore = ast_channel_datastore_find(caller_chan, &dialed_cc_interfaces_info, NULL))) {
+		ast_channel_unlock(caller_chan);
+		return res;
+	}
+
+	cc_interfaces = datastore->data;
+	cc_is_offerable = cc_interfaces->cc_is_offerable;
+	core_id = cc_interfaces->core_id;
+	ast_channel_unlock(caller_chan);
+
+	if (cc_is_offerable) {
+		res = cc_request_state_change(CC_CALLER_OFFERED, core_id, "Offer CC to caller");
+	}
+	return res;
+}
+
+int ast_cc_accept_request(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_CALLER_REQUESTED, core_id, debug);
+}
+
+int ast_cc_request_acknowledged(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_ACTIVE, core_id, debug);
+}
+
+int ast_cc_callee_available(struct ast_cc_monitor *monitor) {
+	return ast_taskprocessor_push(cc_core_taskprocessor, cc_devstate_change,
+			cc_ref(monitor, "Bump reference count until cc_devstate_change executes"));
+}
+
+int ast_cc_caller_busy(int core_id, const char * debug)
+{
+	return cc_request_state_change(CC_CALLER_BUSY, core_id, debug);
+}
+
+int ast_cc_caller_available(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_ACTIVE, core_id, debug);
+}
+
+int ast_cc_recalling(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_RECALLING, core_id, debug);
+}
+
+int ast_cc_completed(struct ast_channel *chan, const char * const debug)
+{
+	struct ast_datastore *recall_datastore;
+	struct cc_recall_ds_data *recall_data;
+	int core_id;
+
+	ast_channel_lock(chan);
+	if (!(recall_datastore = ast_channel_datastore_find(chan, &recall_ds_info, NULL))) {
+		/* Silly! Why did you call this function if there's no recall DS? */
+		ast_channel_unlock(chan);
+		return -1;
+	}
+	recall_data = recall_datastore->data;
+	if (recall_data->nested || recall_data->done) {
+		/* If this is being called from a nested Dial, it is too
+		 * early to determine if the recall has actually completed.
+		 * The outermost dial is the only one with the authority to
+		 * declare the recall to be complete.
+		 *
+		 * Similarly, if this function has been called when the 
+		 * recall has progressed beyond the first dial, this is not
+		 * a legitimate time to declare the recall to be done. In fact,
+		 * that should have been done already.
+		 */
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	core_id = recall_data->core_id;
+	ast_channel_unlock(chan);
+	return cc_request_state_change(CC_COMPLETE, core_id, debug);
+}
+
+int ast_cc_failed(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_FAILED, core_id, debug);
+}
+
+static int cc_status_request(void *data)
+{
+	struct cc_core_instance *core_instance= data;
+	int res;
+
+	res = core_instance->agent->callbacks->status_request(core_instance->agent);
+	cc_unref(core_instance, "Status request finished. Unref core instance");
+	return res;
+}
+
+int ast_cc_status_request(int core_id)
+{
+	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
+
+	if (!core_instance) {
+		return -1;
+	}
+
+	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_request,
+			cc_ref(core_instance, "Ref core instance for status request callback"));
+}
+
+struct cc_status_response_args {
+	enum ast_device_state devstate;
+	struct cc_core_instance *core_instance;
+};
+
+static int cc_status_response(void *data)
+{
+	struct cc_status_response_args *args;
+	struct cc_core_instance *core_instance = args->core_instance;
+	enum ast_device_state devstate = args->devstate;
+	int res;
+
+	res = core_instance->monitor->callbacks->status_response(core_instance->monitor, core_instance->core_id, devstate);
+	cc_unref(core_instance, "Status response finished. Unref core instance");
+	return res;
+}
+
+int ast_cc_status_response(int core_id, enum ast_device_state devstate)
+{
+	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
+
+	if (!core_instance || !core_instance->monitor) {
+		return -1;
+	}
+
+	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_response,
+			cc_ref(core_instance, "Ref core instance for status response callback"));
+}
+
+static char *ccreq_app = "CallCompletionRequest";
+
+static int ccreq_exec(struct ast_channel *chan, const char *data)
+{
+	struct cc_core_instance *core_instance;
+	char interface[AST_CHANNEL_NAME];
+	unsigned long match_flags;
+	int res;
+
+	ast_channel_get_device_name(chan, interface, sizeof(interface));
+
+	match_flags = MATCH_NO_MONITOR;
+	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionRequest"))) {
+		ast_log_dynamic_level(cc_logger_level, "Couldn't find a core instance for caller %s\n", interface);
+		return -1;
+	}
+
+	ast_log_dynamic_level(cc_logger_level, "Found core_instance with core_id %d\n", core_instance->core_id);
+
+	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
+		ast_log_dynamic_level(cc_logger_level, "CallCompletionRequest is only for generic agent types.\n");
+		cc_unref(core_instance, "Unref core_instance since CallCompletionRequest was called with native agent");
+		return -1;
+	}
+
+	if (!ast_cc_request_is_within_limits()) {
+		ast_log_dynamic_level(cc_logger_level, "CallCompletionRequest failed. Too many requests in the system\n");
+		ast_cc_failed(core_instance->core_id, "Too many CC requests\n");
+		return -1;
+	}
+
+	res = ast_cc_accept_request(core_instance->core_id, "CallCompletionRequest called");
+	cc_unref(core_instance, "Done with CallCompletionRequest");
+	return res;
+}
+
+static char *cccancel_app = "CallCompletionCancel";
+
+static int cccancel_exec(struct ast_channel *chan, const char *data)
+{
+	struct cc_core_instance *core_instance;
+	char interface[AST_CHANNEL_NAME];
+	unsigned long match_flags;
+	int res;
+
+	ast_channel_get_device_name(chan, interface, sizeof(interface));
+
+	match_flags = MATCH_MONITOR;
+	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionCancel"))) {
+		ast_log(LOG_WARNING, "Cannot find CC transaction to cancel for caller %s\n", interface);
+		return -1;
+	}
+
+	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
+		ast_log(LOG_WARNING, "CallCompletionCancel may only be used for calles with a generic agent\n");
+		cc_unref(core_instance, "Unref core instance found during CallCompletionCancel");
+		return -1;
+	}
+	res = ast_cc_failed(core_instance->core_id, "Call completion request Cancelled");
+	cc_unref(core_instance, "Unref core instance found during CallCompletionCancel");
+	return res;
+}
+
+
+int ast_cc_monitor_count(const char * const name, const char * const type)
+{
+	struct ast_cc_monitor *monitor;
+	int retval = 0;
+
+	if (!(monitor = find_monitor(name, type))) {
+		/* Can't find it, so there must not be any outstanding requests for it */
+		return 0;
+	}
+
+	retval = monitor->num_requests;
+	cc_unref(monitor, "Unref from ao2_find");
+	return retval;
+}
+
 
 static struct ast_cc_interface *root_interface_init(void)
 {




More information about the asterisk-commits mailing list