#include <glib.h>
#include <glib/gprintf.h>
-FILE *calfile;
-
-int process_relativeyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-int process_absoluteyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-int process_relativemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-int process_absolutemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-int process_weeklyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-int process_dailyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur);
-
-int process_organizer(icalcomponent *comp, xmlNode *xml_node);
-int process_required_attendees(icalcomponent *comp, xmlNode *xml_node);
-int process_optional_attendees(icalcomponent *comp, xmlNode *xml_node);
-int process_time(icalcomponent *comp, xmlNode *xml_node, icaltimetype *ical_time);
-int process_truefalse(icalcomponent *comp, xmlNode *xml_node, gboolean *val);
-int process_location(icalcomponent *comp, xmlNode *xml_node);
-int process_sequence(icalcomponent *comp, xmlNode *xml_node);
-int process_body(icalcomponent *comp, xmlNode *xml_node);
-int process_subject(icalcomponent *comp, xmlNode *xml_node);
-int process_recurrence(icalcomponent *comp, xmlNode *xml_node, icaltimezone *zone);
+int process_relativeyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+int process_absoluteyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+int process_relativemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+int process_absolutemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+int process_weeklyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+int process_dailyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error);
+
+int process_organizer(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_required_attendees(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_optional_attendees(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_time(icalcomponent *comp, xmlNode *xml_node, icaltimetype *ical_time, GError *error);
+int process_truefalse(icalcomponent *comp, xmlNode *xml_node, gboolean *val, GError *error);
+int process_location(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_sequence(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_body(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_subject(icalcomponent *comp, xmlNode *xml_node, GError *error);
+int process_recurrence(icalcomponent *comp, xmlNode *xml_node, icaltimezone *zone, GError *error);
int process_deleted_occurrences(icalcomponent *comp, xmlNode *xml_node,
- icaltimetype **deletia, int *count);
-int process_itemid(icalcomponent *comp, xmlNode *xmlnode);
-int process_reminder_mins(icalcomponent *comp, xmlNode *xmlnode);
-icaltimezone *get_timezone(xmlNode *xmlnode);
-icaltimezone *get_meeting_timezone(xmlNode *xml_node);
+ icaltimetype **deletia, int *count, GError *error);
+int process_itemid(icalcomponent *comp, xmlNode *xmlnode, GError *error);
+int process_reminder_mins(icalcomponent *comp, xmlNode *xmlnode, GError *error);
+icaltimezone *get_timezone(xmlNode *xmlnode, GError *error);
+icaltimezone *get_meeting_timezone(xmlNode *xml_node, GError *error);
icalcomponent *ews_calitem_to_ical(xmlNode *xml_node);
icalcomponent *ews_calitem_to_ical(xmlNode *xml_node)
{
+ GError *error = NULL;
icaltimetype dtstart, dtend;
icaltimetype *deletia = NULL;
int i, deletia_count = 0;
prop = icalproperty_new_version("2.0");
icalcomponent_add_property(calcomp, prop);
- icaltz = get_meeting_timezone(xml_node);
+ icaltz = get_meeting_timezone(xml_node, error);
if (icaltz)
freetz = TRUE;
else {
- icaltz = get_timezone(xml_node);
+ icaltz = get_timezone(xml_node, error);
if (icaltz) {
icalcomponent *comp = icaltimezone_get_component(icaltz);
icalcomponent_add_component(calcomp, comp);
if (xml_node->type != XML_ELEMENT_NODE)
continue;
if (!strcmp((char *)xml_node->name, "Organizer"))
- process_organizer(comp, xml_node);
+ process_organizer(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "RequiredAttendees"))
- process_required_attendees(comp, xml_node);
+ process_required_attendees(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "OptionalAttendees"))
- process_optional_attendees(comp, xml_node);
+ process_optional_attendees(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "Start"))
- process_time(comp, xml_node, &dtstart);
+ process_time(comp, xml_node, &dtstart, error);
else if (!strcmp((char *)xml_node->name, "End"))
- process_time(comp, xml_node, &dtend);
+ process_time(comp, xml_node, &dtend, error);
else if (!strcmp((char *)xml_node->name, "Body"))
- process_body(comp, xml_node);
+ process_body(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "Location"))
- process_location(comp, xml_node);
+ process_location(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "Subject"))
- process_subject(comp, xml_node);
+ process_subject(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "Recurrence"))
- process_recurrence(comp, xml_node, icaltz);
+ process_recurrence(comp, xml_node, icaltz, error);
else if (!strcmp((char *)xml_node->name, "DeletedOccurrences"))
- process_deleted_occurrences(comp, xml_node, &deletia, &deletia_count);
+ process_deleted_occurrences(comp, xml_node, &deletia, &deletia_count, error);
else if (!strcmp((char *)xml_node->name, "ItemId"))
- process_itemid(comp, xml_node);
+ process_itemid(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "IsAllDayEvent"))
- process_truefalse(comp, xml_node, &allday);
+ process_truefalse(comp, xml_node, &allday, error);
else if (!strcmp((char *)xml_node->name, "ReminderMinutesBeforeStart"))
- process_reminder_mins(comp, xml_node);
+ process_reminder_mins(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "AppointmentSequenceNumber"))
- process_sequence(comp, xml_node);
+ process_sequence(comp, xml_node, error);
else if (!strcmp((char *)xml_node->name, "ParentFolderId") ||
!strcmp((char *)xml_node->name, "DateTimeReceived") ||
!strcmp((char *)xml_node->name, "Size") ||
return calcomp;
}
-int process_mailbox(xmlNode *xml_node, const char **r_name, const char **r_email)
+int process_mailbox(xmlNode *xml_node, const char **r_name, const char **r_email, GError *error)
{
const char *type = NULL, *name = NULL, *email = NULL;
return 0;
}
-int process_organizer(icalcomponent *comp, xmlNode *xml_node)
+int process_organizer(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
icalproperty *prop;
icalparameter *param;
if (!strcmp((char *)xml_node->name, "Mailbox")) {
const char *name = NULL, *email = NULL;
char *mailtoname;
- if (process_mailbox(xml_node, &name, &email))
+ if (process_mailbox(xml_node, &name, &email, error))
return -1;
mailtoname = g_strdup_printf("mailto:%s", email);
return 0;
}
-int process_attendee(icalcomponent *comp, xmlNode *xml_node, icalparameter_role role)
+int process_attendee(icalcomponent *comp, xmlNode *xml_node, icalparameter_role role, GError *error)
{
icalproperty *prop;
icalparameter *param;
if (!strcmp((char *)xml_node->name, "Mailbox")) {
const char *name = NULL, *email = NULL;
char *mailtoname;
- if (process_mailbox(xml_node, &name, &email))
+ if (process_mailbox(xml_node, &name, &email, error))
return -1;
mailtoname = g_strdup_printf("mailto:%s", email);
return 0;
}
-int process_required_attendees(icalcomponent *comp, xmlNode *xml_node)
+int process_required_attendees(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
for (xml_node = xml_node->children; xml_node; xml_node = xml_node->next) {
if (xml_node->type != XML_ELEMENT_NODE)
continue;
if (!strcmp((char *)xml_node->name, "Attendee")) {
if (process_attendee(comp, xml_node,
- ICAL_ROLE_REQPARTICIPANT))
+ ICAL_ROLE_REQPARTICIPANT, error))
{ }
}
}
return 0;
}
-int process_optional_attendees(icalcomponent *comp, xmlNode *xml_node)
+int process_optional_attendees(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
for (xml_node = xml_node->children; xml_node; xml_node = xml_node->next) {
if (xml_node->type != XML_ELEMENT_NODE)
continue;
if (!strcmp((char *)xml_node->name, "Attendee")) {
if (process_attendee(comp, xml_node,
- ICAL_ROLE_OPTPARTICIPANT))
+ ICAL_ROLE_OPTPARTICIPANT, error))
{ }
}
}
return 0;
}
-int process_time(icalcomponent *comp, xmlNode *xml_node, icaltimetype *ical_time)
+int process_time(icalcomponent *comp, xmlNode *xml_node, icaltimetype *ical_time, GError *error)
{
char *ews_time = (char *)xmlNodeGetContent(xml_node);
return 0;
}
-int process_truefalse(icalcomponent *comp, xmlNode *xml_node, gboolean *val)
+int process_truefalse(icalcomponent *comp, xmlNode *xml_node, gboolean *val, GError *error)
{
char *truth = (char *)xmlNodeGetContent(xml_node);
return 0;
}
-int process_location (icalcomponent *comp, xmlNode *xml_node)
+int process_location (icalcomponent *comp, xmlNode *xml_node, GError *error)
{
const char *loc = (char *)xmlNodeGetContent(xml_node);
return 0;
}
-int process_sequence (icalcomponent *comp, xmlNode *xml_node)
+int process_sequence (icalcomponent *comp, xmlNode *xml_node, GError *error)
{
const char *seq = (char *)xmlNodeGetContent(xml_node);
return 0;
}
-int process_body(icalcomponent *comp, xmlNode *xml_node)
+int process_body(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
const char *body = (char *)xmlNodeGetContent(xml_node);
return 0;
}
-int process_subject(icalcomponent *comp, xmlNode *xml_node)
+int process_subject(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
const char *subject = (char *)xmlNodeGetContent(xml_node);
}
-static int month_to_number(const char *month)
+static int month_to_number(const char *month, GError *error)
{
static char *months[] = {
"January", "February", "March", "April", "May", "June", "July",
fprintf(stderr, "Unrecognised month name '%s'\n", month);
return 0;
}
-static int weekday_to_number(const char *day, int accept)
+static int weekday_to_number(const char *day, int accept, GError *error)
{
static char *days[] = {
"Sunday", "Monday", "Tuesday", "Wednesday",
}
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-static int weekindex_to_ical(const char *week)
+static int weekindex_to_ical(const char *week, GError *error)
{
static struct {
char *exch;
}
int process_deleted_occurrences(icalcomponent *comp, xmlNode *xml_node,
- icaltimetype **deletia_ret, int *count_ret)
+ icaltimetype **deletia_ret, int *count_ret, GError *error)
{
icaltimetype *deletia = NULL;
int count = 0;
}
count++;
deletia = realloc(deletia, sizeof(icaltimetype) * count);
- if (process_time(comp, xml_node2, &deletia[count-1])) {
+ if (process_time(comp, xml_node2, &deletia[count-1], error)) {
free(deletia);
return -1;
}
return 0;
}
-int process_recurrence(icalcomponent *comp, xmlNode *xml_node, icaltimezone *zone)
+int process_recurrence(icalcomponent *comp, xmlNode *xml_node, icaltimezone *zone, GError *error)
{
struct icalrecurrencetype ical_recur;
char *end_date = NULL, *nr_occurrences = NULL;
if (xml_node->type != XML_ELEMENT_NODE)
continue;
if (!strcmp((char *)xml_node->name, "WeeklyRecurrence")) {
- if (process_weeklyrecurrence(xml_node, &ical_recur))
+ if (process_weeklyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "DailyRecurrence")) {
- if (process_dailyrecurrence(xml_node, &ical_recur))
+ if (process_dailyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "AbsoluteYearlyRecurrence")) {
- if (process_absoluteyearlyrecurrence(xml_node, &ical_recur))
+ if (process_absoluteyearlyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "RelativeYearlyRecurrence")) {
- if (process_relativeyearlyrecurrence(xml_node, &ical_recur))
+ if (process_relativeyearlyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "AbsoluteMonthlyRecurrence")) {
- if (process_absolutemonthlyrecurrence(xml_node, &ical_recur))
+ if (process_absolutemonthlyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "RelativeMonthlyRecurrence")) {
- if (process_relativemonthlyrecurrence(xml_node, &ical_recur))
+ if (process_relativemonthlyrecurrence(xml_node, &ical_recur, error))
return -1;
} else if (!strcmp((char *)xml_node->name, "EndDateRecurrence")) {
for (xml_node2 = xml_node->children; xml_node2;
return 0;
}
-int process_itemid(icalcomponent *comp, xmlNode *xml_node)
+int process_itemid(icalcomponent *comp, xmlNode *xml_node, GError *error)
{
const char *id = (char *)xmlGetProp(xml_node, (unsigned char *)"Id");
if (!id)
icalcomponent_set_uid(comp, id);
return 0;
}
-int process_reminder_mins(icalcomponent *calcomp, xmlNode *xml_node)
+int process_reminder_mins(icalcomponent *calcomp, xmlNode *xml_node, GError *error)
{
const char *minutes;
int minutesnr;
}
-icaltimezone *get_timezone(xmlNode *xml_node)
+icaltimezone *get_timezone(xmlNode *xml_node, GError *error)
{
icaltimezone *zone = NULL;
const char *ews_tzname = NULL;
return NULL;
}
-int get_baseoffset(xmlNode *xml_node, int *retval)
+int get_baseoffset(xmlNode *xml_node, int *retval, GError *error)
{
const char *baseoffset;
struct icaldurationtype ofs;
return 0;
}
-int process_relativeyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_relativeyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *week = NULL, *month = NULL, *weekday = NULL;
int weeknr, monthnr, daynr;
week, month, weekday);
return -1;
}
- monthnr = month_to_number(month);
+ monthnr = month_to_number(month, error);
if (!month)
return -1;
- weeknr = weekindex_to_ical(week);
+ weeknr = weekindex_to_ical(week, error);
if (!weeknr)
return -1;
- daynr = weekday_to_number(weekday, 10);
+ daynr = weekday_to_number(weekday, 10, error);
if (!daynr)
return -1;
return 0;
}
-int process_absoluteyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_absoluteyearlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *day_of_month = NULL;
const char *month = NULL;
fprintf(stderr, "Failed to parse DayOfMonth '%s'\n", day_of_month);
return -1;
}
- monthnr = month_to_number(month);
+ monthnr = month_to_number(month, error);
if (!month)
return -1;
return 0;
}
-int process_relativemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_relativemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *week = NULL, *interval = NULL, *weekday = NULL;
int weeknr, intervalnr, daynr;
fprintf(stderr, "Failed to parse Interval '%s'\n", interval);
return -1;
}
- weeknr = weekindex_to_ical(week);
+ weeknr = weekindex_to_ical(week, error);
if (!weeknr)
return -1;
- daynr = weekday_to_number(weekday, 10);
+ daynr = weekday_to_number(weekday, 10, error);
if (!daynr)
return -1;
return 0;
}
-int process_absolutemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_absolutemonthlyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *interval = NULL, *monthday = NULL;
int intervalnr, monthdaynr;
return 0;
}
-static int weekdays_to_recur_byday(const char *days, struct icalrecurrencetype *ical_recur)
+static int weekdays_to_recur_byday(const char *days, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *space;
const char *day;
else
day = days;
- daynr = weekday_to_number(day, 7);
+ daynr = weekday_to_number(day, 7, error);
if (!daynr)
return -1;
-int process_weeklyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_weeklyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *interval = NULL, *weekday = NULL, *firstday = NULL;
int intervalnr, firstdaynr;
return -1;
}
if (firstday)
- firstdaynr = weekday_to_number(firstday, 7);
+ firstdaynr = weekday_to_number(firstday, 7, error);
else
firstdaynr = 0;
ical_recur->interval = intervalnr;
ical_recur->week_start = firstdaynr;
- if (weekdays_to_recur_byday(weekday, ical_recur))
+ if (weekdays_to_recur_byday(weekday, ical_recur, error))
return -1;
ical_recur->freq = ICAL_WEEKLY_RECURRENCE;
return 0;
}
-int process_dailyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur)
+int process_dailyrecurrence(xmlNode *xml_node, struct icalrecurrencetype *ical_recur, GError *error)
{
const char *interval = NULL;
int intervalnr;
return 0;
}
-icalcomponent *process_timezone_rule(xmlNode *xml_node,
- icalcomponent_kind kind, int *offset)
+icalcomponent *process_timezone_rule(xmlNode *xml_node, icalcomponent_kind kind,
+ int *offset, GError *error)
{
icalcomponent *comp = icalcomponent_new(kind);
char *tzname;
} else if (!strcmp((char *)xml_node->name, "RelativeYearlyRecurrence")) {
struct icalrecurrencetype ical_recur;
- if (process_relativeyearlyrecurrence(xml_node, &ical_recur))
+ if (process_relativeyearlyrecurrence(xml_node, &ical_recur, error))
return NULL;
prop = icalproperty_new_rrule(ical_recur);
icalcomponent_add_property(comp, prop);
return comp;
}
-icaltimezone *get_meeting_timezone(xmlNode *xml_node)
+icaltimezone *get_meeting_timezone(xmlNode *xml_node, GError *error)
{
icalcomponent *comp = NULL, *dst_zone = NULL, *std_zone = NULL;
icalproperty *prop;
prop = icalproperty_new_tzid(tzname);
icalcomponent_add_property(comp, prop);
- if (get_baseoffset(xml_node, &std_offset))
+ if (get_baseoffset(xml_node, &std_offset, error))
return NULL;
dst_offset = std_offset;
else if (!strcmp((char *)xml_node->name, "Standard")) {
std_zone = process_timezone_rule(xml_node,
ICAL_XSTANDARD_COMPONENT,
- &std_offset);
+ &std_offset, error);
} else if (!strcmp((char *)xml_node->name, "Daylight")) {
dst_zone = process_timezone_rule(xml_node,
ICAL_XDAYLIGHT_COMPONENT,
- &dst_offset);
+ &dst_offset, error);
} else {
fprintf(stderr, "Unknown element in MeetingTimeZone: %s\n",
xml_node->name);