Commit 6ee7a9a2 authored by Mark Whitaker's avatar Mark Whitaker

Started work on XML-ti-iCal parser

parent 265527d8
......@@ -9,8 +9,9 @@
# check
# libexpat1-dev
# libsoup2.4-dev
# cmake
# libwbxml (must use 0.11.beta5 - obtain from http://sourceforge.net/projects/libwbxml/files/libwbxml/0.11.beta5/)
# cmake
# libwbxml (must use 0.11.beta5 - obtain from http://sourceforge.net/projects/libwbxml/files/libwbxml/0.11.beta5/)
# libical
# the file accounts.cfg needs to be in your system configuration folder "/usr/local/etc"
......
......@@ -27,7 +27,8 @@ INCLUDES = -I/usr/include/libsoup-2.4 \
-I/usr/include/dbus-1.0 \
-I/usr/lib/dbus-1.0/include \
-I/usr/lib/i386-linux-gnu/glib-2.0/include \
-I/usr/include/evolution-data-server-2.32
-I/usr/include/evolution-data-server-2.32 \
-I/usr/include/libical
LIBS = -L/usr/lib \
......@@ -41,7 +42,8 @@ LIBS = -L/usr/lib \
-ldbus-1 \
-ldbus-glib-1 \
-lwbxml2 \
-ledataserver-1.2
-ledataserver-1.2 \
-lical
# eas-marshal.h
# eas-marshal.c
......
......@@ -9,6 +9,9 @@
#include "eas-cal-info-translator.h"
#include "../../libeascal/src/eas-cal-info.h"
#include <icalparser.h>
#include <icalcomponent.h>
// iCalendar constants defined in RFC5545 (http://tools.ietf.org/html/rfc5545)
const gchar* ICAL_LINE_TERMINATOR = "\r\n";
......@@ -110,9 +113,19 @@ static void _util_append_line_to_ical_buffer(GString** buffer, const gchar* line
}
// Parse a response message
gchar* eas_cal_info_translator_parse_response(xmlNode* node, gchar* server_id)
/**
* \brief Parse an XML-formatted calendar object received from ActiveSync and return
* it as a serialised iCalendar object.
*
* \param node ActiveSync XML <ApplicationData> object containing a calendar.
* \param server_id The ActiveSync server ID from the response
*/
gchar* eas_cal_info_translator_parse_response(xmlNode* node, const gchar* server_id)
{
// TODO: Oops! I only found libical after I'd implemented this.
// We should switch to libical - it will make further development a lot easier and more robust.
gchar* result = NULL;
if (node && (node->type == XML_ELEMENT_NODE) && (!strcmp((char*)(node->name), "ApplicationData")))
......@@ -322,3 +335,48 @@ gchar* eas_cal_info_translator_parse_response(xmlNode* node, gchar* server_id)
return result;
}
/**
* \brief Converts a calendar request object (a serialised EasCalInfo, contaning an iCalendar
* and a server ID) into an Active Sync <ApplicationData> object, ready to send as a request.
*
* \param request The serialised EasCalInfo object
* \param server_id Pointer to a buffer to contain the server ID
*/
xmlNode* eas_cal_info_translator_parse_request(const gchar* request, gchar** server_id)
{
EasCalInfo* cal_info = eas_cal_info_new();
if (eas_cal_info_deserialise(cal_info, request))
{
// Copy the server ID
*server_id = g_strdup(cal_info->server_id);
icalcomponent* ical = icalparser_parse_string(request);
icalcomponent* c;
for (c = icalcomponent_get_first_component(ical, ICAL_ANY_COMPONENT);
c != NULL;
c = icalcomponent_get_next_component(ical, ICAL_ANY_COMPONENT))
{
icalcomponent_kind kind = icalcomponent_isa(c);
switch (kind)
{
case ICAL_VCALENDAR_COMPONENT:
break;
case ICAL_VTIMEZONE_COMPONENT:
break;
case ICAL_VEVENT_COMPONENT:
break;
case ICAL_VALARM_COMPONENT:
break;
// TODO: any others we need to support
default:
break;
}
}
}
}
......@@ -14,7 +14,10 @@
// Parse a response message
gchar* eas_cal_info_translator_parse_response(xmlNode* node, gchar* server_id);
gchar* eas_cal_info_translator_parse_response(xmlNode* node, const gchar* server_id);
// Parse a request message
xmlNode* eas_cal_info_translator_parse_request(const gchar* request, gchar** server_id);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment