[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r270150 - in /team/eliel/data...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jun 12 15:37:46 CDT 2010
Author: eliel
Date: Sat Jun 12 15:36:54 2010
New Revision: 270150
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=270150
Log:
Create a new node type 'PASSWORD', in the future we will be
able to avoid showing this kind of node if neccesary.
Modified:
team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c
team/eliel/data_api_providers_gsoc2010/apps/app_voicemail.c
team/eliel/data_api_providers_gsoc2010/channels/chan_iax2.c
team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c
team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h
team/eliel/data_api_providers_gsoc2010/main/data.c
Modified: team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c Sat Jun 12 15:36:54 2010
@@ -6708,8 +6708,8 @@
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_STRING) \
- MEMBER(ast_conference, pinadmin, AST_DATA_STRING) \
+ MEMBER(ast_conference, pin, AST_DATA_PASSWORD) \
+ MEMBER(ast_conference, pinadmin, AST_DATA_PASSWORD) \
MEMBER(ast_conference, start, AST_DATA_INTEGER) \
MEMBER(ast_conference, endtime, AST_DATA_INTEGER)
Modified: team/eliel/data_api_providers_gsoc2010/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/apps/app_voicemail.c?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_voicemail.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_voicemail.c Sat Jun 12 15:36:54 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) \
@@ -10874,50 +10874,6 @@
ZONE(vm_zone, msg_format, AST_DATA_STRING)
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
Modified: team/eliel/data_api_providers_gsoc2010/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/channels/chan_iax2.c?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/channels/chan_iax2.c (original)
+++ team/eliel/data_api_providers_gsoc2010/channels/chan_iax2.c Sat Jun 12 15:36:54 2010
@@ -14156,8 +14156,8 @@
#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_STRING) \
- MEMBER(iax2_peer, dbsecret, AST_DATA_STRING) \
+ MEMBER(iax2_peer, secret, AST_DATA_PASSWORD) \
+ MEMBER(iax2_peer, dbsecret, AST_DATA_PASSWORD) \
MEMBER(iax2_peer, outkey, AST_DATA_STRING) \
MEMBER(iax2_peer, regexten, AST_DATA_STRING) \
MEMBER(iax2_peer, context, AST_DATA_STRING) \
@@ -14234,7 +14234,7 @@
#define DATA_EXPORT_IAX2_USER(MEMBER) \
MEMBER(iax2_user, name, AST_DATA_STRING) \
- MEMBER(iax2_user, dbsecret, AST_DATA_STRING) \
+ MEMBER(iax2_user, dbsecret, AST_DATA_PASSWORD) \
MEMBER(iax2_user, accountcode, AST_DATA_STRING) \
MEMBER(iax2_user, mohinterpret, AST_DATA_STRING) \
MEMBER(iax2_user, mohsuggest, AST_DATA_STRING) \
@@ -14278,7 +14278,7 @@
} else {
ast_copy_string(auth, "no secret", sizeof(auth));
}
- ast_data_add_str(data_user, "secret", auth);
+ ast_data_add_password(data_user, "secret", auth);
ast_data_add_str(data_user, "context", user->contexts ? user->contexts->context : DEFAULT_CONTEXT);
Modified: team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c (original)
+++ team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c Sat Jun 12 15:36:54 2010
@@ -27600,9 +27600,9 @@
#define DATA_EXPORT_SIP_PEER(MEMBER) \
MEMBER(sip_peer, name, AST_DATA_STRING) \
- MEMBER(sip_peer, secret, AST_DATA_STRING) \
- MEMBER(sip_peer, md5secret, AST_DATA_STRING) \
- MEMBER(sip_peer, remotesecret, AST_DATA_STRING) \
+ MEMBER(sip_peer, secret, AST_DATA_PASSWORD) \
+ MEMBER(sip_peer, md5secret, AST_DATA_PASSWORD) \
+ MEMBER(sip_peer, remotesecret, AST_DATA_PASSWORD) \
MEMBER(sip_peer, context, AST_DATA_STRING) \
MEMBER(sip_peer, subscribecontext, AST_DATA_STRING) \
MEMBER(sip_peer, username, AST_DATA_STRING) \
Modified: team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h (original)
+++ team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h Sat Jun 12 15:36:54 2010
@@ -191,6 +191,7 @@
AST_DATA_DOUBLE,
AST_DATA_BOOLEAN,
AST_DATA_STRING,
+ AST_DATA_PASSWORD,
AST_DATA_IPADDR,
AST_DATA_POINTER
};
@@ -215,6 +216,7 @@
union {
char *AST_DATA_STRING;
+ char *AST_DATA_PASSWORD;
int AST_DATA_INTEGER;
double AST_DATA_DOUBLE;
unsigned int AST_DATA_UNSIGNED_INTEGER;
@@ -271,6 +273,7 @@
/*! \brief member getter. */
union {
char *(*AST_DATA_STRING)(void *ptr);
+ char *(*AST_DATA_PASSWORD)(void *ptr);
int (*AST_DATA_INTEGER)(void *ptr);
double (*AST_DATA_DOUBLE)(void *ptr);
unsigned int (*AST_DATA_UNSIGNED_INTEGER)(void *ptr);
@@ -294,6 +297,8 @@
.type = __type },
/* based on the data type, specifify the type of return value for the getter function. */
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_PASSWORD(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_PASSWORD, char *)
#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_STRING(__structure, __member) \
__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_STRING, char *)
#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_INTEGER(__structure, __member) \
@@ -504,6 +509,17 @@
void *ptr);
/*!
+ * \brief Add a password node type.
+ * \param[in] root The root of the ast_data to insert into.
+ * \param[in] childname The name of the child element to be added.
+ * \param[in] string The value for the new node.
+ * \retval NULL on error (memory exhaustion only).
+ * \retval non-NULL a newly allocated node.
+ */
+struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname,
+ const char *string);
+
+/*!
* \brief Add a string node type.
* \param[in] root The root of the ast_data to insert into.
* \param[in] childname The name of the child element to be added.
@@ -630,6 +646,21 @@
}
/*!
+ * \brief Retrieve the password value of a node.
+ * \param[in] tree The tree from where to get the value.
+ * \param[in] path The node name or path.
+ * \returns The value of the node.
+ */
+static inline const char *ast_data_retrieve_password(struct ast_data *tree, const char *path)
+{
+ struct ast_data_retrieve ret;
+
+ ast_data_retrieve(tree, path, &ret);
+
+ return ret.value.AST_DATA_PASSWORD;
+}
+
+/*!
* \brief Retrieve the string value of a node.
* \param[in] tree The tree from where to get the value.
* \param[in] path The node name or path.
Modified: team/eliel/data_api_providers_gsoc2010/main/data.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/main/data.c?view=diff&rev=270150&r1=270149&r2=270150
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/data.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/data.c Sat Jun 12 15:36:54 2010
@@ -88,6 +88,7 @@
double dbl;
unsigned int boolean;
char *str;
+ char *password;
struct in_addr ipaddr;
void *ptr;
} payload;
@@ -1261,6 +1262,11 @@
notmatch = 0;
switch (mapping[member].type) {
+ case AST_DATA_PASSWORD:
+ notmatch = data_search_cmp_string(struct_children,
+ node->name,
+ mapping[member].get.AST_DATA_PASSWORD(structure));
+ break;
case AST_DATA_STRING:
notmatch = data_search_cmp_string(struct_children,
node->name,
@@ -1318,9 +1324,15 @@
struct ast_data *root = obj;
switch (root->type) {
+ case AST_DATA_PASSWORD:
+ ast_free(root->payload.password);
+ ao2_ref(root->children, -1);
+ break;
+ case AST_DATA_STRING:
+ ast_free(root->payload.str);
+ ao2_ref(root->children, -1);
+ break;
case AST_DATA_POINTER:
- case AST_DATA_STRING:
- ast_free(root->payload.ptr);
case AST_DATA_CONTAINER:
case AST_DATA_INTEGER:
case AST_DATA_UNSIGNED_INTEGER:
@@ -1415,6 +1427,10 @@
}
switch (d_child->type) {
+ case AST_DATA_PASSWORD:
+ notmatch = data_search_cmp_string(s_child, d_child->name,
+ d_child->payload.password);
+ break;
case AST_DATA_STRING:
notmatch = data_search_cmp_string(s_child, d_child->name,
d_child->payload.str);
@@ -2033,6 +2049,9 @@
case AST_DATA_CONTAINER:
data_get_xml_add_child(node, child_xml);
break;
+ case AST_DATA_PASSWORD:
+ ast_xml_set_text(child_xml, node->payload.password);
+ break;
case AST_DATA_STRING:
ast_xml_set_text(child_xml, node->payload.str);
break;
@@ -2175,7 +2194,12 @@
case AST_DATA_DOUBLE:
node->payload.dbl = *(double *) ptr;
break;
+ case AST_DATA_PASSWORD:
+ node->payload.password = (char *) ptr;
+ break;
case AST_DATA_STRING:
+ node->payload.str = (char *) ptr;
+ break;
case AST_DATA_POINTER:
node->payload.ptr = ptr;
break;
@@ -2243,6 +2267,27 @@
return __ast_data_add(root, childname, AST_DATA_POINTER, ptr);
}
+struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname,
+ const char *value)
+{
+ char *name;
+ size_t namelen = 1 + (ast_strlen_zero(value) ? 0 : strlen(value));
+ struct ast_data *res;
+
+ if (!(name = ast_malloc(namelen))) {
+ return NULL;
+ }
+
+ strcpy(name, (ast_strlen_zero(value) ? "" : value));
+
+ res = __ast_data_add(root, childname, AST_DATA_PASSWORD, name);
+ if (!res) {
+ ast_free(name);
+ }
+
+ return res;
+}
+
struct ast_data *ast_data_add_str(struct ast_data *root, const char *childname,
const char *value)
{
@@ -2287,6 +2332,10 @@
case AST_DATA_BOOLEAN:
ast_data_add_bool(root, mapping[i].name,
mapping[i].get.AST_DATA_BOOLEAN(structure));
+ break;
+ case AST_DATA_PASSWORD:
+ ast_data_add_password(root, mapping[i].name,
+ mapping[i].get.AST_DATA_PASSWORD(structure));
break;
case AST_DATA_STRING:
ast_data_add_str(root, mapping[i].name,
@@ -2438,6 +2487,9 @@
case AST_DATA_STRING:
content->value.AST_DATA_STRING = node->payload.str;
break;
+ case AST_DATA_PASSWORD:
+ content->value.AST_DATA_PASSWORD = node->payload.password;
+ break;
case AST_DATA_INTEGER:
content->value.AST_DATA_INTEGER = node->payload.sint;
break;
@@ -2472,6 +2524,7 @@
int color;
} data_result_color[] = {
{ AST_DATA_STRING, COLOR_CYAN },
+ { AST_DATA_PASSWORD, COLOR_BLUE },
{ AST_DATA_INTEGER, COLOR_RED },
{ AST_DATA_UNSIGNED_INTEGER, COLOR_RED },
{ AST_DATA_DOUBLE, COLOR_RED },
@@ -2533,6 +2586,12 @@
case AST_DATA_POINTER:
ast_str_append(&output, 0, "%s%s: %p\n", ast_str_buffer(tabs),
node->name, node->payload.ptr);
+ break;
+ case AST_DATA_PASSWORD:
+ ast_str_append(&output, 0, "%s%s: \"%s\"\n",
+ ast_str_buffer(tabs),
+ node->name,
+ node->payload.password);
break;
case AST_DATA_STRING:
ast_str_append(&output, 0, "%s%s: \"%s\"\n",
@@ -2807,6 +2866,9 @@
break;
case AST_DATA_UNSIGNED_INTEGER:
astman_append(s, ": %u\r\n", node->payload.uint);
+ break;
+ case AST_DATA_PASSWORD:
+ astman_append(s, ": %s\r\n", node->payload.password);
break;
case AST_DATA_STRING:
astman_append(s, ": %s\r\n", node->payload.str);
More information about the asterisk-commits
mailing list