aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal-factory.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-09-26 00:35:40 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-09-26 00:35:40 +0800
commitce71400f35232aa9122fceb3436dfc56b8b206e8 (patch)
tree67fae3fc60b7549edad8d2ccf6965cb7a622fead /calendar/pcs/cal-factory.c
parent240af05417b2f326140a2ac8fe4043f457b00976 (diff)
downloadgsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.gz
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.zst
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.zip
use bonobo-exception stuff to clean code
2001-09-25 JP Rosevear <jpr@ximian.com> * pcs/cal.c: use bonobo-exception stuff to clean code * pcs/cal-factory.c (add_uri): add uri to the list if the type matches (impl_CalFactory_uriList): implement uriList method * pcs/cal-backend.h: new virtual function member * pcs/cal-backend.c (cal_backend_is_remote): call virtual function * pcs/cal-backend-file.c (cal_backend_file_class_init): override virtual function (cal_backend_file_is_remote): new virtual function, always return FALSE * idl/evolution-calendar.idl: uriList factory call, with flags for types to get * gui/dialogs/comp-editor.c (comp_editor_destroy): cast to remove warning * gui/e-itip-control.c (write_label_piece): kill warnings by take const char * * gui/component-factory.c (create_object): aggregate offline interface * gui/Makefile.am: compile new files * calobj.[hc]: Remove obsolete files * cal-util/cal-util.h: enum URI types for uriList call * cal-client/cal-client.c (build_uri_list): build list from string sequence (cal_client_uri_list): factory call to get uri list * cal-client/cal-client.h: new proto * cal-client/cal-client.c: use bonobo exception stuff to clean code * gui/calendar-offline-handler.[hc]: Start some skeleton routines for online/offline handling * pcs/cal-factory.c (launch_backend_for_uri): use accessor and remove FIXME svn path=/trunk/; revision=13110
Diffstat (limited to 'calendar/pcs/cal-factory.c')
-rw-r--r--calendar/pcs/cal-factory.c77
1 files changed, 73 insertions, 4 deletions
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index 00f6d8b6da..458279b65f 100644
--- a/calendar/pcs/cal-factory.c
+++ b/calendar/pcs/cal-factory.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <gtk/gtksignal.h>
#include <liboaf/liboaf.h>
+#include "evolution-calendar.h"
#include "cal.h"
#include "cal-backend.h"
#include "cal-factory.h"
@@ -50,6 +51,13 @@ struct _CalFactoryPrivate {
guint registered : 1;
};
+typedef struct
+{
+ CalFactory *factory;
+ GNOME_Evolution_Calendar_UriType type;
+ GNOME_Evolution_Calendar_StringSeq *list;
+} CalFactoryUriData;
+
/* Signal IDs */
enum SIGNALS {
LAST_CALENDAR_GONE,
@@ -162,15 +170,13 @@ static CalBackend *
launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_Calendar_Listener listener)
{
CalFactoryPrivate *priv;
- char *method;
+ const char *method;
GtkType *type;
CalBackend *backend;
priv = factory->priv;
- /* FIXME: add an accessor function to gnome-vfs */
- method = uri->method_string;
-
+ method = gnome_vfs_uri_get_scheme (uri);
type = g_hash_table_lookup (priv->methods, method);
if (!type) {
@@ -301,6 +307,41 @@ add_calendar_client (CalFactory *factory, CalBackend *backend, GNOME_Evolution_C
CORBA_exception_free (&ev);
}
+/* Add a uri to a string list */
+static void
+add_uri (gpointer key, gpointer value, gpointer data)
+{
+ CalFactoryUriData *cfud = data;
+ CalFactory *factory = cfud->factory;
+ GNOME_Evolution_Calendar_StringSeq *list = cfud->list;
+ GNOME_Evolution_Calendar_UriType type = cfud->type;
+ char *uri_string = key;
+ CalBackend *backend;
+ GnomeVFSURI *uri;
+
+ switch (type) {
+ case GNOME_Evolution_Calendar_URI_LOCAL:
+ uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE);
+ backend = lookup_backend (factory, uri);
+ gnome_vfs_uri_unref (uri);
+ if (backend == NULL && cal_backend_is_remote (backend))
+ return;
+ break;
+ case GNOME_Evolution_Calendar_URI_REMOTE:
+ uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE);
+ backend = lookup_backend (factory, uri);
+ gnome_vfs_uri_unref (uri);
+ if (backend == NULL && !cal_backend_is_remote (backend))
+ return;
+ break;
+ case GNOME_Evolution_Calendar_URI_ANY:
+ break;
+ }
+
+ list->_buffer[list->_length] = CORBA_string_dup (uri_string);
+ list->_length++;
+}
+
/* Job data */
typedef struct {
CalFactory *factory;
@@ -427,6 +468,33 @@ impl_CalFactory_open (PortableServer_Servant servant,
job_add (open_fn, jd);
}
+static GNOME_Evolution_Calendar_StringSeq *
+impl_CalFactory_uriList (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_UriType type,
+ CORBA_Environment *ev)
+{
+ CalFactory *factory;
+ CalFactoryPrivate *priv;
+ CalFactoryUriData cfud;
+ GNOME_Evolution_Calendar_StringSeq *list;
+
+ factory = CAL_FACTORY (bonobo_object_from_servant (servant));
+ priv = factory->priv;
+
+ list = GNOME_Evolution_Calendar_StringSeq__alloc ();
+ list->_length = 0;
+ list->_maximum = g_hash_table_size (priv->backends);
+ list->_buffer = CORBA_sequence_CORBA_string_allocbuf (list->_maximum);
+
+ cfud.factory = factory;
+ cfud.type = type;
+ cfud.list = list;
+ g_hash_table_foreach (priv->backends, add_uri, &cfud);
+
+ return list;
+
+}
+
/**
@@ -508,6 +576,7 @@ cal_factory_class_init (CalFactoryClass *klass)
/* Epv methods */
epv->open = impl_CalFactory_open;
+ epv->uriList = impl_CalFactory_uriList;
}
/* Object initialization function for the calendar factory */