Implement AstData API data providers as part of the GSOC 2010 project,

midterm evaluation.

Review: https://reviewboard.asterisk.org/r/757/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@274727 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Eliel C. Sardanons
2010-07-08 14:48:42 +00:00
parent 21f8c77934
commit a1b89a6a50
17 changed files with 2244 additions and 329 deletions

View File

@@ -38,9 +38,23 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "asterisk/data.h"
#include "asterisk/_private.h" /* _init(), _reload() */
#define DATA_EXPORT_TONE_ZONE(MEMBER) \
MEMBER(ast_tone_zone, country, AST_DATA_STRING) \
MEMBER(ast_tone_zone, description, AST_DATA_STRING) \
MEMBER(ast_tone_zone, nrringcadence, AST_DATA_UNSIGNED_INTEGER)
AST_DATA_STRUCTURE(ast_tone_zone, DATA_EXPORT_TONE_ZONE);
#define DATA_EXPORT_TONE_ZONE_SOUND(MEMBER) \
MEMBER(ast_tone_zone_sound, name, AST_DATA_STRING) \
MEMBER(ast_tone_zone_sound, data, AST_DATA_STRING)
AST_DATA_STRUCTURE(ast_tone_zone_sound, DATA_EXPORT_TONE_ZONE_SOUND);
/* Globals */
static const char config[] = "indications.conf";
@@ -1102,6 +1116,33 @@ static int ast_tone_zone_cmp(void *obj, void *arg, int flags)
CMP_MATCH | CMP_STOP : 0;
}
int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone)
{
struct ast_data *data_zone_sound;
struct ast_tone_zone_sound *s;
ast_data_add_structure(ast_tone_zone, tree, zone);
if (AST_LIST_EMPTY(&zone->tones)) {
return 0;
}
data_zone_sound = ast_data_add_node(tree, "tones");
if (!data_zone_sound) {
return -1;
}
ast_tone_zone_lock(zone);
AST_LIST_TRAVERSE(&zone->tones, s, entry) {
ast_data_add_structure(ast_tone_zone_sound, data_zone_sound, s);
}
ast_tone_zone_unlock(zone);
return 0;
}
/*! \brief Load indications module */
int ast_indications_init(void)
{