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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 10 16:42:44 CDT 2009


Author: mmichelson
Date: Thu Sep 10 16:42:40 2009
New Revision: 217870

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217870
Log:
Code to set the CC_INTERFACES channel variable.

Tested and it works, too!


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=217870&r1=217869&r2=217870
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Thu Sep 10 16:42:40 2009
@@ -766,6 +766,18 @@
 
 /*!
  * \since 1.6.4
+ * \brief Set the CC_INTERFACES channel variable for a channel
+ *
+ * Implementors of protocol-specific CC agents should call this function after
+ * calling ast_setup_cc_recall_datastore.
+ *
+ * The CC_INTERFACES channel variable will have the interfaces that should be
+ * called back for a specific PBX instance.
+ */
+int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char * const extension);
+
+/*!
+ * \since 1.6.4
  * \brief Initialize CCSS
  *
  * XXX This needs to be updated as more functionality is added.

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=217870&r1=217869&r2=217870
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Sep 10 16:42:40 2009
@@ -787,6 +787,7 @@
 	 * function to do so.
 	 */
 	ast_setup_cc_recall_datastore(chan, agent);
+	ast_set_cc_interfaces_chanvar(chan, full_extension);
 	/* Now we can bust apart the outbound name so that the PBX will run. */
 	exten = full_extension;
 	if ((context = strchr(full_extension, '@'))) {
@@ -1598,6 +1599,53 @@
 	return 0;
 }
 
+int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char * const extension)
+{
+	struct ast_datastore *recall_datastore;
+	struct ast_cc_interface_tree *interface_tree;
+	struct ast_cc_interface *interface_iter;
+	unsigned int exten_id = 0;
+	struct ast_str *var_value = ast_str_create(64);
+	int multi = 0;
+
+	ast_channel_lock(chan);
+	if (!(recall_datastore = ast_channel_datastore_find(chan, &recall_ds_info, NULL))) {
+		ast_channel_unlock(chan);
+		return -1;
+	}
+
+	interface_tree = recall_datastore->data;
+
+	AST_LIST_TRAVERSE(interface_tree, interface_iter, next) {
+		if (!strcmp(interface_iter->name, extension)) {
+			exten_id = interface_iter->id;
+			break;
+		}
+	}
+
+	if (!exten_id) {
+		/* We couldn't find this extension. This may be because 
+		 * we have been directed into an unexected extension because
+		 * the admin has changed a CC_INTERFACES variable at some point.
+		 */
+		return -1;
+	}
+
+	/* I kind of feel wrong re-using interface_iter here, but eh, it works
+	 */
+	while ((interface_iter = AST_LIST_NEXT(interface_iter, next))) {
+		if (interface_iter->parent_id == exten_id) {
+			ast_str_append(&var_value, 0, "%s%s", multi ? "&" : "", interface_iter->name);
+			multi = 1;
+		}
+	}
+
+	pbx_builtin_setvar_helper(chan, "CC_INTERFACES", ast_str_buffer(var_value));
+	ast_log(LOG_NOTICE, "I set CC_INTERFACES to %s\n", ast_str_buffer(var_value));
+	ast_channel_unlock(chan);
+	return 0;
+}
+
 int ast_cc_init(void)
 {
 	int res;




More information about the asterisk-commits mailing list