aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2002-05-21 01:00:33 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2002-05-21 01:00:33 +0800
commitde5b0738fd523214973cbc12287a599164baad5c (patch)
tree607359a531abd33569cbbfb29ff829cc14903319 /calendar/gui
parent3b787a2d62b885c248ca92d770e22051d2694091 (diff)
downloadgsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar.gz
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar.bz2
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar.lz
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar.xz
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.tar.zst
gsoc2013-evolution-de5b0738fd523214973cbc12287a599164baad5c.zip
ported changes from evolution-1-0 to make it work with reminders on remote
2002-05-20 Rodrigo Moya <rodrigo@ximian.com> * gui/alarm-notify/alarm-notify.c: * gui/alarm-notify/notify-main.c: ported changes from evolution-1-0 to make it work with reminders on remote backends. svn path=/trunk/; revision=16944
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c61
-rw-r--r--calendar/gui/alarm-notify/notify-main.c10
2 files changed, 62 insertions, 9 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 7dbb77ceeb..2f7889b4db 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -349,6 +349,52 @@ alarm_notify_new (void)
return an;
}
+typedef struct {
+ CalClient *client;
+ char *str_uri;
+} RetryData;
+
+static gboolean
+retry_timeout_cb (gpointer data)
+{
+ RetryData *retry_data = data;
+
+ if (cal_client_get_load_state (retry_data->client) != CAL_CLIENT_LOAD_LOADED) {
+ cal_client_open_calendar (retry_data->client, retry_data->str_uri, FALSE);
+ }
+
+ g_free (retry_data->str_uri);
+ g_free (retry_data);
+
+ return FALSE;
+}
+
+static void
+cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
+{
+ EUri *uri = (EUri *) data;
+
+ if (status == CAL_CLIENT_OPEN_SUCCESS) {
+ add_uri_to_load (uri);
+ alarm_queue_add_client (client);
+
+ e_uri_free (uri);
+ }
+ else {
+ RetryData *retry_data;
+
+ remove_uri_to_load (uri);
+
+ /* retry opening this calendar */
+ retry_data = g_new0 (RetryData, 1);
+ retry_data->client = client;
+ retry_data->str_uri = e_uri_to_string (uri, FALSE);
+
+ /* we set a timeout of 5 mins before retrying */
+ g_timeout_add (300000, (GSourceFunc) retry_timeout_cb, retry_data);
+ }
+}
+
/**
* alarm_notify_add_calendar:
* @an: An alarm notification service.
@@ -385,12 +431,11 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
return;
}
- if (load_afterwards)
- add_uri_to_load (uri);
-
lc = g_hash_table_lookup (priv->uri_client_hash, str_uri);
if (lc) {
+ if (load_afterwards)
+ add_uri_to_load (uri);
e_uri_free (uri);
g_assert (lc->refcount > 0);
lc->refcount++;
@@ -400,6 +445,12 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
client = cal_client_new ();
if (client) {
+ /* we only add the URI to load_afterwards if we open it
+ correctly */
+ gtk_signal_connect (GTK_OBJECT (client), "cal_opened",
+ GTK_SIGNAL_FUNC (cal_opened_cb),
+ e_uri_copy (uri));
+
if (cal_client_open_calendar (client, str_uri, FALSE)) {
lc = g_new (LoadedClient, 1);
lc->client = client;
@@ -407,8 +458,6 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
lc->refcount = 1;
g_hash_table_insert (priv->uri_client_hash,
g_strdup (str_uri), lc);
-
- alarm_queue_add_client (client);
} else {
gtk_object_unref (GTK_OBJECT (client));
client = NULL;
@@ -423,4 +472,6 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
NULL);
return;
}
+
+ e_uri_free (uri);
}
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index 8b6daab254..06fe87b611 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -109,8 +109,8 @@ alarm_notify_factory_fn (BonoboGenericFactory *factory, void *data)
}
/* Loads the calendars that the alarm daemon has been told to load in the past */
-static void
-load_calendars (void)
+static gboolean
+load_calendars (gpointer user_data)
{
GPtrArray *uris;
int i;
@@ -118,7 +118,7 @@ load_calendars (void)
uris = get_calendars_to_load ();
if (!uris) {
g_message ("load_calendars(): Could not get the list of calendars to load");
- return;
+ return TRUE; /* should we continue retrying? */;
}
for (i = 0; i < uris->len; i++) {
@@ -151,6 +151,8 @@ load_calendars (void)
}
g_ptr_array_free (uris, TRUE);
+
+ return FALSE;
}
int
@@ -187,7 +189,7 @@ main (int argc, char **argv)
set_session_parameters (argv);
- load_calendars ();
+ g_idle_add ((GSourceFunc) load_calendars, NULL);
bonobo_main ();