[evolution-data-server/account-mgmt: 12/40] Adapt libebackend to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/account-mgmt: 12/40] Adapt libebackend to the new ESource API.
- Date: Fri, 6 Apr 2012 02:44:19 +0000 (UTC)
commit bed644c88af1b3d80f93ad514580d6e9e09be31d
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Sep 12 14:12:15 2011 -0400
Adapt libebackend to the new ESource API.
.../reference/libebackend/libebackend-sections.txt | 2 +
.../reference/libebackend/tmpl/e-dbus-service.sgml | 76 ------
libebackend/e-backend-factory.c | 5 +-
libebackend/e-backend-factory.h | 2 +
libebackend/e-backend.c | 59 +++++
libebackend/e-backend.h | 4 +-
libebackend/e-data-factory.c | 50 ++++-
libebackend/e-data-factory.h | 3 +
libebackend/e-dbus-service.c | 251 --------------------
libebackend/e-dbus-service.h | 86 -------
libebackend/e-module.c | 4 +-
11 files changed, 121 insertions(+), 421 deletions(-)
---
diff --git a/docs/reference/libebackend/libebackend-sections.txt b/docs/reference/libebackend/libebackend-sections.txt
index cdbe74f..3ea36e1 100644
--- a/docs/reference/libebackend/libebackend-sections.txt
+++ b/docs/reference/libebackend/libebackend-sections.txt
@@ -5,6 +5,7 @@ EBackend
e_backend_get_online
e_backend_set_online
e_backend_get_source
+e_backend_get_registry
e_backend_last_client_gone
<SUBSECTION Standard>
E_BACKEND
@@ -45,6 +46,7 @@ EDataFactory
e_data_factory_get_backend
e_data_factory_get_online
e_data_factory_set_online
+e_data_factory_get_registry
<SUBSECTION Standard>
E_DATA_FACTORY
E_IS_DATA_FACTORY
diff --git a/libebackend/e-backend-factory.c b/libebackend/e-backend-factory.c
index 8050f38..55e2546 100644
--- a/libebackend/e-backend-factory.c
+++ b/libebackend/e-backend-factory.c
@@ -84,6 +84,7 @@ e_backend_factory_get_hash_key (EBackendFactory *factory)
/**
* e_backend_factory_new_backend:
* @factory: an #EBackendFactory
+ * @registry: an #ESourceRegistry
* @source: an #ESource
*
* Returns a new #EBackend instance for @source.
@@ -94,15 +95,17 @@ e_backend_factory_get_hash_key (EBackendFactory *factory)
**/
EBackend *
e_backend_factory_new_backend (EBackendFactory *factory,
+ ESourceRegistry *registry,
ESource *source)
{
EBackendFactoryClass *class;
g_return_val_if_fail (E_IS_BACKEND_FACTORY (factory), NULL);
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
g_return_val_if_fail (E_IS_SOURCE (source), NULL);
class = E_BACKEND_FACTORY_GET_CLASS (factory);
g_return_val_if_fail (class->new_backend != NULL, NULL);
- return class->new_backend (factory, source);
+ return class->new_backend (factory, registry, source);
}
diff --git a/libebackend/e-backend-factory.h b/libebackend/e-backend-factory.h
index 4937e0f..220a65c 100644
--- a/libebackend/e-backend-factory.h
+++ b/libebackend/e-backend-factory.h
@@ -66,6 +66,7 @@ struct _EBackendFactoryClass {
/* Methods */
const gchar * (*get_hash_key) (EBackendFactory *factory);
EBackend * (*new_backend) (EBackendFactory *factory,
+ ESourceRegistry *registry,
ESource *source);
gpointer reserved[16];
@@ -74,6 +75,7 @@ struct _EBackendFactoryClass {
GType e_backend_factory_get_type (void) G_GNUC_CONST;
const gchar * e_backend_factory_get_hash_key (EBackendFactory *factory);
EBackend * e_backend_factory_new_backend (EBackendFactory *factory,
+ ESourceRegistry *registry,
ESource *source);
G_END_DECLS
diff --git a/libebackend/e-backend.c b/libebackend/e-backend.c
index 346f078..e67303f 100644
--- a/libebackend/e-backend.c
+++ b/libebackend/e-backend.c
@@ -40,6 +40,7 @@
((obj), E_TYPE_BACKEND, EBackendPrivate))
struct _EBackendPrivate {
+ ESourceRegistry *registry;
ESource *source;
gboolean online;
};
@@ -47,6 +48,7 @@ struct _EBackendPrivate {
enum {
PROP_0,
PROP_ONLINE,
+ PROP_REGISTRY,
PROP_SOURCE
};
@@ -60,6 +62,16 @@ static guint signals[LAST_SIGNAL];
G_DEFINE_ABSTRACT_TYPE (EBackend, e_backend, G_TYPE_OBJECT)
static void
+backend_set_registry (EBackend *backend,
+ ESourceRegistry *registry)
+{
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (backend->priv->registry == NULL);
+
+ backend->priv->registry = g_object_ref (registry);
+}
+
+static void
backend_set_source (EBackend *backend,
ESource *source)
{
@@ -82,6 +94,12 @@ backend_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_REGISTRY:
+ backend_set_registry (
+ E_BACKEND (object),
+ g_value_get_object (value));
+ return;
+
case PROP_SOURCE:
backend_set_source (
E_BACKEND (object),
@@ -105,6 +123,12 @@ backend_get_property (GObject *object,
E_BACKEND (object)));
return;
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value, e_backend_get_registry (
+ E_BACKEND (object)));
+ return;
+
case PROP_SOURCE:
g_value_set_object (
value, e_backend_get_source (
@@ -122,6 +146,11 @@ backend_dispose (GObject *object)
priv = E_BACKEND_GET_PRIVATE (object);
+ if (priv->registry != NULL) {
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
if (priv->source != NULL) {
g_object_unref (priv->source);
priv->source = NULL;
@@ -157,6 +186,18 @@ e_backend_class_init (EBackendClass *class)
g_object_class_install_property (
object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_SOURCE,
g_param_spec_object (
"source",
@@ -230,6 +271,24 @@ e_backend_set_online (EBackend *backend,
}
/**
+ * e_backend_get_registry:
+ * @backend: an #EBackend
+ *
+ * Returns the data source registry to which #EBackend:source belongs.
+ *
+ * Returns: an #ESourceRegistry
+ *
+ * Since: 3.4
+ **/
+ESourceRegistry *
+e_backend_get_registry (EBackend *backend)
+{
+ g_return_val_if_fail (E_IS_BACKEND (backend), NULL);
+
+ return backend->priv->registry;
+}
+
+/**
* e_backend_get_source:
* @backend: an #EBackend
*
diff --git a/libebackend/e-backend.h b/libebackend/e-backend.h
index 2649aee..e9a3ffc 100644
--- a/libebackend/e-backend.h
+++ b/libebackend/e-backend.h
@@ -19,7 +19,7 @@
#ifndef E_BACKEND_H
#define E_BACKEND_H
-#include <libedataserver/e-source.h>
+#include <libedataserver/e-source-registry.h>
/* Standard GObject macros */
#define E_TYPE_BACKEND \
@@ -73,6 +73,8 @@ gboolean e_backend_get_online (EBackend *backend);
void e_backend_set_online (EBackend *backend,
gboolean online);
ESource * e_backend_get_source (EBackend *backend);
+ESourceRegistry *
+ e_backend_get_registry (EBackend *backend);
void e_backend_last_client_gone (EBackend *backend);
G_END_DECLS
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 93ee067..dfd1256 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -34,6 +34,8 @@
((obj), E_TYPE_DATA_FACTORY, EDataFactoryPrivate))
struct _EDataFactoryPrivate {
+ ESourceRegistry *registry;
+
/* The mutex guards the 'backends' hash table. The
* 'backend_factories' hash table doesn't really need
* guarding since it gets populated during construction
@@ -51,7 +53,8 @@ struct _EDataFactoryPrivate {
enum {
PROP_0,
- PROP_ONLINE
+ PROP_ONLINE,
+ PROP_REGISTRY
};
/* Forward Declarations */
@@ -70,7 +73,7 @@ data_factory_last_client_gone_cb (EBackend *backend,
const gchar *uid;
source = e_backend_get_source (backend);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_return_if_fail (uid != NULL);
g_mutex_lock (factory->priv->mutex);
@@ -107,6 +110,12 @@ data_factory_get_property (GObject *object,
value, e_data_factory_get_online (
E_DATA_FACTORY (object)));
return;
+
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value, e_data_factory_get_registry (
+ E_DATA_FACTORY (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -119,6 +128,11 @@ data_factory_dispose (GObject *object)
priv = E_DATA_FACTORY_GET_PRIVATE (object);
+ if (priv->registry != NULL) {
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
g_hash_table_remove_all (priv->backends);
g_hash_table_remove_all (priv->backend_factories);
@@ -153,6 +167,11 @@ data_factory_initable_init (GInitable *initable,
priv = E_DATA_FACTORY_GET_PRIVATE (initable);
+ priv->registry = e_source_registry_new_sync (cancellable, error);
+
+ if (priv->registry == NULL)
+ return FALSE;
+
/* Synchronize network monitoring. */
monitor = g_network_monitor_get_default ();
@@ -218,6 +237,17 @@ e_data_factory_class_init (EDataFactoryClass *class)
TRUE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -252,6 +282,7 @@ e_data_factory_get_backend (EDataFactory *factory,
ESource *source)
{
EBackendFactory *backend_factory;
+ ESourceRegistry *registry;
EBackend *backend;
const gchar *uid;
@@ -259,7 +290,7 @@ e_data_factory_get_backend (EDataFactory *factory,
g_return_val_if_fail (hash_key != NULL, NULL);
g_return_val_if_fail (E_IS_SOURCE (source), NULL);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_return_val_if_fail (uid != NULL, NULL);
g_mutex_lock (factory->priv->mutex);
@@ -277,8 +308,11 @@ e_data_factory_get_backend (EDataFactory *factory,
if (backend_factory == NULL)
goto exit;
+ registry = e_data_factory_get_registry (factory);
+
/* Create a new backend for the given source and store it. */
- backend = e_backend_factory_new_backend (backend_factory, source);
+ backend = e_backend_factory_new_backend (
+ backend_factory, registry, source);
if (backend == NULL)
goto exit;
@@ -329,3 +363,11 @@ e_data_factory_set_online (EDataFactory *factory,
G_OBJECT_TYPE_NAME (factory),
online ? "online" : "offline");
}
+
+ESourceRegistry *
+e_data_factory_get_registry (EDataFactory *factory)
+{
+ g_return_val_if_fail (E_IS_DATA_FACTORY (factory), NULL);
+
+ return factory->priv->registry;
+}
diff --git a/libebackend/e-data-factory.h b/libebackend/e-data-factory.h
index 0b57fd3..dc5b7d0 100644
--- a/libebackend/e-data-factory.h
+++ b/libebackend/e-data-factory.h
@@ -21,6 +21,7 @@
#include <libebackend/e-backend.h>
#include <libebackend/e-dbus-server.h>
+#include <libedataserver/e-source-registry.h>
/* Standard GObject macros */
#define E_TYPE_DATA_FACTORY \
@@ -73,6 +74,8 @@ EBackend * e_data_factory_get_backend (EDataFactory *factory,
gboolean e_data_factory_get_online (EDataFactory *factory);
void e_data_factory_set_online (EDataFactory *factory,
gboolean online);
+ESourceRegistry *
+ e_data_factory_get_registry (EDataFactory *factory);
G_END_DECLS
diff --git a/libebackend/e-module.c b/libebackend/e-module.c
index b264598..7863bc7 100644
--- a/libebackend/e-module.c
+++ b/libebackend/e-module.c
@@ -159,7 +159,7 @@ module_load (GTypeModule *type_module)
return TRUE;
fail:
- g_warning ("%s", g_module_error ());
+ g_warning ("%s: %s", G_STRFUNC, g_module_error ());
if (priv->module != NULL)
g_module_close (priv->module);
@@ -289,7 +289,7 @@ e_module_load_all_in_directory (const gchar *dirname)
dir = g_dir_open (dirname, 0, &error);
if (dir == NULL) {
- g_warning ("%s", error->message);
+ g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]