[evolution-data-server/uoa: 3/4] Prototype an "ubuntu-online-accounts" module.



commit 2c45ccfa38a3bb9fbcf2d99d3d1a21d03bdeca24
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Oct 7 10:34:48 2012 -0400

    Prototype an "ubuntu-online-accounts" module.

 configure.ac                                       |   10 +
 modules/Makefile.am                                |    5 +
 modules/ubuntu-online-accounts/Makefile.am         |  121 +++
 .../calendar.service-type.in.in                    |    7 +
 .../contacts.service-type.in.in                    |    8 +
 .../evolution-data-server.application.in.in        |   10 +
 .../google-calendar.service.in.in                  |   19 +
 .../google-contacts.service.in.in                  |   19 +
 .../google-gmail.service.in.in                     |   19 +
 .../ubuntu-online-accounts/mail.service-type.in.in |    7 +
 .../module-data-factory-uoa.c                      |  275 +++++++
 .../module-ubuntu-online-accounts.c                |  819 ++++++++++++++++++++
 .../yahoo-calendar.service.in.in                   |   15 +
 .../yahoo-mail.service.in.in                       |   15 +
 14 files changed, 1349 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a92688d..040dbef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1652,6 +1652,16 @@ modules/Makefile
 modules/cache-reaper/Makefile
 modules/gnome-online-accounts/Makefile
 modules/google-backend/Makefile
+modules/ubuntu-online-accounts/Makefile
+modules/ubuntu-online-accounts/calendar.service-type.in
+modules/ubuntu-online-accounts/contacts.service-type.in
+modules/ubuntu-online-accounts/evolution-data-server.application.in
+modules/ubuntu-online-accounts/google-calendar.service.in
+modules/ubuntu-online-accounts/google-contacts.service.in
+modules/ubuntu-online-accounts/google-gmail.service.in
+modules/ubuntu-online-accounts/mail.service-type.in
+modules/ubuntu-online-accounts/yahoo-calendar.service.in
+modules/ubuntu-online-accounts/yahoo-mail.service.in
 modules/yahoo-backend/Makefile
 private/Makefile
 services/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 1aeca75..b1b652e 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -4,11 +4,16 @@ if HAVE_GOA
 GNOME_ONLINE_ACCOUNTS_DIR = gnome-online-accounts
 endif
 
+if HAVE_UOA
+UBUNTU_ONLINE_ACCOUNTS_DIR = ubuntu-online-accounts
+endif
+
 SUBDIRS = \
 	cache-reaper \
 	google-backend \
 	yahoo-backend \
 	$(GNOME_ONLINE_ACCOUNTS_DIR) \
+	$(UBUNTU_ONLINE_ACCOUNTS_DIR) \
 	$(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/modules/ubuntu-online-accounts/Makefile.am b/modules/ubuntu-online-accounts/Makefile.am
new file mode 100644
index 0000000..a3b9196
--- /dev/null
+++ b/modules/ubuntu-online-accounts/Makefile.am
@@ -0,0 +1,121 @@
+NULL =
+
+module_LTLIBRARIES = module-ubuntu-online-accounts.la
+
+# These aren't actually backends, but that's all
+# the installation directory has historically held.
+ecal_backend_LTLIBRARIES = module-data-cal-factory-uoa.la
+ebook_backend_LTLIBRARIES = module-data-book-factory-uoa.la
+
+module_ubuntu_online_accounts_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-DG_LOG_DOMAIN=\"module-ubuntu-online-accounts\" \
+	$(LIBACCOUNTS_GLIB_CFLAGS) \
+	$(E_BACKEND_CFLAGS) \
+	$(CAMEL_CFLAGS) \
+	$(NULL)
+
+module_ubuntu_online_accounts_la_SOURCES = \
+	module-ubuntu-online-accounts.c \
+	$(NULL)
+
+module_ubuntu_online_accounts_la_LIBADD = \
+	$(top_builddir)/libebackend/libebackend-1.2.la \
+	$(top_builddir)/libedataserver/libedataserver-1.2.la \
+	$(LIBACCOUNTS_GLIB_LIBS) \
+	$(E_BACKEND_LIBS) \
+	$(CAMEL_LIBS) \
+	$(NULL)
+
+module_ubuntu_online_accounts_la_LDFLAGS = \
+	-module -avoid-version $(NO_UNDEFINED) \
+	$(NULL)
+
+module_data_factory_uoa_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-DG_LOG_DOMAIN=\"module-data-factory-uoa\" \
+	$(E_BACKEND_CFLAGS) \
+	$(CAMEL_CFLAGS) \
+	$(SOUP_CFLAGS) \
+	$(LIBACCOUNTS_GLIB_CFLAGS) \
+	$(NULL)
+
+module_data_factory_uoa_SOURCES = \
+	module-data-factory-uoa.c \
+	$(NULL)
+
+module_data_factory_uoa_LIBADD = \
+	$(top_builddir)/libebackend/libebackend-1.2.la \
+	$(top_builddir)/libedataserver/libedataserver-1.2.la \
+	$(E_BACKEND_LIBS) \
+	$(CAMEL_LIBS) \
+	$(SOUP_LIBS) \
+	$(LIBACCOUNTS_GLIB_LIBS) \
+	$(NULL)
+
+module_data_factory_uoa_LDFLAGS = \
+	-module -avoid-version $(NO_UNDEFINED) \
+	$(NULL)
+
+# Libtool forces us to build separate modules for the address book
+# and calendar factories, even though the modules are identical.
+
+module_data_cal_factory_uoa_la_CPPFLAGS = $(module_data_factory_uoa_CPPFLAGS)
+module_data_cal_factory_uoa_la_SOURCES = $(module_data_factory_uoa_SOURCES)
+module_data_cal_factory_uoa_la_LIBADD = $(module_data_factory_uoa_LIBADD)
+module_data_cal_factory_uoa_la_LDFLAGS = $(module_data_factory_uoa_LDFLAGS)
+
+module_data_book_factory_uoa_la_CPPFLAGS = $(module_data_factory_uoa_CPPFLAGS)
+module_data_book_factory_uoa_la_SOURCES = $(module_data_factory_uoa_SOURCES)
+module_data_book_factory_uoa_la_LIBADD = $(module_data_factory_uoa_LIBADD)
+module_data_book_factory_uoa_la_LDFLAGS = $(module_data_factory_uoa_LDFLAGS)
+
+%.application: %.application.in
+	$(AM_V_GEN) $(INTLTOOL_MERGE) --no-translations -x -u $< $@
+
+%.service-type: %.service-type.in
+	$(AM_V_GEN) $(INTLTOOL_MERGE) --no-translations -x -u $< $@
+
+%.service: %.service.in
+	$(AM_V_GEN) $(INTLTOOL_MERGE) --no-translations -x -u $< $@
+
+applicationdir = `$(PKG_CONFIG) --variable=applicationfilesdir libaccounts-glib`
+application_DATA = evolution-data-server.application
+
+servicetypedir = `$(PKG_CONFIG) --variable=servicetypefilesdir libaccounts-glib`
+servicetype_DATA = \
+	mail.service-type \
+	calendar.service-type \
+	contacts.service-type \
+	$(NULL)
+
+servicedir = `$(PKG_CONFIG) --variable=servicefilesdir libaccounts-glib`
+service_DATA = \
+	google-gmail.service \
+	google-calendar.service \
+	google-contacts.service \
+	yahoo-mail.service \
+	yahoo-calendar.service \
+	$(NULL)
+
+EXTRA_DIST = \
+	evolution-data-server.application.in.in \
+	mail.service-type.in.in \
+	calendar.service-type.in.in \
+	contacts.service-type.in.in \
+	google-gmail.service.in.in \
+	google-calendar.service.in.in \
+	google-contacts.service.in.in \
+	yahoo-mail.service.in.in \
+	yahoo-calendar.service.in.in \
+	$(NULL)
+
+DISTCLEANFILES = \
+	$(application_DATA) \
+	$(servicetype_DATA) \
+	$(service_DATA) \
+	$(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/ubuntu-online-accounts/calendar.service-type.in.in b/modules/ubuntu-online-accounts/calendar.service-type.in.in
new file mode 100644
index 0000000..ac03f14
--- /dev/null
+++ b/modules/ubuntu-online-accounts/calendar.service-type.in.in
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-type id="calendar">
+  <_name>Calendar</_name>
+  <_description>Integrate your calendars</_description>
+  <icon>x-office-calendar</icon>
+  <translations>@GETTEXT_PACKAGE@</translations>
+</service-type>
diff --git a/modules/ubuntu-online-accounts/contacts.service-type.in.in b/modules/ubuntu-online-accounts/contacts.service-type.in.in
new file mode 100644
index 0000000..3ced915
--- /dev/null
+++ b/modules/ubuntu-online-accounts/contacts.service-type.in.in
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-type id="contacts">
+  <_name>Contacts</_name>
+  <_description>Integrate your contacts</_description>
+  <icon>x-office-address-book</icon>
+  <translations>@GETTEXT_PACKAGE@</translations>
+</service-type>
+
diff --git a/modules/ubuntu-online-accounts/evolution-data-server.application.in.in b/modules/ubuntu-online-accounts/evolution-data-server.application.in.in
new file mode 100644
index 0000000..8d9277e
--- /dev/null
+++ b/modules/ubuntu-online-accounts/evolution-data-server.application.in.in
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application id="evolution-data-server">
+  <description>Evolution-Data-Server</description>
+  <translations>@GETTEXT_PACKAGE@</translations>
+  <service-types>
+    <service-type id="mail"/>
+    <service-type id="calendar"/>
+    <service-type id="contacts"/>
+  </service-types>
+</application>
diff --git a/modules/ubuntu-online-accounts/google-calendar.service.in.in b/modules/ubuntu-online-accounts/google-calendar.service.in.in
new file mode 100644
index 0000000..7f32a64
--- /dev/null
+++ b/modules/ubuntu-online-accounts/google-calendar.service.in.in
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="google-calendar">
+  <type>calendar</type>
+  <_name>Google Calendar</_name>
+  <provider>google</provider>
+  <translations>@GETTEXT_PACKAGE@</translations>
+
+  <!-- default settings (account settings have precedence over these) -->
+  <template>
+    <group name="auth">
+      <group name="oauth2">
+        <group name="user_agent">
+          <setting name="Scope" type="as">["https://www.googleapis.com/auth/calendar";]</setting>
+          <setting name="ClientId" type="s">923794261470.apps.googleusercontent.com</setting>
+        </group>
+      </group>
+    </group>
+  </template>
+</service>
diff --git a/modules/ubuntu-online-accounts/google-contacts.service.in.in b/modules/ubuntu-online-accounts/google-contacts.service.in.in
new file mode 100644
index 0000000..db62235
--- /dev/null
+++ b/modules/ubuntu-online-accounts/google-contacts.service.in.in
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="google-contacts">
+  <type>contacts</type>
+  <_name>Google Contacts</_name>
+  <provider>google</provider>
+  <translations>@GETTEXT_PACKAGE@</translations>
+
+  <!-- default settings (account settings have precedence over these) -->
+  <template>
+    <group name="auth">
+      <group name="oauth2">
+        <group name="user_agent">
+          <setting name="Scope" type="as">["https://www.google.com/m8/feeds/";]</setting>
+          <setting name="ClientId" type="s">923794261470.apps.googleusercontent.com</setting>
+        </group>
+      </group>
+    </group>
+  </template>
+</service>
diff --git a/modules/ubuntu-online-accounts/google-gmail.service.in.in b/modules/ubuntu-online-accounts/google-gmail.service.in.in
new file mode 100644
index 0000000..5d7f267
--- /dev/null
+++ b/modules/ubuntu-online-accounts/google-gmail.service.in.in
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="google-gmail">
+  <type>mail</type>
+  <_name>GMail</_name>
+  <provider>google</provider>
+  <translations>@GETTEXT_PACKAGE@</translations>
+
+  <!-- default settings (account settings have precedence over these) -->
+  <template>
+    <group name="auth">
+      <group name="oauth2">
+        <group name="user_agent">
+          <setting name="Scope" type="as">["https://mail.google.com/";]</setting>
+          <setting name="ClientId" type="s">923794261470.apps.googleusercontent.com</setting>
+        </group>
+      </group>
+    </group>
+  </template>
+</service>
diff --git a/modules/ubuntu-online-accounts/mail.service-type.in.in b/modules/ubuntu-online-accounts/mail.service-type.in.in
new file mode 100644
index 0000000..6917f3e
--- /dev/null
+++ b/modules/ubuntu-online-accounts/mail.service-type.in.in
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-type id="mail">
+  <_name>Mail</_name>
+  <_description>Integrate your mailboxes</_description>
+  <icon>emblem-mail</icon>
+  <translations>@GETTEXT_PACKAGE@</translations>
+</service-type>
diff --git a/modules/ubuntu-online-accounts/module-data-factory-uoa.c b/modules/ubuntu-online-accounts/module-data-factory-uoa.c
new file mode 100644
index 0000000..6808829
--- /dev/null
+++ b/modules/ubuntu-online-accounts/module-data-factory-uoa.c
@@ -0,0 +1,275 @@
+/*
+ * module-data-factory-uoa.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <libebackend/libebackend.h>
+
+#include <libaccounts-glib/accounts-glib.h>
+
+/* Standard GObject macros */
+#define E_TYPE_DATA_FACTORY_UOA \
+	(e_data_factory_uoa_get_type ())
+#define E_DATA_FACTORY_UOA(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_DATA_FACTORY_UOA, EDataFactoryUoa))
+
+typedef struct _EDataFactoryUoa EDataFactoryUoa;
+typedef struct _EDataFactoryUoaClass EDataFactoryUoaClass;
+
+struct _EDataFactoryUoa {
+	EExtension parent;
+
+	AgManager *ag_manager;
+	GHashTable *ag_accounts;
+
+	gulong account_created_handler_id;
+	gulong account_deleted_handler_id;
+};
+
+struct _EDataFactoryUoaClass {
+	EExtensionClass parent_class;
+};
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_data_factory_uoa_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	EDataFactoryUoa,
+	e_data_factory_uoa,
+	E_TYPE_EXTENSION)
+
+static void
+data_factory_uoa_collect_accounts (EDataFactoryUoa *extension)
+{
+	GList *list, *link;
+
+	list = ag_manager_list (extension->ag_manager);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		AgAccount *ag_account;
+		AgAccountId ag_account_id;
+
+		ag_account_id = GPOINTER_TO_UINT (link->data);
+
+		ag_account = ag_manager_get_account (
+			extension->ag_manager, ag_account_id);
+		g_return_if_fail (ag_account != NULL);
+
+		g_hash_table_insert (
+			extension->ag_accounts,
+			GUINT_TO_POINTER (ag_account_id),
+			g_object_ref (ag_account));
+
+		g_object_unref (ag_account);
+	}
+
+	ag_manager_list_free (list);
+}
+
+static void
+data_factory_uoa_account_created_cb (AgManager *ag_manager,
+                                     AgAccountId ag_account_id,
+                                     EDataFactoryUoa *extension)
+{
+	AgAccount *ag_account;
+
+	ag_account = ag_manager_get_account (ag_manager, ag_account_id);
+	g_return_if_fail (ag_account != NULL);
+
+	g_hash_table_insert (
+		extension->ag_accounts,
+		GUINT_TO_POINTER (ag_account_id),
+		g_object_ref (ag_account));
+
+	g_object_unref (ag_account);
+}
+
+static void
+data_factory_uoa_account_deleted_cb (AgManager *ag_manager,
+                                     AgAccountId ag_account_id,
+                                     EDataFactoryUoa *extension)
+{
+	g_hash_table_remove (
+		extension->ag_accounts,
+		GUINT_TO_POINTER (ag_account_id));
+}
+
+static void
+data_factory_uoa_backend_created_cb (EDataFactory *factory,
+                                     EBackend *backend,
+                                     EDataFactoryUoa *extension)
+{
+	ESource *source;
+	AgAccount *ag_account;
+	AgAccountId ag_account_id;
+	ESourceUoa *uoa_extension;
+	ESourceRegistry *registry = NULL;
+	const gchar *extension_name;
+
+	/* Embed the corresponding AgAccount in the EBackend so the
+	 * backend can retrieve it by name with g_object_get_data(). */
+
+	source = e_backend_get_source (backend);
+	extension_name = E_SOURCE_EXTENSION_UOA;
+
+	/* XXX Both EDataBookFactory and EDataCalFactory have an
+	 *     ESourceRegistry property, so retrieve it by name. */
+	g_object_get (factory, "registry", &registry, NULL);
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+
+	/* Check source and its ancestors for a UOA extension. */
+	source = e_source_registry_find_extension (
+		registry, source, extension_name);
+
+	g_object_unref (registry);
+
+	if (source == NULL)
+		return;
+
+	uoa_extension = e_source_get_extension (source, extension_name);
+	ag_account_id = e_source_uoa_get_account_id (uoa_extension);
+	g_return_if_fail (ag_account_id > 0);
+
+	ag_account = g_hash_table_lookup (
+		extension->ag_accounts,
+		GUINT_TO_POINTER (ag_account_id));
+	if (ag_account != NULL) {
+		g_object_set_data_full (
+			G_OBJECT (backend),
+			"Ubuntu Online Account",
+			g_object_ref (ag_account),
+			(GDestroyNotify) g_object_notify);
+	}
+
+	g_object_unref (source);
+}
+
+static void
+data_factory_uoa_dispose (GObject *object)
+{
+	EDataFactoryUoa *extension;
+
+	extension = E_DATA_FACTORY_UOA (object);
+
+	if (extension->ag_manager != NULL) {
+		g_signal_handler_disconnect (
+			extension->ag_manager,
+			extension->account_created_handler_id);
+		g_signal_handler_disconnect (
+			extension->ag_manager,
+			extension->account_deleted_handler_id);
+		g_object_unref (extension->ag_manager);
+		extension->ag_manager = NULL;
+	}
+
+	g_hash_table_remove_all (extension->ag_accounts);
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_data_factory_uoa_parent_class)->dispose (object);
+}
+
+static void
+data_factory_uoa_finalize (GObject *object)
+{
+	EDataFactoryUoa *extension;
+
+	extension = E_DATA_FACTORY_UOA (object);
+
+	g_hash_table_destroy (extension->ag_accounts);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_data_factory_uoa_parent_class)->finalize (object);
+}
+
+static void
+data_factory_uoa_constructed (GObject *object)
+{
+	EDataFactoryUoa *extension;
+	EExtensible *extensible;
+	gulong handler_id;
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_data_factory_uoa_parent_class)->constructed (object);
+
+	extension = E_DATA_FACTORY_UOA (object);
+	extensible = e_extension_get_extensible (E_EXTENSION (extension));
+
+	/* XXX Is ag_manager_new() failable? */
+	extension->ag_manager = ag_manager_new ();
+
+	data_factory_uoa_collect_accounts (extension);
+
+	handler_id = g_signal_connect (
+		extension->ag_manager, "account-created",
+		G_CALLBACK (data_factory_uoa_account_created_cb), extension);
+	extension->account_created_handler_id = handler_id;
+
+	handler_id = g_signal_connect (
+		extension->ag_manager, "account-deleted",
+		G_CALLBACK (data_factory_uoa_account_deleted_cb), extension);
+	extension->account_deleted_handler_id = handler_id;
+
+	g_signal_connect (
+		extensible, "backend-created",
+		G_CALLBACK (data_factory_uoa_backend_created_cb), extension);
+}
+
+static void
+e_data_factory_uoa_class_init (EDataFactoryUoaClass *class)
+{
+	GObjectClass *object_class;
+	EExtensionClass *extension_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = data_factory_uoa_dispose;
+	object_class->finalize = data_factory_uoa_finalize;
+	object_class->constructed = data_factory_uoa_constructed;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_DATA_FACTORY;
+}
+
+static void
+e_data_factory_uoa_class_finalize (EDataFactoryUoaClass *class)
+{
+}
+
+static void
+e_data_factory_uoa_init (EDataFactoryUoa *extension)
+{
+	extension->ag_accounts = g_hash_table_new_full (
+		(GHashFunc) g_direct_hash,
+		(GEqualFunc) g_direct_equal,
+		(GDestroyNotify) NULL,
+		(GDestroyNotify) g_object_unref);
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_data_factory_uoa_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
new file mode 100644
index 0000000..649cca0
--- /dev/null
+++ b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c
@@ -0,0 +1,819 @@
+/*
+ * module-ubuntu-online-accounts.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <libaccounts-glib/accounts-glib.h>
+
+/* XXX accounts-glib.h should include this */
+#include <libaccounts-glib/ag-auth-data.h>
+
+#include <libebackend/libebackend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_UBUNTU_ONLINE_ACCOUNTS \
+	(e_ubuntu_online_accounts_get_type ())
+#define E_UBUNTU_ONLINE_ACCOUNTS(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_UBUNTU_ONLINE_ACCOUNTS, EUbuntuOnlineAccounts))
+
+/* Service types we support. */
+#define SERVICE_TYPE_MAIL	"mail"
+#define SERVICE_TYPE_CALENDAR	"calendar"
+#define SERVICE_TYPE_CONTACTS	"contacts"
+
+typedef struct _EUbuntuOnlineAccounts EUbuntuOnlineAccounts;
+typedef struct _EUbuntuOnlineAccountsClass EUbuntuOnlineAccountsClass;
+
+struct _EUbuntuOnlineAccounts {
+	EExtension parent;
+
+	AgManager *ag_manager;
+
+	/* AgAccountId -> ESource UID */
+	GHashTable *uoa_to_eds;
+};
+
+struct _EUbuntuOnlineAccountsClass {
+	EExtensionClass parent_class;
+};
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_ubuntu_online_accounts_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	EUbuntuOnlineAccounts,
+	e_ubuntu_online_accounts,
+	E_TYPE_EXTENSION)
+
+static const gchar *
+ubuntu_online_accounts_get_backend_name (const gchar *uoa_provider_name)
+{
+	const gchar *eds_backend_name = NULL;
+
+	/* This is a mapping between AgAccount provider names and
+	 * ESourceCollection backend names.  It requires knowledge
+	 * of other registry modules, possibly even from 3rd party
+	 * packages.  No way around it. */
+
+	if (g_strcmp0 (uoa_provider_name, "google") == 0)
+		eds_backend_name = "google";
+
+	if (g_strcmp0 (uoa_provider_name, "yahoo") == 0)
+		eds_backend_name = "yahoo";
+
+	return eds_backend_name;
+}
+
+static ESourceRegistryServer *
+ubuntu_online_accounts_get_server (EUbuntuOnlineAccounts *extension)
+{
+	EExtensible *extensible;
+
+	extensible = e_extension_get_extensible (E_EXTENSION (extension));
+
+	return E_SOURCE_REGISTRY_SERVER (extensible);
+}
+
+#if 0  /* See XXX comment where this is called from. */
+static gboolean
+ubuntu_online_accounts_provider_name_to_backend_name (GBinding *binding,
+                                                      const GValue *source_value,
+                                                      GValue *target_value,
+                                                      gpointer unused)
+{
+	const gchar *provider_name;
+	const gchar *backend_name;
+
+	provider_name = g_value_get_string (source_value);
+	backend_name = ubuntu_online_accounts_get_backend_name (provider_name);
+	g_return_val_if_fail (backend_name != NULL, FALSE);
+	g_value_set_string (target_value, backend_name);
+
+	return TRUE;
+}
+#endif
+
+static ESource *
+ubuntu_online_accounts_new_source (EUbuntuOnlineAccounts *extension)
+{
+	ESourceRegistryServer *server;
+	ESource *source;
+	GFile *file;
+	GError *error = NULL;
+
+	/* This being a brand new data source, creating the instance
+	 * should never fail but we'll check for errors just the same. */
+	server = ubuntu_online_accounts_get_server (extension);
+	file = e_server_side_source_new_user_file (NULL);
+	source = e_server_side_source_new (server, file, &error);
+	g_object_unref (file);
+
+	if (error != NULL) {
+		g_warn_if_fail (source == NULL);
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+
+	return source;
+}
+
+static void
+ubuntu_online_accounts_dump_auth_data (AgAuthData *ag_auth_data)
+{
+	GHashTable *parameters;
+	GHashTableIter iter;
+	gpointer key;
+	gpointer value;
+
+	parameters = ag_auth_data_get_parameters (ag_auth_data);
+	g_hash_table_iter_init (&iter, parameters);
+
+	g_print ("Auth Parameters\n");
+	g_print ("---------------\n");
+
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		gchar *contents;
+
+		contents = g_strdup_value_contents (value);
+		g_print ("  %s: %s\n", (gchar *) key, contents);
+		g_free (contents);
+	}
+
+	g_print ("\n");
+}
+
+static void
+ubuntu_online_accounts_dump_account_service (AgAccountService *ag_account_service)
+{
+	AgService *ag_service;
+	AgAuthData *ag_auth_data;
+	AgAccountSettingIter iter;
+	const GValue *value;
+	const gchar *display_name;
+	const gchar *key;
+
+	ag_service = ag_account_service_get_service (ag_account_service);
+	display_name = ag_service_get_display_name (ag_service);
+	g_print ("AgService: %s\n", display_name);
+
+	g_print ("\n");
+
+	g_print ("Service Settings\n");
+	g_print ("----------------\n");
+	ag_account_service_settings_iter_init (
+		ag_account_service, &iter, NULL);
+	while (ag_account_service_settings_iter_next (&iter, &key, &value)) {
+		gchar *contents;
+
+		contents = g_strdup_value_contents (value);
+		g_print ("  %s: %s\n", key, contents);
+		g_free (contents);
+	}
+
+	g_print ("\n");
+
+	ag_auth_data = ag_account_service_get_auth_data (ag_account_service);
+	ubuntu_online_accounts_dump_auth_data (ag_auth_data);
+	ag_auth_data_unref (ag_auth_data);
+}
+
+static void
+ubuntu_online_accounts_dump_account (AgAccount *ag_account)
+{
+	AgAccountSettingIter iter;
+	const GValue *value;
+	const gchar *display_name;
+	const gchar *key;
+
+	display_name = ag_account_get_display_name (ag_account);
+	g_print ("AgAccount: %s\n", display_name);
+
+	g_print ("\n");
+
+	g_print ("Account Settings\n");
+	g_print ("----------------\n");
+	ag_account_settings_iter_init (ag_account, &iter, NULL);
+	while (ag_account_settings_iter_next (&iter, &key, &value)) {
+		gchar *contents;
+
+		contents = g_strdup_value_contents (value);
+		g_print ("  %s: %s\n", key, contents);
+		g_free (contents);
+	}
+
+	g_print ("\n");
+}
+
+static void
+ubuntu_online_accounts_config_collection (EUbuntuOnlineAccounts *extension,
+                                          ESource *source,
+                                          AgAccount *ag_account)
+{
+	ESourceExtension *source_extension;
+	AgAccountService *ag_account_service_mail = NULL;
+	AgAccountService *ag_account_service_calendar = NULL;
+	AgAccountService *ag_account_service_contacts = NULL;
+	GList *list, *link;
+	const gchar *extension_name;
+	const gchar *provider_name;
+	const gchar *backend_name;
+
+	g_object_bind_property (
+		ag_account, "display-name",
+		source, "display-name",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		ag_account, "enabled",
+		source, "enabled",
+		G_BINDING_SYNC_CREATE);
+
+	extension_name = E_SOURCE_EXTENSION_UOA;
+	source_extension = e_source_get_extension (source, extension_name);
+
+	g_object_bind_property (
+		ag_account, "id",
+		source_extension, "account-id",
+		G_BINDING_SYNC_CREATE);
+
+	extension_name = E_SOURCE_EXTENSION_COLLECTION;
+	source_extension = e_source_get_extension (source, extension_name);
+
+	/* XXX ARGH! The "provider" property is not readable, despite
+	 *     there being an ag_account_get_provider_name()!!  Filed
+	 *     bug, should be fixed for libaccounts-glib 1.4. */
+#if 0
+	g_object_bind_property_full (
+		ag_account, "provider",
+		source_extension, "backend-name",
+		G_BINDING_SYNC_CREATE,
+		ubuntu_online_accounts_provider_name_to_backend_name,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+#endif
+	/* TEMPORARY */
+	provider_name = ag_account_get_provider_name (ag_account);
+	backend_name = ubuntu_online_accounts_get_backend_name (provider_name);
+	e_source_backend_set_backend_name (
+		E_SOURCE_BACKEND (source_extension), backend_name);
+	/* TEMPORARY */
+
+	/* XXX AgAccount:display-name is the nearest approximation to
+	 *     GoaAccount:identity.  Overloading the property this way
+	 *     feels wrong from an API standpoint, but just going from
+	 *     what I was told. */
+	g_object_bind_property (
+		ag_account, "display-name",
+		source_extension, "identity",
+		G_BINDING_SYNC_CREATE);
+
+	/* List all services and find those with relevant service
+	 * types.  There should only be one of each service type.
+	 *
+	 * XXX We really should not have to create AgAccountService
+	 *     instances ourselves.  The AgAccount itself should own
+	 *     them and provide functions for listing them.  Instead
+	 *     it only provides functions for listing its AgServices,
+	 *     which is decidedly less useful. */
+	list = ag_account_list_services (ag_account);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		AgService *ag_service = link->data;
+		const gchar *service_type;
+
+		service_type = ag_service_get_service_type (ag_service);
+
+		if (g_strcmp0 (service_type, SERVICE_TYPE_MAIL) == 0) {
+			g_warn_if_fail (ag_account_service_mail == NULL);
+			ag_account_service_mail =
+				ag_account_service_new (ag_account, ag_service);
+		}
+
+		if (g_strcmp0 (service_type, SERVICE_TYPE_CALENDAR) == 0) {
+			g_warn_if_fail (ag_account_service_calendar == NULL);
+			ag_account_service_calendar =
+				ag_account_service_new (ag_account, ag_service);
+		}
+
+		if (g_strcmp0 (service_type, SERVICE_TYPE_CONTACTS) == 0) {
+			g_warn_if_fail (ag_account_service_contacts == NULL);
+			ag_account_service_contacts =
+				ag_account_service_new (ag_account, ag_service);
+		}
+	}
+	ag_service_list_free (list);
+
+	ubuntu_online_accounts_dump_account (ag_account);
+
+	if (ag_account_service_mail != NULL) {
+		g_object_bind_property (
+			ag_account_service_mail, "enabled",
+			source_extension, "mail-enabled",
+			G_BINDING_SYNC_CREATE);
+		ubuntu_online_accounts_dump_account_service (
+			ag_account_service_mail);
+
+		/* Stash the AgAccountService in the ESource to keep
+		 * the property binding alive.  It will be finalized
+		 * along with the ESource. */
+		g_object_set_data_full (
+			G_OBJECT (source),
+			"ag-account-service-mail",
+			ag_account_service_mail,
+			(GDestroyNotify) g_object_unref);
+	}
+
+	if (ag_account_service_calendar != NULL) {
+		g_object_bind_property (
+			ag_account_service_calendar, "enabled",
+			source_extension, "calendar-enabled",
+			G_BINDING_SYNC_CREATE);
+		ubuntu_online_accounts_dump_account_service (
+			ag_account_service_calendar);
+
+		/* Stash the AgAccountService in the ESource to keep
+		 * the property binding alive.  It will be finalized
+		 * along with the ESource. */
+		g_object_set_data_full (
+			G_OBJECT (source),
+			"ag-account-service-calendar",
+			ag_account_service_calendar,
+			(GDestroyNotify) g_object_unref);
+	}
+
+	if (ag_account_service_contacts != NULL) {
+		g_object_bind_property (
+			ag_account_service_contacts, "enabled",
+			source_extension, "contacts-enabled",
+			G_BINDING_SYNC_CREATE);
+		ubuntu_online_accounts_dump_account_service (
+			ag_account_service_contacts);
+
+		/* Stash the AgAccountService in the ESource to keep
+		 * the property binding alive.  It will be finalized
+		 * along with the ESource. */
+		g_object_set_data_full (
+			G_OBJECT (source),
+			"ag-account-service-contacts",
+			ag_account_service_contacts,
+			(GDestroyNotify) g_object_unref);
+	}
+
+	/* The data source should not be removable by clients. */
+	e_server_side_source_set_removable (
+		E_SERVER_SIDE_SOURCE (source), FALSE);
+}
+
+static void
+ubuntu_online_accounts_config_mail_account (EUbuntuOnlineAccounts *extension,
+                                            ESource *source,
+                                            AgAccount *ag_account)
+{
+	EServerSideSource *server_side_source;
+
+	/* FIXME Configure auth mechanism. */
+
+	/* Clients may change the source but may not remove it. */
+	server_side_source = E_SERVER_SIDE_SOURCE (source);
+	e_server_side_source_set_writable (server_side_source, TRUE);
+	e_server_side_source_set_removable (server_side_source, FALSE);
+}
+
+static void
+ubuntu_online_accounts_config_mail_identity (EUbuntuOnlineAccounts *extension,
+                                             ESource *source,
+                                             AgAccount *ag_account)
+{
+	EServerSideSource *server_side_source;
+
+	/* FIXME Configure email address. */
+
+	/* Clients may change the source but may not remove it. */
+	server_side_source = E_SERVER_SIDE_SOURCE (source);
+	e_server_side_source_set_writable (server_side_source, TRUE);
+	e_server_side_source_set_removable (server_side_source, FALSE);
+}
+
+static void
+ubuntu_online_accounts_config_mail_transport (EUbuntuOnlineAccounts *extension,
+                                              ESource *source,
+                                              AgAccount *ag_account)
+{
+	EServerSideSource *server_side_source;
+
+	/* FIXME Configure auth mechanism. */
+
+	/* Clients may change the source but may not remove it. */
+	server_side_source = E_SERVER_SIDE_SOURCE (source);
+	e_server_side_source_set_writable (server_side_source, TRUE);
+	e_server_side_source_set_removable (server_side_source, FALSE);
+}
+
+static void
+ubuntu_online_accounts_config_sources (EUbuntuOnlineAccounts *extension,
+                                       ESource *source,
+                                       AgAccount *ag_account)
+{
+	ESourceRegistryServer *server;
+	ECollectionBackend *backend;
+	GList *list, *link;
+
+	ubuntu_online_accounts_config_collection (
+		extension, source, ag_account);
+
+	server = ubuntu_online_accounts_get_server (extension);
+	backend = e_source_registry_server_ref_backend (server, source);
+	g_return_if_fail (backend != NULL);
+
+	list = e_collection_backend_list_mail_sources (backend);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		const gchar *extension_name;
+
+		source = E_SOURCE (link->data);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		if (e_source_has_extension (source, extension_name))
+			ubuntu_online_accounts_config_mail_account (
+				extension, source, ag_account);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		if (e_source_has_extension (source, extension_name))
+			ubuntu_online_accounts_config_mail_identity (
+				extension, source, ag_account);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+		if (e_source_has_extension (source, extension_name))
+			ubuntu_online_accounts_config_mail_transport (
+				extension, source, ag_account);
+	}
+
+	g_list_free_full (list, (GDestroyNotify) g_object_unref);
+
+	g_object_unref (backend);
+}
+
+static void
+ubuntu_online_accounts_create_collection (EUbuntuOnlineAccounts *extension,
+                                          EBackendFactory *backend_factory,
+                                          AgAccount *ag_account)
+{
+	ESourceRegistryServer *server;
+	ESource *collection_source;
+	ESource *mail_account_source;
+	ESource *mail_identity_source;
+	ESource *mail_transport_source;
+	const gchar *parent_uid;
+	GError *error = NULL;
+
+	server = ubuntu_online_accounts_get_server (extension);
+
+	collection_source = ubuntu_online_accounts_new_source (extension);
+	g_return_if_fail (E_IS_SOURCE (collection_source));
+
+	mail_account_source = ubuntu_online_accounts_new_source (extension);
+	g_return_if_fail (E_IS_SOURCE (mail_account_source));
+
+	mail_identity_source = ubuntu_online_accounts_new_source (extension);
+	g_return_if_fail (E_IS_SOURCE (mail_identity_source));
+
+	mail_transport_source = ubuntu_online_accounts_new_source (extension);
+	g_return_if_fail (E_IS_SOURCE (mail_transport_source));
+
+	/* Configure parent/child relationships. */
+	parent_uid = e_source_get_uid (collection_source);
+	e_source_set_parent (mail_account_source, parent_uid);
+	e_source_set_parent (mail_identity_source, parent_uid);
+	e_source_set_parent (mail_transport_source, parent_uid);
+
+	/* Give the factory first crack at mail configuration. */
+	e_collection_backend_factory_prepare_mail (
+		E_COLLECTION_BACKEND_FACTORY (backend_factory),
+		mail_account_source,
+		mail_identity_source,
+		mail_transport_source);
+
+	/* Not it's our turn. */
+	ubuntu_online_accounts_config_collection (
+		extension, collection_source, ag_account);
+	ubuntu_online_accounts_config_mail_account (
+		extension, mail_account_source, ag_account);
+	ubuntu_online_accounts_config_mail_identity (
+		extension, mail_identity_source, ag_account);
+	ubuntu_online_accounts_config_mail_transport (
+		extension, mail_transport_source, ag_account);
+
+	/* Export the new source collection. */
+	e_source_registry_server_add_source (server, collection_source);
+	e_source_registry_server_add_source (server, mail_account_source);
+	e_source_registry_server_add_source (server, mail_identity_source);
+	e_source_registry_server_add_source (server, mail_transport_source);
+
+	g_hash_table_insert (
+		extension->uoa_to_eds,
+		GUINT_TO_POINTER (ag_account->id),
+		g_strdup (parent_uid));
+
+	g_object_unref (collection_source);
+	g_object_unref (mail_account_source);
+	g_object_unref (mail_identity_source);
+	g_object_unref (mail_transport_source);
+}
+
+static void
+ubuntu_online_accounts_remove_collection (EUbuntuOnlineAccounts *extension,
+                                          ESource *source)
+{
+	GError *error = NULL;
+
+	/* This removes the entire subtree rooted at source.
+	 * Deletes the corresponding on-disk key files too. */
+	e_source_remove_sync (source, NULL, &error);
+
+	if (error != NULL) {
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
+
+static void
+ubuntu_online_accounts_account_created_cb (AgManager *ag_manager,
+                                           AgAccountId ag_account_id,
+                                           EUbuntuOnlineAccounts *extension)
+{
+	AgAccount *ag_account;
+	ESourceRegistryServer *server;
+	EBackendFactory *backend_factory = NULL;
+	const gchar *provider_name;
+	const gchar *backend_name;
+	const gchar *source_uid;
+
+	server = ubuntu_online_accounts_get_server (extension);
+
+	ag_account = ag_manager_get_account (ag_manager, ag_account_id);
+	g_return_if_fail (ag_account != NULL);
+
+	provider_name = ag_account_get_provider_name (ag_account);
+	backend_name = ubuntu_online_accounts_get_backend_name (provider_name);
+
+	source_uid = g_hash_table_lookup (
+		extension->uoa_to_eds,
+		GUINT_TO_POINTER (ag_account_id));
+
+	if (source_uid == NULL && backend_name != NULL)
+		backend_factory = e_data_factory_ref_backend_factory (
+			E_DATA_FACTORY (server), backend_name);
+
+	if (backend_factory != NULL) {
+		ubuntu_online_accounts_create_collection (
+			extension, backend_factory, ag_account);
+		g_object_unref (backend_factory);
+	}
+
+	g_object_unref (ag_account);
+}
+
+static void
+ubuntu_online_accounts_account_deleted_cb (AgManager *ag_manager,
+                                           AgAccountId ag_account_id,
+                                           EUbuntuOnlineAccounts *extension)
+{
+	ESource *source = NULL;
+	ESourceRegistryServer *server;
+	const gchar *source_uid;
+
+	server = ubuntu_online_accounts_get_server (extension);
+
+	source_uid = g_hash_table_lookup (
+		extension->uoa_to_eds,
+		GUINT_TO_POINTER (ag_account_id));
+
+	if (source_uid != NULL)
+		source = e_source_registry_server_ref_source (
+			server, source_uid);
+
+	if (source != NULL) {
+		ubuntu_online_accounts_remove_collection (extension, source);
+		g_object_unref (source);
+	}
+}
+
+static void
+ubuntu_online_accounts_populate_accounts_table (EUbuntuOnlineAccounts *extension,
+                                                GList *ag_account_ids)
+{
+	ESourceRegistryServer *server;
+	GQueue trash = G_QUEUE_INIT;
+	GList *list, *link;
+	const gchar *extension_name;
+
+	server = ubuntu_online_accounts_get_server (extension);
+
+	extension_name = E_SOURCE_EXTENSION_UOA;
+	list = e_source_registry_server_list_sources (server, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source;
+		ESourceUoa *uoa_ext;
+		AgAccount *ag_account = NULL;
+		AgAccountId ag_account_id;
+		const gchar *source_uid;
+		GList *match;
+
+		source = E_SOURCE (link->data);
+		source_uid = e_source_get_uid (source);
+
+		extension_name = E_SOURCE_EXTENSION_UOA;
+		uoa_ext = e_source_get_extension (source, extension_name);
+		ag_account_id = e_source_uoa_get_account_id (uoa_ext);
+
+		if (ag_account_id == 0)
+			continue;
+
+		/* Verify the UOA account still exists. */
+		match = g_list_find (
+			ag_account_ids,
+			GUINT_TO_POINTER (ag_account_id));
+		if (match != NULL)
+			ag_account = ag_manager_get_account (
+				extension->ag_manager, ag_account_id);
+
+		/* If a matching AgAccountId was found, add it
+		 * to our accounts hash table.  Otherwise remove
+		 * the ESource after we finish looping. */
+		if (ag_account != NULL) {
+			g_hash_table_insert (
+				extension->uoa_to_eds,
+				GUINT_TO_POINTER (ag_account_id),
+				g_strdup (source_uid));
+
+			ubuntu_online_accounts_config_sources (
+				extension, source, ag_account);
+		} else {
+			g_queue_push_tail (&trash, source);
+		}
+	}
+
+	/* Empty the trash. */
+	while (!g_queue_is_empty (&trash)) {
+		ESource *source = g_queue_pop_head (&trash);
+		ubuntu_online_accounts_remove_collection (extension, source);
+	}
+
+	g_list_free_full (list, (GDestroyNotify) g_object_unref);
+}
+
+static void
+ubuntu_online_accounts_bus_acquired_cb (EDBusServer *server,
+                                        GDBusConnection *connection,
+                                        EUbuntuOnlineAccounts *extension)
+{
+	GList *list, *link;
+
+	extension->ag_manager = ag_manager_new ();
+
+	list = ag_manager_list (extension->ag_manager);
+
+	/* This populates a hash table of UOA ID -> ESource UID strings by
+	 * searching through available data sources for ones with a "Ubuntu
+	 * Online Accounts" extension.  If such an extension is found, but
+	 * no corresponding AgAccount (presumably meaning the UOA account
+	 * was somehow deleted between E-D-S sessions) then the ESource in
+	 * which the extension was found gets deleted. */
+	ubuntu_online_accounts_populate_accounts_table (extension, list);
+
+	for (link = list; link != NULL; link = g_list_next (link))
+		ubuntu_online_accounts_account_created_cb (
+			extension->ag_manager,
+			GPOINTER_TO_UINT (link->data),
+			extension);
+
+	ag_manager_list_free (list);
+
+	/* Listen for Online Account changes. */
+	g_signal_connect (
+		extension->ag_manager, "account-created",
+		G_CALLBACK (ubuntu_online_accounts_account_created_cb),
+		extension);
+	g_signal_connect (
+		extension->ag_manager, "account-deleted",
+		G_CALLBACK (ubuntu_online_accounts_account_deleted_cb),
+		extension);
+}
+
+static void
+ubuntu_online_accounts_dispose (GObject *object)
+{
+	EUbuntuOnlineAccounts *extension;
+
+	extension = E_UBUNTU_ONLINE_ACCOUNTS (object);
+
+	if (extension->ag_manager != NULL) {
+		g_signal_handlers_disconnect_matched (
+			extension->ag_manager,
+			G_SIGNAL_MATCH_DATA,
+			0, 0, NULL, NULL, object);
+		g_object_unref (extension->ag_manager);
+		extension->ag_manager = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_ubuntu_online_accounts_parent_class)->
+		dispose (object);
+}
+
+static void
+ubuntu_online_accounts_finalize (GObject *object)
+{
+	EUbuntuOnlineAccounts *extension;
+
+	extension = E_UBUNTU_ONLINE_ACCOUNTS (object);
+
+	g_hash_table_destroy (extension->uoa_to_eds);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_ubuntu_online_accounts_parent_class)->
+		finalize (object);
+}
+
+static void
+ubuntu_online_accounts_constructed (GObject *object)
+{
+	EExtension *extension;
+	EExtensible *extensible;
+
+	extension = E_EXTENSION (object);
+	extensible = e_extension_get_extensible (extension);
+
+	/* Wait for the registry service to acquire its well-known
+	 * bus name so we don't do anything destructive beforehand. */
+
+	g_signal_connect (
+		extensible, "bus-acquired",
+		G_CALLBACK (ubuntu_online_accounts_bus_acquired_cb),
+		extension);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_ubuntu_online_accounts_parent_class)->
+		constructed (object);
+}
+
+static void
+e_ubuntu_online_accounts_class_init (EUbuntuOnlineAccountsClass *class)
+{
+	GObjectClass *object_class;
+	EExtensionClass *extension_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = ubuntu_online_accounts_dispose;
+	object_class->finalize = ubuntu_online_accounts_finalize;
+	object_class->constructed = ubuntu_online_accounts_constructed;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_SOURCE_REGISTRY_SERVER;
+}
+
+static void
+e_ubuntu_online_accounts_class_finalize (EUbuntuOnlineAccountsClass *class)
+{
+}
+
+static void
+e_ubuntu_online_accounts_init (EUbuntuOnlineAccounts *extension)
+{
+	extension->uoa_to_eds = g_hash_table_new_full (
+		(GHashFunc) g_direct_hash,
+		(GEqualFunc) g_direct_equal,
+		(GDestroyNotify) NULL,
+		(GDestroyNotify) g_free);
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_ubuntu_online_accounts_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/modules/ubuntu-online-accounts/yahoo-calendar.service.in.in b/modules/ubuntu-online-accounts/yahoo-calendar.service.in.in
new file mode 100644
index 0000000..b91f1c0
--- /dev/null
+++ b/modules/ubuntu-online-accounts/yahoo-calendar.service.in.in
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="yahoo-calendar">
+  <type>calendar</type>
+  <_name>Yahoo! Calendar</_name>
+  <provider>yahoo</provider>
+  <translations>@GETTEXT_PACKAGE@</translations>
+
+  <!-- default settings (account settings have precedence over these) -->
+  <template>
+    <group name="auth">
+      <setting name="method">password</setting>
+      <setting name="mechanism">password</setting>
+    </group>
+  </template>
+</service>
diff --git a/modules/ubuntu-online-accounts/yahoo-mail.service.in.in b/modules/ubuntu-online-accounts/yahoo-mail.service.in.in
new file mode 100644
index 0000000..e75556f
--- /dev/null
+++ b/modules/ubuntu-online-accounts/yahoo-mail.service.in.in
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service id="yahoo-mail">
+  <type>mail</type>
+  <_name>Yahoo! Mail</_name>
+  <provider>yahoo</provider>
+  <translations>@GETTEXT_PACKAGE@</translations>
+
+  <!-- default settings (account settings have precedence over these) -->
+  <template>
+    <group name="auth">
+      <setting name="method">password</setting>
+      <setting name="mechanism">password</setting>
+    </group>
+  </template>
+</service>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]