[evolution-data-server] Let offline listener set local/remote mode in factory.
- From: Ross Burton <rburton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Let offline listener set local/remote mode in factory.
- Date: Mon, 17 Aug 2009 12:05:17 +0000 (UTC)
commit dd46c649675c61e11d6cef1f17fd0afbabd47251
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/Makefile.am | 4 +--
addressbook/libedata-book/e-data-book-factory.c | 45 ++++++++++++++++++++++-
addressbook/libedata-book/e-data-book-factory.h | 2 +
3 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/libedata-book/Makefile.am b/addressbook/libedata-book/Makefile.am
index a13e143..00eb44e 100644
--- a/addressbook/libedata-book/Makefile.am
+++ b/addressbook/libedata-book/Makefile.am
@@ -35,8 +35,6 @@ libedata_book_1_2_la_SOURCES = \
e-data-book.c \
ximian-vcard.h \
opid.c opid.h \
- offline-listener.c \
- offline-listener.h \
$(ENUM_GENERATED)
libedata_book_1_2_la_LIBADD = \
@@ -92,5 +90,5 @@ dist-hook:
factorydir = $(libexecdir)
factory_PROGRAMS = e-addressbook-factory
-e_addressbook_factory_SOURCES = e-data-book-factory.c e-data-book-factory.h
+e_addressbook_factory_SOURCES = e-data-book-factory.c e-data-book-factory.h offline-listener.c offline-listener.h
e_addressbook_factory_LDADD = libedata-book-1.2.la
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..298a988 100644
--- a/addressbook/libedata-book/e-data-book-factory.h
+++ b/addressbook/libedata-book/e-data-book-factory.h
@@ -52,6 +52,8 @@ 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]