aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-02-21 06:35:35 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-02-21 06:35:35 +0800
commitdae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf (patch)
tree07b54daad83f6572a4162e5a02aaaf58848280a0 /calendar
parentf9a92db9a9b72e9e65f59f20469cc72e6c84186f (diff)
downloadgsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar.gz
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar.bz2
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar.lz
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar.xz
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.tar.zst
gsoc2013-evolution-dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf.zip
Added a `registered' field. (cal_factory_oaf_register): New function; now
2001-02-16 Federico Mena Quintero <federico@ximian.com> * pcs/cal-factory.c (CalFactoryPrivate): Added a `registered' field. (cal_factory_oaf_register): New function; now the factory performs its own registration with OAF. (cal_factory_destroy): Unregister from OAF if appropriate. svn path=/trunk/; revision=8308
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog8
-rw-r--r--calendar/gui/alarm-notify/Makefile.am6
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c55
-rw-r--r--calendar/idl/evolution-calendar.idl13
-rw-r--r--calendar/pcs/cal-factory.c67
-rw-r--r--calendar/pcs/cal-factory.h5
6 files changed, 149 insertions, 5 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 9e37386e7d..acdead7cf6 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,11 @@
+2001-02-16 Federico Mena Quintero <federico@ximian.com>
+
+ * pcs/cal-factory.c (CalFactoryPrivate): Added a `registered'
+ field.
+ (cal_factory_oaf_register): New function; now the factory performs
+ its own registration with OAF.
+ (cal_factory_destroy): Unregister from OAF if appropriate.
+
2001-02-19 JP Rosevear <jpr@ximian.com>
* conduits/todo/Makefile.am: Remove PISOCK_LIBDIR
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 2bfdfa38df..5df0b3c234 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -30,6 +30,12 @@ INCLUDES = \
gladedir = $(datadir)/evolution/glade
evolution_alarm_notify_SOURCES = \
+ alarm.c \
+ alarm.h \
+ alarm-notify.c \
+ alarm-notify.h \
+ alarm-queue.c \
+ alarm-queue.h \
notify-main.c
evolution_alarm_notify_LDADD = \
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 60346ba801..9d64bfd4a8 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -24,6 +24,8 @@
#include "config.h"
#endif
+#include <libgnomevfs/gnome-vfs.h>
+#include <cal-client/cal-client.h>
#include "alarm-notify.h"
@@ -109,7 +111,7 @@ alarm_notify_init (AlarmNotify *an)
priv = g_new0 (AlarmNotifyPrivate, 1);
an->priv = priv;
- /* FIXME */
+ priv->uri_client_hash = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
}
/* Destroy handler for the alarm notify system */
@@ -127,6 +129,9 @@ alarm_notify_destroy (GtkObject *object)
/* FIXME */
+ g_hash_table_destroy (priv->uri_client_hash);
+ priv->uri_client_hash = NULL;
+
g_free (priv);
an->priv = NULL;
@@ -145,13 +150,47 @@ AlarmNotify_addCalendar (PortableServer_Servant servant,
CORBA_Environment *ev)
{
AlarmNotify *an;
+ AlarmNotifyPrivate *priv;
GnomeVFSURI *uri;
CalClient *client;
an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
+ priv = an->priv;
uri = gnome_vfs_uri_new (str_uri);
if (!uri) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_AlarmNotify_InvalidURI,
+ NULL);
+ return;
+ }
+
+ client = g_hash_table_lookup (priv->uri_client_hash, uri);
+
+ if (client) {
+ gnome_vfs_uri_unref (uri);
+
+ gtk_object_ref (GTK_OBJECT (client));
+ 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)) {
+ gtk_object_unref (GTK_OBJECT (client));
+ client = NULL;
+ }
+ } else {
+ gnome_vfs_uri_unref (uri);
+
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_AlarmNotify_BackendContactError,
+ NULL);
+ return;
}
}
@@ -162,10 +201,22 @@ AlarmNotify_removeCalendar (PortableServer_Servant servant,
CORBA_Environment *ev)
{
AlarmNotify *an;
+ AlarmNotifyPrivate *priv;
+ CalClient *client;
+ char *orig_uri;
an = ALARM_NOTIFY (bonobo_object_from_servant (servant));
+ priv = an->priv;
- /* FIXME */
+ if (!g_hash_table_lookup_extended (priv->uri_client_hash, uri, &orig_uri, &client)) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_AlarmNotify_NotFound);
+ return;
+ }
+
+ gtk_object_unref (client);
+
+ /* FIXME: do we need to do anything else? */
}
/**
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index 571d514370..c3de81e41f 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -188,11 +188,20 @@ module Calendar {
/* Interface to the alarm notification service */
interface AlarmNotify : Bonobo::Unknown {
+ exception InvalidURI {};
+ exception BackendContactError {};
+ exception NotFound {};
+
/* Adds a calendar to the alarm notification system */
- void addCalendar (in string uri);
+ void addCalendar (in string uri)
+ raises (InvalidURI, BackendContactError);
/* Removes a calendar from the alarm notification system */
- void removeCalendar (in string uri);
+ void removeCalendar (in string uri)
+ raises (NotFound);
+
+ /* Makes the alarm notification daemon unconditionally exit */
+ void die ();
};
};
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index 40ffd2b735..d0bbd278d1 100644
--- a/calendar/pcs/cal-factory.c
+++ b/calendar/pcs/cal-factory.c
@@ -24,6 +24,7 @@
#include <ctype.h>
#include <stdio.h>
#include <gtk/gtksignal.h>
+#include <liboaf/liboaf.h>
#include "cal.h"
#include "cal-backend.h"
#include "cal-factory.h"
@@ -31,6 +32,9 @@
+/* OAF ID for registration */
+#define CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory"
+
/* Private part of the CalFactory structure */
struct _CalFactoryPrivate {
/* Hash table from URI method strings to GtkType * for backend class types */
@@ -38,6 +42,9 @@ struct _CalFactoryPrivate {
/* Hash table from GnomeVFSURI structures to CalBackend objects */
GHashTable *backends;
+
+ /* Whether we have been registered with OAF yet */
+ guint registered : 1;
};
@@ -136,6 +143,7 @@ cal_factory_init (CalFactory *factory)
priv->methods = g_hash_table_new (g_str_hash, g_str_equal);
priv->backends = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
+ priv->registered = FALSE;
}
/* Frees a method/GtkType * pair from the methods hash table */
@@ -189,6 +197,14 @@ cal_factory_destroy (GtkObject *object)
g_hash_table_destroy (priv->backends);
priv->backends = NULL;
+ if (priv->registered) {
+ CORBA_Object obj;
+
+ obj = bonobo_object_corba_objref (BONOBO_OBJECT (factory));
+ oaf_active_server_unregister (CAL_FACTORY_OAF_ID, obj);
+ priv->registered = FALSE;
+ }
+
g_free (priv);
factory->priv = NULL;
@@ -670,6 +686,57 @@ str_tolower (const char *s)
}
/**
+ * cal_factory_oaf_register:
+ * @factory: A calendar factory.
+ *
+ * Registers a calendar factory with the OAF object activation daemon. This
+ * function must be called before any clients can activate the factory.
+ *
+ * Return value: TRUE on success, FALSE otherwise.
+ **/
+gboolean
+cal_factory_oaf_register (CalFactory *factory)
+{
+ CalFactoryPrivate *priv;
+ OAF_RegistrationResult result;
+ CORBA_Object obj;
+
+ g_return_val_if_fail (factory != NULL, FALSE);
+ g_return_val_if_fail (IS_CAL_FACTORY (factory), FALSE);
+
+ priv = factory->priv;
+
+ g_return_val_if_fail (!priv->registered, FALSE);
+
+ obj = bonobo_object_corba_objref (BONOBO_OBJECT (factory));
+ result = oaf_active_server_register (CAL_FACTORY_OAF_ID, obj);
+
+ switch (result) {
+ case OAF_REG_SUCCESS:
+ priv->registered = TRUE;
+ return TRUE;
+
+ case OAF_REG_NOT_LISTED:
+ g_message ("cal_factory_oaf_register(): Cannot register the calendar factory: "
+ "not listed");
+ break;
+
+ case OAF_REG_ALREADY_ACTIVE:
+ g_message ("cal_factory_oaf_register(): Cannot register the calendar factory: "
+ "already active");
+ break;
+
+ case OAF_REG_ERROR:
+ default:
+ g_message ("cal_factory_oaf_register(): Cannot register the calendar factory: "
+ "generic error");
+ break;
+ }
+
+ return FALSE;
+}
+
+/**
* cal_factory_register_method:
* @factory: A calendar factory.
* @method: Method for the URI, i.e. "http", "file", etc.
diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h
index 4bdf9bf52f..ac28a5935b 100644
--- a/calendar/pcs/cal-factory.h
+++ b/calendar/pcs/cal-factory.h
@@ -60,11 +60,14 @@ struct _CalFactoryClass {
GtkType cal_factory_get_type (void);
-CalFactory *cal_factory_construct (CalFactory *factory, GNOME_Evolution_Calendar_CalFactory corba_factory);
+CalFactory *cal_factory_construct (CalFactory *factory,
+ GNOME_Evolution_Calendar_CalFactory corba_factory);
GNOME_Evolution_Calendar_CalFactory cal_factory_corba_object_create (BonoboObject *object);
CalFactory *cal_factory_new (void);
+gboolean cal_factory_oaf_register (CalFactory *factory);
+
void cal_factory_register_method (CalFactory *factory, const char *method, GtkType backend_type);
int cal_factory_get_n_backends (CalFactory *factory);