[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r273876 - in /team/eliel/data...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 3 20:55:26 CDT 2010


Author: eliel
Date: Sat Jul  3 20:55:22 2010
New Revision: 273876

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=273876
Log:
Implement a three new data formats:
SECONDS, MILLISECONDS and TIMESTAMP.


Modified:
    team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c
    team/eliel/data_api_providers_gsoc2010/apps/app_queue.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=273876&r1=273875&r2=273876
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c Sat Jul  3 20:55:22 2010
@@ -6739,19 +6739,20 @@
 	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_INTEGER)			\
-	MEMBER(ast_conference, endtime, AST_DATA_INTEGER)
+	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_INTEGER)	\
-	MEMBER(ast_conf_user, kicktime, AST_DATA_INTEGER)	\
-	MEMBER(ast_conf_user, timelimit, AST_DATA_INTEGER)	\
-	MEMBER(ast_conf_user, play_warning, AST_DATA_INTEGER)
+#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);
 

Modified: team/eliel/data_api_providers_gsoc2010/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/apps/app_queue.c?view=diff&rev=273876&r1=273875&r2=273876
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_queue.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_queue.c Sat Jul  3 20:55:22 2010
@@ -7777,7 +7777,7 @@
 	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, 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)		\

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=273876&r1=273875&r2=273876
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h (original)
+++ team/eliel/data_api_providers_gsoc2010/include/asterisk/data.h Sat Jul  3 20:55:22 2010
@@ -194,6 +194,9 @@
 	AST_DATA_CHARACTER,
 	AST_DATA_PASSWORD,
 	AST_DATA_IPADDR,
+	AST_DATA_TIMESTAMP,
+	AST_DATA_SECONDS,
+	AST_DATA_MILLISECONDS,
 	AST_DATA_POINTER
 };
 
@@ -220,6 +223,9 @@
 		char *AST_DATA_STRING;
 		char *AST_DATA_PASSWORD;
 		int AST_DATA_INTEGER;
+		unsigned int AST_DATA_TIMESTAMP;
+		unsigned int AST_DATA_SECONDS;
+		unsigned int AST_DATA_MILLISECONDS;
 		double AST_DATA_DOUBLE;
 		unsigned int AST_DATA_UNSIGNED_INTEGER;
 		unsigned int AST_DATA_BOOLEAN;
@@ -278,6 +284,9 @@
 		char *(*AST_DATA_STRING)(void *ptr);
 		char *(*AST_DATA_PASSWORD)(void *ptr);
 		int (*AST_DATA_INTEGER)(void *ptr);
+		int (*AST_DATA_TIMESTAMP)(void *ptr);
+		int (*AST_DATA_SECONDS)(void *ptr);
+		int (*AST_DATA_MILLISECONDS)(void *ptr);
 		double (*AST_DATA_DOUBLE)(void *ptr);
 		unsigned int (*AST_DATA_UNSIGNED_INTEGER)(void *ptr);
 		unsigned int (*AST_DATA_BOOLEAN)(void *ptr);
@@ -307,6 +316,12 @@
 #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CHARACTER(__structure, __member)				\
 	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CHARACTER, char)
 #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_INTEGER(__structure, __member)				\
+	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_TIMESTAMP(__structure, __member)				\
+	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_SECONDS(__structure, __member)				\
+	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_MILLISECONDS(__structure, __member)			\
 	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)
 #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_UNSIGNED_INTEGER(__structure, __member)			\
 	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_UNSIGNED_INTEGER, unsigned int)
@@ -536,6 +551,39 @@
 	const char *string);
 
 /*!
+ * \brief Add a timestamp 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] timestamp 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_timestamp(struct ast_data *root, const char *childname,
+	unsigned int timestamp);
+
+/*!
+ * \brief Add a seconds 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] seconds 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_seconds(struct ast_data *root, const char *childname,
+	unsigned int seconds);
+
+/*!
+ * \brief Add a milliseconds 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] milliseconds 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_milliseconds(struct ast_data *root, const char *childname,
+	unsigned int milliseconds);
+
+/*!
  * \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.

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=273876&r1=273875&r2=273876
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/data.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/data.c Sat Jul  3 20:55:22 2010
@@ -1299,6 +1299,21 @@
 				node->name,
 				mapping[member].get.AST_DATA_PASSWORD(structure));
 			break;
+		case AST_DATA_TIMESTAMP:
+			notmatch = data_search_cmp_uint(struct_children,
+				node->name,
+				mapping[member].get.AST_DATA_TIMESTAMP(structure));
+			break;
+		case AST_DATA_SECONDS:
+			notmatch = data_search_cmp_uint(struct_children,
+				node->name,
+				mapping[member].get.AST_DATA_SECONDS(structure));
+			break;
+		case AST_DATA_MILLISECONDS:
+			notmatch = data_search_cmp_uint(struct_children,
+				node->name,
+				mapping[member].get.AST_DATA_MILLISECONDS(structure));
+			break;
 		case AST_DATA_STRING:
 			notmatch = data_search_cmp_string(struct_children,
 				node->name,
@@ -1370,6 +1385,9 @@
 	case AST_DATA_CHARACTER:
 	case AST_DATA_CONTAINER:
 	case AST_DATA_INTEGER:
+	case AST_DATA_TIMESTAMP:
+	case AST_DATA_SECONDS:
+	case AST_DATA_MILLISECONDS:
 	case AST_DATA_UNSIGNED_INTEGER:
 	case AST_DATA_DOUBLE:
 	case AST_DATA_BOOLEAN:
@@ -1483,8 +1501,11 @@
 				notmatch = data_search_cmp_uint(s_child, d_child->name,
 					d_child->payload.uint);
 				break;
+			case AST_DATA_TIMESTAMP:
+			case AST_DATA_SECONDS:
+			case AST_DATA_MILLISECONDS:
 			case AST_DATA_DOUBLE:
-				notmatch = data_search_cmp_dbl(s_child, d_child->name,
+				notmatch = data_search_cmp_uint(s_child, d_child->name,
 					d_child->payload.dbl);
 				break;
 			case AST_DATA_IPADDR:
@@ -2088,6 +2109,21 @@
 		case AST_DATA_PASSWORD:
 			ast_xml_set_text(child_xml, node->payload.str);
 			break;
+		case AST_DATA_TIMESTAMP:
+			snprintf(node_content, sizeof(node_content), "%d",
+				node->payload.uint);
+			ast_xml_set_text(child_xml, node_content);
+			break;
+		case AST_DATA_SECONDS:
+			snprintf(node_content, sizeof(node_content), "%d",
+				node->payload.uint);
+			ast_xml_set_text(child_xml, node_content);
+			break;
+		case AST_DATA_MILLISECONDS:
+			snprintf(node_content, sizeof(node_content), "%d",
+				node->payload.uint);
+			ast_xml_set_text(child_xml, node_content);
+			break;
 		case AST_DATA_STRING:
 			ast_xml_set_text(child_xml, node->payload.str);
 			break;
@@ -2227,10 +2263,13 @@
 		node->payload.boolean = *(unsigned int *) ptr;
 		break;
 	case AST_DATA_INTEGER:
-		node->payload.sint = *(unsigned int *) ptr;
-		break;
+		node->payload.sint = *(int *) ptr;
+		break;
+	case AST_DATA_TIMESTAMP:
+	case AST_DATA_SECONDS:
+	case AST_DATA_MILLISECONDS:
 	case AST_DATA_UNSIGNED_INTEGER:
-		node->payload.sint = *(unsigned int *) ptr;
+		node->payload.uint = *(unsigned int *) ptr;
 		break;
 	case AST_DATA_DOUBLE:
 		node->payload.dbl = *(double *) ptr;
@@ -2314,6 +2353,24 @@
 	return __ast_data_add(root, childname, AST_DATA_POINTER, ptr);
 }
 
+struct ast_data *ast_data_add_timestamp(struct ast_data *root, const char *childname,
+	unsigned int timestamp)
+{
+	return __ast_data_add(root, childname, AST_DATA_TIMESTAMP, &timestamp);
+}
+
+struct ast_data *ast_data_add_seconds(struct ast_data *root, const char *childname,
+	unsigned int seconds)
+{
+	return __ast_data_add(root, childname, AST_DATA_SECONDS, &seconds);
+}
+
+struct ast_data *ast_data_add_milliseconds(struct ast_data *root, const char *childname,
+	unsigned int milliseconds)
+{
+	return __ast_data_add(root, childname, AST_DATA_MILLISECONDS, &milliseconds);
+}
+
 struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname,
 	const char *value)
 {
@@ -2383,6 +2440,18 @@
 		case AST_DATA_PASSWORD:
 			ast_data_add_password(root, mapping[i].name,
 				mapping[i].get.AST_DATA_PASSWORD(structure));
+			break;
+		case AST_DATA_TIMESTAMP:
+			ast_data_add_timestamp(root, mapping[i].name,
+				mapping[i].get.AST_DATA_TIMESTAMP(structure));
+			break;
+		case AST_DATA_SECONDS:
+			ast_data_add_seconds(root, mapping[i].name,
+				mapping[i].get.AST_DATA_SECONDS(structure));
+			break;
+		case AST_DATA_MILLISECONDS:
+			ast_data_add_milliseconds(root, mapping[i].name,
+				mapping[i].get.AST_DATA_MILLISECONDS(structure));
 			break;
 		case AST_DATA_STRING:
 			ast_data_add_str(root, mapping[i].name,
@@ -2541,6 +2610,15 @@
 	case AST_DATA_PASSWORD:
 		content->value.AST_DATA_PASSWORD = node->payload.str;
 		break;
+	case AST_DATA_TIMESTAMP:
+		content->value.AST_DATA_TIMESTAMP = node->payload.uint;
+		break;
+	case AST_DATA_SECONDS:
+		content->value.AST_DATA_SECONDS = node->payload.uint;
+		break;
+	case AST_DATA_MILLISECONDS:
+		content->value.AST_DATA_MILLISECONDS = node->payload.uint;
+		break;
 	case AST_DATA_CHARACTER:
 		content->value.AST_DATA_CHARACTER = node->payload.character;
 		break;
@@ -2577,8 +2655,11 @@
 	enum ast_data_type type;
 	int color;
 } data_result_color[] = {
-	{ AST_DATA_STRING, COLOR_CYAN },
-	{ AST_DATA_PASSWORD, COLOR_BLUE },
+	{ AST_DATA_STRING, COLOR_BLUE },
+	{ AST_DATA_PASSWORD, COLOR_BRBLUE },
+	{ AST_DATA_TIMESTAMP, COLOR_CYAN },
+	{ AST_DATA_SECONDS, COLOR_MAGENTA },
+	{ AST_DATA_MILLISECONDS, COLOR_BRMAGENTA },
 	{ AST_DATA_CHARACTER, COLOR_GRAY },
 	{ AST_DATA_INTEGER, COLOR_RED },
 	{ AST_DATA_UNSIGNED_INTEGER, COLOR_RED },
@@ -2663,6 +2744,21 @@
 	case AST_DATA_CONTAINER:
 		ast_str_append(&output, 0, "%s%s\n", ast_str_buffer(tabs),
 				node->name);
+		break;
+	case AST_DATA_TIMESTAMP:
+		ast_str_append(&output, 0, "%s%s: %d\n", ast_str_buffer(tabs),
+				node->name,
+				node->payload.uint);
+		break;
+	case AST_DATA_SECONDS:
+		ast_str_append(&output, 0, "%s%s: %d\n", ast_str_buffer(tabs),
+				node->name,
+				node->payload.uint);
+		break;
+	case AST_DATA_MILLISECONDS:
+		ast_str_append(&output, 0, "%s%s: %d\n", ast_str_buffer(tabs),
+				node->name,
+				node->payload.uint);
 		break;
 	case AST_DATA_INTEGER:
 		ast_str_append(&output, 0, "%s%s: %d\n", ast_str_buffer(tabs),
@@ -2927,6 +3023,9 @@
 		case AST_DATA_INTEGER:
 			astman_append(s, ": %d\r\n", node->payload.sint);
 			break;
+		case AST_DATA_TIMESTAMP:
+		case AST_DATA_SECONDS:
+		case AST_DATA_MILLISECONDS:
 		case AST_DATA_UNSIGNED_INTEGER:
 			astman_append(s, ": %u\r\n", node->payload.uint);
 			break;




More information about the asterisk-commits mailing list