Fixes #332911
authorChenthill Palanisamy <pchen@src.gnome.org>
Mon, 10 Jul 2006 10:35:53 +0000 (10:35 +0000)
committerChenthill Palanisamy <pchen@src.gnome.org>
Mon, 10 Jul 2006 10:35:53 +0000 (10:35 +0000)
15 files changed:
calendar/ChangeLog
calendar/backends/caldav/e-cal-backend-caldav.c
calendar/backends/contacts/e-cal-backend-contacts.c
calendar/backends/file/e-cal-backend-file.c
calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
calendar/backends/groupwise/e-cal-backend-groupwise.c
calendar/backends/http/e-cal-backend-http.c
calendar/backends/weather/e-cal-backend-weather.c
calendar/idl/Evolution-DataServer-Calendar.idl
calendar/libecal/e-cal.c
calendar/libedata-cal/e-cal-backend-sync.c
calendar/libedata-cal/e-cal-backend-sync.h
calendar/libedata-cal/e-cal-backend.c
calendar/libedata-cal/e-cal-backend.h
calendar/libedata-cal/e-data-cal.c

index 8fe3d6b..f8549db 100644 (file)
@@ -1,3 +1,46 @@
+2006-07-10  Chenthill Palanisamy  <pchenthill@novell.com>
+       Fixes #332911
+       * backends/caldav/e-cal-backend-caldav.c:
+       (caldav_set_default_zone), (e_cal_backend_caldav_class_init):
+       * backends/contacts/e-cal-backend-contacts.c:
+       (e_cal_backend_contacts_open),
+       (e_cal_backend_contacts_set_default_zone),
+       (e_cal_backend_contacts_finalize),
+       (e_cal_backend_contacts_class_init):
+       * backends/file/e-cal-backend-file.c:
+       (e_cal_backend_file_finalize), (e_cal_backend_file_open),
+       (e_cal_backend_file_set_default_zone),
+       (e_cal_backend_file_class_init):
+       * backends/groupwise/e-cal-backend-groupwise.c:
+       (connect_to_server), (e_cal_backend_groupwise_finalize),
+       (e_cal_backend_groupwise_open),
+       (e_cal_backend_groupwise_set_default_zone),
+       (e_cal_backend_groupwise_class_init):
+       * backends/http/e-cal-backend-http.c:
+       (e_cal_backend_http_finalize), (e_cal_backend_http_open),
+       (e_cal_backend_http_set_default_zone),
+       (e_cal_backend_http_class_init):
+       * backends/weather/e-cal-backend-weather.c:
+       (e_cal_backend_weather_open),
+       (e_cal_backend_weather_set_default_zone),
+       (e_cal_backend_weather_finalize),
+       (e_cal_backend_weather_class_init):
+       * idl/Evolution-DataServer-Calendar.idl:
+       * libedata-cal/e-cal-backend-sync.c:
+       (e_cal_backend_sync_set_default_zone),
+       (_e_cal_backend_set_default_zone), (e_cal_backend_sync_class_init):
+       * libedata-cal/e-cal-backend-sync.h:
+       * libedata-cal/e-cal-backend.c: (e_cal_backend_set_default_zone):
+       * libedata-cal/e-cal-backend.h:
+       * libedata-cal/e-data-cal.c: (impl_Cal_setDefaultTimezone): Added
+       e_cal_backend_set_zone as a replacement for e_cal_backend_set_timezone.
+       Replaced the same for all backends.     
+       * backends/e-cal-backend-groupwise-utils.c (set_properties_from_cal_component):
+       check if the dtstart is date using the is_date parameter.
+       * libecal/e-cal.c: (e_cal_set_default_timezone): Pass the timezone object
+       as a string instead of the tzid.
 2006-07-10  Harish Krishnaswamy  <kharish@novell.com>
 
        * libedata-cal/e-cal-backend-cache.c:
index 3f7a607..3a2fa16 100644 (file)
@@ -2171,9 +2171,9 @@ caldav_add_timezone (ECalBackendSync *backend,
 }
 
 static ECalBackendSyncStatus
-caldav_set_default_timezone (ECalBackendSync *backend, 
+caldav_set_default_zone (ECalBackendSync *backend, 
                             EDataCal        *cal,
-                            const char      *tzid)
+                            const char      *tzobj)
 {
        /* FIXME: implement me! */
        g_warning ("function not implemented %s", G_STRFUNC);
@@ -2536,7 +2536,7 @@ e_cal_backend_caldav_class_init (ECalBackendCalDAVClass *class)
        sync_class->get_object_list_sync      = caldav_get_object_list;
        sync_class->get_timezone_sync         = caldav_get_timezone;
        sync_class->add_timezone_sync         = caldav_add_timezone;
-       sync_class->set_default_timezone_sync = caldav_set_default_timezone;
+       sync_class->set_default_zone_sync = caldav_set_default_zone;
        sync_class->get_freebusy_sync         = caldav_get_free_busy;
        sync_class->get_changes_sync          = caldav_get_changes;
 
index 0cd6a0a..88bfa56 100644 (file)
@@ -732,8 +732,15 @@ e_cal_backend_contacts_open (ECalBackendSync *backend, EDataCal *cal,
 
         if (priv->addressbook_loaded)
                 return GNOME_Evolution_Calendar_Success;
+               
+        if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ()) {
+               icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
+               icaltimezone *zone = icaltimezone_new ();
+
+               icaltimezone_set_component (zone, icalcomponent_new_clone (icalcomp));
 
-        e_cal_backend_contacts_add_timezone (backend, cal, (const char *) icaltimezone_get_tzid (priv->default_zone));
+               g_hash_table_insert (priv->zones, g_strdup (icaltimezone_get_tzid (zone)), zone);
+       }
 
        /* Create address books for existing sources */
         for (i = e_source_list_peek_groups (priv->addressbook_sources); i; i = i->next) {
@@ -825,21 +832,33 @@ e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, co
 }
 
 static ECalBackendSyncStatus
-e_cal_backend_contacts_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+e_cal_backend_contacts_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
 {
+       icalcomponent *tz_comp;
        ECalBackendContacts *cbcontacts;
        ECalBackendContactsPrivate *priv;
+       icaltimezone *zone;
+
+       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);
 
-       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 ();
+       tz_comp = icalparser_parse_string (tzobj);
+       if (!tz_comp)
+               return GNOME_Evolution_Calendar_InvalidObject;
+
+       zone = icaltimezone_new ();
+       icaltimezone_set_component (zone, tz_comp);
+
+       if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ())
+               icaltimezone_free (priv->default_zone, 1);
+
+       /* Set the default timezone to it. */
+       priv->default_zone = zone;
 
-               return GNOME_Evolution_Calendar_ObjectNotFound;
-       }
-       
        return GNOME_Evolution_Calendar_Success;
 }
 
@@ -928,6 +947,11 @@ e_cal_backend_contacts_finalize (GObject *object)
        cbc = E_CAL_BACKEND_CONTACTS (object);
        priv = cbc->priv;
 
+       if (priv->default_zone) {
+               icaltimezone_free (priv->default_zone, 1);
+               priv->default_zone = NULL;
+       }
+
        g_hash_table_destroy (priv->addressbooks);
         g_hash_table_destroy (priv->tracked_contacts);
         g_hash_table_destroy (priv->zones);
@@ -1006,7 +1030,7 @@ e_cal_backend_contacts_class_init (ECalBackendContactsClass *class)
        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->set_default_zone_sync = e_cal_backend_contacts_set_default_zone;
        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;
index 8eac0d9..193d2f6 100644 (file)
@@ -300,6 +300,11 @@ e_cal_backend_file_finalize (GObject *object)
                priv->uri = NULL;
        }
 
+       if (priv->default_zone) {
+               icaltimezone_free (priv->default_zone, 1);
+               priv->default_zone = NULL;
+       }
+
        g_free (priv);
        cbfile->priv = NULL;
 
@@ -916,8 +921,14 @@ e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
                        status = create_cal (cbfile, str_uri);
        }
 
-       if (status == GNOME_Evolution_Calendar_Success)
-               e_cal_backend_file_add_timezone (backend, cal, (const char *) icaltimezone_get_tzid (priv->default_zone));
+       if (status == GNOME_Evolution_Calendar_Success) {
+               if (priv->default_zone) {
+                       icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
+
+                       icalcomponent_add_component (priv->icalcomp, icalcomponent_new_clone (icalcomp));
+                       save (cbfile);
+               }
+       }
 
        g_free (str_uri);
 
@@ -1193,18 +1204,33 @@ e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
        return GNOME_Evolution_Calendar_Success;
 }
 
-
 static ECalBackendSyncStatus
-e_cal_backend_file_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+e_cal_backend_file_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
 {
+       icalcomponent *tz_comp;
        ECalBackendFile *cbfile;
        ECalBackendFilePrivate *priv;
+       icaltimezone *zone;
+
+       cbfile = (ECalBackendFile *) backend;
+
+       g_return_val_if_fail (E_IS_CAL_BACKEND_FILE (cbfile), GNOME_Evolution_Calendar_OtherError);
+       g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
 
-       cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
 
+       tz_comp = icalparser_parse_string (tzobj);
+       if (!tz_comp)
+               return GNOME_Evolution_Calendar_InvalidObject;
+
+       zone = icaltimezone_new ();
+       icaltimezone_set_component (zone, tz_comp);
+
+       if (priv->default_zone != icaltimezone_get_utc_timezone ())
+               icaltimezone_free (priv->default_zone, 1);
+
        /* Set the default timezone to it. */
-       priv->default_zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+       priv->default_zone = zone;
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -2587,7 +2613,7 @@ e_cal_backend_file_class_init (ECalBackendFileClass *class)
        sync_class->get_attachment_list_sync = e_cal_backend_file_get_attachment_list;
        sync_class->get_timezone_sync = e_cal_backend_file_get_timezone;
        sync_class->add_timezone_sync = e_cal_backend_file_add_timezone;
-       sync_class->set_default_timezone_sync = e_cal_backend_file_set_default_timezone;
+       sync_class->set_default_zone_sync = e_cal_backend_file_set_default_zone;
        sync_class->get_freebusy_sync = e_cal_backend_file_get_free_busy;
        sync_class->get_changes_sync = e_cal_backend_file_get_changes;
 
index de0edfb..3debd87 100644 (file)
@@ -631,7 +631,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
        }
        
        /* all day event */
-       if (!dt.tzid && e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT)
+       if (dt.value->is_date && e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT)
                e_gw_item_set_is_allday_event (item, TRUE);
        
        /* creation date */
index 87e5c82..17ec143 100644 (file)
@@ -920,8 +920,7 @@ connect_to_server (ECalBackendGroupwise *cbgw)
                        }
 
                        e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
-                       e_cal_backend_groupwise_add_timezone (E_CAL_BACKEND_SYNC (cbgw), NULL, (const char *) icaltimezone_get_tzid (priv->default_zone));
-
+       
                        /* spawn a new thread for opening the calendar */
                        thread = g_thread_create ((GThreadFunc) cache_init, cbgw, FALSE, &error);
                        if (!thread) {
@@ -1018,6 +1017,11 @@ e_cal_backend_groupwise_finalize (GObject *object)
                priv->timeout_id = 0;
        }
 
+       if (priv->default_zone) {
+               icaltimezone_free (priv->default_zone, 1);
+               priv->default_zone = NULL;
+       }
+
        g_free (priv);
        cbgw->priv = NULL;
 
@@ -1169,7 +1173,6 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean
                }
                
                e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
-               e_cal_backend_groupwise_add_timezone (backend, cal, (const char *) icaltimezone_get_tzid (priv->default_zone));
 
                g_mutex_unlock (priv->mutex);   
                return GNOME_Evolution_Calendar_Success;
@@ -1424,16 +1427,32 @@ e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, c
 }
 
 static ECalBackendSyncStatus
-e_cal_backend_groupwise_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+e_cal_backend_groupwise_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
 {
+       icalcomponent *tz_comp;
        ECalBackendGroupwise *cbgw;
-        ECalBackendGroupwisePrivate *priv;
+       ECalBackendGroupwisePrivate *priv;
+       icaltimezone *zone;
+
+       cbgw = (ECalBackendGroupwise *) backend;
+
+       g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_OtherError);
+       g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
+
+       priv = cbgw->priv;
+
+       tz_comp = icalparser_parse_string (tzobj);
+       if (!tz_comp)
+               return GNOME_Evolution_Calendar_InvalidObject;
+
+       zone = icaltimezone_new ();
+       icaltimezone_set_component (zone, tz_comp);
+
+       if (priv->default_zone)
+               icaltimezone_free (priv->default_zone, 1);
 
-       cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-        priv = cbgw->priv;
-       
        /* Set the default timezone to it. */
-       priv->default_zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+       priv->default_zone = zone;
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -2661,7 +2680,7 @@ e_cal_backend_groupwise_class_init (ECalBackendGroupwiseClass *class)
        sync_class->get_attachment_list_sync = e_cal_backend_groupwise_get_attachment_list;
        sync_class->get_timezone_sync = e_cal_backend_groupwise_get_timezone;
        sync_class->add_timezone_sync = e_cal_backend_groupwise_add_timezone;
-       sync_class->set_default_timezone_sync = e_cal_backend_groupwise_set_default_timezone;
+       sync_class->set_default_zone_sync = e_cal_backend_groupwise_set_default_zone;
        sync_class->get_freebusy_sync = e_cal_backend_groupwise_get_free_busy;
        sync_class->get_changes_sync = e_cal_backend_groupwise_get_changes;
 
index 15623a9..6e22f69 100644 (file)
@@ -123,6 +123,12 @@ e_cal_backend_http_finalize (GObject *object)
                priv->uri = NULL;
        }
 
+       if (priv->default_zone) {
+               icaltimezone_free (priv->default_zone, 1);
+               priv->default_zone = NULL;
+       }
+       
+
        if (priv->soup_session) {
                soup_session_abort (priv->soup_session);
                g_object_unref (priv->soup_session);
@@ -523,7 +529,6 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
                
                if (priv->default_zone) {
                        e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
-                       e_cal_backend_http_add_timezone (backend, cal, (const char *) icaltimezone_get_tzid (priv->default_zone));
                }
 
                if (priv->mode == CAL_MODE_LOCAL) 
@@ -741,17 +746,34 @@ e_cal_backend_http_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
 }
 
 static ECalBackendSyncStatus
-e_cal_backend_http_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+e_cal_backend_http_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
 {
+       icalcomponent *tz_comp;
        ECalBackendHttp *cbhttp;
        ECalBackendHttpPrivate *priv;
+       icaltimezone *zone;
+
+       cbhttp = (ECalBackendHttp *) backend;
+
+       g_return_val_if_fail (E_IS_CAL_BACKEND_HTTP (cbhttp), GNOME_Evolution_Calendar_OtherError);
+       g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
 
-       cbhttp = E_CAL_BACKEND_HTTP (backend);
        priv = cbhttp->priv;
-       
+
+       tz_comp = icalparser_parse_string (tzobj);
+       if (!tz_comp)
+               return GNOME_Evolution_Calendar_InvalidObject;
+
+
+       zone = icaltimezone_new ();
+       icaltimezone_set_component (zone, tz_comp);
+
+       if (priv->default_zone)
+               icaltimezone_free (priv->default_zone, 1);
+
        /* Set the default timezone to it. */
-       priv->default_zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
-       
+       priv->default_zone = zone;
+
        return GNOME_Evolution_Calendar_Success;
 }
 
@@ -1204,7 +1226,7 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
        sync_class->get_object_list_sync = e_cal_backend_http_get_object_list;
        sync_class->get_timezone_sync = e_cal_backend_http_get_timezone;
        sync_class->add_timezone_sync = e_cal_backend_http_add_timezone;
-       sync_class->set_default_timezone_sync = e_cal_backend_http_set_default_timezone;
+       sync_class->set_default_zone_sync = e_cal_backend_http_set_default_zone;
        sync_class->get_freebusy_sync = e_cal_backend_http_get_free_busy;
        sync_class->get_changes_sync = e_cal_backend_http_get_changes;
 
index 25b74c2..f65dde9 100644 (file)
@@ -446,13 +446,20 @@ e_cal_backend_weather_open (ECalBackendSync *backend, EDataCal *cal, gboolean on
        if (!priv->cache) {
                priv->cache = e_cal_backend_cache_new (uri);
 
-               e_cal_backend_weather_add_timezone (backend, cal, (const char *) icaltimezone_get_tzid (priv->default_zone));
-
                if (!priv->cache) {
                        e_cal_backend_notify_error (E_CAL_BACKEND (cbw), _("Could not create cache file"));
                        return GNOME_Evolution_Calendar_OtherError;
                }
 
+               if (priv->default_zone) {
+                       icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
+                       icaltimezone *zone = icaltimezone_new ();
+
+                       icaltimezone_set_component (zone, icalcomponent_new_clone (icalcomp));
+
+                       g_hash_table_insert (priv->zones, g_strdup (icaltimezone_get_tzid (zone)), zone);
+               }
+
                if (priv->mode == CAL_MODE_LOCAL)
                        return GNOME_Evolution_Calendar_Success;
 
@@ -602,20 +609,32 @@ e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, con
 }
 
 static ECalBackendSyncStatus
-e_cal_backend_weather_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
+e_cal_backend_weather_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
 {
+       icalcomponent *tz_comp;
        ECalBackendWeather *cbw;
        ECalBackendWeatherPrivate *priv;
+       icaltimezone *zone;
+
+       cbw = (ECalBackendWeather *) backend;
+
+       g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), GNOME_Evolution_Calendar_OtherError);
+       g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
 
-       cbw = E_CAL_BACKEND_WEATHER (backend);
        priv = cbw->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 ();
+       tz_comp = icalparser_parse_string (tzobj);
+       if (!tz_comp)
+               return GNOME_Evolution_Calendar_InvalidObject;
 
-               return GNOME_Evolution_Calendar_ObjectNotFound;
-       }
+       zone = icaltimezone_new ();
+       icaltimezone_set_component (zone, tz_comp);
+
+       if (priv->default_zone)
+               icaltimezone_free (priv->default_zone, 1);
+
+       /* Set the default timezone to it. */
+       priv->default_zone = zone;
 
        return GNOME_Evolution_Calendar_Success;
 }
@@ -807,6 +826,11 @@ e_cal_backend_weather_finalize (GObject *object)
                priv->city = NULL;
        }
 
+       if (priv->default_zone) {
+               icaltimezone_free (priv->default_zone, 1);
+               priv->default_zone = NULL;
+       }
+
        g_free (priv);
        cbw->priv = NULL;
 
@@ -866,7 +890,7 @@ e_cal_backend_weather_class_init (ECalBackendWeatherClass *class)
        sync_class->get_object_list_sync = e_cal_backend_weather_get_object_list;
        sync_class->get_timezone_sync = e_cal_backend_weather_get_timezone;
        sync_class->add_timezone_sync = e_cal_backend_weather_add_timezone;
-       sync_class->set_default_timezone_sync = e_cal_backend_weather_set_default_timezone;
+       sync_class->set_default_zone_sync = e_cal_backend_weather_set_default_zone;
        sync_class->get_freebusy_sync = e_cal_backend_weather_get_free_busy;
        sync_class->get_changes_sync = e_cal_backend_weather_get_changes;
        backend_class->is_loaded = e_cal_backend_weather_is_loaded;
index 14741dd..a485da0 100644 (file)
@@ -199,7 +199,7 @@ module Calendar {
                oneway void getTimezone (in CalTimezoneObjUID tzid);
                oneway void addTimezone (in CalTimezoneObj tz);
                /* The timezone used to resolve DATE and floating DATE-TIME values. */
-               oneway void setDefaultTimezone (in CalTimezoneObjUID tzid);
+               oneway void setDefaultTimezone (in CalTimezoneObj tz);
 
                /* Gets a list of components that changed */
                oneway void getChanges (in string change_id);
index e188812..5274fb7 100644 (file)
@@ -5028,7 +5028,8 @@ e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error)
        CORBA_Environment ev;
        ECalendarStatus status;
        ECalendarOp *our_op;
-       const char *tzid;
+       icalcomponent *icalcomp = NULL;
+       char *tzobj;
 
        e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);        
        e_return_error_if_fail (zone, E_CALENDAR_STATUS_INVALID_ARG);   
@@ -5053,12 +5054,22 @@ e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error)
        g_mutex_unlock (priv->mutex);
 
        /* FIXME Adding it to the server to change the tzid */
-       tzid = icaltimezone_get_tzid (zone);
+       icalcomp = icaltimezone_get_component (zone);
+       if (!icalcomp) {
+               e_calendar_remove_op (ecal, our_op);
+               g_mutex_unlock (our_op->mutex);
+               e_calendar_free_op (our_op);
+
+               E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
+       }
+
+       /* convert icaltimezone into a string */        
+       tzobj = icalcomponent_as_ical_string (icalcomp);
 
        /* call the backend */
        CORBA_exception_init (&ev);
 
-       GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal, tzid, &ev);
+       GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal, tzobj, &ev);
        if (BONOBO_EX (&ev)) {
                e_calendar_remove_op (ecal, our_op);
                g_mutex_unlock (our_op->mutex);
index 100c16b..6549a9d 100644 (file)
@@ -517,6 +517,50 @@ e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const
 }
 
 /**
+ * e_cal_backend_sync_set_default_zone:
+ * @backend: An ECalBackendSync object.
+ * @cal: An EDataCal object.
+ * @tz: Timezone object as string.
+ *
+ * Calls the set_default_timezone method on the given backend.
+ *
+ * Return value: Status code.
+ */
+ECalBackendSyncStatus
+e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tz)
+{
+       ECalBackendSyncStatus status;
+       g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
+       
+       /* Old backends might be using the set_default_timezone */
+       if (!E_CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_zone_sync) {
+               icalcomponent *icalcomp = icalparser_parse_string (tz);
+               char *tzid = NULL;
+               icaltimezone *zone = icaltimezone_new ();
+
+               if (icalcomp) {
+                       icaltimezone_set_component (zone, icalcomp);
+                       tzid = icaltimezone_get_tzid (zone);
+               }
+
+               icaltimezone_free (zone, 1);
+
+               LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid));
+
+               return status;
+       }
+
+       LOCK_WRAPPER (set_default_zone_sync, (backend, cal, tz));
+  
+       return status;
+}
+
+/**
+ * @deprecated This virual function should not be used in the backends, use
+ * e_cal_backend_sync_set_zone instead. This function restricts the default timezone
+ * to be libical builtin timezone.
+ *
  * e_cal_backend_sync_set_default_timezone:
  * @backend: An ECalBackendSync object.
  * @cal: An EDataCal object.
@@ -855,6 +899,16 @@ _e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const char *tz
 }
 
 static void
+_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const char *tz)
+{
+       ECalBackendSyncStatus status;
+
+       status = e_cal_backend_sync_set_default_zone (E_CAL_BACKEND_SYNC (backend), cal, tz);
+
+       e_data_cal_notify_default_timezone_set (cal, status);
+}
+
+static void
 _e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid)
 {
        ECalBackendSyncStatus status;
@@ -961,6 +1015,7 @@ e_cal_backend_sync_class_init (ECalBackendSyncClass *klass)
        backend_class->get_timezone = _e_cal_backend_get_timezone;
        backend_class->add_timezone = _e_cal_backend_add_timezone;
        backend_class->set_default_timezone = _e_cal_backend_set_default_timezone;
+       backend_class->set_default_zone = _e_cal_backend_set_default_zone;
        backend_class->get_changes = _e_cal_backend_get_changes;
        backend_class->get_free_busy = _e_cal_backend_get_free_busy;
 
index 95326a4..f154d41 100644 (file)
@@ -62,6 +62,7 @@ struct _ECalBackendSyncClass {
        ECalBackendSyncStatus (*get_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object);
        ECalBackendSyncStatus (*add_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzobj);
        ECalBackendSyncStatus (*set_default_timezone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tzid);
+       ECalBackendSyncStatus (*set_default_zone_sync) (ECalBackendSync *backend, EDataCal *cal, const char *tz);
 
        ECalBackendSyncStatus (*get_changes_sync) (ECalBackendSync *backend, EDataCal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes);
        ECalBackendSyncStatus (*get_freebusy_sync) (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy);
@@ -152,6 +153,7 @@ ECalBackendSyncStatus e_cal_backend_sync_get_object_list         (ECalBackendSyn
 ECalBackendSyncStatus e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object);
 ECalBackendSyncStatus e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj);
 ECalBackendSyncStatus e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid);
+ECalBackendSyncStatus e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj);
 
 ECalBackendSyncStatus e_cal_backend_sync_get_changes (ECalBackendSync *backend, EDataCal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes);
 ECalBackendSyncStatus e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users, time_t start, time_t end, GList **freebusy);
index 3d65832..8117c06 100644 (file)
@@ -997,6 +997,29 @@ e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const char *tzi
 }
 
 /**
+ * e_cal_backend_set_default_zone:
+ * @backend: A calendar backend.
+ * @cal: An #EDataCal object.
+ * @tzobj: The timezone object, in a string.
+ * 
+ * Sets the default timezone for the calendar, which is used to resolve
+ * DATE and floating DATE-TIME values. 
+ */
+void
+e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const char *tzobj)
+{
+       g_return_if_fail (backend != NULL);
+       g_return_if_fail (E_IS_CAL_BACKEND (backend));
+       g_return_if_fail (tzobj != NULL);
+
+       (* CLASS (backend)->set_default_zone) (backend, cal, tzobj);
+}
+
+/**
+ * @deprecated This virual function should not be used in the backends, use
+ * e_cal_backend_set_zone instead. This function restricts the default timezone
+ * to be libical builtin timezone.
+ *
  * e_cal_backend_set_default_timezone:
  * @backend: A calendar backend.
  * @cal: An #EDataCal object.
@@ -1004,6 +1027,7 @@ e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const char *tzi
  * 
  * Sets the default timezone for the calendar, which is used to resolve
  * DATE and floating DATE-TIME values. 
+ * 
  */
 void
 e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid)
@@ -1012,7 +1036,6 @@ e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const c
        g_return_if_fail (E_IS_CAL_BACKEND (backend));
        g_return_if_fail (tzid != NULL);
 
-       g_assert (CLASS (backend)->set_default_timezone != NULL);
        (* CLASS (backend)->set_default_timezone) (backend, cal, tzid);
 }
 
index f83de05..846c287 100644 (file)
@@ -95,6 +95,7 @@ struct _ECalBackendClass {
        /* Timezone related virtual methods */
        void (* get_timezone) (ECalBackend *backend, EDataCal *cal, const char *tzid);
        void (* add_timezone) (ECalBackend *backend, EDataCal *cal, const char *object);
+       void (* set_default_zone) (ECalBackend *backend, EDataCal *cal, const char *tzobj);
        void (* set_default_timezone) (ECalBackend *backend, EDataCal *cal, const char *tzid);
 
        void (* start_query) (ECalBackend *backend, EDataCalView *query);
@@ -157,6 +158,7 @@ void e_cal_backend_set_mode (ECalBackend *backend, CalMode mode);
 void e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid);
 void e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const char *object);
 void e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid);
+void e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const char *tzobj);
 
 void e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const char *change_id);
 void e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end);
index 1b5649f..a5514c1 100644 (file)
@@ -467,7 +467,7 @@ impl_Cal_addTimezone (PortableServer_Servant servant,
 /* Cal::setDefaultTimezone method */
 static void
 impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
-                            const CORBA_char *tzid,
+                            const CORBA_char *tz,
                             CORBA_Environment *ev)
 {
        EDataCal *cal;
@@ -476,7 +476,7 @@ impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
        cal = E_DATA_CAL (bonobo_object_from_servant (servant));
        priv = cal->priv;
 
-       e_cal_backend_set_default_timezone (priv->backend, cal, tzid);
+       e_cal_backend_set_default_zone (priv->backend, cal, tz);
 }
 
 /**