[svn-commits] eliel: branch eliel/data_api_providers_gsoc2010 r266284 - in /team/eliel/data...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 28 08:16:16 CDT 2010


Author: eliel
Date: Fri May 28 08:16:14 2010
New Revision: 266284

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=266284
Log:
Add the cdr description to the channel data structure.
Add channel flags to the data structure.
Fix boolean problem while being defined as 1 bit.
Add descriptions to the channel values xxxxx2str().

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/cdr.h
    team/eliel/data_api_providers_gsoc2010/include/asterisk/channel.h
    team/eliel/data_api_providers_gsoc2010/main/cdr.c
    team/eliel/data_api_providers_gsoc2010/main/channel.c
    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=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_meetme.c Fri May 28 08:16:14 2010
@@ -6767,7 +6767,7 @@
 					continue;
 				}
 
-				ast_channel_data_add_structure(data_meetme_user_channel, user->chan);
+				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");

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=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/apps/app_queue.c (original)
+++ team/eliel/data_api_providers_gsoc2010/apps/app_queue.c Fri May 28 08:16:14 2010
@@ -7875,7 +7875,7 @@
 				continue;
 			}
 
-			ast_channel_data_add_structure(data_caller_channel, qe->chan);
+			ast_channel_data_add_structure(data_caller_channel, qe->chan, 1);
 		}
 	}
 

Modified: team/eliel/data_api_providers_gsoc2010/include/asterisk/cdr.h
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/include/asterisk/cdr.h?view=diff&rev=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/include/asterisk/cdr.h (original)
+++ team/eliel/data_api_providers_gsoc2010/include/asterisk/cdr.h Fri May 28 08:16:14 2010
@@ -27,6 +27,8 @@
 #define _ASTERISK_CDR_H
 
 #include <sys/time.h>
+
+#include "asterisk/data.h"
 
 /*!
  * \brief CDR Flags
@@ -435,4 +437,14 @@
 /*! Submit any remaining CDRs and prepare for shutdown */
 void ast_cdr_engine_term(void);
 
+/*!
+ * \brief
+ * \param[in] tree Where to insert the cdr.
+ * \param[in] cdr The cdr structure to insert in 'tree'.
+ * \param[in] recur Go throw all the cdr levels.
+ * \retval <0 on error.
+ * \retval 0 on success.
+ */
+int ast_cdr_data_add_structure(struct ast_data *tree, struct ast_cdr *cdr, int recur);
+
 #endif /* _ASTERISK_CDR_H */

Modified: team/eliel/data_api_providers_gsoc2010/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/include/asterisk/channel.h?view=diff&rev=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/include/asterisk/channel.h (original)
+++ team/eliel/data_api_providers_gsoc2010/include/asterisk/channel.h Fri May 28 08:16:14 2010
@@ -2793,10 +2793,11 @@
  * \brief Insert into an astdata tree, the channel structure.
  * \param[in] tree The ast data tree.
  * \param[in] chan The channel structure to add to tree.
+ * \param[in] add_bridged Add the bridged channel to the structure.
  * \retval <0 on error.
  * \retval 0 on success.
  */
-int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan);
+int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);
 
 /*!
  * \brief Compare to channel structures using the data api.

Modified: team/eliel/data_api_providers_gsoc2010/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/main/cdr.c?view=diff&rev=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/cdr.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/cdr.c Fri May 28 08:16:14 2010
@@ -49,6 +49,7 @@
 #include "asterisk/config.h"
 #include "asterisk/cli.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/data.h"
 
 /*! Default AMA flag for billing records (CDR's) */
 int ast_default_amaflags = AST_CDR_DOCUMENTATION;
@@ -1635,3 +1636,50 @@
 	return do_reload(1);
 }
 
+int ast_cdr_data_add_structure(struct ast_data *tree, struct ast_cdr *cdr, int recur)
+{
+	struct ast_cdr *tmpcdr;
+	struct ast_data *level;
+	struct ast_var_t *variables;
+	const char *var, *val;
+	int x = 1, i;
+	char workspace[256];
+	char *tmp;
+
+	if (!cdr) {
+		return -1;
+	}
+
+	for (tmpcdr = cdr; tmpcdr; tmpcdr = (recur ? tmpcdr->next : NULL)) {
+		level = ast_data_add_node(tree, "level");
+		if (!level) {
+			continue;
+		}
+
+		ast_data_add_int(level, "level_number", x);
+
+		AST_LIST_TRAVERSE(&tmpcdr->varshead, variables, entries) {
+			if (variables && (var = ast_var_name(variables)) &&
+					(val = ast_var_value(variables)) && !ast_strlen_zero(var)
+					&& !ast_strlen_zero(val)) {
+				ast_data_add_str(level, var, val);
+			} else {
+				break;
+			}
+		}
+
+		for (i = 0; cdr_readonly_vars[i]; i++) {
+			workspace[0] = 0; /* null out the workspace, because the cdr_get_tv() won't write anything if time is NULL, so you get old vals */
+			ast_cdr_getvar(tmpcdr, cdr_readonly_vars[i], &tmp, workspace, sizeof(workspace), 0, 0);
+			if (!tmp) {
+				continue;
+			}
+			ast_data_add_str(level, cdr_readonly_vars[i], tmp);
+		}
+
+		x++;
+	}
+
+	return 0;
+}
+

Modified: team/eliel/data_api_providers_gsoc2010/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/main/channel.c?view=diff&rev=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/channel.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/channel.c Fri May 28 08:16:14 2010
@@ -151,10 +151,6 @@
 	MEMBER(ast_channel, hangupsource, AST_DATA_STRING)			\
 	MEMBER(ast_channel, dialcontext, AST_DATA_STRING)			\
 	MEMBER(ast_channel, _softhangup, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, streamid, AST_DATA_INTEGER)				\
-	MEMBER(ast_channel, vstreamid, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, oldwriteformat, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, _state, AST_DATA_INTEGER)				\
 	MEMBER(ast_channel, rings, AST_DATA_INTEGER)				\
 	MEMBER(ast_channel, priority, AST_DATA_INTEGER)				\
 	MEMBER(ast_channel, macropriority, AST_DATA_INTEGER)			\
@@ -162,13 +158,6 @@
 	MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER)				\
 	MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER)			\
 	MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER)			\
-	MEMBER(ast_channel, hangupcause, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, flags, AST_DATA_UNSIGNED_INTEGER)			\
-	MEMBER(ast_channel, nativeformats, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, readformat, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, writeformat, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, rawreadformat, AST_DATA_INTEGER)			\
-	MEMBER(ast_channel, rawwriteformat, AST_DATA_INTEGER)			\
 	MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER)	\
 	MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER)		\
 	MEMBER(ast_channel, transfercapability, AST_DATA_INTEGER)		\
@@ -258,9 +247,79 @@
 	return var;
 }
 
-int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan)
-{
-	return ast_data_add_structure(ast_channel, tree, chan);
+static void channel_data_add_flags(struct ast_data *tree,
+	struct ast_channel *chan)
+{
+	ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF));
+	ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT));
+	ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING));
+	ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE));
+	ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION));
+	ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH));
+	ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING));
+	ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE));
+	ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP));
+	ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING));
+	ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF));
+	ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF));
+	ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY));
+	ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE));
+	ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM));
+	ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
+	ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
+	ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
+}
+
+int ast_channel_data_add_structure(struct ast_data *tree,
+	struct ast_channel *chan, int add_bridged)
+{
+	struct ast_channel *bc;
+	struct ast_data *data_bridged, *data_cdr, *data_flags;
+
+	if (!tree) {
+		return -1;
+	}
+
+	ast_data_add_structure(ast_channel, tree, chan);
+
+	if (add_bridged) {
+		bc = ast_bridged_channel(chan);
+		if (bc) {
+			data_bridged = ast_data_add_node(tree, "bridged");
+			if (!data_bridged) {
+				return -1;
+			}
+			ast_channel_data_add_structure(data_bridged, bc, 0);
+		}
+	}
+
+	ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat);
+	ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
+	ast_data_add_codecs(tree, "readformat", chan->readformat);
+	ast_data_add_codecs(tree, "writeformat", chan->writeformat);
+	ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat);
+	ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat);
+
+	ast_data_add_str(tree, "state", ast_state2str(chan->_state));
+
+	ast_data_add_str(tree, "hangupcause", ast_cause2str(chan->hangupcause));
+
+	/* channel flags */
+	data_flags = ast_data_add_node(tree, "flags");
+	if (!data_flags) {
+		return -1;
+	}
+	channel_data_add_flags(data_flags, chan);
+
+	/* insert cdr */
+	data_cdr = ast_data_add_node(tree, "cdr");
+	if (!data_cdr) {
+		return -1;
+	}
+
+	ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
+
+	return 0;
 }
 
 int ast_channel_data_cmp_structure(const struct ast_data_search *tree,
@@ -6733,9 +6792,9 @@
 static int data_channels_provider_handler(const struct ast_data_search *search,
 	struct ast_data *root)
 {
-	struct ast_channel *c, *bc;
+	struct ast_channel *c;
 	struct ast_channel_iterator *iter = NULL;
-	struct ast_data *data_channel, *data_bridged;
+	struct ast_data *data_channel;
 
 	for (iter = ast_channel_iterator_all_new();
 		iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
@@ -6747,24 +6806,9 @@
 			continue;
 		}
 
-		ast_channel_data_add_structure(data_channel, c);
-
-		bc = ast_bridged_channel(c);
-		if (bc) {
-			data_bridged = ast_data_add_node(data_channel, "bridged");
-			if (!data_bridged) {
-				ast_channel_unlock(c);
-				continue;
-			}
-			ast_channel_data_add_structure(data_bridged, bc);
-		}
-
-		ast_data_add_codecs(data_channel, "oldwriteformat", c->oldwriteformat);
-		ast_data_add_codecs(data_channel, "nativeformats", c->nativeformats);
-		ast_data_add_codecs(data_channel, "readformat", c->readformat);
-		ast_data_add_codecs(data_channel, "writeformat", c->writeformat);
-		ast_data_add_codecs(data_channel, "rawreadformat", c->rawreadformat);
-		ast_data_add_codecs(data_channel, "rawwriteformat", c->rawwriteformat);
+		if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {
+			ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", c->name);
+		}
 
 		ast_channel_unlock(c);
 

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=266284&r1=266283&r2=266284
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/data.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/data.c Fri May 28 08:16:14 2010
@@ -86,7 +86,7 @@
 		int32_t sint;
 		uint32_t uint;
 		double dbl;
-		unsigned int boolean:1;
+		unsigned int boolean;
 		char *str;
 		struct in_addr ipaddr;
 		void *ptr;




More information about the svn-commits mailing list