aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog19
-rw-r--r--calendar/cal-util/icalendar-save.c516
-rw-r--r--calendar/cal-util/icalendar-save.h13
-rw-r--r--calendar/cal-util/icalendar-test.c146
-rw-r--r--calendar/cal-util/icalendar.c673
-rw-r--r--calendar/cal-util/icalendar.h13
-rw-r--r--calendar/cal-util/test-recur.c14
-rw-r--r--calendar/gui/e-itip-control.c5
-rw-r--r--calendar/gui/e-meeting-edit.c9
-rw-r--r--calendar/pcs/cal-backend-file.c11
-rw-r--r--calendar/pcs/cal-backend.c3
11 files changed, 45 insertions, 1377 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 439e6c777e..68698a4f0f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,22 @@
+2000-11-24 Federico Mena Quintero <federico@helixcode.com>
+
+ * pcs/cal-backend-file.c (scan_vcalendar): Use the new libical
+ external iterators (icalcomponent_begin_component() and friends);
+ the internal iterators are deprecated.
+
+ * cal-util/test-recur.c (generate_occurrences): Likewise.
+
+ * gui/e-itip-control.c (pstream_load): Likewise.
+
+ * gui/e-meeting-edit.c (e_meeting_edit): Likewise.
+
+ * pcs/cal-backend.c (cal_backend_log_entry): Plug leak.
+ (cal_backend_log_sync): Free the entry->uid.
+
+ * util/icalendar-save.[ch]:
+ * util/icalendar-test.c:
+ * util/icalendar.[ch]: Removed obsolete files.
+
2000-11-21 Federico Mena Quintero <federico@helixcode.com>
* gui/task.xpm: Remove the check because it makes it look like the
diff --git a/calendar/cal-util/icalendar-save.c b/calendar/cal-util/icalendar-save.c
deleted file mode 100644
index 8f2335763f..0000000000
--- a/calendar/cal-util/icalendar-save.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <config.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "icalendar-save.h"
-
-
-static void unparse_person (iCalPerson *person, icalproperty *person_prop);
-static struct icaltimetype timet_to_icaltime (time_t tt);
-static icalproperty *unparse_related (iCalRelation *rel);
-static icalcomponent *unparse_alarm (CalendarAlarm *alarm);
-
-
-icalcomponent*
-icalcomponent_create_from_ical_object (iCalObject *ical)
-{
- icalcomponent_kind kind;
- icalcomponent *comp;
- icalproperty *prop;
-
- switch (ical->type) {
- case ICAL_EVENT: kind = ICAL_VEVENT_COMPONENT; break;
- case ICAL_TODO: kind = ICAL_VTODO_COMPONENT; break;
- case ICAL_JOURNAL: kind = ICAL_VJOURNAL_COMPONENT; break;
- case ICAL_FBREQUEST: kind = ICAL_VFREEBUSY_COMPONENT; break;
- case ICAL_TIMEZONE: kind = ICAL_VTIMEZONE_COMPONENT; break;
- default:
- kind = ICAL_NO_COMPONENT; break;
- }
-
- comp = icalcomponent_new (kind);
-
- /*** calscale ***/
- prop = icalproperty_new_calscale ("GREGORIAN");
- icalcomponent_add_property (comp, prop);
-
- /*** catagories ***/
- if (ical->categories) {
- /* ical->categories is a GList of (char *) */
- GList *cur;
- for (cur = ical->categories; cur; cur = cur->next) {
- prop = icalproperty_new_categories ((char *) cur);
- icalcomponent_add_property (comp, prop);
- }
- }
-
- /*** class ***/
- if (ical->class) {
- prop = icalproperty_new_class (ical->class);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** comment ***/
- if (ical->comment) {
- prop = icalproperty_new_comment (ical->comment);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** description ***/
- if (ical->desc) {
- prop = icalproperty_new_description (ical->desc);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** geo ***/
- if (ical->geo.valid) {
- struct icalgeotype v;
- v.lat = ical->geo.latitude;
- v.lon = ical->geo.longitude;
- prop = icalproperty_new_geo (v);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** location ***/
- if (ical->location) {
- prop = icalproperty_new_location (ical->location);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** percentcomplete ***/
- prop = icalproperty_new_percentcomplete (ical->percent);
- icalcomponent_add_property (comp, prop);
-
- /*** priority ***/
- if (ical->priority) {
- prop = icalproperty_new_priority (ical->priority);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** resources ***/
- if (ical->resources) {
- /* ical->resources is a GList of (char *) */
- GList *cur;
- for (cur = ical->resources; cur; cur = cur->next) {
- prop = icalproperty_new_resources ((char *) cur);
- icalcomponent_add_property (comp, prop);
- }
- }
-
- /*** status ***/
- if (ical->status) {
- prop = icalproperty_new_status (ical->status);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** summary ***/
- if (ical->summary) {
- prop = icalproperty_new_summary (ical->summary);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** completed ***/
- if (ical->completed) {
- struct icaltimetype ictime;
- ictime = timet_to_icaltime (ical->completed);
- prop = icalproperty_new_completed (ictime);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** dtend ***/ /*** due ***/
- if (ical->dtend) {
- /* FIXME: We should handle timezone specifiers */
- struct icaltimetype ictime;
- ictime = timet_to_icaltime (ical->dtend);
- if (ical->type == ICAL_TODO)
- prop = icalproperty_new_due (ictime);
- else
- prop = icalproperty_new_dtend (ictime);
- if (ical->date_only) {
- icalparameter *param;
- param = icalparameter_new (ICAL_VALUE_PARAMETER);
- icalparameter_set_value (param, ICAL_VALUE_DATE);
- icalproperty_add_parameter (prop, param);
- }
- icalcomponent_add_property (comp, prop);
- }
-
- /*** dtstart ***/
- if (ical->dtstart) {
- /* FIXME: We should handle timezone specifiers */
- struct icaltimetype ictime;
- ictime = timet_to_icaltime (ical->dtstart);
- prop = icalproperty_new_dtstart (ictime);
- if (ical->date_only) {
- icalparameter *param;
- param = icalparameter_new (ICAL_VALUE_PARAMETER);
- icalparameter_set_value (param, ICAL_VALUE_DATE);
- icalproperty_add_parameter (prop, param);
- }
- icalcomponent_add_property (comp, prop);
- }
-
- /*** duration ***/
- {
- /* FIX ME */
- }
-
- /*** freebusy ***/
- {
- /* FIX ME */
- }
-
- /*** transp ***/
- {
- if (ical->transp == ICAL_TRANSP_PROPERTY)
- prop = icalproperty_new_transp ("TRANSPARENT");
- else
- prop = icalproperty_new_transp ("OPAQUE");
- icalcomponent_add_property (comp, prop);
- }
-
- /*
- ICAL_TZID_PROPERTY:
- ICAL_TZNAME_PROPERTY:
- ICAL_TZOFFSETFROM_PROPERTY:
- ICAL_TZOFFSETTO_PROPERTY:
- ICAL_TZURL_PROPERTY:
- */
-
- /*** attendee ***/
- if (ical->attendee) {
- /* a list of (iCalPerson *) */
- GList *cur;
- for (cur = ical->attendee; cur; cur = cur->next) {
- iCalPerson *person = (iCalPerson *) cur->data;
- prop = icalproperty_new_attendee (person->addr);
- unparse_person (person, prop);
- icalcomponent_add_property (comp, prop);
- }
- }
-
- /*** contact ***/
- if (ical->contact) {
- /* a list of (iCalPerson *) */
- GList *cur;
- for (cur = ical->contact; cur; cur = cur->next) {
- iCalPerson *person = (iCalPerson *) cur->data;
- prop = icalproperty_new_contact (person->addr);
- unparse_person (person, prop);
- icalcomponent_add_property (comp, prop);
- }
- }
-
- /*** organizer ***/
- if (ical->organizer) {
- prop = icalproperty_new_organizer (ical->organizer->addr);
- unparse_person (ical->organizer, prop);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** recurrenceid ***/
- if (ical->recurid) {
- struct icaltimetype ictime;
- ictime = timet_to_icaltime (ical->recurid);
- prop = icalproperty_new_recurrenceid (ictime);
- }
-
- /*** relatedto ***/
-
- if (ical->related) {
- /* a list of (iCalPerson *) */
- GList *cur;
- for (cur = ical->related; cur; cur = cur->next) {
- iCalRelation *related = (iCalRelation *) cur->data;
- prop = unparse_related (related);
- icalcomponent_add_property (comp, prop);
- }
- }
-
-
- /*** url ***/
- if (ical->url) {
- prop = icalproperty_new_url (ical->url);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** uid ***/
- if (ical->uid) {
- prop = icalproperty_new_uid (ical->uid);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** exdate ***/
- if (ical->exdate) {
- struct icaltimetype v;
- GList *cur;
- for (cur = ical->exdate; cur; cur = cur->next) {
- time_t t = (time_t) cur->data;
- v = timet_to_icaltime (t);
- prop = icalproperty_new_exdate (v);
- icalcomponent_add_property (comp, prop);
- }
- }
-
- /*** created ***/
- if (ical->created) {
- struct icaltimetype v;
- v = timet_to_icaltime (ical->created);
- prop = icalproperty_new_created (v);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** dtstamp ***/
- if (ical->dtstamp) {
- struct icaltimetype v;
- v = timet_to_icaltime (ical->dtstamp);
- prop = icalproperty_new_created (v);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** lastmodified ***/
- if (ical->last_mod) {
- struct icaltimetype v;
- v = timet_to_icaltime (ical->last_mod);
- prop = icalproperty_new_created (v);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** sequence ***/
- if (ical->seq) {
- prop = icalproperty_new_sequence (ical->seq);
- icalcomponent_add_property (comp, prop);
- }
-
- /*** requeststatus ***/
- if (ical->rstatus) {
- prop = icalproperty_new_requeststatus (ical->rstatus);
- icalcomponent_add_property (comp, prop);
- }
-
- /* if there is a VALARM subcomponent, add it here */
-
- if (ical->alarms) {
- GList *cur;
- for (cur = ical->alarms; cur; cur = cur->next) {
- CalendarAlarm *alarm = (CalendarAlarm *) cur->data;
- icalcomponent *subcomp = unparse_alarm (alarm);
- icalcomponent_add_component (comp, subcomp);
- }
- }
-
- return comp;
-}
-
-
-/* FIX ME -- same as icaltimetype_from_timet in icaltypes.c */
-static
-struct icaltimetype timet_to_icaltime (time_t tt)
-{
- struct tm *t;
- struct icaltimetype i;
-
- //t = gmtime (&tt);
- t = localtime (&tt);
-
- /*return tt - (i->is_utc ? timezone : 0); */
- i.is_utc = 0;
-
- i.year = t->tm_year + 1900;
- i.month = t->tm_mon + 1;
- i.day = t->tm_mday;
-
- if (t->tm_hour == 0 && t->tm_min == 0 && t->tm_sec == 0) {
- i.is_date = 1;
- i.hour = 0;
- i.minute = 0;
- i.second = 0;
- } else {
- i.is_date = 0;
- i.hour = t->tm_hour;
- i.minute = t->tm_min;
- i.second = t->tm_sec;
- }
-
- return i;
-}
-
-
-/* fills in "person_prop" with information from "person" */
-
-static
-void unparse_person (iCalPerson *person, icalproperty *person_prop)
-{
- icalparameter *param;
- GList *cur;
-
- /* convert iCalPerson to an icalproperty */
-
- if (person->name) {
- param = icalparameter_new_cn (person->name);
- icalproperty_add_parameter (person_prop, param);
- }
-
- if (person->role) {
- if (g_strcasecmp (person->role, "CHAIR") == 0)
- param = icalparameter_new_role (ICAL_ROLE_CHAIR);
- else if (g_strcasecmp (person->role, "REQPARTICIPANT") == 0)
- param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
- else if (g_strcasecmp (person->role, "OPTPARTICIPANT") == 0)
- param = icalparameter_new_role (ICAL_ROLE_OPTPARTICIPANT);
- else if (g_strcasecmp (person->role, "NONPARTICIPANT") == 0)
- param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
- else
- param = icalparameter_new_role (ICAL_ROLE_XNAME);
- icalproperty_add_parameter (person_prop, param);
- }
-
- if (person->partstat) {
- if (g_strcasecmp (person->partstat, "NEEDSACTION") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
- else if (g_strcasecmp (person->partstat, "ACCEPTED") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
- else if (g_strcasecmp (person->partstat, "DECLINED") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
- else if (g_strcasecmp (person->partstat, "TENTATIVE") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
- else if (g_strcasecmp (person->partstat, "DELEGATED") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
- else if (g_strcasecmp (person->partstat, "COMPLETED") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_COMPLETED);
- else if (g_strcasecmp (person->partstat, "INPROCESS") == 0)
- param = icalparameter_new_partstat (ICAL_PARTSTAT_INPROCESS);
- else /* FIX ME, NEEDSACTION instead? */
- param = icalparameter_new_partstat (ICAL_PARTSTAT_XNAME);
- icalproperty_add_parameter (person_prop, param);
- }
-
- if (person->rsvp != FALSE) {
- param = icalparameter_new_rsvp (TRUE);
- icalproperty_add_parameter (person_prop, param);
- }
-
- if (person->cutype) {
- if (g_strcasecmp (person->cutype, "INDIVIDUAL") == 0)
- param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
- else if (g_strcasecmp (person->cutype, "GROUP") == 0)
- param = icalparameter_new_cutype (ICAL_CUTYPE_GROUP);
- else if (g_strcasecmp (person->cutype, "RESOURCE") == 0)
- param = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
- else if (g_strcasecmp (person->cutype, "ROOM") == 0)
- param = icalparameter_new_cutype (ICAL_CUTYPE_ROOM);
- else /* FIX ME, INDIVIDUAL instead? */
- param = icalparameter_new_cutype (ICAL_CUTYPE_UNKNOWN);
- icalproperty_add_parameter (person_prop, param);
- }
-
- /* person->member is a list of ICAL_MEMBER_PARAMETER */
- for (cur = person->member; cur; cur = cur->next) {
- gchar *member = (gchar *) cur->data;
- param = icalparameter_new_member (member);
- icalproperty_add_parameter (person_prop, param);
- }
-
- /* person->deleg_to is a list of ICAL_DELEGATEDTO_PARAMETER */
- for (cur = person->deleg_to; cur; cur = cur->next) {
- gchar *deleg_to = (gchar *) cur->data;
- param = icalparameter_new_delegatedto (deleg_to);
- icalproperty_add_parameter (person_prop, param);
- }
-
- /* ret->deleg_from is a list of ICAL_DELEGATEDFROM_PARAMETER */
- for (cur = person->deleg_from; cur; cur = cur->next) {
- gchar *deleg_from = (gchar *) cur->data;
- param = icalparameter_new_delegatedfrom (deleg_from);
- icalproperty_add_parameter (person_prop, param);
- }
-
- if (person->sent_by) {
- param = icalparameter_new_sentby (person->sent_by);
- icalproperty_add_parameter (person_prop, param);
- }
-
- /* ret->deleg_to is a list of ICAL_DIR_PARAMETER */
- /* FIX ME ... */
-}
-
-
-static
-icalproperty *unparse_related (iCalRelation *rel)
-{
- icalproperty *prop;
-
- prop = icalproperty_new_relatedto (rel->reltype);
-
- icalproperty_set_relatedto (prop, rel->uid);
-
- /* FIX ME RELTYPE_XNAME ? */
-
- return prop;
-}
-
-
-static
-icalcomponent *unparse_alarm (CalendarAlarm *alarm)
-{
- icalcomponent *comp = icalcomponent_new (ICAL_VALARM_COMPONENT);
- icalproperty *prop;
-
- prop = NULL;
- switch (alarm->type){
- case ALARM_AUDIO:
- prop = icalproperty_new_action ("AUDIO");
- break;
- case ALARM_DISPLAY:
- prop = icalproperty_new_action ("DISPLAY");
- break;
- case ALARM_MAIL:
- prop = icalproperty_new_action ("EMAIL");
- break;
- case ALARM_PROGRAM:
- prop = icalproperty_new_action ("PROCEDURE");
- break;
- default:
- g_warning ("Unsupported alarm type!");
- break;
- }
- if (prop)
- icalcomponent_add_property (comp, prop);
-
- if (alarm->snooze_repeat)
- prop = icalproperty_new_repeat (alarm->snooze_repeat);
-
- if (alarm->snooze_secs) {
- struct icaldurationtype dur;
- dur = icaldurationtype_from_timet (alarm->snooze_secs);
- prop = icalproperty_new_duration (dur);
- icalcomponent_add_property (comp, prop);
- }
-
- if (alarm->attach) {
- struct icalattachtype *attach;
- attach = icalattachtype_new ();
- icalattachtype_set_url (attach, alarm->attach);
- prop = icalproperty_new_attach (*attach);
- icalattachtype_free (attach);
- icalcomponent_add_property (comp, prop);
- }
-
- if (alarm->desc) {
- prop = icalproperty_new_description (alarm->desc);
- icalcomponent_add_property (comp, prop);
- }
-
- if (alarm->summary) {
- prop = icalproperty_new_summary (alarm->summary);
- icalcomponent_add_property (comp, prop);
- }
-
- if (alarm->attendee) {
- icalproperty_new_attendee (alarm->attendee);
- icalcomponent_add_property (comp, prop);
- }
-
- return comp;
-}
diff --git a/calendar/cal-util/icalendar-save.h b/calendar/cal-util/icalendar-save.h
deleted file mode 100644
index 1e0ab59e70..0000000000
--- a/calendar/cal-util/icalendar-save.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef ICALENDAR_SAVE_H
-#define ICALENDAR_SAVE_H
-
-#include <ical.h>
-#include <cal-util/calobj.h>
-
-
-
-icalcomponent *icalcomponent_create_from_ical_object (iCalObject *ical);
-
-
-
-#endif
diff --git a/calendar/cal-util/icalendar-test.c b/calendar/cal-util/icalendar-test.c
deleted file mode 100644
index 921e109a2c..0000000000
--- a/calendar/cal-util/icalendar-test.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <cal-util/calobj.h>
-#include "libversit/vcc.h"
-
-#include "icalendar-save.h"
-#include "icalendar.h"
-
-
-static icalcomponent*
-icalendar_parse_file (char* fname)
-{
- FILE* fp;
- icalcomponent* comp = NULL;
- gchar* str;
- struct stat st;
- int n;
-
- fp = fopen (fname, "r");
- if (!fp) {
- g_warning ("Cannot open open calendar file.");
- return NULL;
- }
-
- stat (fname, &st);
-
- str = g_malloc (st.st_size + 2);
-
- n = fread ((gchar*) str, 1, st.st_size, fp);
- if (n != st.st_size) {
- g_warning ("Read error.");
- }
- str[n] = '\0';
-
- fclose (fp);
-
- comp = icalparser_parse_string (str);
- g_free (str);
-
- return comp;
-}
-
-
-static GList *
-icalendar_calendar_load (GList *icals, char *fname)
-{
- icalcomponent *comp;
- icalcomponent *subcomp;
- iCalObject *ical;
-
- comp = icalendar_parse_file (fname);
- subcomp = icalcomponent_get_first_component (comp,
- ICAL_ANY_COMPONENT);
- while (subcomp) {
- ical = ical_object_create_from_icalcomponent (subcomp);
- if (ical->type != ICAL_EVENT &&
- ical->type != ICAL_TODO &&
- ical->type != ICAL_JOURNAL) {
- g_warning ("Skipping unsupported iCalendar component");
- } else {
- printf ("prepending %p\n", ical);
- icals = g_list_prepend (icals, ical);
- }
- subcomp = icalcomponent_get_next_component (comp,
- ICAL_ANY_COMPONENT);
- }
-
- return icals;
-}
-
-
-
-
-static void
-icalendar_calendar_save (GList *icals, char *fname)
-{
- GList *cur;
- icalcomponent *top = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
- char *out_cal_string;
-
- for (cur=icals; cur; cur=cur->next) {
- iCalObject *ical = (iCalObject *) cur->data;
- icalcomponent *comp;
- comp = icalcomponent_create_from_ical_object (ical);
- icalcomponent_add_component (top, comp);
- }
-
- out_cal_string = icalcomponent_as_ical_string (top);
-
- printf ("---------------------------------------------------------\n");
- printf ("%s", out_cal_string);
-}
-
-
-
-int main (int argc, char *argv[])
-{
- GList *icals = NULL;
- int i;
- long int n0, n1;
- struct icaldurationtype dt;
-
-
- /* test icaldurationtype_from_timet */
- srandom (time (0));
-
- for (i=0; i<10; i++) {
- n0 = random () % ((60 * 60 * 24 * 7) * 4);
- dt = icaldurationtype_from_timet (n0);
- n1 = icaldurationtype_as_timet (dt);
-
- printf ("%ld -> (%d %d %d %d %d) -> %ld\n",
- n0,
- dt.weeks, dt.days, dt.hours, dt.minutes, dt.seconds,
- n1);
- if (n0 != n1) abort ();
- }
-
- /*****************/
- /* test conversion of icalcomponents to and from iCalObjects */
- /*****************/
-
- /* load an ical file */
-
- if (argc < 2) {
- printf ("give ical file as argument.\n");
- return 1;
- }
-
- icals = icalendar_calendar_load (icals, argv[ 1 ]);
-
- printf ("loaded %d ical components\n", g_list_length (icals));
-
-
- /* save it back out */
-
- icalendar_calendar_save (icals, "out.ical");
-
- return 0;
-}
diff --git a/calendar/cal-util/icalendar.c b/calendar/cal-util/icalendar.c
deleted file mode 100644
index c43d0fba77..0000000000
--- a/calendar/cal-util/icalendar.c
+++ /dev/null
@@ -1,673 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * icalendar server for gnomecal
- *
- * This module interfaces between libical and the gnomecal internal
- * representation
- *
- * Copyright (C) 1999 The Free Software Foundation
- * Authors:
- * Russell Steinthal (rms39@columbia.edu)
- *
- */
-
-#include <config.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "icalendar.h"
-
-static time_t icaltime_to_timet (struct icaltimetype* i);
-static CalendarAlarm* parse_alarm (icalproperty *prop);
-static iCalPerson* parse_person (icalproperty *prop, gchar *value);
-static iCalRelation* parse_related (icalproperty *prop);
-
-/* Duplicate a string without memory leaks */
-static gchar* copy_str (gchar** store, gchar* src)
-{
- if (*store)
- g_free (*store);
- return (*store = g_strdup (src));
-}
-
-static GList*
-copy_to_list (GList** store, gchar* src)
-{
- *store = g_list_prepend (*store, g_strdup (src));
- return *store;
-}
-
-
-iCalObject *
-ical_object_create_from_icalcomponent (icalcomponent* comp)
-{
- iCalObject *ical = NULL;
- iCalPerson *person;
- icalcomponent *subcomp;
- icalproperty *prop;
- icalparameter *param;
- struct icaltimetype ictime;
- time_t *pt;
- CalendarAlarm *alarm = NULL;
- icalcomponent_kind compType;
- struct icalgeotype geo;
- struct icalperiodtype period;
-
- gboolean root = FALSE;
- gboolean attachment = FALSE;
-
- char *tmpStr; /* this is a library-owned string */
-
- ical = g_new0 (iCalObject, 1);
-
- compType = icalcomponent_isa (comp);
-
- switch (compType) {
- case ICAL_XROOT_COMPONENT:
- root = TRUE;
- break;
- case ICAL_XATTACH_COMPONENT:
- attachment = TRUE;
- break;
- case ICAL_VEVENT_COMPONENT:
- ical->type = ICAL_EVENT;
- break;
- case ICAL_VTODO_COMPONENT:
- ical->type = ICAL_TODO;
- break;
- case ICAL_VJOURNAL_COMPONENT:
- ical->type = ICAL_JOURNAL;
- break;
- case ICAL_VCALENDAR_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_VFREEBUSY_COMPONENT:
- ical->type = ICAL_FBREQUEST;
- /* NOTE: This is not conclusive- you need to analyze
- properties to determine whether this is an
- FBREQUEST or an FBREPLY */
- break;
- case ICAL_VTIMEZONE_COMPONENT:
- ical->type = ICAL_TIMEZONE;
- break;
- case ICAL_VALARM_COMPONENT:
- case ICAL_XAUDIOALARM_COMPONENT:
- case ICAL_XDISPLAYALARM_COMPONENT:
- case ICAL_XEMAILALARM_COMPONENT:
- case ICAL_XPROCEDUREALARM_COMPONENT:
- /* this should not be reached, since this loop should
- only be processing first level components */
- break;
- case ICAL_XSTANDARD_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_XDAYLIGHT_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_X_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_VSCHEDULE_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_XLICINVALID_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- case ICAL_NO_COMPONENT:
- case ICAL_ANY_COMPONENT:
- /* should not occur */
- break;
- case ICAL_VQUERY_COMPONENT:
- case ICAL_VCAR_COMPONENT:
- case ICAL_VCOMMAND_COMPONENT:
- /* FIXME: what does this mean? */
- break;
- }
-
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
- switch (icalproperty_isa (prop)) {
- case ICAL_CALSCALE_PROPERTY:
- if (g_strcasecmp (icalproperty_get_calscale (prop),
- "GREGORIAN"))
- g_warning ("Unknown calendar format.");
- break;
- case ICAL_METHOD_PROPERTY:
- /* FIXME: implement something here */
- break;
- case ICAL_ATTACH_PROPERTY:
- /* FIXME: not yet implemented */
- break;
- case ICAL_CATEGORIES_PROPERTY:
- copy_to_list (&ical->categories,
- icalproperty_get_categories (prop));
- break;
- case ICAL_CLASS_PROPERTY:
- copy_str (&ical->class, icalproperty_get_class (prop));
- break;
- case ICAL_COMMENT_PROPERTY:
- /*tmpStr = icalproperty_get_comment (prop);*/
- tmpStr = g_strconcat (icalproperty_get_comment (prop),
- ical->comment,
- NULL);
- if (ical->comment)
- g_free (ical->comment);
- ical->comment = tmpStr;
- break;
- case ICAL_DESCRIPTION_PROPERTY:
- copy_str (&ical->desc,
- icalproperty_get_description (prop));
- break;
- case ICAL_GEO_PROPERTY:
- geo = icalproperty_get_geo (prop);
- ical->geo.latitude = geo.lat;
- ical->geo.longitude = geo.lon;
- ical->geo.valid = TRUE;
- break;
- case ICAL_LOCATION_PROPERTY:
- copy_str (&ical->location,
- icalproperty_get_location (prop));
- break;
- case ICAL_PERCENTCOMPLETE_PROPERTY:
- ical->percent = icalproperty_get_percentcomplete (prop);
- break;
- case ICAL_PRIORITY_PROPERTY:
- ical->priority = icalproperty_get_priority (prop);
- if (ical->priority < 0 || ical->priority > 9)
- g_warning ("Priority out-of-range (see RFC2445)");
- break;
- case ICAL_RESOURCES_PROPERTY:
- copy_to_list (&ical->resources,
- icalproperty_get_resources (prop));
- break;
- case ICAL_STATUS_PROPERTY:
- copy_str (&ical->status,
- icalproperty_get_status (prop));
- break;
- case ICAL_SUMMARY_PROPERTY:
- copy_str (&ical->summary,
- icalproperty_get_summary (prop));
- break;
- case ICAL_COMPLETED_PROPERTY:
- ictime = icalproperty_get_completed (prop);
- ical->completed = icaltime_to_timet (&ictime);
- break;
- case ICAL_DTEND_PROPERTY:
- ictime = icalproperty_get_dtend (prop);
- ical->dtend = icaltime_to_timet (&ictime);
- param = icalproperty_get_first_parameter (prop,
- ICAL_VALUE_PARAMETER);
- if (param)
- ical->date_only = (icalparameter_get_value (param) == ICAL_VALUE_DATE);
- /* FIXME: We should handle timezone specifiers */
- break;
- case ICAL_DUE_PROPERTY:
- ictime = icalproperty_get_due (prop);
- ical->dtend = icaltime_to_timet (&ictime);
- param = icalproperty_get_first_parameter (prop,
- ICAL_VALUE_PARAMETER);
- ical->date_only = (icalparameter_get_value (param) ==
- ICAL_VALUE_DATE);
- /* FIXME: We should handle timezone specifiers */
- break;
- case ICAL_DTSTART_PROPERTY:
- ictime = icalproperty_get_dtstart (prop);
- ical->dtstart = icaltime_to_timet (&ictime);
- param = icalproperty_get_first_parameter (prop,
- ICAL_VALUE_PARAMETER);
- if (param)
- ical->date_only = (icalparameter_get_value (param) == ICAL_VALUE_DATE);
- /* FIXME: We should handle timezone specifiers */
- break;
- case ICAL_DURATION_PROPERTY:
- /* FIXME: I don't see the necessary libical function */
- break;
- case ICAL_FREEBUSY_PROPERTY:
- period = icalproperty_get_freebusy (prop);
- ical->dtstart = icaltime_to_timet (&(period.start));
- /* FIXME: period.end is specified as being relative
- to start, so this may not be correct */
- ical->dtend = icaltime_to_timet (&(period.end));
- break;
- case ICAL_TRANSP_PROPERTY:
- tmpStr = icalproperty_get_transp (prop);
- /* do not i18n the following string constant! */
- if (!g_strcasecmp (tmpStr, "TRANSPARENT"))
- ical->transp = ICAL_TRANSPARENT;
- else
- ical->transp = ICAL_OPAQUE;
- break;
- case ICAL_TZID_PROPERTY:
- case ICAL_TZNAME_PROPERTY:
- case ICAL_TZOFFSETFROM_PROPERTY:
- case ICAL_TZOFFSETTO_PROPERTY:
- case ICAL_TZURL_PROPERTY:
- /* no implementation for now */
- break;
- case ICAL_ATTENDEE_PROPERTY:
- tmpStr = icalproperty_get_attendee (prop);
- person = parse_person (prop, tmpStr);
- ical->attendee = g_list_prepend (ical->attendee,
- person);
- break;
- case ICAL_CONTACT_PROPERTY:
- tmpStr = icalproperty_get_contact (prop);
- person = parse_person (prop, tmpStr);
- ical->contact = g_list_prepend (ical->contact, person);
- break;
- case ICAL_ORGANIZER_PROPERTY:
- tmpStr = icalproperty_get_organizer (prop);
- person = parse_person (prop, tmpStr);
- if (ical->organizer)
- g_free (ical->organizer);
- ical->organizer = person;
- break;
- case ICAL_RECURRENCEID_PROPERTY:
- ictime = icalproperty_get_recurrenceid (prop);
- ical->recurid = icaltime_to_timet (&ictime);
- /* FIXME: Range parameter not implemented */
- break;
- case ICAL_RELATEDTO_PROPERTY:
- ical->related = g_list_prepend (ical->related,
- parse_related (prop));
- break;
- case ICAL_URL_PROPERTY:
- copy_str (&ical->url,
- icalproperty_get_url (prop));
- break;
- case ICAL_UID_PROPERTY:
- copy_str (&ical->uid,
- icalproperty_get_uid (prop));
- break;
- case ICAL_EXDATE_PROPERTY:
- /* FIXME: This does not appear to parse
- multiple exdate values in one property, as
- allowed by the RFC; needs a libical fix */
- ictime = icalproperty_get_exdate (prop);
- pt = g_new0 (time_t, 1);
- *pt = icaltime_to_timet (&ictime);
- ical->exdate = g_list_prepend (ical->exdate, pt);
- break;
- case ICAL_EXRULE_PROPERTY:
- case ICAL_RDATE_PROPERTY:
- case ICAL_RRULE_PROPERTY:
- /* FIXME: need recursion processing */
- break;
- case ICAL_ACTION_PROPERTY:
- case ICAL_REPEAT_PROPERTY:
- case ICAL_TRIGGER_PROPERTY:
- /* should only occur in VALARM's, handled below */
- g_assert_not_reached();
- break;
- case ICAL_CREATED_PROPERTY:
- ictime = icalproperty_get_created (prop);
- ical->created = icaltime_to_timet (&ictime);
- break;
- case ICAL_DTSTAMP_PROPERTY:
- ictime = icalproperty_get_dtstamp (prop);
- ical->dtstamp = icaltime_to_timet (&ictime);
- break;
- case ICAL_LASTMODIFIED_PROPERTY:
- ictime = icalproperty_get_lastmodified (prop);
- ical->last_mod = icaltime_to_timet (&ictime);
- break;
- case ICAL_SEQUENCE_PROPERTY:
- ical->seq = icalproperty_get_sequence (prop);
- break;
- case ICAL_REQUESTSTATUS_PROPERTY:
- copy_str (&ical->rstatus,
- icalproperty_get_requeststatus (prop));
- break;
- case ICAL_X_PROPERTY:
- g_warning ("Unsupported X-property: %s",
- icalproperty_as_ical_string (prop));
- break;
- case ICAL_XLICERROR_PROPERTY:
- g_warning ("Unsupported property: %s",
- icalproperty_get_xlicerror (prop));
- break;
- case ICAL_PRODID_PROPERTY:
- case ICAL_VERSION_PROPERTY:
- /* nothing to do for this property */
- break;
- default:
- g_warning ("Unsupported property: %s", icalproperty_as_ical_string (prop));
- break;
-
- }
-
- prop = icalcomponent_get_next_property (comp,
- ICAL_ANY_PROPERTY);
- }
-
- /* now parse subcomponents --- should only be VALARM's */
- subcomp = icalcomponent_get_first_component (comp,
- ICAL_ANY_COMPONENT);
- while (subcomp) {
- compType = icalcomponent_isa (subcomp);
- switch (compType) {
- case ICAL_VALARM_COMPONENT:
- alarm = parse_alarm (subcomp);
- if (alarm)
- ical->alarms = g_list_prepend (ical->alarms,
- alarm);
- break;
- default:
- g_warning ("Only nested VALARM components are supported.");
- }
-
- subcomp = icalcomponent_get_next_component (comp,
- ICAL_ANY_COMPONENT);
- }
-
- return ical;
-}
-
-
-static time_t icaltime_to_timet (struct icaltimetype* i)
-{
- struct tm t;
- time_t ret;
-
- t.tm_year = i->year - 1900;
- t.tm_mon = i->month - 1;
- t.tm_mday = i->day;
- if (!i->is_date) {
- t.tm_hour = i->hour;
- t.tm_min = i->minute;
- t.tm_sec = i->second;
- } else {
- t.tm_hour = 0;
- t.tm_min = 0;
- t.tm_sec = 0;
- }
-
- ret = mktime(&t);
-
- if (i->is_utc) {
-#ifdef HAVE_TIMEZONE
- extern long timezone;
- ret -= timezone;
-#else
- struct tm *tmp;
- time_t tod = time(NULL);
- tmp = localtime (&tod);
- ret += tmp->tm_gmtoff;
-#endif
- }
-
- return ret;
-}
-
-static iCalPerson*
-parse_person (icalproperty* prop, gchar* value)
-{
- icalparameter* param;
- icalparameter_role role;
- icalparameter_partstat partstat;
- icalparameter_cutype cutype;
-
- iCalPerson* ret;
-
- ret = g_new0 (iCalPerson, 1);
-
- ret->addr = g_strdup (value);
-
- param = icalproperty_get_first_parameter (prop,
- ICAL_CN_PARAMETER);
- if (param)
- ret->name = g_strdup (icalparameter_get_cn (param));
- else
- ret->name = NULL;
-
-
- param = icalproperty_get_first_parameter (prop,
- ICAL_ROLE_PARAMETER);
- if (param) {
- role = icalparameter_get_role (param);
- switch (role) {
- case ICAL_ROLE_CHAIR:
- ret->role = g_strdup ("CHAIR");
- break;
- case ICAL_ROLE_REQPARTICIPANT:
- ret->role = g_strdup ("REQPARTICIPANT");
- break;
- case ICAL_ROLE_OPTPARTICIPANT:
- ret->role = g_strdup ("OPTPARTICIPANT");
- break;
- case ICAL_ROLE_NONPARTICIPANT:
- ret->role = g_strdup ("NONPARTICIPANT");
- break;
- case ICAL_ROLE_XNAME:
- default:
- ret->role = g_strdup ("UNKNOWN");
- break;
- }
- } else
- ret->role = g_strdup ("REQPARTICIPANT");
-
- param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER);
- if (param) {
- partstat = icalparameter_get_partstat (param);
- switch (partstat) {
- case ICAL_PARTSTAT_NEEDSACTION:
- ret->partstat = g_strdup ("NEEDSACTION");
- break;
- case ICAL_PARTSTAT_ACCEPTED:
- ret->partstat = g_strdup ("ACCEPTED");
- break;
- case ICAL_PARTSTAT_DECLINED:
- ret->partstat = g_strdup ("DECLINED");
- break;
- case ICAL_PARTSTAT_TENTATIVE:
- ret->partstat = g_strdup ("TENTATIVE");
- break;
- case ICAL_PARTSTAT_DELEGATED:
- ret->partstat = g_strdup ("DELEGATED");
- break;
- case ICAL_PARTSTAT_COMPLETED:
- ret->partstat = g_strdup ("COMPLETED");
- break;
- case ICAL_PARTSTAT_INPROCESS:
- ret->partstat = g_strdup ("INPROCESS");
- break;
- case ICAL_PARTSTAT_XNAME:
- ret->partstat = g_strdup (icalparameter_get_xvalue (param));
- break;
- default:
- ret->partstat = g_strdup ("UNKNOWN");
- break;
- }
- } else
- ret->partstat = g_strdup ("NEEDSACTION");
-
- param = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER);
- if (param)
- ret->rsvp = icalparameter_get_rsvp (param);
- else
- ret->rsvp = FALSE;
-
- param = icalproperty_get_first_parameter (prop, ICAL_CUTYPE_PARAMETER
-);
- if (param) {
- cutype = icalparameter_get_cutype (param);
- switch (cutype) {
- case ICAL_CUTYPE_INDIVIDUAL:
- ret->cutype = g_strdup ("INDIVIDUAL");
- break;
- case ICAL_CUTYPE_GROUP:
- ret->cutype = g_strdup ("GROUP");
- break;
- case ICAL_CUTYPE_RESOURCE:
- ret->cutype = g_strdup ("RESOURCE");
- break;
- case ICAL_CUTYPE_ROOM:
- ret->cutype = g_strdup ("ROOM");
- break;
- case ICAL_CUTYPE_UNKNOWN:
- case ICAL_CUTYPE_XNAME:
- default:
- ret->cutype = g_strdup ("UNKNOWN");
- break;
- }
- } else
- ret->cutype = g_strdup ("INDIVIDUAL");
-
- param = icalproperty_get_first_parameter (prop, ICAL_MEMBER_PARAMETER
-);
- while (param) {
- copy_to_list (&ret->member, icalparameter_get_member (param));
- param = icalproperty_get_next_parameter (prop,
- ICAL_MEMBER_PARAMETER);
- }
-
- param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDTO_PARAMETER);
- while (param) {
- copy_to_list (&ret->deleg_to,
- icalparameter_get_delegatedto (param));
- param = icalproperty_get_next_parameter (prop,
- ICAL_DELEGATEDTO_PARAMETER);
- }
-
- param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDFROM_PARAMETER);
- while (param) {
- copy_to_list (&ret->deleg_from,
- icalparameter_get_delegatedfrom (param));
- param = icalproperty_get_next_parameter (prop,
- ICAL_DELEGATEDFROM_PARAMETER);
- }
-
- param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER);
- if (param)
- copy_str (&ret->sent_by, icalparameter_get_sentby (param));
- else
- ret->sent_by = NULL;
-
- param = icalproperty_get_first_parameter (prop, ICAL_DIR_PARAMETER);
- while (param) {
- copy_to_list (&ret->deleg_to,
- icalparameter_get_delegatedto (param));
- param = icalproperty_get_next_parameter (prop,
- ICAL_DIR_PARAMETER);
- }
-
- return ret;
-}
-
-static iCalRelation*
-parse_related (icalproperty* prop)
-{
- iCalRelation* rel;
- icalparameter* param;
- icalparameter_reltype type;
-
- rel = g_new0 (iCalRelation, 1);
- rel->uid = g_strdup (icalproperty_get_relatedto (prop));
-
- param = icalproperty_get_first_parameter (prop,
- ICAL_RELTYPE_PARAMETER);
- if (param) {
- type = icalparameter_get_reltype (param);
- switch (type) {
- case ICAL_RELTYPE_PARENT:
- rel->reltype = g_strdup ("PARENT");
- break;
- case ICAL_RELTYPE_CHILD:
- rel->reltype = g_strdup ("CHILD");
- break;
- case ICAL_RELTYPE_SIBLING:
- rel->reltype = g_strdup ("SIBLING");
- break;
- case ICAL_RELTYPE_XNAME:
- rel->reltype = g_strdup (icalparameter_get_xvalue (param));
- break;
- default:
- rel->reltype = g_strdup ("UNKNOWN");
- break;
- }
- } else
- rel->reltype = g_strdup ("PARENT");
-
- return rel;
-}
-
-#ifdef TEST
-
-int main(int argc, char* argv[])
-{
- icalcomponent* comp;
- comp = icalendar_parse_file (argv[1]);
- printf ("%s\n", icalcomponent_as_ical_string (comp));
- return 0;
-}
-
-#endif
-
-
-static CalendarAlarm*
-parse_alarm (icalcomponent* comp)
-{
- CalendarAlarm *alarm;
- icalproperty *prop;
- char *tmpStr;
- struct icaldurationtype dur;
- struct icalattachtype attach;
-
- g_return_val_if_fail (comp != NULL, NULL);
-
- alarm = g_new0 (CalendarAlarm, 1);
-
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
- switch (icalproperty_isa (prop)) {
- case ICAL_ACTION_PROPERTY:
- tmpStr = icalproperty_get_action (prop);
- if (!g_strcasecmp (tmpStr, "AUDIO"))
- alarm->type = ALARM_AUDIO;
- else if (!g_strcasecmp (tmpStr, "DISPLAY"))
- alarm->type = ALARM_DISPLAY;
- else if (!g_strcasecmp (tmpStr, "EMAIL"))
- alarm->type = ALARM_MAIL;
- else if (!g_strcasecmp (tmpStr, "PROCEDURE"))
- alarm->type = ALARM_PROGRAM;
- else
- g_warning ("Unsupported alarm type!");
- break;
- case ICAL_TRIGGER_PROPERTY:
- /* FIXME: waiting on proper libical support */
- break;
- case ICAL_REPEAT_PROPERTY:
- alarm->snooze_repeat = icalproperty_get_repeat (prop);
- break;
- case ICAL_DURATION_PROPERTY:
- dur = icalproperty_get_duration (prop);
- alarm->snooze_secs = icaldurationtype_as_timet (dur);
- break;
- case ICAL_ATTACH_PROPERTY:
- attach = icalproperty_get_attach (prop);
- copy_str (&alarm->attach,
- icalattachtype_get_url (&attach));
- break;
- case ICAL_DESCRIPTION_PROPERTY:
- copy_str (&alarm->desc,
- icalproperty_get_description (prop));
- break;
- case ICAL_SUMMARY_PROPERTY:
- copy_str (&alarm->summary,
- icalproperty_get_summary (prop));
- break;
- case ICAL_ATTENDEE_PROPERTY:
- copy_str (&alarm->attendee,
- icalproperty_get_attendee (prop));
- break;
- default:
- g_warning ("Unsupported alarm property: %s",
- icalproperty_as_ical_string (prop));
- break;
- }
-
- prop = icalcomponent_get_next_property (comp,
- ICAL_ANY_PROPERTY);
- }
-
- return alarm;
-}
diff --git a/calendar/cal-util/icalendar.h b/calendar/cal-util/icalendar.h
deleted file mode 100644
index 2a22fbab71..0000000000
--- a/calendar/cal-util/icalendar.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef ICALENDAR_H
-#define ICALENDAR_H
-
-#include <ical.h>
-#include <cal-util/calobj.h>
-
-
-
-iCalObject *ical_object_create_from_icalcomponent (icalcomponent* comp);
-
-
-
-#endif
diff --git a/calendar/cal-util/test-recur.c b/calendar/cal-util/test-recur.c
index 6ec214b18b..2c94b28921 100644
--- a/calendar/cal-util/test-recur.c
+++ b/calendar/cal-util/test-recur.c
@@ -117,15 +117,17 @@ get_line (char *s,
static void
generate_occurrences (icalcomponent *icalcomp)
{
- icalcomponent *tmp_icalcomp;
- CalComponent *comp;
- gint occurrences;
+ icalcompiter iter;
- for (tmp_icalcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
- tmp_icalcomp;
- tmp_icalcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT)) {
+ for (iter = icalcomponent_begin_component (icalcomp, ICAL_ANY_COMPONENT);
+ icalcompiter_deref (&iter) != NULL;
+ icalcompiter_next (&iter)) {
+ icalcomponent *tmp_icalcomp;
+ CalComponent *comp;
icalcomponent_kind kind;
+ gint occurrences;
+ tmp_icalcomp = icalcompiter_deref (&iter);
kind = icalcomponent_isa (tmp_icalcomp);
if (!(kind == ICAL_VEVENT_COMPONENT
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index e545f326be..d3a6a35311 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -592,6 +592,7 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
{
EItipControlPrivate *priv = data;
gint pos, length, length2;
+ icalcompiter iter;
icalcomponent_kind comp_kind;
char message[256];
@@ -617,8 +618,8 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
return;
}
- priv->comp = icalcomponent_get_first_component (priv->main_comp,
- ICAL_ANY_COMPONENT);
+ iter = icalcomponent_begin_component (priv->main_comp, ICAL_ANY_COMPONENT);
+ priv->comp = icalcompiter_deref (&iter);
#if 0
{
diff --git a/calendar/gui/e-meeting-edit.c b/calendar/gui/e-meeting-edit.c
index bdacb7514b..80202fd804 100644
--- a/calendar/gui/e-meeting-edit.c
+++ b/calendar/gui/e-meeting-edit.c
@@ -949,9 +949,12 @@ e_meeting_edit (EMeetingEditor *editor)
priv->organizer_entry = glade_xml_get_widget (priv->xml, "organizer_entry");
- if (icalcomponent_isa (priv->icalcomp) != ICAL_VEVENT_COMPONENT)
- priv->vevent = icalcomponent_get_first_component(priv->icalcomp,ICAL_VEVENT_COMPONENT);
- else
+ if (icalcomponent_isa (priv->icalcomp) != ICAL_VEVENT_COMPONENT) {
+ icalcompiter iter;
+
+ iter = icalcomponent_begin_component (priv->icalcomp, ICAL_VEVENT_COMPONENT);
+ priv->vevent = icalcompiter_deref (&iter);
+ } else
priv->vevent = priv->icalcomp;
g_assert (priv->vevent != NULL);
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index 715e1e70bc..c63e690246 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -550,18 +550,21 @@ static void
scan_vcalendar (CalBackendFile *cbfile)
{
CalBackendFilePrivate *priv;
- icalcomponent *icalcomp;
+ icalcompiter iter;
priv = cbfile->priv;
g_assert (priv->icalcomp != NULL);
g_assert (priv->comp_uid_hash != NULL);
- for (icalcomp = icalcomponent_get_first_component (priv->icalcomp, ICAL_ANY_COMPONENT);
- icalcomp;
- icalcomp = icalcomponent_get_next_component (priv->icalcomp, ICAL_ANY_COMPONENT)) {
+ for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_ANY_COMPONENT);
+ icalcompiter_deref (&iter) != NULL;
+ icalcompiter_next (&iter)) {
+ icalcomponent *icalcomp;
icalcomponent_kind kind;
CalComponent *comp;
+ icalcomp = icalcompiter_deref (&iter);
+
kind = icalcomponent_isa (icalcomp);
if (!(kind == ICAL_VEVENT_COMPONENT
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index b2b16b2c9e..f4d06518c1 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -479,7 +479,7 @@ cal_backend_log_entry (CalBackend *backend,
CalObjType cot,
CalBackendLogEntryType type)
{
- CalBackendLogEntry *entry = g_new0 (CalBackendLogEntry, 1);
+ CalBackendLogEntry *entry;
g_assert (CLASS (backend)->get_type_by_uid != NULL);
@@ -565,6 +565,7 @@ cal_backend_log_sync (CalBackend *backend)
|| entry->time_stamp > end_time)
end_time = entry->time_stamp;
+ g_free (entry->uid);
g_free (entry);
}
cal_backend_set_node_timet (tnode, "start", start_time);