[asterisk-commits] mjordan: trunk r375533 - in /trunk: ./ res/res_calendar_ews.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 31 09:58:47 CDT 2012
Author: mjordan
Date: Wed Oct 31 09:58:44 2012
New Revision: 375533
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=375533
Log:
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
Modified:
trunk/ (props changed)
trunk/res/res_calendar_ews.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Modified: trunk/res/res_calendar_ews.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_calendar_ews.c?view=diff&rev=375533&r1=375532&r2=375533
==============================================================================
--- trunk/res/res_calendar_ews.c (original)
+++ trunk/res/res_calendar_ews.c Wed Oct 31 09:58:44 2012
@@ -80,7 +80,9 @@
/* 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 @@
/* 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 @@
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 @@
}
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;
@@ -386,6 +395,11 @@
/* Event name end*/
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 */
More information about the asterisk-commits
mailing list