[evolution-data-server] Add e_data_factory_ref_backend_factory().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add e_data_factory_ref_backend_factory().
- Date: Tue, 17 Apr 2012 16:59:00 +0000 (UTC)
commit 936eed3e0baaa0c262ebb0b968d0bb70475a9ff4
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Apr 17 12:43:43 2012 -0400
Add e_data_factory_ref_backend_factory().
Just a way to get access to the EBackendFactory itself.
Needed on the account-mgmt branch to check whether a suitable E-D-S
backend factory is available to handle a given GNOME Online Account
provider type such as "exchange".
.../reference/libebackend/libebackend-sections.txt | 1 +
libebackend/e-data-factory.c | 48 +++++++++++++++++++-
libebackend/e-data-factory.h | 6 ++-
3 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/libebackend/libebackend-sections.txt b/docs/reference/libebackend/libebackend-sections.txt
index e9fae05..f1872c3 100644
--- a/docs/reference/libebackend/libebackend-sections.txt
+++ b/docs/reference/libebackend/libebackend-sections.txt
@@ -42,6 +42,7 @@ e_backend_factory_get_type
<TITLE>EDataFactory</TITLE>
EDataFactory
e_data_factory_ref_backend
+e_data_factory_ref_backend_factory
<SUBSECTION Standard>
E_DATA_FACTORY
E_IS_DATA_FACTORY
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 206b98f..d415695 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -239,8 +239,8 @@ e_data_factory_ref_backend (EDataFactory *factory,
goto exit;
/* Find a suitable backend factory using the hash key. */
- backend_factory = g_hash_table_lookup (
- factory->priv->backend_factories, hash_key);
+ backend_factory =
+ e_data_factory_ref_backend_factory (factory, hash_key);
if (backend_factory == NULL)
goto exit;
@@ -251,9 +251,53 @@ e_data_factory_ref_backend (EDataFactory *factory,
/* This still does the right thing if backend is NULL. */
g_weak_ref_set (weak_ref, backend);
+ g_object_unref (backend_factory);
+
exit:
g_mutex_unlock (factory->priv->mutex);
return backend;
}
+/**
+ * e_data_factory_ref_backend_factory:
+ * @factory: an #EDataFactory
+ * @hash_key: hash key for an #EBackendFactory
+ *
+ * Returns the #EBackendFactory for @hash_key, or %NULL if no such factory
+ * is registered.
+ *
+ * The returned #EBackendFactory is referenced for thread-safety.
+ * Unreference the #EBackendFactory with g_object_unref() when finished
+ * with it.
+ *
+ * Returns: the #EBackendFactory for @hash_key, or %NULL
+ *
+ * Since: 3.6
+ **/
+EBackendFactory *
+e_data_factory_ref_backend_factory (EDataFactory *factory,
+ const gchar *hash_key)
+{
+ GHashTable *backend_factories;
+ EBackendFactory *backend_factory;
+
+ g_return_val_if_fail (E_IS_DATA_FACTORY (factory), NULL);
+ g_return_val_if_fail (hash_key != NULL, NULL);
+
+ /* It should be safe to lookup backend factories without a mutex
+ * because once initially populated the hash table remains fixed.
+ *
+ * XXX Which might imply the returned factory doesn't *really* need
+ * to be referenced for thread-safety, but better to do it when
+ * not really needed than wish we had in the future. */
+
+ backend_factories = factory->priv->backend_factories;
+ backend_factory = g_hash_table_lookup (backend_factories, hash_key);
+
+ if (backend_factory != NULL)
+ g_object_ref (backend_factory);
+
+ return backend_factory;
+}
+
diff --git a/libebackend/e-data-factory.h b/libebackend/e-data-factory.h
index be6705f..9abf1ef 100644
--- a/libebackend/e-data-factory.h
+++ b/libebackend/e-data-factory.h
@@ -19,8 +19,8 @@
#ifndef E_DATA_FACTORY_H
#define E_DATA_FACTORY_H
-#include <libebackend/e-backend.h>
#include <libebackend/e-dbus-server.h>
+#include <libebackend/e-backend-factory.h>
/* Standard GObject macros */
#define E_TYPE_DATA_FACTORY \
@@ -72,6 +72,10 @@ GType e_data_factory_get_type (void) G_GNUC_CONST;
EBackend * e_data_factory_ref_backend (EDataFactory *factory,
const gchar *hash_key,
ESource *source);
+EBackendFactory *
+ e_data_factory_ref_backend_factory
+ (EDataFactory *factory,
+ const gchar *hash_key);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]