diff options
Diffstat (limited to 'calendar/pcs')
-rw-r--r-- | calendar/pcs/calobj.c | 55 | ||||
-rw-r--r-- | calendar/pcs/calobj.h | 47 |
2 files changed, 91 insertions, 11 deletions
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 01e90e3b50..ce0d330303 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -82,7 +82,8 @@ ical_new (char *comment, char *organizer, char *summary) ico = ical_object_new (); ico->comment = g_strdup (comment); - ico->organizer = g_strdup (organizer); + ico->organizer = g_new0 (iCalPerson, 1); + ico->organizer->addr = g_strdup (organizer); ico->summary = g_strdup (summary); ico->class = g_strdup ("PUBLIC"); ico->status = g_strdup ("NEEDS ACTION"); @@ -705,13 +706,23 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) /* Organizer */ if (has (o, VCOrgNameProp)){ - ical->organizer = g_strdup (str_val (vo)); + ical->organizer = g_new0 (iCalPerson, 1); + ical->organizer->addr = g_strdup (str_val (vo)); free (the_str); } /* related */ if (has (o, VCRelatedToProp)){ - ical->related = set_list (str_val (vo)); + char *str; + char *s; + iCalRelation *rel; + str = str_val (vo); + for (s = strtok (str, ";"); s; s = strtok (NULL, ";")) { + rel = g_new0 (iCalRelation, 1); + rel->uid = g_strdup (s); + rel->reltype = g_strdup ("PARENT"); + ical->related = g_list_prepend (ical->related, rel); + } free (the_str); } @@ -855,6 +866,36 @@ store_list (VObject *o, char *prop, GList *values) } static void +store_rel_list (VObject *o, char *prop, GList *values) +{ + GList *l; + int len; + char *result, *p; + + for (len = 0, l = values; l; l = l->next) + len += strlen (((iCalRelation*)(l->data))->uid) + 1; + + result = g_malloc (len); + + for (p = result, l = values; l; l = l->next) { + int len = strlen (((iCalRelation*)(l->data))->uid); + + strcpy (p, ((iCalRelation*)(l->data))->uid); + + if (l->next) { + p [len] = ';'; + p += len+1; + } else + p += len; + } + + *p = 0; + + addPropValue (o, prop, result); + g_free (result); +} + +static void store_date_list (VObject *o, char *prop, GList *values) { GList *l; @@ -1001,13 +1042,13 @@ ical_object_to_vobject (iCalObject *ical) /* transparency */ addPropValue (o, VCTranspProp, to_str (ical->transp)); - /* Owenr/organizer */ - if (ical->organizer) - addPropValue (o, VCOrgNameProp, ical->organizer); + /* Owner/organizer */ + if (ical->organizer && ical->organizer->addr) + addPropValue (o, VCOrgNameProp, ical->organizer->addr); /* related */ if (ical->related) - store_list (o, VCRelatedToProp, ical->related); + store_rel_list (o, VCRelatedToProp, ical->related); /* attach */ for (l = ical->attach; l; l = l->next) diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h index dabbc36c2d..38d9598298 100644 --- a/calendar/pcs/calobj.h +++ b/calendar/pcs/calobj.h @@ -31,7 +31,14 @@ typedef struct { int enabled; int count; enum AlarmUnit units; - char *data; + char *data; /* not used for iCalendar alarms */ + + /* the following pointers are used for iCalendar alarms */ + + char *attach; /* AUDIO, EMAIL, PROC */ + char *desc; /* DISPLAY, EMAIL, PROC */ + char *summary; /* EMAIL */ + char *attendee; /* EMAIL */ /* Does not get saved, internally used */ time_t offset; @@ -82,6 +89,11 @@ typedef enum { ICAL_TRANSPARENT } iCalTransp; +typedef struct { + char *uid; + char *reltype; +} iCalRelation; + typedef char NotYet; enum RecurType { @@ -119,6 +131,28 @@ typedef struct { int __count; } Recurrence; +/* + NOTE: iCalPerson is used for various property values which specify + people (e.g. ATTENDEE, ORGANIZER, etc. Not all fields are valid + under RFC 2445 for all property values, but iCalPerson can store + them anyway. Enforcing the RFC is a job for the parser. +*/ + +typedef struct { + char *addr; + char *name; + char *role; + char *partstat; + gboolean rsvp; + char *cutype; /* calendar user type */ + GList *member; /* group memberships */ + GList *deleg_to; + GList *deleg_from; + char *sent_by; + char *directory; + GList *altrep; /* list of char* URI's */ +} iCalPerson; + #define IS_INFINITE(r) (r->duration == 0) /* Flags to indicate what has changed in an object */ @@ -137,7 +171,7 @@ typedef struct { iCalType type; GList *attach; /* type: one or more URIs or binary data */ - GList *attendee; /* type: CAL-ADDRESS */ + GList *attendee; /* type: CAL-ADDRESS (list of iCalPerson) */ GList *categories; /* type: one or more TEXT */ char *class; @@ -145,15 +179,18 @@ typedef struct { time_t completed; time_t created; GList *contact; /* type: one or more TEXT */ + char *desc; time_t dtstamp; time_t dtstart; - time_t dtend; + time_t dtend; /* also duedate for todo's */ + gboolean date_only; /* set if the start/end times were + specified using dates, not times (internal use, not stored to disk) */ GList *exdate; /* type: one or more time_t's */ GList *exrule; /* type: one or more RECUR */ iCalGeo geo; time_t last_mod; char *location; - char *organizer; + iCalPerson *organizer; int percent; int priority; char *rstatus; /* request status for freebusy */ @@ -174,6 +211,8 @@ typedef struct { CalendarAlarm palarm; CalendarAlarm malarm; + GList *alarms; + Recurrence *recur; int new; |