aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-07-28 06:12:29 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-07-28 06:12:29 +0800
commitb5599101cc489814899bccd7bc3fff0052b878dd (patch)
treeb577be2ef745714f1e07951a6a048a3f4f531527
parent14e018afc44ef95d46be133b23490ab7dd3c05c0 (diff)
downloadgsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar.gz
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar.bz2
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar.lz
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar.xz
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.tar.zst
gsoc2013-evolution-b5599101cc489814899bccd7bc3fff0052b878dd.zip
handle timezones everywhere (get_timezone): new function to get a timezone
2001-07-27 JP Rosevear <jpr@ximian.com> * conduits/calendar/calendar-conduit.c: handle timezones everywhere (get_timezone): new function to get a timezone based on a tzid (get_default_timezone): get default timezone * conduits/calendar/calendar-conduit.h: time zone field for the context * conduits/calendar/Makefile.am: link to bonobo conf * conduits/todo/todo-conduit.c: handle timezones everywhere (get_timezone): new function to get a timezone based on a tzid (get_default_timezone): get default timezone * conduits/todo/todo-conduit.h: time zone field for the context * conduits/todo/Makefile.am: link to bonobo conf svn path=/trunk/; revision=11461
-rw-r--r--calendar/ChangeLog24
-rw-r--r--calendar/conduits/calendar/Makefile.am2
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c82
-rw-r--r--calendar/conduits/calendar/calendar-conduit.h2
-rw-r--r--calendar/conduits/todo/Makefile.am2
-rw-r--r--calendar/conduits/todo/todo-conduit.c66
-rw-r--r--calendar/conduits/todo/todo-conduit.h2
7 files changed, 158 insertions, 22 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 59cd002e21..641f590684 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,27 @@
+2001-07-27 JP Rosevear <jpr@ximian.com>
+
+ * conduits/calendar/calendar-conduit.c: handle timezones
+ everywhere
+ (get_timezone): new function to get a timezone based
+ on a tzid
+ (get_default_timezone): get default timezone
+
+ * conduits/calendar/calendar-conduit.h: time zone field for the
+ context
+
+ * conduits/calendar/Makefile.am: link to bonobo conf
+
+ * conduits/todo/todo-conduit.c: handle timezones
+ everywhere
+ (get_timezone): new function to get a timezone based
+ on a tzid
+ (get_default_timezone): get default timezone
+
+ * conduits/todo/todo-conduit.h: time zone field for the
+ context
+
+ * conduits/todo/Makefile.am: link to bonobo conf
+
2001-07-27 Rodrigo Moya <rodrigo@ximian.com>
* gui/e-day-view-main-item.c (e_day_view_main_item_draw_day_event):
diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am
index 0a71acb974..2b9b8053a8 100644
--- a/calendar/conduits/calendar/Makefile.am
+++ b/calendar/conduits/calendar/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES = \
-I$(top_srcdir)/e-util \
-I$(top_builddir)/e-util \
$(BONOBO_GNOME_CFLAGS) \
+ $(BONOBO_CONF_CFLAGS) \
$(PISOCK_CFLAGS) \
$(GNOME_PILOT_CFLAGS)
@@ -28,6 +29,7 @@ libecalendar_conduit_la_LIBADD = \
$(top_builddir)/libwombat/libwombat-static.la \
$(top_builddir)/e-util/libeconduit-static.la \
$(BONOBO_GNOME_LIBS) \
+ $(BONOBO_CONF_LIBS) \
$(PISOCK_LIBS) \
$(GNOME_LIBDIR) \
$(GNOME_LIBS)
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 5d93e77bce..38c5758090 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -26,6 +26,7 @@
#include <liboaf/liboaf.h>
#include <bonobo.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <cal-client/cal-client-types.h>
#include <cal-client/cal-client.h>
#include <cal-util/timeutil.h>
@@ -211,6 +212,51 @@ start_calendar_server (ECalConduitContext *ctxt)
}
/* Utility routines */
+static icaltimezone *
+get_timezone (CalClient *client, const char *tzid)
+{
+ icaltimezone *timezone = NULL;
+
+ timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (timezone == NULL)
+ cal_client_get_timezone (client, tzid, &timezone);
+
+ return timezone;
+}
+
+static icaltimezone *
+get_default_timezone (void)
+{
+ Bonobo_ConfigDatabase db;
+ icaltimezone *timezone = NULL;
+ char *location;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ location = bonobo_config_get_string (db, "/Calendar/Display/Timezone", NULL);
+ if (location == NULL)
+ goto cleanup;
+
+ timezone = icaltimezone_get_builtin_timezone (location);
+ g_free (location);
+
+ cleanup:
+ bonobo_object_release_unref (db, NULL);
+
+ return timezone;
+}
+
+
static char *
map_name (ECalConduitContext *ctxt)
{
@@ -402,14 +448,14 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
cal_component_get_dtstart (comp, &dt);
if (dt.value) {
- dt_time = icaltime_as_timet (*dt.value);
+ dt_time = icaltime_as_timet_with_zone (*dt.value, get_timezone (ctxt->client, dt.tzid));
local->appt->begin = *localtime (&dt_time);
}
cal_component_get_dtend (comp, &dt);
- if (dt.value && time_add_day (dt_time, 1) != icaltime_as_timet (*dt.value)) {
- dt_time = icaltime_as_timet (*dt.value);
+ if (dt.value && time_add_day (dt_time, 1) != icaltime_as_timet_with_zone (*dt.value, get_timezone (ctxt->client, dt.tzid))) {
+ dt_time = icaltime_as_timet_with_zone (*dt.value, get_timezone (ctxt->client, dt.tzid));
local->appt->end = *localtime (&dt_time);
local->appt->event = 0;
@@ -483,7 +529,7 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
local->appt->repeatForever = 1;
} else {
local->appt->repeatForever = 0;
- dt_time = icaltime_as_timet (recur->until);
+ dt_time = icaltime_as_timet_with_zone (recur->until, ctxt->timezone);
local->appt->repeatEnd = *localtime (&dt_time);
}
@@ -527,15 +573,16 @@ local_record_from_uid (ECalLocalRecord *local,
static CalComponent *
comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
- CalComponent *in_comp)
+ CalComponent *in_comp,
+ icaltimezone *timezone)
{
CalComponent *comp;
struct Appointment appt;
- struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE), it;
+ struct icaltimetype now = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone), it;
struct icalrecurrencetype recur;
int pos, i;
CalComponentText summary = {NULL, NULL};
- CalComponentDateTime dt = {NULL, NULL};
+ CalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)};
char *txt;
g_return_val_if_fail (remote != NULL, NULL);
@@ -574,7 +621,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
if (!is_empty_time (appt.begin)) {
- it = icaltime_from_timet (mktime (&appt.begin), FALSE);
+ it = icaltime_from_timet_with_zone (mktime (&appt.begin), FALSE, timezone);
dt.value = &it;
cal_component_set_dtstart (comp, &dt);
}
@@ -583,11 +630,11 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
time_t t = mktime (&appt.begin);
t = time_day_end (t);
- it = icaltime_from_timet (t, FALSE);
+ it = icaltime_from_timet_with_zone (t, FALSE, timezone);
dt.value = &it;
cal_component_set_dtend (comp, &dt);
} else if (!is_empty_time (appt.end)) {
- it = icaltime_from_timet (mktime (&appt.end), FALSE);
+ it = icaltime_from_timet_with_zone (mktime (&appt.end), FALSE, timezone);
dt.value = &it;
cal_component_set_dtend (comp, &dt);
}
@@ -647,7 +694,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
if (!appt.repeatForever) {
time_t t = mktime (&appt.repeatEnd);
t = time_add_day (t, 1);
- recur.until = icaltime_from_timet (t, FALSE);
+ recur.until = icaltime_from_timet_with_zone (t, FALSE, timezone);
}
list = g_slist_append (list, &recur);
@@ -722,7 +769,6 @@ pre_sync (GnomePilotConduit *conduit,
LOG ("---------------------------------------------------------\n");
LOG ("pre_sync: Calendar Conduit v.%s", CONDUIT_VERSION);
- g_message ("Calendar Conduit v.%s", CONDUIT_VERSION);
ctxt->client = NULL;
@@ -732,6 +778,12 @@ pre_sync (GnomePilotConduit *conduit,
return -1;
}
+ /* Get the timezone */
+ ctxt->timezone = get_default_timezone ();
+ if (ctxt->timezone == NULL)
+ return -1;
+ LOG (" Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone));
+
/* Load the uid <--> pilot id mapping */
filename = map_name (ctxt);
e_pilot_map_read (filename, &ctxt->map);
@@ -908,7 +960,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit,
static GList *iterator;
static int count;
- g_return_val_if_fail (local != NULL, 0);
+ g_return_val_if_fail (local != NULL, -1);
if (*local == NULL) {
LOG ("beginning for_each_modified: beginning\n");
@@ -992,7 +1044,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG ("add_record: adding %s to desktop\n", print_remote (remote));
- comp = comp_from_remote_record (conduit, remote, NULL);
+ comp = comp_from_remote_record (conduit, remote, NULL, ctxt->timezone);
update_comp (conduit, comp, ctxt);
cal_component_get_uid (comp, &uid);
@@ -1016,7 +1068,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote));
- new_comp = comp_from_remote_record (conduit, remote, local->comp);
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone);
gtk_object_unref (GTK_OBJECT (local->comp));
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);
diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h
index a236eacae6..fc142efc36 100644
--- a/calendar/conduits/calendar/calendar-conduit.h
+++ b/calendar/conduits/calendar/calendar-conduit.h
@@ -32,6 +32,7 @@
#include <pi-datebook.h>
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-sync-abs.h>
+#include <libical/src/libical/icaltime.h>
#include <cal-client/cal-client.h>
#include <e-pilot-map.h>
@@ -62,6 +63,7 @@ struct _ECalConduitContext {
char *calendar_file;
gboolean calendar_open_success;
+ icaltimezone *timezone;
time_t since;
GList *uids;
GList *changed;
diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am
index 90cc75b3bd..a9f4e73eee 100644
--- a/calendar/conduits/todo/Makefile.am
+++ b/calendar/conduits/todo/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES = \
-I$(top_srcdir)/e-util \
-I$(top_builddir)/e-util \
$(BONOBO_GNOME_CFLAGS) \
+ $(BONOBO_CONF_CFLAGS) \
$(PISOCK_CFLAGS) \
$(GNOME_PILOT_CFLAGS)
@@ -28,6 +29,7 @@ libetodo_conduit_la_LIBADD = \
$(top_builddir)/libwombat/libwombat-static.la \
$(top_builddir)/e-util/libeconduit-static.la \
$(BONOBO_GNOME_LIBS) \
+ $(BONOBO_CONF_LIBS) \
$(PISOCK_LIBS) \
$(GNOME_LIBDIR) \
$(GNOME_LIBS)
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index b531492b4f..e0b3d6384d 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -26,6 +26,7 @@
#include <liboaf/liboaf.h>
#include <bonobo.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <cal-client/cal-client-types.h>
#include <cal-client/cal-client.h>
#include <cal-util/timeutil.h>
@@ -215,6 +216,50 @@ start_calendar_server (EToDoConduitContext *ctxt)
}
/* Utility routines */
+static icaltimezone *
+get_timezone (CalClient *client, const char *tzid)
+{
+ icaltimezone *timezone = NULL;
+
+ timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (timezone == NULL)
+ cal_client_get_timezone (client, tzid, &timezone);
+
+ return timezone;
+}
+
+static icaltimezone *
+get_default_timezone (void)
+{
+ Bonobo_ConfigDatabase db;
+ icaltimezone *timezone = NULL;
+ char *location;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ location = bonobo_config_get_string (db, "/Calendar/Display/Timezone", NULL);
+ if (location == NULL)
+ goto cleanup;
+
+ timezone = icaltimezone_get_builtin_timezone (location);
+ g_free (location);
+
+ cleanup:
+ bonobo_object_release_unref (db, NULL);
+
+ return timezone;
+}
+
static char *
map_name (EToDoConduitContext *ctxt)
{
@@ -356,7 +401,7 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui
cal_component_get_due (comp, &due);
if (due.value) {
- due_time = icaltime_as_timet (*due.value);
+ due_time = icaltime_as_timet_with_zone (*due.value, get_timezone (ctxt->client, due.tzid));
local->todo->due = *localtime (&due_time);
local->todo->indefinite = 0;
@@ -414,13 +459,14 @@ local_record_from_uid (EToDoLocalRecord *local,
static CalComponent *
comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
GnomePilotRecord *remote,
- CalComponent *in_comp)
+ CalComponent *in_comp,
+ icaltimezone *timezone)
{
CalComponent *comp;
struct ToDo todo;
- struct icaltimetype now = icaltime_from_timet (time (NULL), FALSE);
+ struct icaltimetype now = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone);
CalComponentText summary = {NULL, NULL};
- CalComponentDateTime dt = {NULL, NULL};
+ CalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)};
struct icaltimetype due;
char *txt;
@@ -466,7 +512,7 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit,
}
if (!is_empty_time (todo.due)) {
- due = icaltime_from_timet (mktime (&todo.due), FALSE);
+ due = icaltime_from_timet_with_zone (mktime (&todo.due), FALSE, timezone);
dt.value = &due;
cal_component_set_due (comp, &dt);
}
@@ -547,6 +593,12 @@ pre_sync (GnomePilotConduit *conduit,
return -1;
}
+ /* Get the timezone */
+ ctxt->timezone = get_default_timezone ();
+ if (ctxt->timezone == NULL)
+ return -1;
+ LOG (" Using timezone: %s", icaltimezone_get_tzid (ctxt->timezone));
+
/* Load the uid <--> pilot id map */
filename = map_name (ctxt);
e_pilot_map_read (filename, &ctxt->map);
@@ -807,7 +859,7 @@ add_record (GnomePilotConduitSyncAbs *conduit,
LOG ("add_record: adding %s to desktop\n", print_remote (remote));
- comp = comp_from_remote_record (conduit, remote, NULL);
+ comp = comp_from_remote_record (conduit, remote, NULL, ctxt->timezone);
update_comp (conduit, comp, ctxt);
cal_component_get_uid (comp, &uid);
@@ -831,7 +883,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit,
LOG ("replace_record: replace %s with %s\n",
print_local (local), print_remote (remote));
- new_comp = comp_from_remote_record (conduit, remote, local->comp);
+ new_comp = comp_from_remote_record (conduit, remote, local->comp, ctxt->timezone);
gtk_object_unref (GTK_OBJECT (local->comp));
local->comp = new_comp;
update_comp (conduit, local->comp, ctxt);
diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h
index 2415e189c0..a7f533ddde 100644
--- a/calendar/conduits/todo/todo-conduit.h
+++ b/calendar/conduits/todo/todo-conduit.h
@@ -32,6 +32,7 @@
#include <pi-todo.h>
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-sync-abs.h>
+#include <libical/src/libical/icaltime.h>
#include <cal-client/cal-client.h>
#include <e-pilot-map.h>
@@ -62,6 +63,7 @@ struct _EToDoConduitContext {
char *calendar_file;
gboolean calendar_open_success;
+ icaltimezone *timezone;
GList *uids;
GList *changed;
GHashTable *changed_hash;