diff options
author | Miguel de Icaza <miguel@gnu.org> | 1999-07-28 16:41:12 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1999-07-28 16:41:12 +0800 |
commit | e49e9cc1755266dade86ce33662ceff466f5ca07 (patch) | |
tree | 9c26f2dea9902aef6d691d70ddeee07293cba176 /calendar/calendar.c | |
parent | 81207158058c5f5e4315e3b66f92a46aec64e5ae (diff) | |
download | gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar.gz gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar.bz2 gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar.lz gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar.xz gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.tar.zst gsoc2013-evolution-e49e9cc1755266dade86ce33662ceff466f5ca07.zip |
New file. Implements PalmPilot syncronization with the Gnome Calendar.
1999-07-28 Miguel de Icaza <miguel@gnu.org>
* calendar-pilot-sync.c: New file. Implements PalmPilot
syncronization with the Gnome Calendar.
1999-07-27 Miguel de Icaza <miguel@gnu.org>
* calobj.c (ical_object_new_from_string): New function. Creates
an iCalObject from a vCalendar string that is supposed to contain
only one vEvent.
* calendar.c:
(calendar_save): Split this routine in two.
* gnome-cal.c (gnome_calendar_new): Create the corba server here.
* main.c: Include gnorba.h, and corba-cal-factory.h here
(close_cmd): Kill the calendar server on shutdown.
* calobj.c (load_recur_yearly_day): Added a fixme comment. WE
need to handle intervals in the years.
* calendar.c (calendar_object_find_in_list, calendar_object_find,
calendar_object_find_todo, calendar_object_find_event): New
functions for looking up information.
* main.c (gnome_calendar_locate): New function.
* corba-cal.c (calendar_create_object): New file. Implements the
corba server.
* calendar.c (calendar_object_changed): Flag pilot-status as changed.
* calobj.c (ical_object_to_vobject): Save pilot information for syncing.
(ical_object_create_from_vobject): Load syncing information for
pilot. Do it in a way compatible with KOrganizer.
1999-07-26 Miguel de Icaza <miguel@gnu.org>
* calobj.c (ical_object_create_from_vobject): Generate unique IDs
on Vevents we load that lack it. WE need this for the old
gnome calendar generated files (ie, before now :-).
svn path=/trunk/; revision=1038
Diffstat (limited to 'calendar/calendar.c')
-rw-r--r-- | calendar/calendar.c | 139 |
1 files changed, 132 insertions, 7 deletions
diff --git a/calendar/calendar.c b/calendar/calendar.c index ff7ae8ee5d..b67f875fdc 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -4,7 +4,7 @@ * This keeps track of a given calendar. Eventually this will abtract everything * related to getting calendars/saving calendars locally or to a remote Calendar Service * - * Copyright (C) 1998 the Free Software Foundation + * Copyright (C) 1998, 1999 the Free Software Foundation * * Authors: * Miguel de Icaza (miguel@gnu.org) @@ -323,18 +323,14 @@ calendar_load (Calendar *cal, char *fname) return NULL; } -void -calendar_save (Calendar *cal, char *fname) +static VObject * +vcalendar_create_from_calendar (Calendar *cal) { VObject *vcal; GList *l; time_t now = time (NULL); - struct stat s; struct tm *tm; - if (fname == NULL) - fname = cal->filename; - /* WE call localtime for the side effect of setting tzname */ tm = localtime (&now); @@ -366,6 +362,19 @@ calendar_save (Calendar *cal, char *fname) addVObjectProp (vcal, obj); } + return vcal; +} + +void +calendar_save (Calendar *cal, char *fname) +{ + VObject *vcal; + struct stat s; + + if (fname == NULL) + fname = cal->filename; + + vcal = vcalendar_create_from_calendar (cal); if (g_file_exists (fname)){ char *backup_name = g_strconcat (fname, "~", NULL); @@ -375,6 +384,7 @@ calendar_save (Calendar *cal, char *fname) rename (fname, backup_name); g_free (backup_name); } + writeVObjectToFile (fname, vcal); stat (fname, &s); @@ -384,6 +394,23 @@ calendar_save (Calendar *cal, char *fname) cleanStrTbl (); } +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; +} + static gint calendar_object_compare_by_start (gconstpointer a, gconstpointer b) { @@ -440,6 +467,8 @@ calendar_object_changed (Calendar *cal, iCalObject *obj, int flags) while (alarm_kill (obj)) ; ical_object_try_alarms (obj); + + obj->pilot_status = ICAL_PILOT_SYNC_MOD; } static void @@ -466,3 +495,99 @@ calendar_init_alarms (Calendar *cal) alarm_add (&day_change_alarm, calendar_day_change, cal); } +static iCalObject * +calendar_object_find_in_list (Calendar *cal, GList *list, const char *uid) +{ + GList *l; + + for (l = list; l; l = l->next){ + iCalObject *obj = l->data; + + if (strcmp (obj->uid, uid) == 0) + return obj; + } + + return NULL; +} + +iCalObject * +calendar_object_find_event (Calendar *cal, const char *uid) +{ + g_return_val_if_fail (cal != NULL, NULL); + g_return_val_if_fail (uid != NULL, NULL); + + return calendar_object_find_in_list (cal, cal->events, uid); +} + +iCalObject * +calendar_object_find_todo (Calendar *cal, const char *uid) +{ + g_return_val_if_fail (cal != NULL, NULL); + g_return_val_if_fail (uid != NULL, NULL); + + return calendar_object_find_in_list (cal, cal->todo, uid); +} + +iCalObject * +calendar_object_find (Calendar *cal, const char *uid) +{ + iCalObject *obj; + + g_return_val_if_fail (cal != NULL, NULL); + g_return_val_if_fail (uid != NULL, NULL); + + obj = calendar_object_find_in_list (cal, cal->todo, uid); + + if (obj == NULL) + obj = calendar_object_find_in_list (cal, cal->events, uid); + + return obj; +} + +iCalObject * +calendar_object_find_by_pilot (Calendar *cal, int pilot_id) +{ + GList *l; + + g_return_val_if_fail (cal != NULL, NULL); + + for (l = cal->events; l; l = l->next){ + iCalObject *obj = l->data; + + if (obj->pilot_id == pilot_id) + return obj; + } + + for (l = cal->todo; l; l = l->next){ + iCalObject *obj = l->data; + + if (obj->pilot_id == pilot_id) + return obj; + } + + return NULL; +} + +/* + * 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_add_object (cal, object); + str = calendar_get_as_vcal_string (cal); + calendar_remove_object (cal, object); + + calendar_destroy (cal); + + return str; +} |