mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Properly extract the Body information of an EWS calendar item
Unlike all other calendar modules, res_calendar_ews fails to extract the Body information for a calendar item. This is due, in part, to a quirk in the schema in the XML - not only does a CalendarItem contain a Body element, but the CalendarItem exists as a descendant of a different Body element. The neon parser was erroneously skipping all Body elements. This patch fixes that by bypassing Body elements that are not a child of CalendarItem, and parsing the Body element out if it is a child. Note that the original patch by Terry Wilson only needed slight modifications to make it properly pull the Body information out; as such, while I've linked to the patch that I uploaded for Dmitry, I've attributed the patch to Terry. (closes issue ASTERISK-19738) Reported by: Dmitry Burilov Tested by: Dmitry Burilov patches: calendar_ews_body_2012_10_29.diff uploaded by Terry Wilson (license 6283) ........ Merged revisions 375528 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 375531 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 375532 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@375533 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -80,7 +80,9 @@ struct xml_context {
|
||||
|
||||
/* Important states of XML parsing */
|
||||
enum {
|
||||
XML_EVENT_CALENDAR_ITEM = 9,
|
||||
XML_EVENT_NAME = 10,
|
||||
XML_EVENT_DESCRIPTION,
|
||||
XML_EVENT_START,
|
||||
XML_EVENT_END,
|
||||
XML_EVENT_BUSY,
|
||||
@@ -180,7 +182,7 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
|
||||
|
||||
/* Nodes needed for traversing until CalendarItem is found */
|
||||
if (!strcmp(name, "Envelope") ||
|
||||
!strcmp(name, "Body") ||
|
||||
(!strcmp(name, "Body") && parent != XML_EVENT_CALENDAR_ITEM) ||
|
||||
!strcmp(name, "FindItemResponse") ||
|
||||
!strcmp(name, "GetItemResponse") ||
|
||||
!strcmp(name, "CreateItemResponse") ||
|
||||
@@ -228,7 +230,7 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
|
||||
return NE_XML_ABORT;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return XML_EVENT_CALENDAR_ITEM;
|
||||
} else if (!strcmp(name, "ItemId")) {
|
||||
/* Event UID */
|
||||
if (ctx->op == XML_OP_FIND) {
|
||||
@@ -255,6 +257,13 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
|
||||
}
|
||||
ast_str_reset(ctx->cdata);
|
||||
return XML_EVENT_NAME;
|
||||
} else if (!strcmp(name, "Body") && parent == XML_EVENT_CALENDAR_ITEM) {
|
||||
/* Event body/description */
|
||||
if (!ctx->cdata) {
|
||||
return NE_XML_ABORT;
|
||||
}
|
||||
ast_str_reset(ctx->cdata);
|
||||
return XML_EVENT_DESCRIPTION;
|
||||
} else if (!strcmp(name, "Start")) {
|
||||
/* Event start time */
|
||||
return XML_EVENT_START;
|
||||
@@ -387,6 +396,11 @@ static int endelm(void *userdata, int state, const char *nspace, const char *nam
|
||||
ast_string_field_set(ctx->event, summary, ast_str_buffer(ctx->cdata));
|
||||
ast_debug(3, "EWS: XML: Summary: %s\n", ctx->event->summary);
|
||||
ast_str_reset(ctx->cdata);
|
||||
} else if (!strcmp(name, "Body") && state == XML_EVENT_DESCRIPTION) {
|
||||
/* Event body/description end */
|
||||
ast_string_field_set(ctx->event, description, ast_str_buffer(ctx->cdata));
|
||||
ast_debug(3, "EWS: XML: Description: %s\n", ctx->event->description);
|
||||
ast_str_reset(ctx->cdata);
|
||||
} else if (!strcmp(name, "Organizer")) {
|
||||
/* Event organizer end */
|
||||
ast_string_field_set(ctx->event, organizer, ast_str_buffer(ctx->cdata));
|
||||
|
Reference in New Issue
Block a user