aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-02-24 08:32:36 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-02-24 08:32:36 +0800
commit06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a (patch)
tree661fa622332869da7d7c6c2a7fef8162b14e93f6 /calendar/gui/alarm-notify
parent40d58afa7ce854ae8154a7f0ce32997f57d99ea4 (diff)
downloadgsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar.gz
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar.bz2
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar.lz
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar.xz
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.tar.zst
gsoc2013-evolution-06c876bf8ee5f22fd5e9e60fb9dbc3cc06756c1a.zip
Switched to using our own refcounted structure for loaded clients.
2001-02-23 Federico Mena Quintero <federico@ximian.com> * gui/alarm-notify/alarm-notify.c (AlarmNotify_addCalendar): Switched to using our own refcounted structure for loaded clients. (AlarmNotify_removeCalendar): Ditto. Also, do the full destruction of the client. (alarm_notify_destroy): Destroy each element in the hash table. * cal-client/cal-client.c (cal_client_construct): Test for exceptions from OAF when activating the Wombat calendar factory. * gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in: New .oaf.in file. * gui/alarm-notify/Makefile.am (oaf_in_files): Updated. * gui/GNOME_Evolution_Calendar.oaf.in: Put all the servers here instead of in a million files. * gui/GNOME_Evolution_Calendar_Control.oaf.in: Removed file. * gui/GNOME_Evolution_Calendar_gnomecal.oaf.in: Removed *REALLY* obsolete file. * gui/Makefile.am (oaf_in_files): Updated. svn path=/trunk/; revision=8375
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r--calendar/gui/alarm-notify/.cvsignore2
-rw-r--r--calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in24
-rw-r--r--calendar/gui/alarm-notify/Makefile.am10
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c107
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c12
5 files changed, 129 insertions, 26 deletions
diff --git a/calendar/gui/alarm-notify/.cvsignore b/calendar/gui/alarm-notify/.cvsignore
index fa1c1f7c87..1f2b546c7c 100644
--- a/calendar/gui/alarm-notify/.cvsignore
+++ b/calendar/gui/alarm-notify/.cvsignore
@@ -6,3 +6,5 @@ evolution-calendar-stubs.c
evolution-calendar-skels.c
evolution-calendar-common.c
evolution-calendar.h
+evolution-alarm-notify
+GNOME_Evolution_Calendar_AlarmNotify.oaf
diff --git a/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in b/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in
new file mode 100644
index 0000000000..86f5c71493
--- /dev/null
+++ b/calendar/gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.oaf.in
@@ -0,0 +1,24 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory"
+ type="exe"
+ location="evolution-alarm-notify">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/ObjectFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ _value="Factory for the alarm notification service"/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:GNOME_Evolution_Calendar_AlarmNotify"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory">
+
+ <oaf_attribute name="description" type="string"
+ _value="Alarm notification service"/>
+</oaf_server>
+
+</oaf_info>
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 5df0b3c234..3201f062f6 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -47,10 +47,16 @@ evolution_alarm_notify_LDADD = \
$(INTLLIBS)
oafdir = $(datadir)/oaf
-oaf_DATA = GNOME_Evolution_Calendar_AlarmNotify.oafinfo
+oaf_in_files = \
+ GNOME_Evolution_Calendar_AlarmNotify.oaf.in
+
+oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
+
+@XML_I18N_MERGE_OAF_RULE@
EXTRA_DIST = \
- $(oaf_DATA)
+ $(oaf_DATA) \
+ $(oaf_in_files)
BUILT_SOURCES = $(CORBA_GENERATED)
CLEANFILES += $(BUILT_SOURCES)
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 9d64bfd4a8..fa70a1d236 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -27,12 +27,29 @@
#include <libgnomevfs/gnome-vfs.h>
#include <cal-client/cal-client.h>
#include "alarm-notify.h"
+#include "alarm-queue.h"
+/* A loaded client */
+typedef struct {
+ /* The actual client */
+ CalClient *client;
+
+ /* The URI of the client in gnome-vfs's format. This *is* the key that
+ * is stored in the uri_client_hash hash table below.
+ */
+ GnomeVFSURI *uri;
+
+ /* Number of times clients have requested this URI to be added to the
+ * alarm notification system.
+ */
+ int refcount;
+} LoadedClient;
+
/* Private part of the AlarmNotify structure */
struct _AlarmNotifyPrivate {
- /* Mapping from GnomeVFSURIs to loaded clients */
+ /* Mapping from GnomeVFSURIs to LoadedClient structures */
GHashTable *uri_client_hash;
};
@@ -114,6 +131,19 @@ alarm_notify_init (AlarmNotify *an)
priv->uri_client_hash = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
}
+/* Callback used from g_hash-table_forach(), used to destroy a loade client */
+static void
+destroy_loaded_client_cb (gpointer key, gpointer value, gpointer data)
+{
+ LoadedClient *lc;
+
+ lc = value;
+
+ gtk_object_unref (GTK_OBJECT (lc->client));
+ gnome_vfs_uri_unref (lc->uri);
+ g_free (lc);
+}
+
/* Destroy handler for the alarm notify system */
static void
alarm_notify_destroy (GtkObject *object)
@@ -127,7 +157,7 @@ alarm_notify_destroy (GtkObject *object)
an = ALARM_NOTIFY (object);
priv = an->priv;
- /* FIXME */
+ g_hash_table_foreach (priv->uri_client_hash, destroy_loaded_client_cb, NULL);
g_hash_table_destroy (priv->uri_client_hash);
priv->uri_client_hash = NULL;
@@ -153,6 +183,7 @@ AlarmNotify_addCalendar (PortableServer_Servant servant,
AlarmNotifyPrivate *priv;
GnomeVFSURI *uri;
CalClient *client;
+ LoadedClient *lc;
an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
priv = an->priv;
@@ -165,26 +196,33 @@ AlarmNotify_addCalendar (PortableServer_Servant servant,
return;
}
- client = g_hash_table_lookup (priv->uri_client_hash, uri);
+ lc = g_hash_table_lookup (priv->uri_client_hash, uri);
- if (client) {
+ if (lc) {
gnome_vfs_uri_unref (uri);
-
- gtk_object_ref (GTK_OBJECT (client));
+ g_assert (lc->refcount > 0);
+ lc->refcount++;
return;
}
client = cal_client_new ();
if (client) {
- g_hash_table_insert (priv->uri_client_hash, uri);
- alarm_queue_add_client (client);
-
- if (!cal_client_open_calendar (client, str_uri, FALSE)) {
+ if (cal_client_open_calendar (client, str_uri, FALSE)) {
+ lc = g_new (LoadedClient, 1);
+ lc->client = client;
+ lc->uri = uri;
+ lc->refcount = 1;
+ g_hash_table_insert (priv->uri_client_hash, uri, lc);
+
+ alarm_queue_add_client (client);
+ } else {
gtk_object_unref (GTK_OBJECT (client));
client = NULL;
}
- } else {
+ }
+
+ if (!client) {
gnome_vfs_uri_unref (uri);
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
@@ -197,26 +235,59 @@ AlarmNotify_addCalendar (PortableServer_Servant servant,
/* AlarmNotify::removeCalendar method */
static void
AlarmNotify_removeCalendar (PortableServer_Servant servant,
- const CORBA_char *uri,
+ const CORBA_char *str_uri,
CORBA_Environment *ev)
{
AlarmNotify *an;
AlarmNotifyPrivate *priv;
- CalClient *client;
- char *orig_uri;
+ LoadedClient *lc;
+ GnomeVFSURI *uri;
an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
priv = an->priv;
- if (!g_hash_table_lookup_extended (priv->uri_client_hash, uri, &orig_uri, &client)) {
+ uri = gnome_vfs_uri_new (str_uri);
+ if (!uri) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound);
+ ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI,
+ NULL);
return;
}
- gtk_object_unref (client);
+ lc = g_hash_table_lookup (priv->uri_client_hash, uri);
+ gnome_vfs_uri_unref (uri);
+
+ if (!lc) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound,
+ NULL);
+ return;
+ }
- /* FIXME: do we need to do anything else? */
+ g_assert (lc->refcount > 0);
+
+ lc->refcount--;
+ if (lc->refcount > 0)
+ return;
+
+ g_hash_table_remove (priv->uri_client_hash, lc->uri);
+
+ gtk_object_unref (GTK_OBJECT (lc->client));
+ gnome_vfs_uri_unref (lc->uri);
+ g_free (lc);
+}
+
+static void
+AlarmNotify_die (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ AlarmNotify *an;
+ AlarmNotifyPrivate *priv;
+
+ an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
+ priv = an->priv;
+
+ /* FIXME */
}
/**
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index e2f2ae88db..1e235c116d 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -286,13 +286,13 @@ load_alarms (ClientAlarms *ca)
/* Called when a calendar client finished loading; we load its alarms */
static void
-cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data)
+cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
{
ClientAlarms *ca;
ca = data;
- if (status != CAL_CLIENT_LOAD_SUCCESS)
+ if (status != CAL_CLIENT_OPEN_SUCCESS)
return;
load_alarms (ca);
@@ -463,16 +463,16 @@ alarm_queue_add_client (CalClient *client)
ca->uid_alarms_hash = g_hash_table_new (g_str_hash, g_str_equal);
- if (!cal_client_is_loaded (client))
- gtk_signal_connect (GTK_OBJECT (client), "cal_loaded",
- GTK_SIGNAL_FUNC (cal_loaded_cb), ca);
+ if (cal_client_get_load_state (client) != CAL_CLIENT_LOAD_LOADED)
+ gtk_signal_connect (GTK_OBJECT (client), "cal_opened",
+ GTK_SIGNAL_FUNC (cal_opened_cb), ca);
gtk_signal_connect (GTK_OBJECT (client), "obj_updated",
GTK_SIGNAL_FUNC (obj_updated_cb), ca);
gtk_signal_connect (GTK_OBJECT (client), "obj_removed",
GTK_SIGNAL_FUNC (obj_removed_cb), ca);
- if (cal_client_is_loaded (client))
+ if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED)
load_alarms (ca);
}