[evolution-patches] 56416



This was exposed fixing another bug where the backends wouldn't be told
the timezones they needed.

-JP
-- 
JP Rosevear <jpr ximian com>
Novell, Inc.
? 56111.patch
? backend-debug.patch
? contact-zone.patch
? parse.patch
? libecal/old.c
? libical/compile.patch
? libical/src/libicalss/icalssyacc.output
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.235
diff -u -r1.235 ChangeLog
--- ChangeLog	2 Apr 2004 12:14:23 -0000	1.235
+++ ChangeLog	3 Apr 2004 05:25:17 -0000
@@ -1,3 +1,17 @@
+2004-04-03  JP Rosevear  <jpr ximian com>
+
+	Fixes #56416
+	
+	* backends/contacts/e-cal-backend-contacts.c
+	(e_cal_backend_contacts_get_timezone): implement
+	(e_cal_backend_contacts_add_timezone): ditto
+	(e_cal_backend_contacts_set_default_timezone): ditto
+	(free_zone): free a timezone
+	(e_cal_backend_contacts_finalize): destroy the zones hash table
+	(e_cal_backend_contacts_class_init): add new method
+	implementations
+	(e_cal_backend_contacts_init): set up zones hash table
+
 2004-04-02  Rodrigo Moya <rodrigo ximian com>
 
 	Fixes #55719
Index: backends/contacts/e-cal-backend-contacts.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/contacts/e-cal-backend-contacts.c,v
retrieving revision 1.8
diff -u -r1.8 e-cal-backend-contacts.c
--- backends/contacts/e-cal-backend-contacts.c	31 Mar 2004 15:56:22 -0000	1.8
+++ backends/contacts/e-cal-backend-contacts.c	3 Apr 2004 05:25:17 -0000
@@ -53,6 +53,7 @@
         EBookView    *book_view;
         GHashTable   *tracked_contacts;   /* UID -> ContactRecord */
 
+	GHashTable *zones;	
 	icaltimezone *default_zone;
 };
 
@@ -729,6 +730,84 @@
 }
 
 static ECalBackendSyncStatus
+e_cal_backend_contacts_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object)
+{
+	ECalBackendContacts *cbcontacts;
+	ECalBackendContactsPrivate *priv;
+	icaltimezone *zone;
+	icalcomponent *icalcomp;
+
+	cbcontacts = E_CAL_BACKEND_CONTACTS (backend);
+	priv = cbcontacts->priv;
+
+	g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
+
+	zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
+	if (!zone)
+		return GNOME_Evolution_Calendar_ObjectNotFound;
+
+	icalcomp = icaltimezone_get_component (zone);
+	if (!icalcomp)
+		return GNOME_Evolution_Calendar_InvalidObject;
+
+	*object = g_strdup (icalcomponent_as_ical_string (icalcomp));
+
+	return GNOME_Evolution_Calendar_Success;
+}
+
+/* Add_timezone handler for the file backend */
+static ECalBackendSyncStatus
+e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
+{
+	ECalBackendContacts *cbcontacts;
+	ECalBackendContactsPrivate *priv;
+	icalcomponent *tz_comp;
+
+	cbcontacts = (ECalBackendContacts *) backend;
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_CONTACTS (cbcontacts), GNOME_Evolution_Calendar_OtherError);
+	g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
+
+	priv = cbcontacts->priv;
+
+	tz_comp = icalparser_parse_string (tzobj);
+	if (!tz_comp)
+		return GNOME_Evolution_Calendar_InvalidObject;
+
+	if (icalcomponent_isa (tz_comp) == ICAL_VTIMEZONE_COMPONENT) {
+		icaltimezone *zone;
+		char *tzid;
+		
+		zone = icaltimezone_new ();
+		icaltimezone_set_component (zone, tz_comp);
+		tzid = icaltimezone_get_tzid (zone);
+		
+		g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
+	}	
+
+	return GNOME_Evolution_Calendar_Success;
+}
+
+static ECalBackendSyncStatus
+e_cal_backend_contacts_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+{
+	ECalBackendContacts *cbcontacts;
+	ECalBackendContactsPrivate *priv;
+
+	cbcontacts = E_CAL_BACKEND_CONTACTS (backend);
+	priv = cbcontacts->priv;
+
+	priv->default_zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
+	if (priv->default_zone) {
+		priv->default_zone = icaltimezone_get_utc_timezone ();
+
+		return GNOME_Evolution_Calendar_ObjectNotFound;
+	}
+	
+	return GNOME_Evolution_Calendar_Success;
+}
+
+static ECalBackendSyncStatus
 e_cal_backend_contacts_get_object_list (ECalBackendSync *backend, EDataCal *cal,
 					const char *sexp_string, GList **objects)
 {
@@ -794,6 +873,12 @@
 /***********************************************************************************
  */
 
+static void
+free_zone (gpointer data)
+{
+	icaltimezone_free (data, TRUE);
+}
+
 /* Finalize handler for the contacts backend */
 static void
 e_cal_backend_contacts_finalize (GObject *object)
@@ -808,6 +893,7 @@
 	priv = cbc->priv;
 
         g_hash_table_destroy (priv->tracked_contacts);
+        g_hash_table_destroy (priv->zones);
         
 	g_free (priv);
 	cbc->priv = NULL;
@@ -831,6 +917,7 @@
         priv->tracked_contacts = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                         g_free, (GDestroyNotify)contact_record_free);
         
+	priv->zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_zone);
 	priv->default_zone = icaltimezone_get_utc_timezone ();
         
 	cbc->priv = priv;
@@ -865,6 +952,9 @@
  	sync_class->get_default_object_sync = e_cal_backend_contacts_get_default_object;
 	sync_class->get_object_sync = e_cal_backend_contacts_get_object;
 	sync_class->get_object_list_sync = e_cal_backend_contacts_get_object_list;
+	sync_class->get_timezone_sync = e_cal_backend_contacts_get_timezone;
+	sync_class->add_timezone_sync = e_cal_backend_contacts_add_timezone;
+	sync_class->set_default_timezone_sync = e_cal_backend_contacts_set_default_timezone;
 	sync_class->get_freebusy_sync = e_cal_backend_contacts_get_free_busy;
 	sync_class->get_changes_sync = e_cal_backend_contacts_get_changes;
 	backend_class->is_loaded = e_cal_backend_contacts_is_loaded;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]