From 8f6adf987eabf47bbe8266f6a0f29de1e7ce2e68 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 28 Mar 2000 08:05:08 +0000 Subject: Use ical_object_to_string(). 2000-03-27 Federico Mena Quintero * pcs/cal-backend.c (cal_backend_get_object): Use ical_object_to_string(). * cal-util/calobj.c (ical_object_to_string): Moved over from pcs/cal-backend.c (was string_from_ical_object). (get_calendar_base_vobject): Likewise, moved over from pcs/cal-backend.c. * cal-util/cal-util.c: Removed string_to_ical_object(); the correct function is in calobj.[ch], called ical_object_find_in_string(). Removed ical_object_to_string, since we now implement it in calobj.c. * cal-util/calobj.c: Removed ical_object_new_from_string(); see above. * idl/evolution-calendar.idl (CalObjInstance): Calendar object instances now contain only the UID for the object, not the whole string representation of the object. This allows clients to implement caching of objects if they wish. * pcs/cal.c (Cal_get_events_in_range): Likewise. * pcs/cal-backend.c (build_event_list): Likewise. * cal-client/cal-client.c (cal_client_get_events_in_range): Likewise. * cal-util/cal-util.h (CalObjInstance): Likewise. * cal-util/cal-util.c (cal_obj_instance_list_free): Likewise. (cal_obj_uid_list_free): Assert that the UIDs in the list are not NULL. * pcs/tlacuache.gnorba (repo_id): The calendar factory also supports the Unknown interface. svn path=/trunk/; revision=2211 --- calendar/ChangeLog | 39 +++++++++++++++ calendar/cal-client/cal-client.c | 1 - calendar/cal-util/cal-util.c | 76 +---------------------------- calendar/cal-util/cal-util.h | 6 +-- calendar/cal-util/calobj.c | 97 ++++++++++++++++++++++++++----------- calendar/cal-util/calobj.h | 3 +- calendar/idl/evolution-calendar.idl | 1 - calendar/pcs/cal-backend.c | 74 ++-------------------------- calendar/pcs/cal.c | 1 - calendar/pcs/tlacuache.gnorba | 2 +- po/ChangeLog | 4 ++ 11 files changed, 120 insertions(+), 184 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 63ea78ef10..ab9eace69b 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,42 @@ +2000-03-27 Federico Mena Quintero + + * pcs/cal-backend.c (cal_backend_get_object): Use + ical_object_to_string(). + + * cal-util/calobj.c (ical_object_to_string): Moved over from + pcs/cal-backend.c (was string_from_ical_object). + (get_calendar_base_vobject): Likewise, moved over from + pcs/cal-backend.c. + + * cal-util/cal-util.c: Removed string_to_ical_object(); the + correct function is in calobj.[ch], called + ical_object_find_in_string(). Removed ical_object_to_string, + since we now implement it in calobj.c. + + * cal-util/calobj.c: Removed ical_object_new_from_string(); see + above. + + * idl/evolution-calendar.idl (CalObjInstance): Calendar object + instances now contain only the UID for the object, not the whole + string representation of the object. This allows clients to + implement caching of objects if they wish. + + * pcs/cal.c (Cal_get_events_in_range): Likewise. + + * pcs/cal-backend.c (build_event_list): Likewise. + + * cal-client/cal-client.c (cal_client_get_events_in_range): + Likewise. + + * cal-util/cal-util.h (CalObjInstance): Likewise. + + * cal-util/cal-util.c (cal_obj_instance_list_free): Likewise. + (cal_obj_uid_list_free): Assert that the UIDs in the list are not + NULL. + + * pcs/tlacuache.gnorba (repo_id): The calendar factory also + supports the Unknown interface. + 2000-03-17 Federico Mena Quintero * gui/e-day-view.c: Fix includes. diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index ebf2b5cb31..168ec31d72 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -685,7 +685,6 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end) icoi = g_new (CalObjInstance, 1); icoi->uid = g_strdup (corba_icoi->uid); - icoi->calobj = g_strdup (corba_icoi->calobj); icoi->start = corba_icoi->start; icoi->end = corba_icoi->end; diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c index c49045c141..fc5a22dae9 100644 --- a/calendar/cal-util/cal-util.c +++ b/calendar/cal-util/cal-util.c @@ -43,10 +43,8 @@ cal_obj_instance_list_free (GList *list) g_assert (i != NULL); g_assert (i->uid != NULL); - g_assert (i->calobj != NULL); g_free (i->uid); - g_free (i->calobj); g_free (i); } @@ -68,80 +66,10 @@ cal_obj_uid_list_free (GList *list) char *uid; uid = l->data; + + g_assert (uid != NULL); g_free (uid); } g_list_free (list); } - - -#warning FIXME -- do we need a complete calendar here? should we use libical instead of libversit? can this be the same as string_from_ical_object in cal-backend.c? -char *ical_object_to_string (iCalObject *ico) -{ - VObject *vobj; - char *buf; - - vobj = ical_object_to_vobject (ico); - buf = writeMemVObject (NULL, NULL, vobj); - cleanStrTbl (); - return buf; -} - -iCalObject *string_to_ical_object (char *buffer) -{ - /* FIX ME */ -#if 0 - /* something */ - VObject *vcal; - vcal = Parse_MIME (buffer, strlen (buffer)); -#endif /* 0 */ - return NULL; -} - - -#if 0 -this is the one from calendar.c: - -/* - * calendar_string_from_object: - * - * Returns the iCalObject @object armored around a vCalendar - * object as a string. - */ -char * -calendar_string_from_object (iCalObject *object) -{ - Calendar *cal; - char *str; - - g_return_val_if_fail (object != NULL, NULL); - - cal = calendar_new ("Temporal",CALENDAR_INIT_NIL); - calendar_add_object (cal, object); - str = calendar_get_as_vcal_string (cal); - calendar_remove_object (cal, object); - - calendar_destroy (cal); - - return str; -} - -char * -calendar_get_as_vcal_string (Calendar *cal) -{ - VObject *vcal; - char *result; - - g_return_val_if_fail (cal != NULL, NULL); - - vcal = vcalendar_create_from_calendar (cal); - result = writeMemVObject (NULL, 0, vcal); - - cleanVObject (vcal); - cleanStrTbl (); - - return result; -} - -#endif /* 0 */ - diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index c5c3fcdb00..6adb7104a5 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -35,8 +35,7 @@ BEGIN_GNOME_DECLS * recurrence, or an alarm trigger of a `real' calendar object. */ typedef struct { - char *uid; /* Identifier for the object wrapped in calobj */ - char *calobj; /* String representation of calendar object */ + char *uid; /* UID of the object */ time_t start; /* Start time of instance */ time_t end; /* End time of instance */ } CalObjInstance; @@ -54,9 +53,6 @@ typedef enum { void cal_obj_uid_list_free (GList *list); -char *ical_object_to_string (iCalObject *ico); -iCalObject *string_to_ical_object (char *); - END_GNOME_DECLS #endif diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 2aa8b434a8..53be88f362 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -17,6 +17,11 @@ +/* VCalendar product ID */ +#define PRODID "-//Helix Code//NONSGML Evolution Calendar//EN" + + + static char * ical_gen_uid (void) { @@ -1493,35 +1498,6 @@ alarm_compute_offset (CalendarAlarm *a) return a->offset; } -iCalObject * -ical_object_new_from_string (const char *vcal_string) -{ - iCalObject *ical = NULL; - VObject *cal, *event; - VObjectIterator i; - const char *object_name; - - cal = Parse_MIME (vcal_string, strlen (vcal_string)); - - initPropIterator (&i, cal); - - while (moreIteration (&i)){ - event = nextVObject (&i); - - object_name = vObjectName (event); - - if (strcmp (object_name, VCEventProp) == 0){ - ical = ical_object_create_from_vobject (event, object_name); - break; - } - } - - cleanVObject (cal); - cleanStrTbl (); - - return ical; -} - /** * ical_object_find_in_string: * @uid: Unique identifier of the sought object. @@ -1593,3 +1569,66 @@ ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **i return status; } + +/* Creates a VObject with the base information of a calendar */ +static VObject * +get_calendar_base_vobject (void) +{ + VObject *vobj; + time_t now; + struct tm tm; + + /* We call localtime for the side effect of setting tzname */ + + now = time (NULL); + tm = *localtime (&now); + + vobj = newVObject (VCCalProp); + + addPropValue (vobj, VCProdIdProp, PRODID); + +#if defined (HAVE_TM_ZONE) + addPropValue (vobj, VCTimeZoneProp, tm.tm_zone); +#elif defined (HAVE_TZNAME) + addPropValue (vobj, VCTimeZoneProp, tzname[0]); +#endif + + /* Per the vCalendar spec, this must be "1.0" */ + addPropValue (vobj, VCVersionProp, "1.0"); + + return vobj; +} + +/** + * ical_object_to_string: + * @ico: A calendar object. + * + * Converts a vCalendar object to its string representation. It is wrapped + * inside a complete VCALENDAR object because other auxiliary information such + * as timezones may appear there. + * + * Return value: String representation of the object. + **/ +char * +ical_object_to_string (iCalObject *ico) +{ + VObject *vcalobj, *vobj; + char *buf, *gbuf; + + vcalobj = get_calendar_base_vobject (); + vobj = ical_object_to_vobject (ico); + addVObjectProp (vcalobj, vobj); + + buf = writeMemVObject (NULL, NULL, vcalobj); + + cleanVObject (vcalobj); + cleanStrTbl (); + + /* We have to g_strdup() it because libversit uses malloc()/realloc(), + * and we want clients to be able to use g_free(). Sigh. + */ + gbuf = g_strdup (buf); + free (buf); + + return gbuf; +} diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h index 421e0fc923..cb0e22f741 100644 --- a/calendar/cal-util/calobj.h +++ b/calendar/cal-util/calobj.h @@ -228,7 +228,6 @@ typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *); iCalObject *ical_new (char *comment, char *organizer, char *summary); iCalObject *ical_object_new (void); -iCalObject *ical_object_new_from_string (const char *vcalendar_string); void ical_object_destroy (iCalObject *ico); iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); VObject *ical_object_to_vobject (iCalObject *ical); @@ -248,6 +247,8 @@ typedef enum { CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico); +char *ical_object_to_string (iCalObject *ico); + /* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple * days on a monthly-by-pos recurrence. If no days are toggled, it returns -1. diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index bc4266c3ae..6de8fa57b4 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -45,7 +45,6 @@ module Calendar { */ struct CalObjInstance { CalObjUID uid; - CalObj calobj; Time_t start; Time_t end; }; diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 4406fac599..2d8807d08a 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -28,11 +28,6 @@ -/* VCalendar product ID */ -#define PRODID "-//Helix Code//NONSGML Tlacuache//EN" - - - /* Private part of the CalBackend structure */ typedef struct { /* URI where the calendar data is stored */ @@ -391,59 +386,6 @@ load_from_vobject (CalBackend *backend, VObject *vobject) } } -/* Creates a VObject with the base information of a calendar */ -static VObject * -get_calendar_base_vobject (CalBackend *backend) -{ - VObject *vobj; - time_t now; - struct tm tm; - - /* We call localtime for the side effect of setting tzname */ - - now = time (NULL); - tm = *localtime (&now); - - vobj = newVObject (VCCalProp); - - addPropValue (vobj, VCProdIdProp, PRODID); - -#if defined (HAVE_TM_ZONE) - addPropValue (vobj, VCTimeZoneProp, tm.tm_zone); -#elif defined (HAVE_TZNAME) - addPropValue (vobj, VCTimeZoneProp, tzname[0]); -#endif - - /* Per the vCalendar spec, this must be "1.0" */ - addPropValue (vobj, VCVersionProp, "1.0"); - - return vobj; -} - -/* Builds the string representation of a complete calendar object wrapping the - * specified object --- a complete calendar is needed because of the timezone - * information. The return value must be freed with free(), not g_free(), since - * the internal implementation calls writeMemVObject() from libversit, which - * uses realloc() to allocate this string. - */ -static char * -string_from_ical_object (CalBackend *backend, iCalObject *ico) -{ - VObject *vcalobj, *vobj; - char *buf; - - vcalobj = get_calendar_base_vobject (backend); - vobj = ical_object_to_vobject (ico); - addVObjectProp (vcalobj, vobj); - - buf = writeMemVObject (NULL, NULL, vcalobj); - - cleanVObject (vcalobj); - cleanStrTbl (); - - return buf; -} - /** @@ -775,7 +717,7 @@ cal_backend_get_object (CalBackend *backend, const char *uid) { CalBackendPrivate *priv; iCalObject *ico; - char *buf, *retval; + char *buf; g_return_val_if_fail (backend != NULL, NULL); g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); @@ -792,17 +734,8 @@ cal_backend_get_object (CalBackend *backend, const char *uid) if (!ico) return NULL; - /* string_from_ical_object() uses writeMemVObject(), which uses - * realloc(), so we must free its result with free() instead of - * g_free(). We take a copy of the result so that callers can use the - * normal glib function to free it. - */ - - buf = string_from_ical_object (backend, ico); - retval = g_strdup (buf); - free (buf); - - return retval; + buf = ical_object_to_string (ico); + return buf; } struct get_uids_closure { @@ -893,7 +826,6 @@ build_event_list (iCalObject *ico, time_t start, time_t end, void *data) g_assert (ico->uid != NULL); icoi->uid = g_strdup (ico->uid); - icoi->calobj = string_from_ical_object (c->backend, ico); icoi->start = start; icoi->end = end; diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 8263bfe491..0dd3e81649 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -294,7 +294,6 @@ Cal_get_events_in_range (PortableServer_Servant servant, corba_icoi = &seq->_buffer[i]; corba_icoi->uid = CORBA_string_dup (icoi->uid); - corba_icoi->calobj = CORBA_string_dup (icoi->calobj); corba_icoi->start = icoi->start; corba_icoi->end = icoi->end; } diff --git a/calendar/pcs/tlacuache.gnorba b/calendar/pcs/tlacuache.gnorba index da0f4ed552..8f600305d7 100644 --- a/calendar/pcs/tlacuache.gnorba +++ b/calendar/pcs/tlacuache.gnorba @@ -1,5 +1,5 @@ [evolution:calendar-factory] type=exe -repo_id=IDL:Evolution/Calendar/CalFactory:1.0 +repo_id=IDL:Evolution/Calendar/CalFactory:1.0 IDL:Bonobo/Unknown:1.0 description=Calendar factory for the Personal Calendar Server location_info=tlacuache diff --git a/po/ChangeLog b/po/ChangeLog index 7d7a252a7c..2e9fd68500 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2000-03-27 Federico Mena Quintero + + * POTFILES.in: Removed the calendar files for now. + 1998-07-23 Nuno Ferreira * pt.po: Added Portuguese translation. -- cgit v1.2.3