[asterisk-commits] russell: branch russell/events r59296 - in
/team/russell/events: apps/ includ...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Mar 28 15:01:12 MST 2007
Author: russell
Date: Wed Mar 28 17:01:11 2007
New Revision: 59296
URL: http://svn.digium.com/view/asterisk?view=rev&rev=59296
Log:
Allow information elements to be passed to ast_event_new
Modified:
team/russell/events/apps/app_voicemail.c
team/russell/events/include/asterisk/event.h
team/russell/events/main/event.c
team/russell/events/res/res_eventtest.c
Modified: team/russell/events/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_voicemail.c?view=diff&rev=59296&r1=59295&r2=59296
==============================================================================
--- team/russell/events/apps/app_voicemail.c (original)
+++ team/russell/events/apps/app_voicemail.c Wed Mar 28 17:01:11 2007
@@ -3954,14 +3954,13 @@
return;
}
- if (!(event = ast_event_new(AST_EVENT_MWI)))
+ if (!(event = ast_event_new(AST_EVENT_MWI,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new,
+ AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
+ AST_EVENT_IE_END))) {
return;
- if (ast_event_append_ie_str(&event, AST_EVENT_IE_MAILBOX, mailbox))
- return;
- if (ast_event_append_ie_uint(&event, AST_EVENT_IE_NEWMSGS, new))
- return;
- if (ast_event_append_ie_uint(&event, AST_EVENT_IE_OLDMSGS, old))
- return;
+ }
ast_event_queue_and_cache(event,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,
Modified: team/russell/events/include/asterisk/event.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/event.h?view=diff&rev=59296&r1=59295&r2=59296
==============================================================================
--- team/russell/events/include/asterisk/event.h (original)
+++ team/russell/events/include/asterisk/event.h Wed Mar 28 17:01:11 2007
@@ -125,7 +125,7 @@
*/
enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type event_type, ...);
-struct ast_event *ast_event_new(enum ast_event_type);
+struct ast_event *ast_event_new(enum ast_event_type, ...);
void ast_event_destroy(struct ast_event *);
Modified: team/russell/events/main/event.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/main/event.c?view=diff&rev=59296&r1=59295&r2=59296
==============================================================================
--- team/russell/events/main/event.c (original)
+++ team/russell/events/main/event.c Wed Mar 28 17:01:11 2007
@@ -312,9 +312,13 @@
return 0;
}
-struct ast_event *ast_event_new(enum ast_event_type type)
-{
+struct ast_event *ast_event_new(enum ast_event_type type, ...)
+{
+ va_list ap;
struct ast_event *event;
+ enum ast_event_type ie_type;
+ struct ast_event_ie_val *ie_val;
+ AST_LIST_HEAD_NOLOCK_STATIC(ie_vals, ast_event_ie_val);
/* Invalid type */
if (type >= AST_EVENT_TOTAL) {
@@ -323,11 +327,38 @@
return NULL;
}
+ va_start(ap, type);
+ for (ie_type = va_arg(ap, enum ast_event_type);
+ ie_type != AST_EVENT_IE_END;
+ ie_type = va_arg(ap, enum ast_event_type))
+ {
+ struct ast_event_ie_val *ie_val = alloca(sizeof(*ie_val));
+ memset(ie_val, 0, sizeof(*ie_val));
+ ie_val->ie_type = ie_type;
+ ie_val->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
+ if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
+ ie_val->payload.uint = va_arg(ap, uint32_t);
+ else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
+ ie_val->payload.str = ast_strdupa(va_arg(ap, const char *));
+ AST_LIST_INSERT_TAIL(&ie_vals, ie_val, entry);
+ }
+ va_end(ap);
+
if (!(event = ast_calloc(1, sizeof(*event))))
return NULL;
event->type = htons(type);
event->event_len = htons(sizeof(*event));
+
+ AST_LIST_TRAVERSE(&ie_vals, ie_val, entry) {
+ if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
+ ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
+ else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
+ ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
+
+ if (!event)
+ break;
+ }
return event;
}
Modified: team/russell/events/res/res_eventtest.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/res_eventtest.c?view=diff&rev=59296&r1=59295&r2=59296
==============================================================================
--- team/russell/events/res/res_eventtest.c (original)
+++ team/russell/events/res/res_eventtest.c Wed Mar 28 17:01:11 2007
@@ -98,14 +98,13 @@
return CLI_FAILURE;
}
- if (!(event = ast_event_new(AST_EVENT_MWI)))
+ if (!(event = ast_event_new(AST_EVENT_MWI,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new,
+ AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
+ AST_EVENT_IE_END))) {
return CLI_FAILURE;
- if (ast_event_append_ie_str(&event, AST_EVENT_IE_MAILBOX, mailbox))
- return CLI_FAILURE;
- if (ast_event_append_ie_uint(&event, AST_EVENT_IE_NEWMSGS, new))
- return CLI_FAILURE;
- if (ast_event_append_ie_uint(&event, AST_EVENT_IE_OLDMSGS, old))
- return CLI_FAILURE;
+ }
ast_event_queue_and_cache(event,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,
More information about the asterisk-commits
mailing list