aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-factory.c67
-rw-r--r--calendar/pcs/cal-factory.h5
2 files changed, 71 insertions, 1 deletions
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);