Skip to content
Snippets Groups Projects
Commit d908c686 authored by Jan Kalab's avatar Jan Kalab
Browse files

Merged revisions 286617 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r286617 | pitel | 2010-09-14 08:55:44 +0200 (Út, 14 zář 2010) | 7 lines
  
  Merging events for Exchange web service doesn't work as expected, resulting in only one event in calendar
  
  The solution is to use "global" counter of events, since we do new requests for every event and calendar sync after every request. So now we do sync only after last request.
  
  (closes issue #17877)
  Review: https://reviewboard.asterisk.org/r/916/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@286618 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 77cbbce5
Branches
Tags
No related merge requests found
...@@ -102,6 +102,7 @@ struct ewscal_pvt { ...@@ -102,6 +102,7 @@ struct ewscal_pvt {
ne_uri uri; ne_uri uri;
ne_session *session; ne_session *session;
struct ao2_container *events; struct ao2_container *events;
unsigned int items;
}; };
static void ewscal_destructor(void *obj) static void ewscal_destructor(void *obj)
...@@ -169,7 +170,7 @@ static int startelm(void *userdata, int parent, const char *nspace, const char * ...@@ -169,7 +170,7 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
{ {
struct xml_context *ctx = userdata; struct xml_context *ctx = userdata;
ast_debug(3, "EWS: XML: Start: %s\n", name); ast_debug(5, "EWS: XML: Start: %s\n", name);
if (ctx->op == XML_OP_CREATE) { if (ctx->op == XML_OP_CREATE) {
return NE_XML_DECLINE; return NE_XML_DECLINE;
} }
...@@ -187,16 +188,17 @@ static int startelm(void *userdata, int parent, const char *nspace, const char * ...@@ -187,16 +188,17 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
return 1; return 1;
} else if (!strcmp(name, "RootFolder")) { } else if (!strcmp(name, "RootFolder")) {
/* Get number of events */ /* Get number of events */
int items; unsigned int items;
ast_debug(3, "EWS: XML: <RootFolder>\n"); ast_debug(3, "EWS: XML: <RootFolder>\n");
if (sscanf(ne_xml_get_attr(ctx->parser, atts, NULL, "TotalItemsInView"), "%d", &items) != 1) { if (sscanf(ne_xml_get_attr(ctx->parser, atts, NULL, "TotalItemsInView"), "%u", &items) != 1) {
/* Couldn't read enything */ /* Couldn't read enything */
ne_xml_set_error(ctx->parser, "Could't read number of events."); ne_xml_set_error(ctx->parser, "Could't read number of events.");
return NE_XML_ABORT; return NE_XML_ABORT;
} }
ast_debug(3, "EWS: %d calendar items to load\n", items); ast_debug(3, "EWS: %d calendar items to load\n", items);
ctx->pvt->items = items;
if (items < 1) { if (items < 1) {
/* Stop processing XML if there are no events */ /* Stop processing XML if there are no events */
return NE_XML_DECLINE; return NE_XML_DECLINE;
...@@ -434,8 +436,11 @@ static int endelm(void *userdata, int state, const char *nspace, const char *nam ...@@ -434,8 +436,11 @@ static int endelm(void *userdata, int state, const char *nspace, const char *nam
} }
} else if (!strcmp(name, "Envelope")) { } else if (!strcmp(name, "Envelope")) {
/* Events end */ /* Events end */
ast_debug(3, "EWS: XML: All events has been parsed, merging…\n"); ast_debug(3, "EWS: XML: %d of %d event(s) has been parsed…\n", ao2_container_count(ctx->pvt->events), ctx->pvt->items);
ast_calendar_merge_events(ctx->pvt->owner, ctx->pvt->events); if (ao2_container_count(ctx->pvt->events) >= ctx->pvt->items) {
ast_debug(3, "EWS: XML: All events has been parsed, merging…\n");
ast_calendar_merge_events(ctx->pvt->owner, ctx->pvt->events);
}
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment