From f865d886f5aae9279d44f726a0b8093316a40e09 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 2 Apr 1998 07:57:58 +0000 Subject: New main program that uses our new datatypes and objects. 1998-04-02 Miguel de Icaza * main.c: New main program that uses our new datatypes and objects. * calendar.c (calendar_load_from_vobject, calendar_load): Implement loading of vCalendar objects and vCalendar files. * calobj.c (ical_object_create_from_vobject): Implement loading of vCalendar event and todo objects. * timeutil.c (isodate_from_time_t): New function. * gnome-cal.c, gnome-cal.h: Implement a toplevel widget, derived from GnomeApp. It holds all of the day views and arbitrates the display. svn path=/trunk/; revision=93 --- calendar/calendar.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'calendar/calendar.c') diff --git a/calendar/calendar.c b/calendar/calendar.c index e077279461..5d7cb1dd8a 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -13,6 +13,7 @@ */ #include "calendar.h" +#include "versit/vcc.h" Calendar * calendar_new (char *title) @@ -28,6 +29,7 @@ calendar_new (char *title) void calendar_add_object (Calendar *cal, iCalObject *obj) { + printf ("Adding object\n"); switch (obj->type){ case ICAL_EVENT: cal->events = g_list_prepend (cal->events, obj); @@ -133,3 +135,56 @@ calendar_compare_by_dtstart (gpointer a, gpointer b) return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; } + +#define str_val(obj) (char *) vObjectUStringZValue (obj) + +/* Loads our calendar contents from a vObject */ +void +calendar_load_from_vobject (Calendar *cal, VObject *vcal) +{ + VObjectIterator i;; + + initPropIterator (&i, vcal); + + while (moreIteration (&i)){ + VObject *this = nextVObject (&i); + iCalObject *ical; + const char *object_name = vObjectName (this); + + if (strcmp (object_name, VCDCreatedProp) == 0){ + cal->created = time_from_isodate (str_val (this)); + continue; + } + + if (strcmp (object_name, VCLocationProp) == 0) + continue; /* FIXME: imlement */ + + if (strcmp (object_name, VCProdIdProp) == 0) + continue; /* FIXME: implement */ + + if (strcmp (object_name, VCVersionProp) == 0) + continue; /* FIXME: implement */ + + ical = ical_object_create_from_vobject (this, object_name); + + if (ical) + calendar_add_object (cal, ical); + } +} + +/* Loads a calendar from a file */ +void +calendar_load (Calendar *cal, char *fname) +{ + VObject *vcal; + + if (cal->filename){ + g_warning ("Calendar load called again\n"); + return; + } + + cal->filename = g_strdup (fname); + vcal = Parse_MIME_FromFileName (fname); + calendar_load_from_vobject (cal, vcal); + cleanVObject (vcal); +} -- cgit v1.2.3