diff options
author | JP Rosevear <jpr@novell.com> | 2004-08-27 23:41:04 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2004-08-27 23:41:04 +0800 |
commit | 2971f1b0e3fcb9a435c10fc8e04d44809bc72177 (patch) | |
tree | 8512f0873fad78e1fdcf39b5443afbbdeec79524 | |
parent | f96c63d552bd85644d4e785427ca10b7c1521deb (diff) | |
download | gsoc2013-evolution-2971f1b0e3fcb9a435c10fc8e04d44809bc72177.tar.gz gsoc2013-evolution-2971f1b0e3fcb9a435c10fc8e04d44809bc72177.tar.zst gsoc2013-evolution-2971f1b0e3fcb9a435c10fc8e04d44809bc72177.zip |
update proto
2004-08-27 JP Rosevear <jpr@novell.com>
* gui/alarm-notify/alarm-notify.h: update proto
* gui/alarm-notify/alarm-notify.c (list_changed_cb): use per
source type client hash
(alarm_notify_init): ditto
(alarm_notify_finalize): ditto
(cal_opened_cb): ditto
(alarm_notify_add_calendar): ditto
(alarm_notify_remove_calendar): ditto, take source_type arg
(load_calendars_cb): don't call list_changed if the source list is
NULL
svn path=/trunk/; revision=27042
-rw-r--r-- | calendar/ChangeLog | 14 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.c | 46 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.h | 2 |
3 files changed, 43 insertions, 19 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a7575148c3..054b809548 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,17 @@ +2004-08-27 JP Rosevear <jpr@novell.com> + + * gui/alarm-notify/alarm-notify.h: update proto + + * gui/alarm-notify/alarm-notify.c (list_changed_cb): use per + source type client hash + (alarm_notify_init): ditto + (alarm_notify_finalize): ditto + (cal_opened_cb): ditto + (alarm_notify_add_calendar): ditto + (alarm_notify_remove_calendar): ditto, take source_type arg + (load_calendars_cb): don't call list_changed if the source list is + NULL + 2004-08-26 Christian Neumair <chris@gnome-de.org> * gui/GNOME_Evolution_Calendar.server.in.in: diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 9ebf5c4ca9..0b62873e23 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -39,7 +39,7 @@ struct _AlarmNotifyPrivate { /* Mapping from EUri's to LoadedClient structures */ /* FIXME do we need per source type uri hashes? or perhaps we just need to hash based on source */ - GHashTable *uri_client_hash; + GHashTable *uri_client_hash [E_CAL_SOURCE_TYPE_LAST]; ESourceList *source_lists [E_CAL_SOURCE_TYPE_LAST]; GMutex *mutex; }; @@ -93,7 +93,7 @@ process_removal_in_hash (gpointer key, gpointer value, gpointer data) for (q = sources; q != NULL; q = q->next) { ESource *source = E_SOURCE (q->data); char *source_uri; - + source_uri = e_source_get_uri (source); if (strcmp (source_uri, uri) == 0) found = TRUE; @@ -142,7 +142,7 @@ list_changed_cb (ESourceList *source_list, gpointer data) char *uri; uri = e_source_get_uri (source); - if (!g_hash_table_lookup (priv->uri_client_hash, uri)) { + if (!g_hash_table_lookup (priv->uri_client_hash[source_type], uri)) { g_message ("Adding %s", uri); alarm_notify_add_calendar (an, source_type, source, FALSE); } @@ -154,11 +154,11 @@ list_changed_cb (ESourceList *source_list, gpointer data) prd.an = an; prd.source_list = priv->source_lists[source_type]; prd.removals = NULL; - g_hash_table_foreach (priv->uri_client_hash, (GHFunc) process_removal_in_hash, &prd); + g_hash_table_foreach (priv->uri_client_hash[source_type], (GHFunc) process_removal_in_hash, &prd); for (l = prd.removals; l; l = l->next) { g_message ("Removing %s", (char *)l->data); - alarm_notify_remove_calendar (an, l->data); + alarm_notify_remove_calendar (an, source_type, l->data); } g_list_free (prd.removals); } @@ -206,8 +206,11 @@ load_calendars_cb (gpointer data) int i; AlarmNotify *an = ALARM_NOTIFY (data); - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) - list_changed_cb (an->priv->source_lists[i], an); + for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { + if (an->priv->source_lists[i]) + list_changed_cb (an->priv->source_lists[i], an); + } + return FALSE; } @@ -221,7 +224,9 @@ alarm_notify_init (AlarmNotify *an, AlarmNotifyClass *klass) priv = g_new0 (AlarmNotifyPrivate, 1); an->priv = priv; priv->mutex = g_mutex_new (); - priv->uri_client_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + + for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) + priv->uri_client_hash[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); alarm_queue_init (); @@ -244,14 +249,19 @@ alarm_notify_finalize (GObject *object) { AlarmNotify *an; AlarmNotifyPrivate *priv; - + int i; + g_return_if_fail (object != NULL); g_return_if_fail (IS_ALARM_NOTIFY (object)); an = ALARM_NOTIFY (object); priv = an->priv; - g_hash_table_foreach (priv->uri_client_hash, dequeue_client, NULL); - g_hash_table_destroy (priv->uri_client_hash); + + for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { + g_hash_table_foreach (priv->uri_client_hash[i], dequeue_client, NULL); + g_hash_table_destroy (priv->uri_client_hash[i]); + } + g_mutex_free (priv->mutex); g_free (priv); @@ -291,7 +301,7 @@ cal_opened_cb (ECal *client, ECalendarStatus status, gpointer user_data) if (status == E_CALENDAR_STATUS_OK) alarm_queue_add_client (client); else { - g_hash_table_remove (priv->uri_client_hash, + g_hash_table_remove (priv->uri_client_hash[e_cal_get_source_type (client)], e_cal_get_uri (client)); } } @@ -322,7 +332,7 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource g_mutex_lock (an->priv->mutex); /* See if we already know about this uri */ - if (g_hash_table_lookup (priv->uri_client_hash, str_uri)) { + if (g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri)) { g_mutex_unlock (an->priv->mutex); return; } @@ -337,7 +347,7 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource client = auth_new_cal_from_source (source, source_type); if (client) { - g_hash_table_insert (priv->uri_client_hash, g_strdup (str_uri), client); + g_hash_table_insert (priv->uri_client_hash[source_type], g_strdup (str_uri), client); g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (cal_opened_cb), an); e_cal_open_async (client, FALSE); } @@ -345,16 +355,16 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource } void -alarm_notify_remove_calendar (AlarmNotify *an, const char *str_uri) +alarm_notify_remove_calendar (AlarmNotify *an, ECalSourceType source_type, const char *str_uri) { AlarmNotifyPrivate *priv; ECal *client; - + priv = an->priv; - client = g_hash_table_lookup (priv->uri_client_hash, str_uri); + client = g_hash_table_lookup (priv->uri_client_hash[source_type], str_uri); if (client) { alarm_queue_remove_client (client); - g_hash_table_remove (priv->uri_client_hash, str_uri); + g_hash_table_remove (priv->uri_client_hash[source_type], str_uri); } } diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h index 7aea798402..4d8b5f194f 100644 --- a/calendar/gui/alarm-notify/alarm-notify.h +++ b/calendar/gui/alarm-notify/alarm-notify.h @@ -56,7 +56,7 @@ GType alarm_notify_get_type (void); AlarmNotify *alarm_notify_new (void); void alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource *source, gboolean load_afterwards); -void alarm_notify_remove_calendar (AlarmNotify *an, const char *str_uri); +void alarm_notify_remove_calendar (AlarmNotify *an, ECalSourceType source_type, const char *str_uri); |