[asterisk-commits] eliel: trunk r274727 - in /trunk: apps/ channels/ include/asterisk/ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 8 09:48:49 CDT 2010
Author: eliel
Date: Thu Jul 8 09:48:42 2010
New Revision: 274727
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=274727
Log:
Implement AstData API data providers as part of the GSOC 2010 project,
midterm evaluation.
Review: https://reviewboard.asterisk.org/r/757/
Modified:
trunk/apps/app_meetme.c
trunk/apps/app_queue.c
trunk/apps/app_voicemail.c
trunk/channels/chan_agent.c
trunk/channels/chan_dahdi.c
trunk/channels/chan_iax2.c
trunk/channels/chan_sip.c
trunk/include/asterisk/cdr.h
trunk/include/asterisk/channel.h
trunk/include/asterisk/data.h
trunk/include/asterisk/indications.h
trunk/main/cdr.c
trunk/main/channel.c
trunk/main/data.c
trunk/main/indications.c
trunk/main/pbx.c
trunk/res/res_odbc.c
Modified: trunk/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_meetme.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Thu Jul 8 09:48:42 2010
@@ -59,6 +59,8 @@
#include "asterisk/dial.h"
#include "asterisk/causes.h"
#include "asterisk/paths.h"
+#include "asterisk/data.h"
+#include "asterisk/test.h"
#include "enter.h"
#include "leave.h"
@@ -1775,6 +1777,7 @@
}
ast_mutex_destroy(&conf->announcelistlock);
}
+
if (conf->origframe)
ast_frfree(conf->origframe);
if (conf->lchan)
@@ -1786,6 +1789,7 @@
if (conf->recordingfilename) {
ast_free(conf->recordingfilename);
}
+
if (conf->recordingformat) {
ast_free(conf->recordingformat);
}
@@ -6723,6 +6727,170 @@
return sla_load_config(0);
}
+#define MEETME_DATA_EXPORT(MEMBER) \
+ MEMBER(ast_conference, confno, AST_DATA_STRING) \
+ MEMBER(ast_conference, dahdiconf, AST_DATA_INTEGER) \
+ MEMBER(ast_conference, users, AST_DATA_INTEGER) \
+ MEMBER(ast_conference, markedusers, AST_DATA_INTEGER) \
+ MEMBER(ast_conference, maxusers, AST_DATA_INTEGER) \
+ MEMBER(ast_conference, isdynamic, AST_DATA_BOOLEAN) \
+ MEMBER(ast_conference, locked, AST_DATA_BOOLEAN) \
+ MEMBER(ast_conference, recordingfilename, AST_DATA_STRING) \
+ MEMBER(ast_conference, recordingformat, AST_DATA_STRING) \
+ MEMBER(ast_conference, pin, AST_DATA_PASSWORD) \
+ MEMBER(ast_conference, pinadmin, AST_DATA_PASSWORD) \
+ MEMBER(ast_conference, start, AST_DATA_TIMESTAMP) \
+ MEMBER(ast_conference, endtime, AST_DATA_TIMESTAMP)
+
+AST_DATA_STRUCTURE(ast_conference, MEETME_DATA_EXPORT);
+
+#define MEETME_USER_DATA_EXPORT(MEMBER) \
+ MEMBER(ast_conf_user, user_no, AST_DATA_INTEGER) \
+ MEMBER(ast_conf_user, talking, AST_DATA_BOOLEAN) \
+ MEMBER(ast_conf_user, dahdichannel, AST_DATA_BOOLEAN) \
+ MEMBER(ast_conf_user, jointime, AST_DATA_TIMESTAMP) \
+ MEMBER(ast_conf_user, kicktime, AST_DATA_TIMESTAMP) \
+ MEMBER(ast_conf_user, timelimit, AST_DATA_MILLISECONDS) \
+ MEMBER(ast_conf_user, play_warning, AST_DATA_MILLISECONDS) \
+ MEMBER(ast_conf_user, warning_freq, AST_DATA_MILLISECONDS)
+
+AST_DATA_STRUCTURE(ast_conf_user, MEETME_USER_DATA_EXPORT);
+
+/*!
+ * \internal
+ * \brief Implements the meetme data provider.
+ */
+static int meetme_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ struct ast_conference *cnf;
+ struct ast_conf_user *user;
+ struct ast_data *data_meetme, *data_meetme_users, *data_meetme_user;
+ struct ast_data *data_meetme_user_channel, *data_meetme_user_volume;
+
+ AST_LIST_LOCK(&confs);
+ AST_LIST_TRAVERSE(&confs, cnf, list) {
+ data_meetme = ast_data_add_node(data_root, "meetme");
+ if (!data_meetme) {
+ continue;
+ }
+
+ ast_data_add_structure(ast_conference, data_meetme, cnf);
+
+ if (!AST_LIST_EMPTY(&cnf->userlist)) {
+ data_meetme_users = ast_data_add_node(data_meetme, "users");
+ if (!data_meetme_users) {
+ ast_data_remove_node(data_root, data_meetme);
+ continue;
+ }
+
+ AST_LIST_TRAVERSE(&cnf->userlist, user, list) {
+ data_meetme_user = ast_data_add_node(data_meetme_users, "user");
+ if (!data_meetme_user) {
+ continue;
+ }
+ /* user structure. */
+ ast_data_add_structure(ast_conf_user, data_meetme_user, user);
+
+ /* user's channel */
+ data_meetme_user_channel = ast_data_add_node(data_meetme_user, "channel");
+ if (!data_meetme_user_channel) {
+ continue;
+ }
+
+ ast_channel_data_add_structure(data_meetme_user_channel, user->chan, 1);
+
+ /* volume structure */
+ data_meetme_user_volume = ast_data_add_node(data_meetme_user, "listen-volume");
+ if (!data_meetme_user_volume) {
+ continue;
+ }
+ ast_data_add_int(data_meetme_user_volume, "desired", user->listen.desired);
+ ast_data_add_int(data_meetme_user_volume, "actual", user->listen.actual);
+
+ data_meetme_user_volume = ast_data_add_node(data_meetme_user, "talk-volume");
+ if (!data_meetme_user_volume) {
+ continue;
+ }
+ ast_data_add_int(data_meetme_user_volume, "desired", user->talk.desired);
+ ast_data_add_int(data_meetme_user_volume, "actual", user->talk.actual);
+ }
+ }
+
+ if (!ast_data_search_match(search, data_meetme)) {
+ ast_data_remove_node(data_root, data_meetme);
+ }
+ }
+ AST_LIST_UNLOCK(&confs);
+
+ return 0;
+}
+
+static const struct ast_data_handler meetme_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = meetme_data_provider_get
+};
+
+static const struct ast_data_entry meetme_data_providers[] = {
+ AST_DATA_ENTRY("asterisk/application/meetme/list", &meetme_data_provider),
+};
+
+#ifdef TEST_FRAMEWORK
+AST_TEST_DEFINE(test_meetme_data_provider)
+{
+ struct ast_channel *chan;
+ struct ast_conference *cnf;
+ struct ast_data *node;
+ struct ast_data_query query = {
+ .path = "/asterisk/application/meetme/list",
+ .search = "list/meetme/confno=9898"
+ };
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "meetme_get_data_test";
+ info->category = "main/data/app_meetme/list";
+ info->summary = "Meetme data provider unit test";
+ info->description =
+ "Tests whether the Meetme data provider implementation works as expected.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, NULL, NULL, 0, 0, "MeetMeTest");
+ if (!chan) {
+ return AST_TEST_FAIL;
+ }
+
+ cnf = build_conf("9898", "", "1234", 1, 1, 1, chan);
+ if (!cnf) {
+ ast_hangup(chan);
+ return AST_TEST_FAIL;
+ }
+
+ node = ast_data_get(&query);
+ if (!node) {
+ dispose_conf(cnf);
+ ast_hangup(chan);
+ return AST_TEST_FAIL;
+ }
+
+ if (strcmp(ast_data_retrieve_string(node, "meetme/confno"), "9898")) {
+ dispose_conf(cnf);
+ ast_hangup(chan);
+ ast_data_free(node);
+ return AST_TEST_FAIL;
+ }
+
+ ast_data_free(node);
+ dispose_conf(cnf);
+ ast_hangup(chan);
+
+ return AST_TEST_PASS;
+}
+#endif
+
static int unload_module(void)
{
int res = 0;
@@ -6738,6 +6906,11 @@
res |= ast_unregister_application(slastation_app);
res |= ast_unregister_application(slatrunk_app);
+#ifdef TEST_FRAMEWORK
+ AST_TEST_UNREGISTER(test_meetme_data_provider);
+#endif
+ ast_data_unregister(NULL);
+
ast_devstate_prov_del("Meetme");
ast_devstate_prov_del("SLA");
@@ -6748,6 +6921,8 @@
return res;
}
+
+
static int load_module(void)
{
@@ -6766,6 +6941,11 @@
res |= ast_register_application_xml(slastation_app, sla_station_exec);
res |= ast_register_application_xml(slatrunk_app, sla_trunk_exec);
+#ifdef TEST_FRAMEWORK
+ AST_TEST_REGISTER(test_meetme_data_provider);
+#endif
+ ast_data_register_multiple(meetme_data_providers, ARRAY_LEN(meetme_data_providers));
+
res |= ast_devstate_prov_add("Meetme", meetmestate);
res |= ast_devstate_prov_add("SLA", sla_state);
Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jul 8 09:48:42 2010
@@ -7762,7 +7762,7 @@
MEMBER(call_queue, sound_reporthold, AST_DATA_STRING) \
MEMBER(call_queue, dead, AST_DATA_BOOLEAN) \
MEMBER(call_queue, eventwhencalled, AST_DATA_BOOLEAN) \
- MEMBER(call_queue, ringinuse, AST_DATA_INTEGER) \
+ MEMBER(call_queue, ringinuse, AST_DATA_BOOLEAN) \
MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN) \
MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN) \
MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN) \
@@ -7770,20 +7770,18 @@
MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN) \
MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN) \
MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER) \
- MEMBER(call_queue, announceposition, AST_DATA_INTEGER) \
- MEMBER(call_queue, strategy, AST_DATA_INTEGER) \
MEMBER(call_queue, maskmemberstatus, AST_DATA_BOOLEAN) \
MEMBER(call_queue, realtime, AST_DATA_BOOLEAN) \
MEMBER(call_queue, found, AST_DATA_BOOLEAN) \
MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER) \
- MEMBER(call_queue, announcefrequency, AST_DATA_INTEGER) \
- MEMBER(call_queue, minannouncefrequency, AST_DATA_INTEGER) \
- MEMBER(call_queue, periodicannouncefrequency, AST_DATA_INTEGER) \
+ MEMBER(call_queue, announcefrequency, AST_DATA_SECONDS) \
+ MEMBER(call_queue, minannouncefrequency, AST_DATA_SECONDS) \
+ MEMBER(call_queue, periodicannouncefrequency, AST_DATA_SECONDS) \
MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER) \
MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER) \
- MEMBER(call_queue, roundingseconds, AST_DATA_INTEGER) \
- MEMBER(call_queue, holdtime, AST_DATA_INTEGER) \
- MEMBER(call_queue, talktime, AST_DATA_INTEGER) \
+ MEMBER(call_queue, roundingseconds, AST_DATA_SECONDS) \
+ MEMBER(call_queue, holdtime, AST_DATA_SECONDS) \
+ MEMBER(call_queue, talktime, AST_DATA_SECONDS) \
MEMBER(call_queue, callscompleted, AST_DATA_INTEGER) \
MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER) \
MEMBER(call_queue, servicelevel, AST_DATA_INTEGER) \
@@ -7792,9 +7790,9 @@
MEMBER(call_queue, montype, AST_DATA_INTEGER) \
MEMBER(call_queue, count, AST_DATA_INTEGER) \
MEMBER(call_queue, maxlen, AST_DATA_INTEGER) \
- MEMBER(call_queue, wrapuptime, AST_DATA_INTEGER) \
- MEMBER(call_queue, retry, AST_DATA_INTEGER) \
- MEMBER(call_queue, timeout, AST_DATA_INTEGER) \
+ MEMBER(call_queue, wrapuptime, AST_DATA_SECONDS) \
+ MEMBER(call_queue, retry, AST_DATA_SECONDS) \
+ MEMBER(call_queue, timeout, AST_DATA_SECONDS) \
MEMBER(call_queue, weight, AST_DATA_INTEGER) \
MEMBER(call_queue, autopause, AST_DATA_INTEGER) \
MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER) \
@@ -7856,18 +7854,11 @@
static void queues_data_provider_get_helper(const struct ast_data_search *search,
struct ast_data *data_root, struct call_queue *queue)
{
- int member_notmatch, caller_notmatch, caller_channel_notmatch;
struct ao2_iterator im;
struct member *member;
struct queue_ent *qe;
- struct ast_data *data_queue, *data_members = NULL;
+ struct ast_data *data_queue, *data_members = NULL, *enum_node;
struct ast_data *data_member, *data_callers = NULL, *data_caller, *data_caller_channel;
-
- /* compare the search pattern. */
- if (ast_data_search_cmp_structure(search, call_queue, queue, "queue")) {
- /* this doesn't match! continue! */
- return;
- }
data_queue = ast_data_add_node(data_root, "queue");
if (!data_queue) {
@@ -7876,16 +7867,35 @@
ast_data_add_structure(call_queue, data_queue, queue);
- member_notmatch = ast_data_search_has_condition(search, "queue/members/member");
+ ast_data_add_str(data_queue, "strategy", int2strat(queue->strategy));
+
+ /* announce position */
+ enum_node = ast_data_add_node(data_queue, "announceposition");
+ if (!enum_node) {
+ return;
+ }
+ switch (queue->announceposition) {
+ case ANNOUNCEPOSITION_LIMIT:
+ ast_data_add_str(enum_node, "text", "limit");
+ break;
+ case ANNOUNCEPOSITION_MORE_THAN:
+ ast_data_add_str(enum_node, "text", "more");
+ break;
+ case ANNOUNCEPOSITION_YES:
+ ast_data_add_str(enum_node, "text", "yes");
+ break;
+ case ANNOUNCEPOSITION_NO:
+ ast_data_add_str(enum_node, "text", "no");
+ break;
+ default:
+ ast_data_add_str(enum_node, "text", "unknown");
+ break;
+ }
+ ast_data_add_int(enum_node, "value", queue->announceposition);
+
/* add queue members */
im = ao2_iterator_init(queue->members, 0);
while ((member = ao2_iterator_next(&im))) {
- /* compare the member structure. */
- if (!ast_data_search_cmp_structure(search, member, member,
- "queue/members/member")) {
- member_notmatch = 0;
- }
-
if (!data_members) {
data_members = ast_data_add_node(data_queue, "members");
if (!data_members) {
@@ -7905,28 +7915,9 @@
ao2_ref(member, -1);
}
- if (member_notmatch) {
- ast_data_remove_node(data_root, data_queue);
- return;
- }
-
- caller_notmatch = ast_data_search_has_condition(search, "queue/callers/caller");
- caller_channel_notmatch = ast_data_search_has_condition(search,
- "queue/callers/caller/channel");
/* include the callers inside the result. */
if (queue->head) {
for (qe = queue->head; qe; qe = qe->next) {
- /* compare the member structure. */
- if (!ast_data_search_cmp_structure(search, queue_ent, qe,
- "queue/callers/caller")) {
- caller_notmatch = 0;
- }
-
- if (!ast_channel_data_cmp_structure(search, qe->chan,
- "queue/callers/caller/channel")) {
- caller_channel_notmatch = 0;
- }
-
if (!data_callers) {
data_callers = ast_data_add_node(data_queue, "callers");
if (!data_callers) {
@@ -7947,12 +7938,12 @@
continue;
}
- ast_channel_data_add_structure(data_caller_channel, qe->chan);
+ ast_channel_data_add_structure(data_caller_channel, qe->chan, 1);
}
}
/* if this queue doesn't match remove the added queue. */
- if (caller_notmatch || caller_channel_notmatch) {
+ if (!ast_data_search_match(search, data_queue)) {
ast_data_remove_node(data_root, data_queue);
}
}
@@ -8011,7 +8002,7 @@
};
static const struct ast_data_entry queue_data_providers[] = {
- AST_DATA_ENTRY("asterisk/application/app_queue/queues", &queues_data_provider),
+ AST_DATA_ENTRY("asterisk/application/queue/list", &queues_data_provider),
};
static int unload_module(void)
Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Jul 8 09:48:42 2010
@@ -10815,7 +10815,7 @@
#define DATA_EXPORT_VM_USERS(USER) \
USER(ast_vm_user, context, AST_DATA_STRING) \
USER(ast_vm_user, mailbox, AST_DATA_STRING) \
- USER(ast_vm_user, password, AST_DATA_STRING) \
+ USER(ast_vm_user, password, AST_DATA_PASSWORD) \
USER(ast_vm_user, fullname, AST_DATA_STRING) \
USER(ast_vm_user, email, AST_DATA_STRING) \
USER(ast_vm_user, emailsubject, AST_DATA_STRING) \
@@ -10843,7 +10843,7 @@
#define DATA_EXPORT_VM_USERS(USER) \
USER(ast_vm_user, context, AST_DATA_STRING) \
USER(ast_vm_user, mailbox, AST_DATA_STRING) \
- USER(ast_vm_user, password, AST_DATA_STRING) \
+ USER(ast_vm_user, password, AST_DATA_PASSWORD) \
USER(ast_vm_user, fullname, AST_DATA_STRING) \
USER(ast_vm_user, email, AST_DATA_STRING) \
USER(ast_vm_user, emailsubject, AST_DATA_STRING) \
@@ -10875,50 +10875,6 @@
AST_DATA_STRUCTURE(vm_zone, DATA_EXPORT_VM_ZONES);
-#ifdef IMAP_STORAGE
- #define DATA_EXPORT_VM_STATES(STATE) \
- STATE(vm_state, curbox, AST_DATA_STRING) \
- STATE(vm_state, username, AST_DATA_STRING) \
- STATE(vm_state, context, AST_DATA_STRING) \
- STATE(vm_state, curdir, AST_DATA_STRING) \
- STATE(vm_state, vmbox, AST_DATA_STRING) \
- STATE(vm_state, fn, AST_DATA_STRING) \
- STATE(vm_state, intro, AST_DATA_STRING) \
- STATE(vm_state, curmsg, AST_DATA_INTEGER) \
- STATE(vm_state, lastmsg, AST_DATA_INTEGER) \
- STATE(vm_state, newmessages, AST_DATA_INTEGER) \
- STATE(vm_state, oldmessages, AST_DATA_INTEGER) \
- STATE(vm_state, urgentmessages, AST_DATA_INTEGER) \
- STATE(vm_state, starting, AST_DATA_INTEGER) \
- STATE(vm_state, repeats, AST_DATA_INTEGER) \
- STATE(vm_state, updated, AST_DATA_INTEGER) \
- STATE(vm_state, msgArray, AST_DATA_CONTAINER) \
- STATE(vm_state, vmArrayIndex, AST_DATA_INTEGER) \
- STATE(vm_state, imapuser, AST_DATA_STRING) \
- STATE(vm_state, interactive, AST_DATA_INTEGER) \
- STATE(vm_state, introfn, AST_DATA_STRING) \
- STATE(vm_state, quota_limit, AST_DATA_UNSIGNED_INTEGER) \
- STATE(vm_state, quota_usage, AST_DATA_UNSIGNED_INTEGER)
-#else
- #define DATA_EXPORT_VM_STATES(STATE) \
- STATE(vm_state, curbox, AST_DATA_STRING) \
- STATE(vm_state, username, AST_DATA_STRING) \
- STATE(vm_state, context, AST_DATA_STRING) \
- STATE(vm_state, curdir, AST_DATA_STRING) \
- STATE(vm_state, vmbox, AST_DATA_STRING) \
- STATE(vm_state, fn, AST_DATA_STRING) \
- STATE(vm_state, intro, AST_DATA_STRING) \
- STATE(vm_state, curmsg, AST_DATA_INTEGER) \
- STATE(vm_state, lastmsg, AST_DATA_INTEGER) \
- STATE(vm_state, newmessages, AST_DATA_INTEGER) \
- STATE(vm_state, oldmessages, AST_DATA_INTEGER) \
- STATE(vm_state, urgentmessages, AST_DATA_INTEGER) \
- STATE(vm_state, starting, AST_DATA_INTEGER) \
- STATE(vm_state, repeats, AST_DATA_INTEGER)
-#endif
-
-AST_DATA_STRUCTURE(vm_state, DATA_EXPORT_VM_STATES);
-
/*!
* \internal
* \brief Add voicemail user to the data_root.
@@ -10926,31 +10882,21 @@
* \param[in] data_root The main result node.
* \param[in] user The voicemail user.
*/
-static void vm_users_data_provider_get_helper(const struct ast_data_search *search,
+static int vm_users_data_provider_get_helper(const struct ast_data_search *search,
struct ast_data *data_root, struct ast_vm_user *user)
{
struct ast_data *data_user, *data_zone;
-#ifdef IMAP_STORAGE
struct ast_data *data_state;
- struct vm_state *state;
-#endif
struct vm_zone *zone = NULL;
-
- /* check the search pattern to make sure it's valid to add it */
- if (ast_data_search_cmp_structure(search, ast_vm_user, user, "user")) {
- return;
- }
+ int urgentmsg = 0, newmsg = 0, oldmsg = 0;
+ char ext_context[256] = "";
data_user = ast_data_add_node(data_root, "user");
if (!data_user) {
- return;
+ return -1;
}
ast_data_add_structure(ast_vm_user, data_user, user);
-
-#ifdef IMAP_STORAGE
- state = get_vm_state_by_mailbox(user->mailbox, user->context, 0);
-#endif
AST_LIST_LOCK(&zones);
AST_LIST_TRAVERSE(&zones, zone, list) {
@@ -10960,35 +10906,30 @@
}
AST_LIST_UNLOCK(&zones);
- /* TODO: Should a user's vm state be accessible without compiling in
- * IMAP support? */
-
- if (
-#ifdef IMAP_STORAGE
- !ast_data_search_cmp_structure(search, vm_state, state, "user/state") ||
-#endif
- (zone && !ast_data_search_cmp_structure(search, vm_zone,
- zone, "user/zone"))) {
- ast_data_remove_node(data_root, data_user);
- return;
- }
-
-#ifdef IMAP_STORAGE
+ /* state */
data_state = ast_data_add_node(data_user, "state");
- ast_data_add_structure(vm_state, data_state, state);
- ast_data_add_int(data_state, "deleted", *(state->deleted));
- ast_data_add_int(data_state, "heard", *(state->heard));
-#endif
+ if (!data_state) {
+ return -1;
+ }
+ snprintf(ext_context, sizeof(ext_context), "%s@%s", user->mailbox, user->context);
+ inboxcount2(ext_context, &urgentmsg, &newmsg, &oldmsg);
+ ast_data_add_int(data_state, "urgentmsg", urgentmsg);
+ ast_data_add_int(data_state, "newmsg", newmsg);
+ ast_data_add_int(data_state, "oldmsg", oldmsg);
if (zone) {
data_zone = ast_data_add_node(data_user, "zone");
ast_data_add_structure(vm_zone, data_zone, zone);
}
- return;
-}
-
-static int vm_data_provider_get(const struct ast_data_search *search,
+ if (!ast_data_search_match(search, data_user)) {
+ ast_data_remove_node(data_root, data_user);
+ }
+
+ return 0;
+}
+
+static int vm_users_data_provider_get(const struct ast_data_search *search,
struct ast_data *data_root)
{
struct ast_vm_user *user;
@@ -11002,13 +10943,13 @@
return 0;
}
-static const struct ast_data_handler vm_data_provider = {
+static const struct ast_data_handler vm_users_data_provider = {
.version = AST_DATA_HANDLER_VERSION,
- .get = vm_data_provider_get
+ .get = vm_users_data_provider_get
};
static const struct ast_data_entry vm_data_providers[] = {
- AST_DATA_ENTRY("asterisk/application/app_voicemail/voicemail", &vm_data_provider)
+ AST_DATA_ENTRY("asterisk/application/voicemail/list", &vm_users_data_provider)
};
static void poll_subscribed_mailbox(struct mwi_sub *mwi_sub)
Modified: trunk/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_agent.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Thu Jul 8 09:48:42 2010
@@ -67,6 +67,7 @@
#include "asterisk/monitor.h"
#include "asterisk/stringfields.h"
#include "asterisk/event.h"
+#include "asterisk/data.h"
/*** DOCUMENTATION
<application name="AgentLogin" language="en_US">
@@ -278,6 +279,19 @@
AST_LIST_ENTRY(agent_pvt) list; /**< Next Agent in the linked list. */
};
+#define DATA_EXPORT_AGENT(MEMBER) \
+ MEMBER(agent_pvt, autologoff, AST_DATA_INTEGER) \
+ MEMBER(agent_pvt, ackcall, AST_DATA_BOOLEAN) \
+ MEMBER(agent_pvt, deferlogoff, AST_DATA_BOOLEAN) \
+ MEMBER(agent_pvt, wrapuptime, AST_DATA_MILLISECONDS) \
+ MEMBER(agent_pvt, acknowledged, AST_DATA_BOOLEAN) \
+ MEMBER(agent_pvt, name, AST_DATA_STRING) \
+ MEMBER(agent_pvt, password, AST_DATA_PASSWORD) \
+ MEMBER(agent_pvt, acceptdtmf, AST_DATA_CHARACTER) \
+ MEMBER(agent_pvt, logincallerid, AST_DATA_STRING)
+
+AST_DATA_STRUCTURE(agent_pvt, DATA_EXPORT_AGENT);
+
static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (loaded form agents.conf). */
#define CHECK_FORMATS(ast, p) do { \
@@ -2321,6 +2335,75 @@
.read = function_agent,
};
+/*!
+ * \internal
+ * \brief Callback used to generate the agents tree.
+ * \param[in] search The search pattern tree.
+ * \retval NULL on error.
+ * \retval non-NULL The generated tree.
+ */
+static int agents_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ struct agent_pvt *p;
+ struct ast_data *data_agent, *data_channel, *data_talkingto;
+
+ AST_LIST_LOCK(&agents);
+ AST_LIST_TRAVERSE(&agents, p, list) {
+ data_agent = ast_data_add_node(data_root, "agent");
+ if (!data_agent) {
+ continue;
+ }
+
+ ast_mutex_lock(&p->lock);
+ if (!(p->pending)) {
+ ast_data_add_str(data_agent, "id", p->agent);
+ ast_data_add_structure(agent_pvt, data_agent, p);
+
+ ast_data_add_bool(data_agent, "logged", p->chan ? 1 : 0);
+ if (p->chan) {
+ data_channel = ast_data_add_node(data_agent, "loggedon");
+ if (!data_channel) {
+ ast_mutex_unlock(&p->lock);
+ ast_data_remove_node(data_root, data_agent);
+ continue;
+ }
+ ast_channel_data_add_structure(data_channel, p->chan, 0);
+ if (p->owner && ast_bridged_channel(p->owner)) {
+ data_talkingto = ast_data_add_node(data_agent, "talkingto");
+ if (!data_talkingto) {
+ ast_mutex_unlock(&p->lock);
+ ast_data_remove_node(data_root, data_agent);
+ continue;
+ }
+ ast_channel_data_add_structure(data_talkingto, ast_bridged_channel(p->owner), 0);
+ }
+ } else {
+ ast_data_add_node(data_agent, "talkingto");
+ ast_data_add_node(data_agent, "loggedon");
+ }
+ ast_data_add_str(data_agent, "musiconhold", p->moh);
+ }
+ ast_mutex_unlock(&p->lock);
+
+ /* if this agent doesn't match remove the added agent. */
+ if (!ast_data_search_match(search, data_agent)) {
+ ast_data_remove_node(data_root, data_agent);
+ }
+ }
+ AST_LIST_UNLOCK(&agents);
+
+ return 0;
+}
+
+static const struct ast_data_handler agents_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = agents_data_provider_get
+};
+
+static const struct ast_data_entry agents_data_providers[] = {
+ AST_DATA_ENTRY("asterisk/channel/agent/list", &agents_data_provider),
+};
/*!
* \brief Initialize the Agents module.
@@ -2342,6 +2425,9 @@
/* Dialplan applications */
ast_register_application_xml(app, login_exec);
ast_register_application_xml(app3, agentmonitoroutgoing_exec);
+
+ /* data tree */
+ ast_data_register_multiple(agents_data_providers, ARRAY_LEN(agents_data_providers));
/* Manager commands */
ast_manager_register_xml("Agents", EVENT_FLAG_AGENT, action_agents);
@@ -2376,6 +2462,8 @@
/* Unregister manager command */
ast_manager_unregister("Agents");
ast_manager_unregister("AgentLogoff");
+ /* Unregister the data tree */
+ ast_data_unregister(NULL);
/* Unregister channel */
AST_LIST_LOCK(&agents);
/* Hangup all interfaces if they have an owner */
Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Jul 8 09:48:42 2010
@@ -117,6 +117,7 @@
#include "asterisk/devicestate.h"
#include "asterisk/paths.h"
#include "asterisk/ccss.h"
+#include "asterisk/data.h"
/*** DOCUMENTATION
<application name="DAHDISendKeypadFacility" language="en_US">
@@ -1204,6 +1205,77 @@
char dialstring[AST_CHANNEL_NAME];
};
+#define DATA_EXPORT_DAHDI_PVT(MEMBER) \
+ MEMBER(dahdi_pvt, cid_rxgain, AST_DATA_DOUBLE) \
+ MEMBER(dahdi_pvt, rxgain, AST_DATA_DOUBLE) \
+ MEMBER(dahdi_pvt, txgain, AST_DATA_DOUBLE) \
+ MEMBER(dahdi_pvt, txdrc, AST_DATA_DOUBLE) \
+ MEMBER(dahdi_pvt, rxdrc, AST_DATA_DOUBLE) \
+ MEMBER(dahdi_pvt, adsi, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, answeronpolarityswitch, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, busydetect, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, callreturn, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, callwaiting, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, callwaitingcallerid, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, cancallforward, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, canpark, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, confirmanswer, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, destroy, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, didtdd, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, dialednone, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, dialing, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, digital, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, dnd, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, echobreak, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, echocanbridged, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, echocanon, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, faxhandled, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, usefaxbuffers, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, bufferoverrideinuse, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, firstradio, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, hanguponpolarityswitch, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, hardwaredtmf, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, hidecallerid, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, hidecalleridname, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, ignoredtmf, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, immediate, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, inalarm, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mate, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, outgoing, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, permcallwaiting, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, priindication_oob, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, priexclusive, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, pulse, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, pulsedial, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, restartpending, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, restrictcid, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, threewaycalling, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, transfer, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, use_callerid, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, use_callingpres, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, usedistinctiveringdetection, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, dahditrcallerid, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, transfertobusy, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mwimonitor_neon, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mwimonitor_fsk, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mwimonitor_rpas, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mwimonitoractive, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, mwisendactive, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, inservice, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, locallyblocked, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, remotelyblocked, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, manages_span_alarms, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, use_smdi, AST_DATA_BOOLEAN) \
+ MEMBER(dahdi_pvt, context, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, defcontext, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, exten, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, language, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, mohinterpret, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, mohsuggest, AST_DATA_STRING) \
+ MEMBER(dahdi_pvt, parkinglot, AST_DATA_STRING)
+
+AST_DATA_STRUCTURE(dahdi_pvt, DATA_EXPORT_DAHDI_PVT);
+
static struct dahdi_pvt *iflist = NULL; /*!< Main interface list start */
static struct dahdi_pvt *ifend = NULL; /*!< Main interface list end */
@@ -15823,6 +15895,7 @@
ast_manager_unregister("DAHDIDNDon");
ast_manager_unregister("DAHDIShowChannels");
ast_manager_unregister("DAHDIRestart");
+ ast_data_unregister(NULL);
ast_channel_unregister(&dahdi_tech);
/* Hangup all interfaces if they have an owner */
@@ -17402,6 +17475,163 @@
return res;
}
+/*!
+ * \internal
+ * \brief Callback used to generate the dahdi status tree.
+ * \param[in] search The search pattern tree.
+ * \retval NULL on error.
+ * \retval non-NULL The generated tree.
+ */
+static int dahdi_status_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ int ctl, res, span;
+ struct ast_data *data_span, *data_alarms;
+ struct dahdi_spaninfo s;
+
+ ctl = open("/dev/dahdi/ctl", O_RDWR);
+ if (ctl < 0) {
+ ast_log(LOG_ERROR, "No DAHDI found. Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));
+ return -1;
+ }
+ for (span = 1; span < DAHDI_MAX_SPANS; ++span) {
+ s.spanno = span;
+ res = ioctl(ctl, DAHDI_SPANSTAT, &s);
+ if (res) {
+ continue;
+ }
+
+ data_span = ast_data_add_node(data_root, "span");
+ if (!data_span) {
+ continue;
+ }
+ ast_data_add_str(data_span, "description", s.desc);
+
+ /* insert the alarms status */
+ data_alarms = ast_data_add_node(data_span, "alarms");
+ if (!data_alarms) {
+ continue;
+ }
+
+ ast_data_add_bool(data_alarms, "BLUE", s.alarms & DAHDI_ALARM_BLUE);
+ ast_data_add_bool(data_alarms, "YELLOW", s.alarms & DAHDI_ALARM_YELLOW);
+ ast_data_add_bool(data_alarms, "RED", s.alarms & DAHDI_ALARM_RED);
+ ast_data_add_bool(data_alarms, "LOOPBACK", s.alarms & DAHDI_ALARM_LOOPBACK);
+ ast_data_add_bool(data_alarms, "RECOVER", s.alarms & DAHDI_ALARM_RECOVER);
+ ast_data_add_bool(data_alarms, "NOTOPEN", s.alarms & DAHDI_ALARM_NOTOPEN);
+
+ ast_data_add_int(data_span, "irqmisses", s.irqmisses);
+ ast_data_add_int(data_span, "bpviol", s.bpvcount);
+ ast_data_add_int(data_span, "crc4", s.crc4count);
+ ast_data_add_str(data_span, "framing", s.lineconfig & DAHDI_CONFIG_D4 ? "D4" :
+ s.lineconfig & DAHDI_CONFIG_ESF ? "ESF" :
+ s.lineconfig & DAHDI_CONFIG_CCS ? "CCS" :
+ "CAS");
+ ast_data_add_str(data_span, "coding", s.lineconfig & DAHDI_CONFIG_B8ZS ? "B8ZS" :
+ s.lineconfig & DAHDI_CONFIG_HDB3 ? "HDB3" :
+ s.lineconfig & DAHDI_CONFIG_AMI ? "AMI" :
+ "Unknown");
+ ast_data_add_str(data_span, "options", s.lineconfig & DAHDI_CONFIG_CRC4 ?
+ s.lineconfig & DAHDI_CONFIG_NOTOPEN ? "CRC4/YEL" : "CRC4" :
+ s.lineconfig & DAHDI_CONFIG_NOTOPEN ? "YEL" : "");
+ ast_data_add_str(data_span, "lbo", lbostr[s.lbo]);
+
+ /* if this span doesn't match remove it. */
+ if (!ast_data_search_match(search, data_span)) {
+ ast_data_remove_node(data_root, data_span);
+ }
+ }
+ close(ctl);
+
+ return 0;
+}
+
+/*!
+ * \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.
+ */
+static int dahdi_channels_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ struct dahdi_pvt *tmp;
+ struct ast_data *data_channel;
+
+ ast_mutex_lock(&iflock);
+ for (tmp = iflist; tmp; tmp = tmp->next) {
+ data_channel = ast_data_add_node(data_root, "channel");
+ if (!data_channel) {
+ continue;
+ }
+
+ ast_data_add_structure(dahdi_pvt, data_channel, tmp);
+
+ /* 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_mutex_unlock(&iflock);
+
+ return 0;
+}
+
+/*!
+ * \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.
+ */
+static int dahdi_version_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
+{
+ int pseudo_fd = -1;
+ struct dahdi_versioninfo vi = {
+ .version = "Unknown",
+ .echo_canceller = "Unknown"
+ };
+
+ if ((pseudo_fd = open("/dev/dahdi/ctl", O_RDONLY)) < 0) {
+ ast_log(LOG_ERROR, "Failed to open control file to get version.\n");
+ return -1;
+ }
+
+ if (ioctl(pseudo_fd, DAHDI_GETVERSION, &vi)) {
+ ast_log(LOG_ERROR, "Failed to get DAHDI version: %s\n", strerror(errno));
+ }
+
+ close(pseudo_fd);
+
+ ast_data_add_str(data_root, "value", vi.version);
+ ast_data_add_str(data_root, "echocanceller", vi.echo_canceller);
+
+ return 0;
+}
+
+static const struct ast_data_handler dahdi_status_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = dahdi_status_data_provider_get
+};
+
+static const struct ast_data_handler dahdi_channels_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = dahdi_channels_data_provider_get
+};
+
+static const struct ast_data_handler dahdi_version_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = dahdi_version_data_provider_get
+};
+
+static const struct ast_data_entry dahdi_data_providers[] = {
+ AST_DATA_ENTRY("asterisk/channel/dahdi/status", &dahdi_status_data_provider),
+ AST_DATA_ENTRY("asterisk/channel/dahdi/channels", &dahdi_channels_data_provider),
+ AST_DATA_ENTRY("asterisk/channel/dahdi/version", &dahdi_version_data_provider)
+};
+
static int load_module(void)
{
int res;
@@ -17467,7 +17697,8 @@
#endif
ast_cli_register_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli));
-
+ /* register all the data providers */
+ ast_data_register_multiple(dahdi_data_providers, ARRAY_LEN(dahdi_data_providers));
memset(round_robin, 0, sizeof(round_robin));
ast_manager_register_xml("DAHDITransfer", 0, action_transfer);
ast_manager_register_xml("DAHDIHangup", 0, action_transferhangup);
Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=274727&r1=274726&r2=274727
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Jul 8 09:48:42 2010
@@ -90,6 +90,8 @@
#include "asterisk/astobj2.h"
#include "asterisk/timing.h"
#include "asterisk/taskprocessor.h"
+#include "asterisk/test.h"
+#include "asterisk/data.h"
#include "iax2.h"
#include "iax2-parser.h"
@@ -13852,6 +13854,125 @@
#endif /* IAXTESTS */
};
+#ifdef TEST_FRAMEWORK
+AST_TEST_DEFINE(test_iax2_peers_get)
+{
+ struct ast_data_query query = {
+ .path = "/asterisk/channel/iax2/peers",
+ .search = "peers/peer/name=test_peer_data_provider"
+ };
+ struct ast_data *node;
+ struct iax2_peer *peer;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "iax2_peers_get_data_test";
+ info->category = "main/data/iax2/peers";
+ info->summary = "IAX2 peers data providers unit test";
+ info->description =
+ "Tests whether the IAX2 peers data provider implementation works as expected.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ /* build a test peer */
+ peer = build_peer("test_peer_data_provider", NULL, NULL, 0);
+ if (!peer) {
+ return AST_TEST_FAIL;
+ }
+ peer->expiry= 1010;
+ ao2_link(peers, peer);
+
+ node = ast_data_get(&query);
+ if (!node) {
+ ao2_unlink(peers, peer);
+ peer_unref(peer);
+ return AST_TEST_FAIL;
+ }
+
+ /* check returned data node. */
+ if (strcmp(ast_data_retrieve_string(node, "peer/name"), "test_peer_data_provider")) {
+ ao2_unlink(peers, peer);
+ peer_unref(peer);
+ ast_data_free(node);
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_data_retrieve_int(node, "peer/expiry") != 1010) {
+ ao2_unlink(peers, peer);
+ peer_unref(peer);
+ ast_data_free(node);
+ return AST_TEST_FAIL;
+ }
+
+ /* release resources */
+ ast_data_free(node);
+
+ ao2_unlink(peers, peer);
+ peer_unref(peer);
+
+ return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(test_iax2_users_get)
+{
+ struct ast_data_query query = {
+ .path = "/asterisk/channel/iax2/users",
+ .search = "users/user/name=test_user_data_provider"
+ };
+ struct ast_data *node;
+ struct iax2_user *user;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "iax2_users_get_data_test";
+ info->category = "main/data/iax2/users";
+ info->summary = "IAX2 users data providers unit test";
+ info->description =
+ "Tests whether the IAX2 users data provider implementation works as expected.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ user = build_user("test_user_data_provider", NULL, NULL, 0);
+ if (!user) {
+ return AST_TEST_FAIL;
+ }
+ user->amaflags = 1010;
+ ao2_link(users, user);
+
+ node = ast_data_get(&query);
+ if (!node) {
+ ao2_unlink(users, user);
+ user_unref(user);
+ return AST_TEST_FAIL;
+ }
+
+ if (strcmp(ast_data_retrieve_string(node, "user/name"), "test_user_data_provider")) {
+ ao2_unlink(users, user);
+ user_unref(user);
+ ast_data_free(node);
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_data_retrieve_int(node, "user/amaflags") != 1010) {
+ ao2_unlink(users, user);
+ user_unref(user);
+ ast_data_free(node);
+ return AST_TEST_FAIL;
+ }
+
+ ast_data_free(node);
+
+ ao2_unlink(users, user);
+ user_unref(user);
+
+ return AST_TEST_PASS;
+}
+#endif
+
static void cleanup_thread_list(void *head)
{
AST_LIST_HEAD(iax2_thread_list, iax2_thread);
@@ -13907,7 +14028,24 @@
ast_netsock_release(netsock);
ast_netsock_release(outsock);
-
+ for (x = 0; x < ARRAY_LEN(iaxs); x++) {
+ if (iaxs[x]) {
+ iax2_destroy(x);
+ }
+ }
+ ast_manager_unregister( "IAXpeers" );
+ ast_manager_unregister( "IAXpeerlist" );
+ ast_manager_unregister( "IAXnetstats" );
+ ast_manager_unregister( "IAXregistry" );
+ ast_unregister_application(papp);
+#ifdef TEST_FRAMEWORK
+ AST_TEST_UNREGISTER(test_iax2_peers_get);
+ AST_TEST_UNREGISTER(test_iax2_users_get);
+#endif
+ ast_data_unregister(NULL);
+ ast_cli_unregister_multiple(cli_iax2, ARRAY_LEN(cli_iax2));
+ ast_unregister_switch(&iax2_switch);
+ ast_channel_unregister(&iax2_tech);
delete_users();
iax_provision_unload();
reload_firmware(1);
@@ -14048,6 +14186,188 @@
return AST_MODULE_LOAD_FAILURE;
}
+
+#define DATA_EXPORT_IAX2_PEER(MEMBER) \
+ MEMBER(iax2_peer, name, AST_DATA_STRING) \
+ MEMBER(iax2_peer, username, AST_DATA_STRING) \
+ MEMBER(iax2_peer, secret, AST_DATA_PASSWORD) \
+ MEMBER(iax2_peer, dbsecret, AST_DATA_PASSWORD) \
+ MEMBER(iax2_peer, outkey, AST_DATA_STRING) \
[... 2362 lines stripped ...]
More information about the asterisk-commits
mailing list