[evolution-data-server/dbus-hybrid] Let offline listener set local/remote mode in factory.
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/dbus-hybrid] Let offline listener set local/remote mode in factory.
- Date: Mon, 3 Aug 2009 07:28:22 +0000 (UTC)
commit 16532ad9dbe4f3668d2c4e23a9c0f9f2b412dd48
Author: Johnny Jacob <jjohnny novell com>
Date: Mon Aug 3 12:54:48 2009 +0530
Let offline listener set local/remote mode in factory.
addressbook/libedata-book/e-data-book-factory.c | 45 ++++++++++++++++++++++-
addressbook/libedata-book/e-data-book-factory.h | 3 ++
2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index 0692f96..0b2a8b3 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -35,6 +35,7 @@
#include "e-data-book.h"
#include "e-book-backend.h"
#include "e-book-backend-factory.h"
+#include "offline-listener.h"
static void impl_BookFactory_getBook(EDataBookFactory *factory, const char *IN_uri, DBusGMethodInvocation *context);
#include "e-data-book-factory-glue.h"
@@ -72,6 +73,8 @@ struct _EDataBookFactoryPrivate {
GHashTable *connections;
guint exit_timeout;
+
+ gint mode;
};
/* Create the EDataBookFactory error quark */
@@ -135,6 +138,40 @@ e_data_book_factory_register_backends (EDataBookFactory *book_factory)
}
static void
+set_backend_online_status (gpointer key, gpointer value, gpointer data)
+{
+#if 0
+ GList *books = (GList *) value;
+ EBookBackend *backend = NULL;
+
+ while (books = g_list_next (books)) {
+ backend = E_BOOK_BACKEND (books->data);
+ e_book_backend_set_mode (backend, GPOINTER_TO_INT (data));
+ }
+#endif
+}
+
+/**
+ * e_data_book_factory_set_backend_mode:
+ * @factory: A bookendar factory.
+ * @mode: Online mode to set.
+ *
+ * Sets the online mode for all backends created by the given factory.
+ */
+void
+e_data_book_factory_set_backend_mode (EDataBookFactory *factory, gint mode)
+{
+ EDataBookFactoryPrivate *priv = factory->priv;
+
+ priv->mode = mode;
+ g_mutex_lock (priv->connections_lock);
+ g_hash_table_foreach (priv->connections, set_backend_online_status, GINT_TO_POINTER (priv->mode));
+ g_mutex_unlock (priv->connections_lock);
+}
+
+
+
+static void
e_data_book_factory_class_init (EDataBookFactoryClass *e_data_book_factory_class)
{
g_type_class_add_private (e_data_book_factory_class, sizeof (EDataBookFactoryPrivate));
@@ -265,7 +302,7 @@ impl_BookFactory_getBook(EDataBookFactory *factory, const char *IN_source, DBusG
EBookBackend *backend = NULL;
backend = e_book_backend_factory_new_backend (e_data_book_factory_lookup_backend_factory (factory, uri));
book = e_data_book_new (backend, source, book_closed_cb);
- e_book_backend_set_mode (backend, 2); /* TODO: very odd */
+ e_book_backend_set_mode (backend, factory->priv->mode);
g_hash_table_insert (priv->books, g_strdup (path), book);
e_book_backend_add_client (backend, book);
dbus_g_connection_register_g_object (connection, path, G_OBJECT (book));
@@ -327,6 +364,8 @@ main (int argc, char **argv)
DBusGProxy *bus_proxy;
guint32 request_name_ret;
+ OfflineListener *offline_listener = NULL;
+
g_type_init ();
if (!g_thread_supported ()) g_thread_init (NULL);
dbus_g_thread_init ();
@@ -361,8 +400,12 @@ main (int argc, char **argv)
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (bus_proxy, "NameOwnerChanged", G_CALLBACK (name_owner_changed), factory, NULL);
+ offline_listener = offline_listener_new (factory);
+
g_main_loop_run (loop);
+ g_object_unref (offline_listener);
+
dbus_g_connection_unref (connection);
return 0;
diff --git a/addressbook/libedata-book/e-data-book-factory.h b/addressbook/libedata-book/e-data-book-factory.h
index d90a061..13dbb20 100644
--- a/addressbook/libedata-book/e-data-book-factory.h
+++ b/addressbook/libedata-book/e-data-book-factory.h
@@ -52,6 +52,9 @@ GQuark e_data_book_factory_error_quark (void);
GType e_data_book_factory_get_type (void);
+void
+e_data_book_factory_set_backend_mode (EDataBookFactory *factory, gint mode);
+
G_END_DECLS
#endif /* ! __E_DATA_BOOK_FACTORY_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]