diff options
author | Miguel de Icaza <miguel@nuclecu.unam.mx> | 1998-04-02 15:57:58 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-02 15:57:58 +0800 |
commit | f865d886f5aae9279d44f726a0b8093316a40e09 (patch) | |
tree | f397fa0ffb407d2ae4c15c61335bac25cb68d2a0 /calendar/cal-util | |
parent | 33b0ab0d0f19c405445315446fd584748538a1ed (diff) | |
download | gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.gz gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.bz2 gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.lz gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.xz gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.zst gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.zip |
New main program that uses our new datatypes and objects.
1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* 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
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/calobj.c | 168 | ||||
-rw-r--r-- | calendar/cal-util/calobj.h | 7 |
2 files changed, 173 insertions, 2 deletions
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index fcdfb7e59d..2f4647548f 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -6,7 +6,10 @@ * Miguel de Icaza (miguel@gnu.org) * Federico Mena (federico@gimp.org) */ +#include <string.h> +#include <glib.h> #include "calobj.h" +#include "versit/vcc.h" iCalObject * ical_object_new (void) @@ -46,3 +49,168 @@ ical_object_destroy (iCalObject *ico) g_free (ico); } + +GList * +set_list (char *str, char *sc) +{ + GList *list = 0; + char *s; + + for (s = strtok (str, sc); s; s = strtok (NULL, sc)) + list = g_list_prepend (list, g_strdup (s)); + + return list; +} + +#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) +#define str_val(obj) (char *) vObjectUStringZValue (obj) +#define has(obj,prop) (vo = isAPropertyOf (obj, prop)) + +/* FIXME: we need to load the recurrence properties */ +iCalObject * +ical_object_create_from_vobject (VObject *o, const char *object_name) +{ + time_t now = time (NULL); + iCalObject *ical; + VObject *vo; + VObjectIterator i; + + ical = g_new0 (iCalObject, 1); + + if (strcmp (object_name, VCEventProp) == 0) + ical->type = ICAL_EVENT; + else if (strcmp (object_name, VCTodoProp) == 0) + ical->type = ICAL_TODO; + else + return 0; + /* uid */ + if (has (o, VCUniqueStringProp)) + ical->uid = g_strdup (str_val (vo)); + + /* seq */ + if (has (o, VCSequenceProp)) + ical->seq = atoi (str_val (vo)); + else + ical->seq = 0; + + /* dtstart */ + if (has (o, VCDTstartProp)) + ical->dtstart = time_from_isodate (str_val (vo)); + else + ical->dtstart = 0; + + /* dtend */ + if (has (o, VCDTendProp)) + ical->dtend = time_from_isodate (str_val (vo)); + else + ical->dtend = 0; + + /* dcreated */ + if (has (o, VCDCreatedProp)) + ical->created = time_from_isodate (str_val (vo)); + + /* completed */ + if (has (o, VCCompletedProp)) + ical->completed = time_from_isodate (str_val (vo)); + + /* last_mod */ + if (has (o, VCLastModifiedProp)) + ical->last_mod = time_from_isodate (str_val (vo)); + else + ical->last_mod = now; + + /* exdate */ + if (has (o, VCExpDateProp)) + ical->exdate = set_list (str_val (vo), ","); + + /* description */ + if (has (o, VCDescriptionProp)) + ical->description = g_strdup (str_val (vo)); + + /* summary */ + if (has (o, VCSummaryProp)) + ical->summary = g_strdup (str_val (vo)); + else + ical->summary = g_strdup (""); + + /* status */ + if (has (o, VCStatusProp)) + ical->status = g_strdup (str_val (vo)); + else + ical->status = g_strdup ("NEEDS ACTION"); + + if (has (o, VCClassProp)) + ical->class = g_strdup (str_val (vo)); + else + ical->status = g_strdup ("PUBLIC"); + + /* categories */ + if (has (o, VCCategoriesProp)) + ical->categories = set_list (str_val (vo), ","); + + /* resources */ + if (has (o, VCResourcesProp)) + ical->resources = set_list (str_val (vo), ";"); + + /* priority */ + if (has (o, VCPriorityProp)) + ical->priority = atoi (str_val (vo)); + + /* tranparency */ + if (has (o, VCTranspProp)) + ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; + + /* related */ + if (has (o, VCRelatedToProp)) + ical->related = set_list (str_val (vo), ";"); + + /* attach */ + initPropIterator (&i, o); + while (moreIteration (&i)){ + vo = nextVObject (&i); + if (strcmp (vObjectName (vo), VCAttachProp) == 0) + ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); + } + + /* url */ + if (has (o, VCURLProp)) + ical->url = g_strdup (str_val (vo)); + + /* FIXME: dalarm */ + if (has (o, VCDAlarmProp)) + ; + + /* FIXME: aalarm */ + if (has (o, VCAAlarmProp)) + ; + + /* FIXME: palarm */ + if (has (o, VCPAlarmProp)) + ; + + /* FIXME: malarm */ + if (has (o, VCMAlarmProp)) + ; + + /* FIXME: rdate */ + if (has (o, VCRDateProp)) + ; + + /* FIXME: rrule */ + if (has (o, VCRRuleProp)) + ; + + return ical; +} + +void +ical_object_save (iCalObject *ical) +{ + VObject *o; + + if (ical->type == ICAL_EVENT) + o = newVObject (VCEventProp); + else + o = newVObject (VCTodoProp); +} + diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h index d5f6db0ae0..85f88dccd9 100644 --- a/calendar/cal-util/calobj.h +++ b/calendar/cal-util/calobj.h @@ -8,6 +8,7 @@ #define CALOBJ_H #include <libgnome/libgnome.h> +#include "versit/vcc.h" BEGIN_GNOME_DECLS @@ -89,14 +90,16 @@ typedef struct { char *url; time_t recurid; - /* VALARM objects are always inside another object, never alone */ - CalendarAlarm *alarm; + CalendarAlarm *dalarm; + CalendarAlarm *aalarm; } iCalObject; iCalObject *ical_new (char *comment, char *organizer, char *summary); iCalObject *ical_object_new (void); void ical_object_destroy (iCalObject *ico); +iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); END_GNOME_DECLS #endif + |