aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-10-11 02:42:47 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-10-11 02:42:47 +0800
commit22d4b2eee51a1854d782d9f6d9d4d61588056666 (patch)
tree0fb69d16d0c4f0ce88cc5eab61e720d19bf275b6
parent5e55caa71bb1a65e5fcde13ae8082780901f85f3 (diff)
downloadgsoc2013-evolution-22d4b2eee51a1854d782d9f6d9d4d61588056666.tar.gz
gsoc2013-evolution-22d4b2eee51a1854d782d9f6d9d4d61588056666.tar.zst
gsoc2013-evolution-22d4b2eee51a1854d782d9f6d9d4d61588056666.zip
Return the original key in the hash table if requested.
2001-10-10 Federico Mena Quintero <federico@ximian.com> * pcs/cal-factory.c (lookup_backend): Return the original key in the hash table if requested. (backend_last_client_gone_cb): Use lookup_backend() so that we have the URI mangling done for us. (impl_CalFactory_open): The type should be GtkType *, not GtkType! svn path=/trunk/; revision=13557
-rw-r--r--calendar/ChangeLog8
-rw-r--r--calendar/pcs/cal-factory.c53
2 files changed, 43 insertions, 18 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 5dd46c31e9..77f93c9f9f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-10 Federico Mena Quintero <federico@ximian.com>
+
+ * pcs/cal-factory.c (lookup_backend): Return the original key in
+ the hash table if requested.
+ (backend_last_client_gone_cb): Use lookup_backend() so that we
+ have the URI mangling done for us.
+ (impl_CalFactory_open): The type should be GtkType *, not GtkType!
+
2001-10-10 JP Rosevear <jpr@ximian.com>
* cal-client/cal-client.c (cal_set_mode_cb): remove unneeded
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index d962b22862..785892ddc4 100644
--- a/calendar/pcs/cal-factory.c
+++ b/calendar/pcs/cal-factory.c
@@ -97,27 +97,46 @@ free_backend (gpointer key, gpointer value, gpointer data)
/* Opening calendars */
-/* Looks up a calendar backend in a factory's hash table of uri->cal */
+/* Looks up a calendar backend in a factory's hash table of uri->cal. If
+ * *non-NULL, orig_uri_return will be set to point to the original key in the
+ * *hash table.
+ */
static CalBackend *
-lookup_backend (CalFactory *factory, const char *uristr)
+lookup_backend (CalFactory *factory, const char *uristr, char **orig_uri_return)
{
CalFactoryPrivate *priv;
- CalBackend *backend;
EUri *uri;
char *tmp;
+ gboolean found;
+ gpointer orig_key;
+ gpointer data;
priv = factory->priv;
uri = e_uri_new (uristr);
- if (!uri)
+ if (!uri) {
+ if (orig_uri_return)
+ *orig_uri_return = NULL;
+
return NULL;
+ }
tmp = e_uri_to_string (uri, FALSE);
- backend = g_hash_table_lookup (priv->backends, tmp);
+ found = g_hash_table_lookup_extended (priv->backends, tmp, &orig_key, &data);
g_free (tmp);
e_uri_free (uri);
- return backend;
+ if (found) {
+ if (orig_uri_return)
+ *orig_uri_return = orig_key;
+
+ return CAL_BACKEND (data);
+ } else {
+ if (orig_uri_return)
+ *orig_uri_return = FALSE;
+
+ return NULL;
+ }
}
/* Callback used when a backend loses its last connected client */
@@ -126,10 +145,9 @@ backend_last_client_gone_cb (CalBackend *backend, gpointer data)
{
CalFactory *factory;
CalFactoryPrivate *priv;
+ CalBackend *ret_backend;
const char *uristr;
- gpointer orig_key;
- gboolean result;
- const char *orig_uristr;
+ char *orig_uristr;
fprintf (stderr, "backend_last_client_gone_cb() called!\n");
@@ -141,13 +159,12 @@ backend_last_client_gone_cb (CalBackend *backend, gpointer data)
uristr = cal_backend_get_uri (backend);
g_assert (uristr != NULL);
- result = g_hash_table_lookup_extended (priv->backends, uristr, &orig_key, NULL);
- g_assert (result != FALSE);
-
- orig_uristr = orig_key;
+ ret_backend = lookup_backend (factory, uristr, &orig_uristr);
+ g_assert (ret_backend != NULL);
+ g_assert (ret_backend == backend);
g_hash_table_remove (priv->backends, orig_uristr);
- g_free ((gpointer) orig_uristr);
+ g_free (orig_uristr);
gtk_object_unref (GTK_OBJECT (backend));
@@ -348,12 +365,12 @@ add_uri (gpointer key, gpointer value, gpointer data)
switch (mode) {
case GNOME_Evolution_Calendar_MODE_LOCAL:
- backend = lookup_backend (factory, uri_string);
+ backend = lookup_backend (factory, uri_string, NULL);
if (backend == NULL || cal_backend_get_mode (backend) != CAL_MODE_LOCAL)
return;
break;
case GNOME_Evolution_Calendar_MODE_REMOTE:
- backend = lookup_backend (factory, uri_string);
+ backend = lookup_backend (factory, uri_string, NULL);
if (backend == NULL || cal_backend_get_mode (backend) != CAL_MODE_REMOTE)
return;
break;
@@ -414,7 +431,7 @@ open_fn (gpointer data)
/* Look up the backend and create it if needed */
- backend = lookup_backend (factory, uri_string);
+ backend = lookup_backend (factory, uri_string, NULL);
if (!backend)
backend = open_backend (factory, uri_string, only_if_exists, listener);
@@ -448,7 +465,7 @@ impl_CalFactory_open (PortableServer_Servant servant,
gboolean result;
OpenJobData *jd;
GNOME_Evolution_Calendar_Listener listener_copy;
- GtkType type;
+ GtkType *type;
EUri *uri;
factory = CAL_FACTORY (bonobo_object_from_servant (servant));