[asterisk-commits] mmichelson: branch group/CCSS r214608 - in /team/group/CCSS: apps/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 28 10:56:45 CDT 2009


Author: mmichelson
Date: Fri Aug 28 10:56:41 2009
New Revision: 214608

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214608
Log:
Commit a bit of progress that compiles!

Try to get the ${CC_AVAIL} dialplan variable
set properly by app_dial. Modify pbx_builtin_hangup
to take a core_id so that a state change request
may be made.

I *should* be able to run a call to the point where
CC is offered to the caller, and then the offer timer
will eventually expire. Memory won't all be cleared
at this time since I don't have handlers installed for
CC_FAILED, but I can see if there are any serious
problems yet.


Modified:
    team/group/CCSS/apps/app_dial.c
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/pbx.c

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=214608&r1=214607&r2=214608
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Fri Aug 28 10:56:41 2009
@@ -1929,10 +1929,12 @@
 static void handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data)
 {
 	char device_name[AST_CHANNEL_NAME];
+	char core_id_str[20];
 	char *dash;
 	struct ast_cc_interface *cc_interface;
 	struct ast_datastore *cc_datastore;
 	struct dial_cc_interfaces *cc_interfaces;
+	int core_id;
 
 	ast_copy_string(device_name, outbound->name, sizeof(device_name));
 	if ((dash = strrchr(device_name, '-'))) {
@@ -1959,8 +1961,10 @@
 	 * save the list in the core.
 	 */
 	if (!cc_interfaces->core_created) {
-		ast_cc_core_init_instance(inbound, cc_interfaces->interface_tree);
+		core_id = ast_cc_core_init_instance(inbound, cc_interfaces->interface_tree);
 		cc_interfaces->core_created = 1;
+		snprintf(core_id_str, sizeof(core_id_str), "%d", core_id);
+		pbx_builtin_setvar_helper(inbound, "CC_AVAIL", core_id_str);
 	}
 }
 

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=214608&r1=214607&r2=214608
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Aug 28 10:56:41 2009
@@ -610,7 +610,7 @@
 		*dash = '\0';
 	}
 
-	/* First, we need to kill off other pending CC offers to caller. If the caller is going
+	/* First, we need to kill off other pending CC offers from caller. If the caller is going
 	 * to request a CC service, it may only be for the latest call he made.
 	 */
 	kill_duplicate_offers(caller);
@@ -635,7 +635,7 @@
 
 	ao2_link(cc_core_instances, core_instance);
 
-	return 0;
+	return core_instance->core_id;
 }
 
 static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
@@ -765,10 +765,12 @@
 			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
 			break;
 		}
-
 		if (core_instance->agent->callbacks->start_offer_timer(core_instance->agent)) {
 			ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Failed to start the offer timer\n");
+			break;
 		}
+		ast_log(LOG_NOTICE, "Started the offer timer for the agent!\n"); 
+		core_instance->current_state = args->state;
 		break;
 	case CC_CALLER_REQUESTED:
 		/* An English translation of this is that the only valid state change here is either if the current
@@ -846,6 +848,7 @@
 		return -1;
 	}
 
+	ast_log(LOG_NOTICE, "Placing request for state change to state %d\n", state);
 	return ast_taskprocessor_push(cc_core_taskprocessor, cc_do_state_change, args);
 }
 
@@ -855,15 +858,19 @@
 					pending_offer_hash_fn, pending_offer_cmp_fn))) {
 		return -1;
 	}
+	ast_log(LOG_NOTICE, "Successfully created pending offers container\n");
 	if (!(cc_core_instances = ao2_container_alloc(CC_CORE_INSTANCES_BUCKETS,
 					cc_core_instance_hash_fn, cc_core_instance_cmp_fn))) {
 		return -1;
 	}
+	ast_log(LOG_NOTICE, "Successfully created core instancess container\n");
 	if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS core", TPS_REF_DEFAULT))) {
 		return -1;
 	}
+	ast_log(LOG_NOTICE, "Successfully started CC task processor\n");
 	if (!(cc_sched = sched_context_create())) {
 		return -1;
 	}
-	return 0;
-}
+	ast_log(LOG_NOTICE, "Successfully created CC sched context\n");
+	return 0;
+}

Modified: team/group/CCSS/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/pbx.c?view=diff&rev=214608&r1=214607&r2=214608
==============================================================================
--- team/group/CCSS/main/pbx.c (original)
+++ team/group/CCSS/main/pbx.c Fri Aug 28 10:56:41 2009
@@ -8878,24 +8878,45 @@
  */
 static int pbx_builtin_hangup(struct ast_channel *chan, const char *data)
 {
+	char *parse;
+	AST_DECLARE_APP_ARGS( args,
+		AST_APP_ARG(cause);
+		AST_APP_ARG(cc);
+	);
+
 	ast_set_hangupsource(chan, "dialplan/builtin", 0);
 
-	if (!ast_strlen_zero(data)) {
+	parse = ast_strdupa(S_OR(data, ""));
+
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (!ast_strlen_zero(args.cause)) {
 		int cause;
 		char *endptr;
 
-		if ((cause = ast_str2cause(data)) > -1) {
+		if ((cause = ast_str2cause(args.cause)) > -1) {
 			chan->hangupcause = cause;
 			return -1;
 		}
 
-		cause = strtol((const char *) data, &endptr, 10);
-		if (cause != 0 || (data != endptr)) {
+		cause = strtol((const char *) args.cause, &endptr, 10);
+		if (cause != 0 || (args.cause != endptr)) {
 			chan->hangupcause = cause;
 			return -1;
 		}
 
 		ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
+	}
+
+	if (!ast_strlen_zero(args.cc)) {
+		int cc_core_id;
+		char *endptr;
+
+		cc_core_id = strtol((const char *) args.cc, &endptr, 10);
+		if (cc_core_id != 0 || (args.cc != endptr)) {
+			ast_cc_request_state_change(CC_CALLER_OFFERED, cc_core_id,
+					"CC offered to caller");
+		}
 	}
 
 	if (!chan->hangupcause) {




More information about the asterisk-commits mailing list