aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_calendar_ews.c
diff options
context:
space:
mode:
authorbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-09 18:51:52 +0000
committerbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-09 18:51:52 +0000
commit722eb3c4c3cfa1c0cee915c949c5f95199ee24dd (patch)
tree25683963c5e51bdedd6211cd0ea92a85639505c3 /res/res_calendar_ews.c
parent815b5b09da5e555add7bba3d8fca588e7611248a (diff)
Merged revisions 285710 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ........ r285710 | bbryant | 2010-09-09 14:50:13 -0400 (Thu, 09 Sep 2010) | 8 lines Fixes an issue with dialplan pattern matching where the specificity for pattern ranges and pattern special characters was inconsistent. (closes issue #16903) Reported by: Nick_Lewis Patches: pbx.c-specificity.patch uploaded by Nick Lewis (license 657) Tested by: Nick_Lewis ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@285711 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_calendar_ews.c')
-rw-r--r--res/res_calendar_ews.c82
1 files changed, 76 insertions, 6 deletions
diff --git a/res/res_calendar_ews.c b/res/res_calendar_ews.c
index 931e36854..840ca104e 100644
--- a/res/res_calendar_ews.c
+++ b/res/res_calendar_ews.c
@@ -87,6 +87,9 @@ enum {
XML_EVENT_ATTENDEE,
XML_EVENT_MAILBOX,
XML_EVENT_EMAIL_ADDRESS,
+ XML_EVENT_CATEGORIES,
+ XML_EVENT_CATEGORY,
+ XML_EVENT_IMPORTANCE,
};
struct ewscal_pvt {
@@ -271,6 +274,23 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
}
ast_str_reset(ctx->cdata);
return XML_EVENT_LOCATION;
+ } else if (!strcmp(name, "Categories")) {
+ /* Event categories */
+ if (!ctx->cdata) {
+ return NE_XML_ABORT;
+ }
+ ast_str_reset(ctx->cdata);
+ return XML_EVENT_CATEGORIES;
+ } else if (parent == XML_EVENT_CATEGORIES && !strcmp(name, "String")) {
+ /* Event category */
+ return XML_EVENT_CATEGORY;
+ } else if (!strcmp(name, "Importance")) {
+ /* Event importance (priority) */
+ if (!ctx->cdata) {
+ return NE_XML_ABORT;
+ }
+ ast_str_reset(ctx->cdata);
+ return XML_EVENT_IMPORTANCE;
} else if (!strcmp(name, "RequiredAttendees") || !strcmp(name, "OptionalAttendees")) {
return XML_EVENT_ATTENDEE_LIST;
} else if (!strcmp(name, "Attendee") && parent == XML_EVENT_ATTENDEE_LIST) {
@@ -331,6 +351,13 @@ static int cdata(void *userdata, int state, const char *cdata, size_t len)
ctx->event->busy_state = AST_CALENDAR_BS_FREE;
}
break;
+ case XML_EVENT_CATEGORY:
+ if (ast_str_strlen(ctx->cdata) == 0) {
+ ast_str_set(&ctx->cdata, 0, "%s", data);
+ } else {
+ ast_str_append(&ctx->cdata, 0, ",%s", data);
+ }
+ break;
default:
ast_str_append(&ctx->cdata, 0, "%s", data);
}
@@ -364,6 +391,22 @@ static int endelm(void *userdata, int state, const char *nspace, const char *nam
ast_string_field_set(ctx->event, location, ast_str_buffer(ctx->cdata));
ast_debug(3, "EWS: XML: Location: %s\n", ctx->event->location);
ast_str_reset(ctx->cdata);
+ } else if (!strcmp(name, "Categories")) {
+ /* Event categories end */
+ ast_string_field_set(ctx->event, categories, ast_str_buffer(ctx->cdata));
+ ast_debug(3, "EWS: XML: Categories: %s\n", ctx->event->categories);
+ ast_str_reset(ctx->cdata);
+ } else if (!strcmp(name, "Importance")) {
+ /* Event importance end */
+ if (!strcmp(ast_str_buffer(ctx->cdata), "Low")) {
+ ctx->event->priority = 9;
+ } else if (!strcmp(ast_str_buffer(ctx->cdata), "Normal")) {
+ ctx->event->priority = 5;
+ } else if (!strcmp(ast_str_buffer(ctx->cdata), "High")) {
+ ctx->event->priority = 1;
+ }
+ ast_debug(3, "EWS: XML: Importance: %s (%d)\n", ast_str_buffer(ctx->cdata), ctx->event->priority);
+ ast_str_reset(ctx->cdata);
} else if (state == XML_EVENT_EMAIL_ADDRESS) {
struct ast_calendar_attendee *attendee;
@@ -501,6 +544,7 @@ static int ewscal_write_event(struct ast_calendar_event *event)
.pvt = pvt,
};
int ret;
+ char *category, *categories;
if (!pvt) {
return -1;
@@ -531,12 +575,7 @@ static int ewscal_write_event(struct ast_calendar_event *event)
"<End>%s</End>"
"<IsAllDayEvent>false</IsAllDayEvent>"
"<LegacyFreeBusyStatus>%s</LegacyFreeBusyStatus>"
- "<Location>%s</Location>"
- "</t:CalendarItem>"
- "</Items>"
- "</CreateItem>"
- "</soap:Body>"
- "</soap:Envelope>",
+ "<Location>%s</Location>",
event->summary,
event->description,
mstime(event->start, start, sizeof(start)),
@@ -544,6 +583,37 @@ static int ewscal_write_event(struct ast_calendar_event *event)
msstatus(event->busy_state),
event->location
);
+ /* Event priority */
+ switch (event->priority) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ ast_str_append(&request, 0, "<Importance>High</Importance>");
+ break;
+ case 5:
+ ast_str_append(&request, 0, "<Importance>Normal</Importance>");
+ break;
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ ast_str_append(&request, 0, "<Importance>Low</Importance>");
+ break;
+ }
+ /* Event categories*/
+ if (strlen(event->categories) > 0) {
+ ast_str_append(&request, 0, "<Categories>");
+ categories = ast_strdupa(event->categories); /* Duplicate string, since strsep() is destructive */
+ category = strsep(&categories, ",");
+ while (category != NULL) {
+ ast_str_append(&request, 0, "<String>%s</String>", category);
+ category = strsep(&categories, ",");
+ }
+ ast_str_append(&request, 0, "</Categories>");
+ }
+ /* Finish request */
+ ast_str_append(&request, 0, "</t:CalendarItem></Items></CreateItem></soap:Body></soap:Envelope>");
ret = send_ews_request_and_parse(request, &ctx);