aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/todo
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 /calendar/conduits/todo
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
Diffstat (limited to 'calendar/conduits/todo')
-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
3 files changed, 63 insertions, 7 deletions
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;