aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/calendar.c
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-07-29 12:25:08 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-07-29 12:25:08 +0800
commitcabedf4da95562f8372a543840748ea43dff2a91 (patch)
tree9d15220864e12083fa4747a775400446cd0502d3 /calendar/calendar.c
parent094deb7bca96f1dcf97952b93a7c4745cd799ebc (diff)
downloadgsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.gz
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.bz2
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.lz
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.xz
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.zst
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.zip
Make the code not take arguments (sync_cal_to_pilot): Nice event update
1999-07-28 Miguel de Icaza <miguel@gnu.org> * calendar-pilot-sync.c: Make the code not take arguments (sync_cal_to_pilot): Nice event update information * calendar.c (calendar_new): Add Event UID hash table. (calendar_add_object): Add events to the hash table here. (calendar_remove_object): Remove events here. (calendar_object_find_event): Use the hash table here. * main.c (save_calendar_cmd): The object is already destroyed by gnome_dialog_run. * calendar-pilot-sync.c (sync_object_to_pilot): Do not turn archived bit on. svn path=/trunk/; revision=1041
Diffstat (limited to 'calendar/calendar.c')
-rw-r--r--calendar/calendar.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 30e4e0168c..339995cb92 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -38,6 +38,8 @@ calendar_new (char *title)
cal->title = g_strdup (title);
+ cal->event_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
calendar_init_alarms (cal);
return cal;
@@ -93,9 +95,14 @@ ical_object_try_alarms (iCalObject *obj)
void
calendar_add_object (Calendar *cal, iCalObject *obj)
{
+ g_return_if_fail (cal != NULL);
+ g_return_if_fail (obj != NULL);
+ g_return_if_fail (obj->uid != NULL);
+
obj->new = 0;
switch (obj->type){
case ICAL_EVENT:
+ g_hash_table_insert (cal->event_hash, obj->uid, obj);
cal->events = g_list_prepend (cal->events, obj);
ical_object_try_alarms (obj);
#ifdef DEBUGGING_MAIL_ALARM
@@ -133,6 +140,7 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_remove (cal->events, obj);
+ g_hash_table_remove (cal->event_hash, obj->uid);
break;
case ICAL_TODO:
@@ -161,6 +169,8 @@ calendar_destroy (Calendar *cal)
g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
g_list_free (cal->journal);
+ g_hash_table_destroy (cal->event_hash);
+
if (cal->title)
g_free (cal->title);
if (cal->filename)
@@ -169,17 +179,6 @@ calendar_destroy (Calendar *cal)
g_free (cal);
}
-static char *
-ice (time_t t)
-{
- static char buffer [100];
- struct tm *tm;
-
- tm = localtime (&t);
- sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
- return buffer;
-}
-
void
calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
{
@@ -544,7 +543,7 @@ 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);
+ return g_hash_table_lookup (cal->event_hash, uid);
}
iCalObject *