Remove inconsistency in CEL eventtype for user defined events.

The CEL eventtype field for ODBC and PGSQL backends should be USER_DEFINED
instead of the user defined event name supplied by the CELGenUserEvent
application.  If the field is output as a number, the user defined name
does not have a value and is always output as 21 for USER_DEFINED and the
userdeftype field would be required to supply the user defined name.

The following CEL backends (cel_odbc, cel_pgsql, cel_custom, cel_manager,
and cel_sqlite3_custom) can be independently configured to remove this
inconsistency.

* Allows cel_manager, cel_custom, and cel_sqlite3_custom to behave the
same way.

(closes issue ASTERISK-17189)
Reported by: Bryant Zimmerman

Review: https://reviewboard.asterisk.org/r/1669/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2012-02-01 17:42:15 +00:00
parent a99b3c817b
commit 797d633139
10 changed files with 119 additions and 23 deletions

View File

@@ -402,6 +402,7 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
{
struct varshead *headp;
struct ast_var_t *newvariable;
const char *mixed_name;
char timebuf[30];
struct ast_channel *tchan;
struct ast_cel_event_record record = {
@@ -422,7 +423,9 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
}
/* next, fill the channel with their data */
if ((newvariable = ast_var_assign("eventtype", record.event_name))) {
mixed_name = (record.event_type == AST_CEL_USER_DEFINED)
? record.user_defined_name : record.event_name;
if ((newvariable = ast_var_assign("eventtype", mixed_name))) {
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
@@ -439,6 +442,9 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
if ((newvariable = ast_var_assign("eventenum", record.event_name))) {
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
if ((newvariable = ast_var_assign("userdeftype", record.user_defined_name))) {
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
@@ -598,13 +604,11 @@ int ast_cel_fill_record(const struct ast_event *e, struct ast_cel_event_record *
r->event_time.tv_sec = ast_event_get_ie_uint(e, AST_EVENT_IE_CEL_EVENT_TIME);
r->event_time.tv_usec = ast_event_get_ie_uint(e, AST_EVENT_IE_CEL_EVENT_TIME_USEC);
r->user_defined_name = "";
r->event_name = ast_cel_get_type_name(r->event_type);
if (r->event_type == AST_CEL_USER_DEFINED) {
r->user_defined_name = ast_event_get_ie_str(e, AST_EVENT_IE_CEL_USEREVENT_NAME);
r->event_name = r->user_defined_name;
} else {
r->event_name = ast_cel_get_type_name(r->event_type);
r->user_defined_name = "";
}
r->caller_id_name = S_OR(ast_event_get_ie_str(e, AST_EVENT_IE_CEL_CIDNAME), "");