mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
Support for calendar events priorities and categories
Review 880 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@284849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -95,7 +95,9 @@ struct ast_calendar_event {
|
|||||||
AST_STRING_FIELD(organizer);
|
AST_STRING_FIELD(organizer);
|
||||||
AST_STRING_FIELD(location);
|
AST_STRING_FIELD(location);
|
||||||
AST_STRING_FIELD(uid);
|
AST_STRING_FIELD(uid);
|
||||||
|
AST_STRING_FIELD(categories);
|
||||||
);
|
);
|
||||||
|
int priority; /*!< Priority of event */
|
||||||
struct ast_calendar *owner; /*!< The calendar that owns this event */
|
struct ast_calendar *owner; /*!< The calendar that owns this event */
|
||||||
time_t start; /*!< Start of event (UTC) */
|
time_t start; /*!< Start of event (UTC) */
|
||||||
time_t end; /*!< End of event (UTC) */
|
time_t end; /*!< End of event (UTC) */
|
||||||
|
@@ -65,6 +65,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
<enum name="description"><para>The text description of the event</para></enum>
|
<enum name="description"><para>The text description of the event</para></enum>
|
||||||
<enum name="organizer"><para>The organizer of the event</para></enum>
|
<enum name="organizer"><para>The organizer of the event</para></enum>
|
||||||
<enum name="location"><para>The location of the eventt</para></enum>
|
<enum name="location"><para>The location of the eventt</para></enum>
|
||||||
|
<enum name="categories"><para>The categories of the event</para></enum>
|
||||||
|
<enum name="priority"><para>The priority of the event</para></enum>
|
||||||
<enum name="calendar"><para>The name of the calendar associated with the event</para></enum>
|
<enum name="calendar"><para>The name of the calendar associated with the event</para></enum>
|
||||||
<enum name="uid"><para>The unique identifier for this event</para></enum>
|
<enum name="uid"><para>The unique identifier for this event</para></enum>
|
||||||
<enum name="start"><para>The start time of the event</para></enum>
|
<enum name="start"><para>The start time of the event</para></enum>
|
||||||
@@ -112,6 +114,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
<enum name="description"><para>The full event description</para></enum>
|
<enum name="description"><para>The full event description</para></enum>
|
||||||
<enum name="organizer"><para>The event organizer</para></enum>
|
<enum name="organizer"><para>The event organizer</para></enum>
|
||||||
<enum name="location"><para>The event location</para></enum>
|
<enum name="location"><para>The event location</para></enum>
|
||||||
|
<enum name="categories"><para>The categories of the event</para></enum>
|
||||||
|
<enum name="priority"><para>The priority of the event</para></enum>
|
||||||
<enum name="calendar"><para>The name of the calendar associted with the event</para></enum>
|
<enum name="calendar"><para>The name of the calendar associted with the event</para></enum>
|
||||||
<enum name="uid"><para>The unique identifier for the event</para></enum>
|
<enum name="uid"><para>The unique identifier for the event</para></enum>
|
||||||
<enum name="start"><para>The start time of the event (in seconds since epoch)</para></enum>
|
<enum name="start"><para>The start time of the event (in seconds since epoch)</para></enum>
|
||||||
@@ -142,6 +146,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
<enum name="description"><para>The full event description</para></enum>
|
<enum name="description"><para>The full event description</para></enum>
|
||||||
<enum name="organizer"><para>The event organizer</para></enum>
|
<enum name="organizer"><para>The event organizer</para></enum>
|
||||||
<enum name="location"><para>The event location</para></enum>
|
<enum name="location"><para>The event location</para></enum>
|
||||||
|
<enum name="categories"><para>The categories of the event</para></enum>
|
||||||
|
<enum name="priority"><para>The priority of the event</para></enum>
|
||||||
<enum name="uid"><para>The unique identifier for the event</para></enum>
|
<enum name="uid"><para>The unique identifier for the event</para></enum>
|
||||||
<enum name="start"><para>The start time of the event (in seconds since epoch)</para></enum>
|
<enum name="start"><para>The start time of the event (in seconds since epoch)</para></enum>
|
||||||
<enum name="end"><para>The end time of the event (in seconds since epoch)</para></enum>
|
<enum name="end"><para>The end time of the event (in seconds since epoch)</para></enum>
|
||||||
@@ -786,6 +792,8 @@ static void copy_event_data(struct ast_calendar_event *dst, struct ast_calendar_
|
|||||||
ast_string_field_set(dst, organizer, src->organizer);
|
ast_string_field_set(dst, organizer, src->organizer);
|
||||||
ast_string_field_set(dst, location, src->location);
|
ast_string_field_set(dst, location, src->location);
|
||||||
ast_string_field_set(dst, uid, src->uid);
|
ast_string_field_set(dst, uid, src->uid);
|
||||||
|
ast_string_field_set(dst, categories, src->categories);
|
||||||
|
dst->priority = src->priority;
|
||||||
dst->owner = src->owner;
|
dst->owner = src->owner;
|
||||||
dst->start = src->start;
|
dst->start = src->start;
|
||||||
dst->end = src->end;
|
dst->end = src->end;
|
||||||
@@ -1228,6 +1236,10 @@ static int calendar_query_result_exec(struct ast_channel *chan, const char *cmd,
|
|||||||
ast_copy_string(buf, entry->event->organizer, len);
|
ast_copy_string(buf, entry->event->organizer, len);
|
||||||
} else if (!strcasecmp(args.field, "location")) {
|
} else if (!strcasecmp(args.field, "location")) {
|
||||||
ast_copy_string(buf, entry->event->location, len);
|
ast_copy_string(buf, entry->event->location, len);
|
||||||
|
} else if (!strcasecmp(args.field, "categories")) {
|
||||||
|
ast_copy_string(buf, entry->event->categories, len);
|
||||||
|
} else if (!strcasecmp(args.field, "priority")) {
|
||||||
|
snprintf(buf, len, "%d", entry->event->priority);
|
||||||
} else if (!strcasecmp(args.field, "calendar")) {
|
} else if (!strcasecmp(args.field, "calendar")) {
|
||||||
ast_copy_string(buf, entry->event->owner->name, len);
|
ast_copy_string(buf, entry->event->owner->name, len);
|
||||||
} else if (!strcasecmp(args.field, "uid")) {
|
} else if (!strcasecmp(args.field, "uid")) {
|
||||||
@@ -1313,6 +1325,10 @@ static int calendar_write_exec(struct ast_channel *chan, const char *cmd, char *
|
|||||||
ast_string_field_set(event, organizer, values.value[j]);
|
ast_string_field_set(event, organizer, values.value[j]);
|
||||||
} else if (!strcasecmp(fields.field[i], "location")) {
|
} else if (!strcasecmp(fields.field[i], "location")) {
|
||||||
ast_string_field_set(event, location, values.value[j]);
|
ast_string_field_set(event, location, values.value[j]);
|
||||||
|
} else if (!strcasecmp(fields.field[i], "categories")) {
|
||||||
|
ast_string_field_set(event, categories, values.value[j]);
|
||||||
|
} else if (!strcasecmp(fields.field[i], "priority")) {
|
||||||
|
event->priority = atoi(values.value[j]);
|
||||||
} else if (!strcasecmp(fields.field[i], "uid")) {
|
} else if (!strcasecmp(fields.field[i], "uid")) {
|
||||||
ast_string_field_set(event, uid, values.value[j]);
|
ast_string_field_set(event, uid, values.value[j]);
|
||||||
} else if (!strcasecmp(fields.field[i], "start")) {
|
} else if (!strcasecmp(fields.field[i], "start")) {
|
||||||
@@ -1468,6 +1484,8 @@ static char *handle_show_calendar(struct ast_cli_entry *e, int cmd, struct ast_c
|
|||||||
ast_cli(a->fd, FORMAT2, "Description", event->description);
|
ast_cli(a->fd, FORMAT2, "Description", event->description);
|
||||||
ast_cli(a->fd, FORMAT2, "Organizer", event->organizer);
|
ast_cli(a->fd, FORMAT2, "Organizer", event->organizer);
|
||||||
ast_cli(a->fd, FORMAT2, "Location", event->location);
|
ast_cli(a->fd, FORMAT2, "Location", event->location);
|
||||||
|
ast_cli(a->fd, FORMAT2, "Cartegories", event->categories);
|
||||||
|
ast_cli(a->fd, "%-12.12s: %d\n", "Priority", event->priority);
|
||||||
ast_cli(a->fd, FORMAT2, "UID", event->uid);
|
ast_cli(a->fd, FORMAT2, "UID", event->uid);
|
||||||
ast_cli(a->fd, FORMAT2, "Start", epoch_to_string(buf, sizeof(buf), event->start));
|
ast_cli(a->fd, FORMAT2, "Start", epoch_to_string(buf, sizeof(buf), event->start));
|
||||||
ast_cli(a->fd, FORMAT2, "End", epoch_to_string(buf, sizeof(buf), event->end));
|
ast_cli(a->fd, FORMAT2, "End", epoch_to_string(buf, sizeof(buf), event->end));
|
||||||
@@ -1539,6 +1557,10 @@ static int calendar_event_read(struct ast_channel *chan, const char *cmd, char *
|
|||||||
ast_copy_string(buf, event->organizer, len);
|
ast_copy_string(buf, event->organizer, len);
|
||||||
} else if (!strcasecmp(data, "location")) {
|
} else if (!strcasecmp(data, "location")) {
|
||||||
ast_copy_string(buf, event->location, len);
|
ast_copy_string(buf, event->location, len);
|
||||||
|
} else if (!strcasecmp(data, "categories")) {
|
||||||
|
ast_copy_string(buf, event->categories, len);
|
||||||
|
} else if (!strcasecmp(data, "priority")) {
|
||||||
|
snprintf(buf, len, "%d", event->priority);
|
||||||
} else if (!strcasecmp(data, "calendar")) {
|
} else if (!strcasecmp(data, "calendar")) {
|
||||||
ast_copy_string(buf, event->owner->name, len);
|
ast_copy_string(buf, event->owner->name, len);
|
||||||
} else if (!strcasecmp(data, "uid")) {
|
} else if (!strcasecmp(data, "uid")) {
|
||||||
|
@@ -216,6 +216,12 @@ static int caldav_write_event(struct ast_calendar_event *event)
|
|||||||
if (!ast_strlen_zero(event->location)) {
|
if (!ast_strlen_zero(event->location)) {
|
||||||
icalcomponent_add_property(icalevent, icalproperty_new_location(event->location));
|
icalcomponent_add_property(icalevent, icalproperty_new_location(event->location));
|
||||||
}
|
}
|
||||||
|
if (!ast_strlen_zero(event->categories)) {
|
||||||
|
icalcomponent_add_property(icalevent, icalproperty_new_categories(event->categories));
|
||||||
|
}
|
||||||
|
if (event->priority > 0) {
|
||||||
|
icalcomponent_add_property(icalevent, icalproperty_new_priority(event->priority));
|
||||||
|
}
|
||||||
|
|
||||||
switch (event->busy_state) {
|
switch (event->busy_state) {
|
||||||
case AST_CALENDAR_BS_BUSY:
|
case AST_CALENDAR_BS_BUSY:
|
||||||
@@ -365,6 +371,14 @@ static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, vo
|
|||||||
ast_string_field_set(event, location, icalproperty_get_value_as_string(prop));
|
ast_string_field_set(event, location, icalproperty_get_value_as_string(prop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_CATEGORIES_PROPERTY))) {
|
||||||
|
ast_string_field_set(event, categories, icalproperty_get_value_as_string(prop));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_PRIORITY_PROPERTY))) {
|
||||||
|
event->priority = icalvalue_get_integer(icalproperty_get_value(prop));
|
||||||
|
}
|
||||||
|
|
||||||
if ((prop = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY))) {
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY))) {
|
||||||
ast_string_field_set(event, uid, icalproperty_get_value_as_string(prop));
|
ast_string_field_set(event, uid, icalproperty_get_value_as_string(prop));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -87,6 +87,9 @@ enum {
|
|||||||
XML_EVENT_ATTENDEE,
|
XML_EVENT_ATTENDEE,
|
||||||
XML_EVENT_MAILBOX,
|
XML_EVENT_MAILBOX,
|
||||||
XML_EVENT_EMAIL_ADDRESS,
|
XML_EVENT_EMAIL_ADDRESS,
|
||||||
|
XML_EVENT_CATEGORIES,
|
||||||
|
XML_EVENT_CATEGORY,
|
||||||
|
XML_EVENT_IMPORTANCE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ewscal_pvt {
|
struct ewscal_pvt {
|
||||||
@@ -271,6 +274,23 @@ static int startelm(void *userdata, int parent, const char *nspace, const char *
|
|||||||
}
|
}
|
||||||
ast_str_reset(ctx->cdata);
|
ast_str_reset(ctx->cdata);
|
||||||
return XML_EVENT_LOCATION;
|
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")) {
|
} else if (!strcmp(name, "RequiredAttendees") || !strcmp(name, "OptionalAttendees")) {
|
||||||
return XML_EVENT_ATTENDEE_LIST;
|
return XML_EVENT_ATTENDEE_LIST;
|
||||||
} else if (!strcmp(name, "Attendee") && parent == 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;
|
ctx->event->busy_state = AST_CALENDAR_BS_FREE;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
ast_str_append(&ctx->cdata, 0, "%s", data);
|
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_string_field_set(ctx->event, location, ast_str_buffer(ctx->cdata));
|
||||||
ast_debug(3, "EWS: XML: Location: %s\n", ctx->event->location);
|
ast_debug(3, "EWS: XML: Location: %s\n", ctx->event->location);
|
||||||
ast_str_reset(ctx->cdata);
|
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) {
|
} else if (state == XML_EVENT_EMAIL_ADDRESS) {
|
||||||
struct ast_calendar_attendee *attendee;
|
struct ast_calendar_attendee *attendee;
|
||||||
|
|
||||||
@@ -531,12 +574,7 @@ static int ewscal_write_event(struct ast_calendar_event *event)
|
|||||||
"<End>%s</End>"
|
"<End>%s</End>"
|
||||||
"<IsAllDayEvent>false</IsAllDayEvent>"
|
"<IsAllDayEvent>false</IsAllDayEvent>"
|
||||||
"<LegacyFreeBusyStatus>%s</LegacyFreeBusyStatus>"
|
"<LegacyFreeBusyStatus>%s</LegacyFreeBusyStatus>"
|
||||||
"<Location>%s</Location>"
|
"<Location>%s</Location>",
|
||||||
"</t:CalendarItem>"
|
|
||||||
"</Items>"
|
|
||||||
"</CreateItem>"
|
|
||||||
"</soap:Body>"
|
|
||||||
"</soap:Envelope>",
|
|
||||||
event->summary,
|
event->summary,
|
||||||
event->description,
|
event->description,
|
||||||
mstime(event->start, start, sizeof(start)),
|
mstime(event->start, start, sizeof(start)),
|
||||||
@@ -544,6 +582,37 @@ static int ewscal_write_event(struct ast_calendar_event *event)
|
|||||||
msstatus(event->busy_state),
|
msstatus(event->busy_state),
|
||||||
event->location
|
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>");
|
||||||
|
char *categories = strdupa(event->categories); /* Duplicate string, since strsep() is destructive */
|
||||||
|
char *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);
|
ret = send_ews_request_and_parse(request, &ctx);
|
||||||
|
|
||||||
|
@@ -224,6 +224,14 @@ static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span,
|
|||||||
ast_string_field_set(event, location, icalproperty_get_value_as_string(prop));
|
ast_string_field_set(event, location, icalproperty_get_value_as_string(prop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_CATEGORIES_PROPERTY))) {
|
||||||
|
ast_string_field_set(event, categories, icalproperty_get_value_as_string(prop));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_PRIORITY_PROPERTY))) {
|
||||||
|
event->priority = icalvalue_get_integer(icalproperty_get_value(prop));
|
||||||
|
}
|
||||||
|
|
||||||
if ((prop = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY))) {
|
if ((prop = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY))) {
|
||||||
ast_string_field_set(event, uid, icalproperty_get_value_as_string(prop));
|
ast_string_field_set(event, uid, icalproperty_get_value_as_string(prop));
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user