aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal-factory.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-10-04 02:03:14 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-10-04 02:03:14 +0800
commit967083749da817df0ea296343528361c3564a798 (patch)
tree669a3acc0d27852b72a3a5de34446e8ad8d6806b /calendar/pcs/cal-factory.c
parent6726c35ab5c59ac587a3347117b86e91e8655337 (diff)
downloadgsoc2013-evolution-967083749da817df0ea296343528361c3564a798.tar.gz
gsoc2013-evolution-967083749da817df0ea296343528361c3564a798.tar.zst
gsoc2013-evolution-967083749da817df0ea296343528361c3564a798.zip
replace use of gnome_vfs_uri with e_uri
2001-10-03 Rodrigo Moya <rodrigo@ximian.com> * gui/component-factory.c: * gui/calendar-offline-handler.c: * gui/comp-editor-factory.c: replace use of gnome_vfs_uri with e_uri * gui/e-meeting-model.c (start_addressbook_server): make it return void, since the return value does not mind * pcs/cal.c: * pcs/cal-factory.c: * pcs/cal-backend.[ch]: don't use GnomeVFS for URI management * pcs/cal-backend-file.c: ditto, only use GnomeVFS for internal operations * cal-client/cal-client.c (cal_client_open_calendar): don't CORBA_exception_free before checking for exceptions svn path=/trunk/; revision=13380
Diffstat (limited to 'calendar/pcs/cal-factory.c')
-rw-r--r--calendar/pcs/cal-factory.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index 32786861bd..9b4bc2fc67 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 "e-util/e-url.h"
#include "evolution-calendar.h"
#include "cal.h"
#include "cal-backend.h"
@@ -84,13 +85,13 @@ free_method (gpointer key, gpointer value, gpointer data)
static void
free_backend (gpointer key, gpointer value, gpointer data)
{
- GnomeVFSURI *uri;
+ char *uri;
CalBackend *backend;
uri = key;
backend = value;
- gnome_vfs_uri_unref (uri);
+ g_free (uri);
gtk_object_unref (GTK_OBJECT (backend));
}
@@ -98,14 +99,14 @@ free_backend (gpointer key, gpointer value, gpointer data)
/* Looks up a calendar backend in a factory's hash table of uri->cal */
static CalBackend *
-lookup_backend (CalFactory *factory, GnomeVFSURI *uri)
+lookup_backend (CalFactory *factory, const char *uristr)
{
CalFactoryPrivate *priv;
CalBackend *backend;
priv = factory->priv;
- backend = g_hash_table_lookup (priv->backends, uri);
+ backend = g_hash_table_lookup (priv->backends, uristr);
return backend;
}
@@ -115,10 +116,10 @@ backend_last_client_gone_cb (CalBackend *backend, gpointer data)
{
CalFactory *factory;
CalFactoryPrivate *priv;
- GnomeVFSURI *uri;
+ const char *uristr;
gpointer orig_key;
gboolean result;
- GnomeVFSURI *orig_uri;
+ const char *orig_uristr;
fprintf (stderr, "backend_last_client_gone_cb() called!\n");
@@ -127,16 +128,16 @@ backend_last_client_gone_cb (CalBackend *backend, gpointer data)
/* Remove the backend from the hash table */
- uri = cal_backend_get_uri (backend);
- g_assert (uri != NULL);
+ uristr = cal_backend_get_uri (backend);
+ g_assert (uristr != NULL);
- result = g_hash_table_lookup_extended (priv->backends, uri, &orig_key, NULL);
+ result = g_hash_table_lookup_extended (priv->backends, uristr, &orig_key, NULL);
g_assert (result != FALSE);
- orig_uri = orig_key;
+ orig_uristr = orig_key;
- g_hash_table_remove (priv->backends, orig_uri);
- gnome_vfs_uri_unref (orig_uri);
+ g_hash_table_remove (priv->backends, orig_uristr);
+ g_free ((gpointer) orig_uristr);
gtk_object_unref (GTK_OBJECT (backend));
@@ -148,14 +149,13 @@ backend_last_client_gone_cb (CalBackend *backend, gpointer data)
/* Adds a backend to the calendar factory's hash table */
static void
-add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend)
+add_backend (CalFactory *factory, const char *uristr, CalBackend *backend)
{
CalFactoryPrivate *priv;
priv = factory->priv;
- gnome_vfs_uri_ref (uri);
- g_hash_table_insert (priv->backends, uri, backend);
+ g_hash_table_insert (priv->backends, g_strdup (uristr), backend);
gtk_signal_connect (GTK_OBJECT (backend), "last_client_gone",
GTK_SIGNAL_FUNC (backend_last_client_gone_cb),
@@ -167,17 +167,25 @@ add_backend (CalFactory *factory, GnomeVFSURI *uri, CalBackend *backend)
* MethodNotSupported error code.
*/
static CalBackend *
-launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_Calendar_Listener listener)
+launch_backend_for_uri (CalFactory *factory,
+ const char *uristr,
+ GNOME_Evolution_Calendar_Listener listener)
{
CalFactoryPrivate *priv;
const char *method;
GtkType *type;
CalBackend *backend;
+ EUri *uri;
priv = factory->priv;
- method = gnome_vfs_uri_get_scheme (uri);
+ uri = e_uri_new (uristr);
+ if (!uri)
+ return NULL;
+
+ method = uri->protocol;
type = g_hash_table_lookup (priv->methods, method);
+ e_uri_free (uri);
if (!type) {
CORBA_Environment ev;
@@ -205,7 +213,7 @@ launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_C
/* Opens a calendar backend and puts it in the factory's backend hash table */
static CalBackend *
-open_backend (CalFactory *factory, GnomeVFSURI *uri, gboolean only_if_exists,
+open_backend (CalFactory *factory, const char *uristr, gboolean only_if_exists,
GNOME_Evolution_Calendar_Listener listener)
{
CalFactoryPrivate *priv;
@@ -215,15 +223,15 @@ open_backend (CalFactory *factory, GnomeVFSURI *uri, gboolean only_if_exists,
priv = factory->priv;
- backend = launch_backend_for_uri (factory, uri, listener);
+ backend = launch_backend_for_uri (factory, uristr, listener);
if (!backend)
return NULL;
- status = cal_backend_open (backend, uri, only_if_exists);
+ status = cal_backend_open (backend, uristr, only_if_exists);
switch (status) {
case CAL_BACKEND_OPEN_SUCCESS:
- add_backend (factory, uri, backend);
+ add_backend (factory, uristr, backend);
return backend;
case CAL_BACKEND_OPEN_ERROR:
@@ -268,7 +276,9 @@ open_backend (CalFactory *factory, GnomeVFSURI *uri, gboolean only_if_exists,
* object.
*/
static void
-add_calendar_client (CalFactory *factory, CalBackend *backend, GNOME_Evolution_Calendar_Listener listener)
+add_calendar_client (CalFactory *factory,
+ CalBackend *backend,
+ GNOME_Evolution_Calendar_Listener listener)
{
Cal *cal;
CORBA_Environment ev;
@@ -316,21 +326,16 @@ add_uri (gpointer key, gpointer value, gpointer data)
GNOME_Evolution_Calendar_StringSeq *list = cfud->list;
GNOME_Evolution_Calendar_CalMode mode = cfud->mode;
char *uri_string = key;
- CalBackend *backend;
- GnomeVFSURI *uri;
+ CalBackend *backend;
switch (mode) {
case GNOME_Evolution_Calendar_MODE_LOCAL:
- uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE);
- backend = lookup_backend (factory, uri);
- gnome_vfs_uri_unref (uri);
+ backend = lookup_backend (factory, uri_string);
if (backend == NULL && cal_backend_get_mode (backend) == CAL_MODE_LOCAL)
return;
break;
case GNOME_Evolution_Calendar_MODE_REMOTE:
- uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE);
- backend = lookup_backend (factory, uri);
- gnome_vfs_uri_unref (uri);
+ backend = lookup_backend (factory, uri_string);
if (backend == NULL && cal_backend_get_mode (backend) == CAL_MODE_REMOTE)
return;
break;
@@ -356,18 +361,17 @@ open_fn (gpointer data)
{
OpenJobData *jd;
CalFactory *factory;
- GnomeVFSURI *uri;
gboolean only_if_exists;
GNOME_Evolution_Calendar_Listener listener;
CalBackend *backend;
CORBA_Environment ev;
+ char *uri_string;
jd = data;
g_assert (jd->uri != NULL);
/* Check the URI */
-
- uri = gnome_vfs_uri_new_private (jd->uri, TRUE, TRUE, TRUE);
+ uri_string = g_strdup (jd->uri);
g_free (jd->uri);
only_if_exists = jd->only_if_exists;
@@ -375,7 +379,7 @@ open_fn (gpointer data)
listener = jd->listener;
g_free (jd);
- if (!uri) {
+ if (!uri_string) {
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Listener_notifyCalOpened (
listener,
@@ -392,12 +396,10 @@ open_fn (gpointer data)
/* Look up the backend and create it if needed */
- backend = lookup_backend (factory, uri);
+ backend = lookup_backend (factory, uri_string);
if (!backend)
- backend = open_backend (factory, uri, only_if_exists, listener);
-
- gnome_vfs_uri_unref (uri);
+ backend = open_backend (factory, uri_string, only_if_exists, listener);
if (backend)
add_calendar_client (factory, backend, listener);
@@ -428,16 +430,15 @@ impl_CalFactory_open (PortableServer_Servant servant,
gboolean result;
OpenJobData *jd;
GNOME_Evolution_Calendar_Listener listener_copy;
- GnomeVFSURI *uri;
- const char *method_str;
GtkType type;
+ EUri *uri;
factory = CAL_FACTORY (bonobo_object_from_servant (servant));
priv = factory->priv;
/* check URI to see if we support it */
- uri = gnome_vfs_uri_new_private (str_uri, TRUE, TRUE, TRUE);
+ uri = e_uri_new (str_uri);
if (!uri) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI,
@@ -445,10 +446,9 @@ impl_CalFactory_open (PortableServer_Servant servant,
return;
}
- method_str = gnome_vfs_uri_get_scheme (uri);
- type = g_hash_table_lookup (priv->methods, method_str);
+ type = g_hash_table_lookup (priv->methods, uri->protocol);
- gnome_vfs_uri_unref (uri);
+ e_uri_free (uri);
if (!type) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod,
@@ -615,7 +615,7 @@ cal_factory_init (CalFactory *factory)
factory->priv = priv;
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->backends = g_hash_table_new (g_str_hash, g_str_equal);
priv->registered = FALSE;
}