[asterisk-commits] eliel: branch group/data_api_gsoc2009 r211710 - /team/group/data_api_gsoc2009...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 11 10:48:14 CDT 2009
Author: eliel
Date: Tue Aug 11 10:48:10 2009
New Revision: 211710
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=211710
Log:
Implement the data callback for the list of channels.
Modified:
team/group/data_api_gsoc2009/main/channel.c
Modified: team/group/data_api_gsoc2009/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/channel.c?view=diff&rev=211710&r1=211709&r2=211710
==============================================================================
--- team/group/data_api_gsoc2009/main/channel.c (original)
+++ team/group/data_api_gsoc2009/main/channel.c Tue Aug 11 10:48:10 2009
@@ -6317,12 +6317,88 @@
return ret;
}
+/*!
+ * \internal
+ * \brief Implements the channels provider.
+ */
+static int data_channels_provider_handler(const struct ast_data_search *search,
+ struct ast_data *root)
+{
+ struct ast_channel *c, *bc;
+ struct ast_channel_iterator *iter = NULL;
+ struct ast_data *data_channel, *data_bridged;
+ int channel_match, bridged_match;
+
+ channel_match = ast_data_search_has_condition(search,
+ "channel");
+ bridged_match = ast_data_search_has_condition(search,
+ "channel/bridged");
+
+ for (iter = ast_channel_iterator_all_new(0);
+ iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
+ ast_channel_lock(c);
+
+ if (channel_match &&
+ ast_channel_data_cmp_structure(search, c, "channel")) {
+ ast_channel_unlock(c);
+ continue;
+ }
+
+ bc = ast_bridged_channel(c);
+
+ if (bridged_match && bc &&
+ ast_channel_data_cmp_structure(search, bc, "channel/bridged")) {
+ ast_channel_unlock(c);
+ continue;
+ }
+
+ data_channel = ast_data_add_node(root, "channel");
+ if (!data_channel) {
+ ast_channel_unlock(c);
+ continue;
+ }
+
+ ast_channel_data_add_structure(data_channel, c);
+
+ if (bc) {
+ data_bridged = ast_data_add_node(data_channel, "bridged");
+ if (!data_bridged) {
+ ast_channel_unlock(c);
+ continue;
+ }
+ ast_channel_data_add_structure(data_bridged, bc);
+ }
+
+ ast_channel_unlock(c);
+ }
+ if (iter) {
+ ast_channel_iterator_destroy(iter);
+ }
+
+ return 0;
+}
+
+/*!
+ * \internal
+ * \brief /asterisk/core/channels provider.
+ */
+static const struct ast_data_handler channels_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = data_channels_provider_handler
+};
+
+static const struct ast_data_entry channel_providers[] = {
+ AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),
+};
+
void ast_channels_init(void)
{
channels = ao2_container_alloc(NUM_CHANNEL_BUCKETS,
ast_channel_hash_cb, ast_channel_cmp_cb);
ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));
+
+ ast_data_register_multiple_core(channel_providers, ARRAY_LEN(channel_providers));
}
/*! \brief Print call group and pickup group ---*/
More information about the asterisk-commits
mailing list