aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2003-03-10 19:53:36 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-03-10 19:53:36 +0800
commit6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2 (patch)
treee781beaf534ee8f97a4d9e2389ce93dfffe4e689
parentc8a1141a55840d16dca6fc863d8fbab7d0b4ab26 (diff)
downloadgsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.gz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.bz2
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.lz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.xz
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.tar.zst
gsoc2013-evolution-6c2bba29f7cfa297e4fb0a9f60ac90f430c1e3e2.zip
if we already have the client loaded, don't remove it, just increment its
2003-03-09 Rodrigo Moya <rodrigo@ximian.com> * gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): if we already have the client loaded, don't remove it, just increment its reference count. * gui/alarm-notify/alarm-queue.c (remove_queued_alarm): added new argument to specify whether we want the component's structure removed if no more alarms exist, and only free the structure if TRUE. (remove_alarms): added same new argument and pass it over to remove_queued_alarm. (remove_comp, obj_updated_cb): passed new argument to remove_alarms. (procedure_notification): passed new argument to remove_queued_alarm. (obj_removed_cb): set all freed pointers to NULL. (notify_dialog_cb): only remove the alarm if the pointers are not NULL. svn path=/trunk/; revision=20232
-rw-r--r--calendar/ChangeLog16
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c68
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c38
3 files changed, 72 insertions, 50 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6c91692b24..499e8dcb54 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,19 @@
+2003-03-09 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): if we
+ already have the client loaded, don't remove it, just increment its
+ reference count.
+
+ * gui/alarm-notify/alarm-queue.c (remove_queued_alarm): added new
+ argument to specify whether we want the component's structure removed
+ if no more alarms exist, and only free the structure if TRUE.
+ (remove_alarms): added same new argument and pass it over to
+ remove_queued_alarm.
+ (remove_comp, obj_updated_cb): passed new argument to remove_alarms.
+ (procedure_notification): passed new argument to remove_queued_alarm.
+ (obj_removed_cb): set all freed pointers to NULL.
+ (notify_dialog_cb): only remove the alarm if the pointers are not NULL.
+
2003-03-07 Rodrigo Moya <rodrigo@ximian.com>
* gui/alarm-notify/save.c (get_calendars_to_load): create the array
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index aefdceeeb1..fb1491bea9 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -441,7 +441,9 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
lc = lc_ptr;
s = s_ptr;
- g_hash_table_remove (priv->uri_client_hash, str_uri);
+ lc->refcount++;
+
+ /*g_hash_table_remove (priv->uri_client_hash, str_uri);
g_signal_handlers_disconnect_matched (G_OBJECT (lc->client),
G_SIGNAL_MATCH_DATA,
@@ -453,40 +455,38 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
e_uri_free (lc->uri);
g_free (lc);
- g_free (s);
- }
-
- client = cal_client_new ();
-
- if (client) {
- /* we only add the URI to load_afterwards if we open it
- correctly */
- lc = g_new (LoadedClient, 1);
-
- g_signal_connect (G_OBJECT (client), "cal_opened",
- G_CALLBACK (cal_opened_cb),
- lc);
-
- if (cal_client_open_calendar (client, str_uri, FALSE)) {
- lc->client = client;
- lc->uri = uri;
- lc->refcount = 1;
- lc->timeout_id = -1;
- g_hash_table_insert (priv->uri_client_hash,
- g_strdup (str_uri), lc);
+ g_free (s);*/
+ } else {
+ client = cal_client_new ();
+
+ if (client) {
+ /* we only add the URI to load_afterwards if we open it
+ correctly */
+ lc = g_new (LoadedClient, 1);
+
+ g_signal_connect (G_OBJECT (client), "cal_opened",
+ G_CALLBACK (cal_opened_cb),
+ lc);
+
+ if (cal_client_open_calendar (client, str_uri, FALSE)) {
+ lc->client = client;
+ lc->uri = uri;
+ lc->refcount = 1;
+ lc->timeout_id = -1;
+ g_hash_table_insert (priv->uri_client_hash,
+ g_strdup (str_uri), lc);
+ } else {
+ g_free (lc);
+ g_object_unref (G_OBJECT (client));
+ client = NULL;
+ }
} else {
- g_free (lc);
- g_object_unref (G_OBJECT (client));
- client = NULL;
- }
- }
-
- if (!client) {
- e_uri_free (uri);
+ e_uri_free (uri);
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError,
- NULL);
- return;
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError,
+ NULL);
+ return;
+ }
}
}
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 50a36fe4f1..58f3429ab6 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -192,7 +192,7 @@ lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
* the last one listed for the component, it removes the component itself.
*/
static void
-remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
+remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, gboolean free_object)
{
QueuedAlarm *qa;
const char *uid;
@@ -221,14 +221,16 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id)
if (cqa->queued_alarms != NULL)
return;
- cal_component_get_uid (cqa->alarms->comp, &uid);
- g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid);
- cqa->parent_client = NULL;
-
- cal_component_alarms_free (cqa->alarms);
- cqa->alarms = NULL;
-
- g_free (cqa);
+ if (free_object) {
+ cal_component_get_uid (cqa->alarms->comp, &uid);
+ g_hash_table_remove (cqa->parent_client->uid_alarms_hash, uid);
+ cqa->parent_client = NULL;
+ cal_component_alarms_free (cqa->alarms);
+ g_free (cqa);
+ } else {
+ cal_component_alarms_free (cqa->alarms);
+ cqa->alarms = NULL;
+ }
}
/* Callback used when an alarm triggers */
@@ -424,7 +426,7 @@ lookup_comp_queued_alarms (ClientAlarms *ca, const char *uid)
}
static void
-remove_alarms (CompQueuedAlarms *cqa)
+remove_alarms (CompQueuedAlarms *cqa, gboolean free_object)
{
GSList *l;
@@ -440,7 +442,7 @@ remove_alarms (CompQueuedAlarms *cqa)
l = l->next;
alarm_remove (qa->alarm_id);
- remove_queued_alarm (cqa, qa->alarm_id);
+ remove_queued_alarm (cqa, qa->alarm_id, free_object);
}
}
@@ -460,7 +462,7 @@ remove_comp (ClientAlarms *ca, const char *uid)
*/
g_assert (cqa->queued_alarms != NULL);
- remove_alarms (cqa);
+ remove_alarms (cqa, TRUE);
/* The list should be empty now, and thus the queued component alarms
* structure should have been freed and removed from the hash table.
@@ -503,7 +505,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
GSList *l;
/* if already in the list, just update it */
- remove_alarms (cqa);
+ remove_alarms (cqa, FALSE);
cqa->alarms = alarms;
cqa->queued_alarms = NULL;
@@ -664,8 +666,11 @@ on_dialog_obj_removed_cb (CalClient *client, const char *uid, gpointer data)
cal_component_get_uid (c->comp, &our_uid);
g_return_if_fail (our_uid && *our_uid);
- if (!strcmp (uid, our_uid))
+ if (!strcmp (uid, our_uid)) {
alarm_notify_dialog_disable_buttons (c->dialog);
+ c->cqa = NULL;
+ c->alarm_id = NULL;
+ }
}
/* Callback used from the alarm notify dialog */
@@ -698,7 +703,8 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
g_assert_not_reached ();
}
- remove_queued_alarm (c->cqa, c->alarm_id);
+ if (c->cqa != NULL)
+ remove_queued_alarm (c->cqa, c->alarm_id, TRUE);
g_object_unref (c->comp);
g_object_unref (c->client);
g_free (c);
@@ -935,7 +941,7 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id
if (result < 0)
goto fallback;
- remove_queued_alarm (cqa, alarm_id);
+ remove_queued_alarm (cqa, alarm_id, TRUE);
return;
fallback: