From dae9728b0d2a4c24b8ddc1a8a45a3e2ca02c18bf Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 20 Feb 2001 22:35:35 +0000 Subject: Added a `registered' field. (cal_factory_oaf_register): New function; now 2001-02-16 Federico Mena Quintero * 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 --- calendar/pcs/cal-factory.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++ calendar/pcs/cal-factory.h | 5 +++- 2 files changed, 71 insertions(+), 1 deletion(-) (limited to 'calendar/pcs') 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 #include #include +#include #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; @@ -669,6 +685,57 @@ str_tolower (const char *s) return str; } +/** + * 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. 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); -- cgit v1.2.3