[asterisk-commits] russell: branch russell/events r84629 - in /team/russell/events: include/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 3 21:52:31 CDT 2007


Author: russell
Date: Wed Oct  3 21:52:31 2007
New Revision: 84629

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84629
Log:
Dynamically build an internal event subscription from the parameters provided
by the event mappings in dundi.conf.  Next comes adding real code to the event
callback for sending the events over the network ...

Modified:
    team/russell/events/include/asterisk/event_defs.h
    team/russell/events/pbx/pbx_dundi.c

Modified: team/russell/events/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/event_defs.h?view=diff&rev=84629&r1=84628&r2=84629
==============================================================================
--- team/russell/events/include/asterisk/event_defs.h (original)
+++ team/russell/events/include/asterisk/event_defs.h Wed Oct  3 21:52:31 2007
@@ -122,6 +122,7 @@
  * \brief Payload types for event information elements
  */
 enum ast_event_ie_pltype {
+	AST_EVENT_IE_PLTYPE_UNKNOWN = -1,
 	/*! Just check if it exists, not the value */
 	AST_EVENT_IE_PLTYPE_EXISTS,
 	/*! Unsigned Integer (Can be used for signed, too ...) */

Modified: team/russell/events/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/pbx_dundi.c?view=diff&rev=84629&r1=84628&r2=84629
==============================================================================
--- team/russell/events/pbx/pbx_dundi.c (original)
+++ team/russell/events/pbx/pbx_dundi.c Wed Oct  3 21:52:31 2007
@@ -4713,6 +4713,77 @@
 	return -1;
 }
 
+static enum ast_event_ie_pltype get_ie_pltype_mwi(const char *val)
+{
+	if (!strcasecmp(val, "context"))
+		return AST_EVENT_IE_CONTEXT;
+	
+	return -1;
+}
+
+static enum ast_event_ie_pltype get_ie_pltype(enum ast_event_ie_type ie_type,
+	const char *val)
+{
+	switch (ie_type) {
+	case AST_EVENT_MWI:
+		return get_ie_pltype_mwi(val);
+	default:
+		return -1;
+	}
+}
+
+static enum ast_event_ie_type get_supported_event_ie_type(enum ast_event_type event_type,
+	const char *val)
+{
+	if (!strcasecmp(val, "mwi"))
+		return AST_EVENT_MWI;
+
+	return -1;
+}
+
+static int add_param_to_event_sub(struct pub_event_map *pub_event_map,
+	struct ast_variable *param)
+{
+	enum ast_event_ie_type ie_type;
+	struct ast_event_sub *sub = pub_event_map->event_sub;
+
+	ie_type = get_supported_event_ie_type(pub_event_map->event_type, param->name);
+	if (ie_type == -1) {
+		ast_log(LOG_ERROR, "Invalid parameter type '%s' for event mapping "
+			" for DUNDi context '%s'\n", param->name, pub_event_map->context);
+		return -1;
+	}
+
+	switch (get_ie_pltype(ie_type, param->value)) {
+	case -1:
+		ast_log(LOG_ERROR, "Invalie value '%s' for parameter in event "
+			"mapping for DUNDi context '%s\n", 
+			param->value, pub_event_map->context);
+		return -1;
+	case AST_EVENT_IE_PLTYPE_UINT:
+	{
+		uint32_t uint;
+		if (sscanf(param->value, "%u", &uint) != 1) {
+			ast_log(LOG_ERROR, "Invalid value '%s' in parameter for "
+				"event mapping '%s'\n", param->value, param->value);
+			return -1;
+		}
+		ast_event_sub_append_ie_uint(sub, ie_type, uint);
+		break;
+	}
+	case AST_EVENT_IE_PLTYPE_STR:
+	{
+		ast_event_sub_append_ie_str(sub, ie_type, param->value);
+		break;
+	}
+	case AST_EVENT_IE_PLTYPE_EXISTS:
+		ast_event_sub_append_ie_exists(sub, ie_type);
+		break;
+	}
+
+	return 0;
+}
+
 /*!
  * \brief Parse an event mapping from dundi.conf
  */
@@ -4779,7 +4850,8 @@
 			v->next = pub_event_map->parameters;
 		pub_event_map->parameters = v;
 
-		/* XXX add param to sub */
+		if (add_param_to_event_sub(pub_event_map, v))
+			goto return_unref;
 	}
 
 	if (ast_event_sub_activate(pub_event_map->event_sub)) {




More information about the asterisk-commits mailing list