#include "asterisk.h"
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
#include <ne_request.h>
#include <ne_session.h>
#include <ne_redirect.h>
#include "asterisk/module.h"
+#include "asterisk/channel.h"
#include "asterisk/calendar.h"
#include "asterisk/lock.h"
#include "asterisk/config.h"
/* 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,
/* 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") ||
return NE_XML_ABORT;
}
- return 1;
+ return XML_EVENT_CALENDAR_ITEM;
} else if (!strcmp(name, "ItemId")) {
/* Event UID */
if (ctx->op == XML_OP_FIND) {
struct calendar_id *id;
- if (!(id = ast_calloc(1, sizeof(id)))) {
+ if (!(id = ast_calloc(1, sizeof(*id)))) {
return NE_XML_ABORT;
}
if (!(id->id = ast_str_create(256))) {
}
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;
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));
}
} else if (!strcmp(name, "Envelope")) {
/* Events end */
- ast_debug(3, "EWS: XML: %d of %d event(s) has been parsed…\n", ao2_container_count(ctx->pvt->events), ctx->pvt->items);
+ ast_debug(3, "EWS: XML: %d of %u event(s) has been parsed…\n", ao2_container_count(ctx->pvt->events), ctx->pvt->items);
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);
static int load_module(void)
{
/* Actualy, 0.29.1 is required (because of NTLM authentication), but this
- * function does not support matching patch version. */
- if (ne_version_match(0, 29)) {
+ * function does not support matching patch version.
+ *
+ * The ne_version_match function returns non-zero if the library
+ * version is not of major version major, or the minor version
+ * is less than minor. For neon versions 0.x, every minor
+ * version is assumed to be incompatible with every other minor
+ * version.
+ *
+ * I.e. for version 1.2..1.9 we would do ne_version_match(1, 2)
+ * but for version 0.29 and 0.30 we need two checks. */
+ if (ne_version_match(0, 29) && ne_version_match(0, 30)) {
ast_log(LOG_ERROR, "Exchange Web Service calendar module require neon >= 0.29.1, but %s is installed.\n", ne_version_string());
return AST_MODULE_LOAD_DECLINE;
}
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Asterisk MS Exchange Web Service Calendar Integration",
+ .support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
.load_pri = AST_MODPRI_DEVSTATE_PLUGIN,