aboutsummaryrefslogtreecommitdiffstats
path: root/my-evolution
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-09-15 06:43:17 +0800
committerIain Holmes <iain@src.gnome.org>2001-09-15 06:43:17 +0800
commit127ee49f7c8e076dd5acb4f0d8c60d5475014fe3 (patch)
tree33e5c50aa6c0a209fee1ac6a02177fcb818f3b7a /my-evolution
parent8e88e78fbb50309ef2c225e2dcf1466ccfcc49b4 (diff)
downloadgsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar.gz
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar.bz2
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar.lz
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar.xz
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.tar.zst
gsoc2013-evolution-127ee49f7c8e076dd5acb4f0d8c60d5475014fe3.zip
Timezone stuff
svn path=/trunk/; revision=12835
Diffstat (limited to 'my-evolution')
-rw-r--r--my-evolution/ChangeLog7
-rw-r--r--my-evolution/e-summary-calendar.c207
-rw-r--r--my-evolution/e-summary.c36
-rw-r--r--my-evolution/e-summary.h5
4 files changed, 126 insertions, 129 deletions
diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog
index 81e38b46a7..7b00808e7b 100644
--- a/my-evolution/ChangeLog
+++ b/my-evolution/ChangeLog
@@ -1,3 +1,10 @@
+2001-09-14 Iain Holmes <iain@ximian.com>
+
+ * e-summary-calendar.c (uids_to_array): Create ESummaryCalEvents and
+ put them in an array to get the timezone stuff right.
+ (e_summary_calendar_event_sort_func): Sort the array.
+ (generate_html): Use the timezone formats of things.
+
2001-09-13 Iain Holmes <iain@ximian.com>
* Locations: Removed duff Norway station
diff --git a/my-evolution/e-summary-calendar.c b/my-evolution/e-summary-calendar.c
index ab143cc718..789cff124a 100644
--- a/my-evolution/e-summary-calendar.c
+++ b/my-evolution/e-summary-calendar.c
@@ -39,111 +39,80 @@ e_summary_calendar_get_html (ESummary *summary)
return summary->calendar->html;
}
-/* list_sort_merge, and list_sort are copied from GNOME-VFS.
- Author: Sven Oliver <sven.over@ob.kamp.net>
- Modified by Ettore Perazzoli <ettore@comm2000.it> to let the compare
- functions get an additional gpointer parameter.
-
- Included here as using gnome-vfs for 1 20 line function
- seems a bit of overkill.
-*/
-
-typedef gint (* CalSummaryListCompareFunc) (gconstpointer a,
- gconstpointer b,
- gpointer data);
-static GList *
-cal_list_sort_merge (GList *l1,
- GList *l2,
- CalSummaryListCompareFunc compare_func,
- gpointer data)
+typedef struct {
+ CalComponent *comp;
+ CalComponentDateTime dt;
+ icaltimezone *zone;
+} ESummaryCalEvent;
+
+static int
+e_summary_calendar_event_sort_func (const void *e1,
+ const void *e2)
{
- GList list, *l, *lprev;
-
- l = &list;
- lprev = NULL;
-
- while (l1 && l2) {
- if (compare_func (l1->data, l2->data, data) < 0) {
- l->next = l1;
- l = l->next;
- l->prev = lprev;
- lprev = l;
- l1 = l1->next;
- } else {
- l->next = l2;
- l = l->next;
- l->prev = lprev;
- lprev = l;
- l2 = l2->next;
- }
- }
+ ESummaryCalEvent *event1, *event2;
- l->next = l1 ? l1 : l2;
- l->next->prev = l;
+ event1 = (ESummaryCalEvent *) e1;
+ event2 = (ESummaryCalEvent *) e2;
- return list.next;
+ return icaltime_compare (*event1->dt.value, *event2->dt.value);
}
-static GList *
-cal_list_sort (GList *list,
- CalSummaryListCompareFunc compare_func,
- gpointer data)
+static GPtrArray *
+uids_to_array (ESummary *summary,
+ CalClient *client,
+ GList *uids)
{
- GList *l1, *l2;
+ GList *p;
+ GPtrArray *array;
- if (!list)
- return NULL;
- if (!list->next)
- return list;
+ g_return_val_if_fail (IS_E_SUMMARY (summary), NULL);
+ g_return_val_if_fail (client != NULL, NULL);
+ g_return_val_if_fail (uids != NULL, NULL);
- l1 = list;
- l2 = list->next;
+ array = g_ptr_array_new ();
+ for (p = uids; p; p = p->next) {
+ ESummaryCalEvent *event;
+ CalClientGetStatus status;
- while ((l2 = l2->next) != NULL) {
- if ((l2 = l2->next) == NULL)
- break;
- l1 = l1->next;
- }
+ event = g_new (ESummaryCalEvent, 1);
- l2 = l1->next;
- l1->next = NULL;
-
- return cal_list_sort_merge (cal_list_sort (list, compare_func, data),
- cal_list_sort (l2, compare_func, data),
- compare_func, data);
-}
-
-static int
-sort_uids (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- CalComponent *comp_a, *comp_b;
- ESummary *summary = user_data;
- ESummaryCalendar *calendar = summary->calendar;
- CalClientGetStatus status;
- CalComponentDateTime start_a, start_b;
- int retval;
+ status = cal_client_get_object (client, p->data, &event->comp);
+ if (status != CAL_CLIENT_GET_SUCCESS) {
+ g_free (event);
+ continue;
+ }
- /* a after b then return > 0 */
+ cal_component_get_dtstart (event->comp, &event->dt);
- status = cal_client_get_object (calendar->client, a, &comp_a);
- if (status != CAL_CLIENT_GET_SUCCESS)
- return -1;
+ status = cal_client_get_timezone (client, event->dt.tzid, &event->zone);
+ if (status != CAL_CLIENT_GET_SUCCESS) {
+ gtk_object_unref (GTK_OBJECT (event->comp));
+ g_free (event);
+ continue;
+ }
- status = cal_client_get_object (calendar->client, b, &comp_b);
- if (status != CAL_CLIENT_GET_SUCCESS)
- return 1;
+ icaltimezone_convert_time (event->dt.value, event->zone, summary->tz);
+ g_ptr_array_add (array, event);
+ }
+
+ qsort (array->pdata, array->len, sizeof (ESummaryCalEvent), e_summary_calendar_event_sort_func);
- cal_component_get_dtstart (comp_a, &start_a);
- cal_component_get_dtstart (comp_b, &start_b);
+ return array;
+}
- retval = icaltime_compare (*start_a.value, *start_b.value);
+static void
+free_event_array (GPtrArray *array)
+{
+ int i;
- cal_component_free_datetime (&start_a);
- cal_component_free_datetime (&start_b);
+ for (i = 0; i < array->len; i++) {
+ ESummaryCalEvent *event;
+
+ event = array->pdata[i];
+ gtk_object_unref (GTK_OBJECT (event->comp));
+ }
- return retval;
+ g_ptr_array_free (array, TRUE);
}
static gboolean
@@ -151,32 +120,32 @@ generate_html (gpointer data)
{
ESummary *summary = data;
ESummaryCalendar *calendar = summary->calendar;
- GList *uids, *l;
+ GList *uids;
GString *string;
char *tmp;
time_t t, begin, end, f;
t = time (NULL);
- begin = time_day_begin (t);
+ begin = time_day_begin_with_zone (t, summary->tz);
switch (summary->preferences->days) {
case E_SUMMARY_CALENDAR_ONE_DAY:
- end = time_day_end (t);
+ end = time_day_end_with_zone (t, summary->tz);
break;
case E_SUMMARY_CALENDAR_FIVE_DAYS:
f = time_add_day (t, 5);
- end = time_day_end (f);
+ end = time_day_end_with_zone (f, summary->tz);
break;
case E_SUMMARY_CALENDAR_ONE_WEEK:
f = time_add_week (t, 1);
- end = time_day_end (f);
+ end = time_day_end_with_zone (f, summary->tz);
break;
case E_SUMMARY_CALENDAR_ONE_MONTH:
default:
f = time_add_month (t, 1);
- end = time_day_end (f);
+ end = time_day_end_with_zone (f, summary->tz);
break;
}
@@ -197,40 +166,28 @@ generate_html (gpointer data)
e_summary_draw (summary);
return FALSE;
} else {
+ GPtrArray *uidarray;
+ int i;
char *s;
- uids = cal_list_sort (uids, sort_uids, summary);
-
string = g_string_new ("<dl><dt><img src=\"myevo-appointments.png\" align=\"middle\" "
"alt=\"\" width=\"48\" height=\"48\"> <b><a href=\"evolution:/local/Calendar\">");
s = e_utf8_from_locale_string (_("Appointments"));
g_string_append (string, s);
g_free (s);
g_string_append (string, "</a></b></dt><dd>");
- for (l = uids; l; l = l->next) {
- char *uid, *start_str;
- CalComponent *comp;
+
+ uidarray = uids_to_array (summary, calendar->client, uids);
+ for (i = 0; i < uidarray->len; i++) {
+ ESummaryCalEvent *event;
CalComponentText text;
- CalClientGetStatus status;
- CalComponentDateTime start, end;
- time_t start_t, dt;
+ time_t start_t;
struct tm *start_tm;
+ char *start_str;
- uid = l->data;
- status = cal_client_get_object (calendar->client, uid, &comp);
- if (status != CAL_CLIENT_GET_SUCCESS) {
- continue;
- }
-
- cal_component_get_summary (comp, &text);
-
- cal_component_get_dtstart (comp, &start);
- cal_component_get_dtend (comp, &end);
-
- start_t = icaltime_as_timet (*start.value);
-
- cal_component_free_datetime (&start);
- cal_component_free_datetime (&end);
+ event = uidarray->pdata[i];
+ cal_component_get_summary (event->comp, &text);
+ start_t = icaltime_as_timet (*event->dt.value);
start_str = g_new (char, 20);
start_tm = localtime (&start_t);
@@ -250,7 +207,7 @@ generate_html (gpointer data)
g_free (tmp);
}
- cal_obj_uid_list_free (uids);
+ free_event_array (uidarray);
g_string_append (string, "</dd></dl>");
}
@@ -335,18 +292,20 @@ e_summary_calendar_init (ESummary *summary)
if (result == FALSE) {
g_message ("Open calendar failed");
}
-
+
+ e_summary_add_protocol_listener (summary, "calendar", e_summary_calendar_protocol, calendar);
+
CORBA_exception_init (&ev);
db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
g_warning ("Error getting Wombat. Using defaults");
- } else {
- calendar->wants24hr = bonobo_config_get_boolean_with_default (db, "/Calendar/Display/Use24HourFormat", locale_uses_24h_time_format (), NULL);
- bonobo_object_release_unref (db, NULL);
+ return;
}
- CORBA_exception_free (&ev);
- e_summary_add_protocol_listener (summary, "calendar", e_summary_calendar_protocol, calendar);
+ calendar->wants24hr = bonobo_config_get_boolean_with_default (db, "/Calendar/Display/Use24HourFormat", locale_uses_24h_time_format (), NULL);
+ bonobo_object_release_unref (db, NULL);
+ CORBA_exception_free (&ev);
}
void
diff --git a/my-evolution/e-summary.c b/my-evolution/e-summary.c
index 0df4dc3bc1..979dd97cd9 100644
--- a/my-evolution/e-summary.c
+++ b/my-evolution/e-summary.c
@@ -27,6 +27,10 @@
#include <gal/widgets/e-unicode.h>
#include <bonobo/bonobo-listener.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
+
#include <libgnome/gnome-paper.h>
#include <libgnome/gnome-url.h>
@@ -148,7 +152,8 @@ e_summary_draw (ESummary *summary)
g_return_if_fail (IS_E_SUMMARY (summary));
if (summary->mail == NULL || summary->calendar == NULL
- || summary->rdf == NULL || summary->weather == NULL) {
+ || summary->rdf == NULL || summary->weather == NULL
+ || summary->tasks == NULL) {
return;
}
@@ -401,6 +406,8 @@ alarm_fn (gpointer alarm_id,
static void
e_summary_init (ESummary *summary)
{
+ Bonobo_ConfigDatabase db;
+ CORBA_Environment ev;
ESummaryPrivate *priv;
GdkColor bgcolor = {0, 0xffff, 0xffff, 0xffff};
time_t t, day_end;
@@ -438,13 +445,32 @@ e_summary_init (ESummary *summary)
priv->protocol_hash = NULL;
priv->connections = NULL;
+ summary->prefs_window = NULL;
+ e_summary_preferences_init (summary);
+
+ CORBA_exception_init (&ev);
+ db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ g_warning ("Error getting Wombat. Using defaults");
+ return;
+ }
+
+ summary->timezone = bonobo_config_get_string (db, "/Calendar/Display/Timezone", NULL);
+ summary->tz = icaltimezone_get_builtin_timezone (summary->timezone);
+
+ bonobo_object_release_unref (db, NULL);
+ CORBA_exception_free (&ev);
+
alarm_init ();
t = time (NULL);
- day_end = time_day_end (t);
- priv->alarm = alarm_add (day_end, alarm_fn, summary, NULL);
+ if (summary->tz == NULL) {
+ day_end = time_day_end (t);
+ } else {
+ day_end = time_day_end_with_zone (t, summary->tz);
+ }
- summary->prefs_window = NULL;
- e_summary_preferences_init (summary);
+ priv->alarm = alarm_add (day_end, alarm_fn, summary, NULL);
}
E_MAKE_TYPE (e_summary, "ESummary", ESummary, e_summary_class_init,
diff --git a/my-evolution/e-summary.h b/my-evolution/e-summary.h
index 4fb4a8ef21..70ddbc3dd9 100644
--- a/my-evolution/e-summary.h
+++ b/my-evolution/e-summary.h
@@ -17,6 +17,8 @@
#include "e-summary-weather.h"
#include "e-summary-tasks.h"
+#include <ical.h>
+
#include <Evolution.h>
#define E_SUMMARY_TYPE (e_summary_get_type ())
@@ -99,6 +101,9 @@ struct _ESummary {
GtkWidget *prefs_window;
gboolean online;
+
+ char *timezone;
+ icaltimezone *tz;
};
struct _ESummaryClass {