[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r275508 - /team/eliel/data_ap...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jul 10 15:01:51 CDT 2010
Author: eliel
Date: Sat Jul 10 15:01:43 2010
New Revision: 275508
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=275508
Log:
- Implement the astdata provider for the local channels.
- Correct a function documentation.
Modified:
team/eliel/data_api_providers_gsoc2010/channels/chan_dahdi.c
team/eliel/data_api_providers_gsoc2010/channels/chan_local.c
Modified: team/eliel/data_api_providers_gsoc2010/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/channels/chan_dahdi.c?view=diff&rev=275508&r1=275507&r2=275508
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/channels/chan_dahdi.c (original)
+++ team/eliel/data_api_providers_gsoc2010/channels/chan_dahdi.c Sat Jul 10 15:01:43 2010
@@ -17582,8 +17582,8 @@
* \internal
* \brief Callback used to generate the dahdi channels tree.
* \param[in] search The search pattern tree.
- * \retval NULL on error.
- * \retval non-NULL The generated tree.
+ * \retval <0 on error.
+ * \retval 0 on success.
*/
static int dahdi_version_data_provider_get(const struct ast_data_search *search,
struct ast_data *data_root)
Modified: team/eliel/data_api_providers_gsoc2010/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/channels/chan_local.c?view=diff&rev=275508&r1=275507&r2=275508
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/channels/chan_local.c (original)
+++ team/eliel/data_api_providers_gsoc2010/channels/chan_local.c Sat Jul 10 15:01:43 2010
@@ -48,6 +48,7 @@
#include "asterisk/manager.h"
#include "asterisk/stringfields.h"
#include "asterisk/devicestate.h"
+#include "asterisk/data.h"
/*** DOCUMENTATION
<manager name="LocalOptimizeAway" language="en_US">
@@ -138,6 +139,12 @@
struct ast_module_user *u_chan; /*!< reference to keep the module loaded while in use */
AST_LIST_ENTRY(local_pvt) list; /*!< Next entity */
};
+
+#define DATA_EXPORT_LOCAL_CHANNELS(MEMBER) \
+ MEMBER(local_pvt, context, AST_DATA_STRING) \
+ MEMBER(local_pvt, exten, AST_DATA_STRING)
+
+AST_DATA_STRUCTURE(local_pvt, DATA_EXPORT_LOCAL_CHANNELS);
#define LOCAL_GLARE_DETECT (1 << 0) /*!< Detect glare on hangup */
#define LOCAL_CANCEL_QUEUE (1 << 1) /*!< Cancel queue */
@@ -1000,6 +1007,62 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Callback used to generate the local channels tree.
+ * \param[in] search The search pattern tree.
+ * \retval < 0 on error.
+ * \retval 0 on success.
+ */
+static int local_list_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ struct local_pvt *p;
+ struct ast_data *data_channel, *data_owner, *data_chan;
+
+ AST_LIST_LOCK(&locals);
+ if (!AST_LIST_EMPTY(&locals)) {
+ AST_LIST_TRAVERSE(&locals, p, list) {
+ data_channel = ast_data_add_node(data_root, "channel");
+ if (!data_channel) {
+ continue;
+ }
+ ast_mutex_lock(&p->lock);
+ ast_data_add_structure(local_pvt, data_channel, p);
+ ast_data_add_codecs(data_channel, "reqformat", p->reqformat);
+ data_owner = ast_data_add_node(data_channel, "owner");
+ if (!data_owner) {
+ ast_mutex_unlock(&p->lock);
+ continue;
+ }
+ ast_channel_data_add_structure(data_owner, p->owner, 0);
+ data_chan = ast_data_add_node(data_channel, "chan");
+ if (!data_chan) {
+ ast_mutex_unlock(&p->lock);
+ continue;
+ }
+ ast_channel_data_add_structure(data_chan, p->chan, 0);
+ ast_mutex_unlock(&p->lock);
+
+ /* if this channel doesn't match remove it. */
+ if (!ast_data_search_match(search, data_channel)) {
+ ast_data_remove_node(data_root, data_channel);
+ }
+ }
+ }
+ AST_LIST_UNLOCK(&locals);
+
+ return 0;
+}
+
+static const struct ast_data_handler local_list_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = local_list_data_provider_get
+};
+
+static const struct ast_data_entry local_data_providers[] = {
+ AST_DATA_ENTRY("asterisk/channel/local/channels", &local_list_data_provider)
+};
/*! \brief Load module into PBX, register channel */
static int load_module(void)
@@ -1010,6 +1073,7 @@
return AST_MODULE_LOAD_FAILURE;
}
ast_cli_register_multiple(cli_local, sizeof(cli_local) / sizeof(struct ast_cli_entry));
+ ast_data_register_multiple(local_data_providers, ARRAY_LEN(local_data_providers));
ast_manager_register_xml("LocalOptimizeAway", EVENT_FLAG_SYSTEM|EVENT_FLAG_CALL, manager_optimize_away);
return AST_MODULE_LOAD_SUCCESS;
@@ -1022,6 +1086,8 @@
/* First, take us out of the channel loop */
ast_cli_unregister_multiple(cli_local, sizeof(cli_local) / sizeof(struct ast_cli_entry));
+ /* unregister the data providers */
+ ast_data_unregister(NULL);
ast_manager_unregister("LocalOptimizeAway");
ast_channel_unregister(&local_tech);
if (!AST_LIST_LOCK(&locals)) {
More information about the asterisk-commits
mailing list