[evolution-data-server/email-factory: 1/2] EMailFactory a camel based daemon.



commit fa627d6e6b9a51d760ca0504ca434e8f3eac91a1
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Tue Apr 5 10:09:50 2011 +0530

    EMailFactory a camel based daemon.

 Makefile.am                             |    4 +-
 configure.ac                            |   21 +
 mail/Makefile.am                        |    7 +
 mail/daemon/Makefile.am                 |   92 +
 mail/daemon/e-dbus-manager.c            |  173 ++
 mail/daemon/e-dbus-manager.h            |   46 +
 mail/daemon/e-mail-data-folder.c        | 1611 ++++++++++
 mail/daemon/e-mail-data-folder.h        |   50 +
 mail/daemon/e-mail-data-folder.xml      |  158 +
 mail/daemon/e-mail-data-session.c       |  409 +++
 mail/daemon/e-mail-data-session.h       |   53 +
 mail/daemon/e-mail-data-session.xml     |   34 +
 mail/daemon/e-mail-data-store.c         |  990 +++++++
 mail/daemon/e-mail-data-store.h         |   52 +
 mail/daemon/e-mail-data-store.xml       |  121 +
 mail/daemon/e-mail-local.c              |  128 +
 mail/daemon/e-mail-local.h              |   50 +
 mail/daemon/e-mail-store.c              |  418 +++
 mail/daemon/e-mail-store.h              |   42 +
 mail/daemon/mail-config.c               |  714 +++++
 mail/daemon/mail-config.h               |  104 +
 mail/daemon/mail-folder-cache.c         | 1373 +++++++++
 mail/daemon/mail-folder-cache.h         |  110 +
 mail/daemon/mail-ops.c                  | 3286 ++++++++++++++++++++
 mail/daemon/mail-ops.h                  |  198 ++
 mail/daemon/mail-send-recv.c            | 1313 ++++++++
 mail/daemon/mail-send-recv.h            |   45 +
 mail/daemon/mail-session.c              | 1027 +++++++
 mail/daemon/mail-session.h              |   57 +
 mail/daemon/mail-tools.c                |  938 ++++++
 mail/daemon/mail-tools.h                |   77 +
 mail/daemon/main.c                      |  132 +
 mail/daemon/test-email-client.c         | 1050 +++++++
 mail/daemon/utils.c                     |   47 +
 mail/daemon/utils.h                     |   22 +
 mail/libegdbus/Makefile.am              |   40 +
 mail/libegdbus/e-gdbus-emailfolder.c    | 4930 +++++++++++++++++++++++++++++++
 mail/libegdbus/e-gdbus-emailfolder.h    | 1113 +++++++
 mail/libegdbus/e-gdbus-emailsession.c   | 1423 +++++++++
 mail/libegdbus/e-gdbus-emailsession.h   |  302 ++
 mail/libegdbus/e-gdbus-emailstore.c     | 3411 +++++++++++++++++++++
 mail/libegdbus/e-gdbus-emailstore.h     |  714 +++++
 mail/libemailutils/Makefile.am          |   49 +
 mail/libemailutils/e-account-utils.c    |  181 ++
 mail/libemailutils/e-account-utils.h    |   36 +
 mail/libemailutils/e-marshal.list       |   57 +
 mail/libemailutils/libemail-utils.pc.in |   15 +
 mail/libemailutils/mail-mt.c            |  889 ++++++
 mail/libemailutils/mail-mt.h            |  128 +
 49 files changed, 28238 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4763c89..3b1fc88 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,8 +6,8 @@ if ENABLE_CALENDAR
 CALENDAR_DIR = calendar
 endif
 
-SUBDIRS = libedataserver libebackend servers camel addressbook $(CALENDAR_DIR) libedataserverui docs art po
-DIST_SUBDIRS = libedataserver libebackend servers camel addressbook calendar libedataserverui docs art po
+SUBDIRS = libedataserver libebackend servers camel addressbook $(CALENDAR_DIR) libedataserverui mail docs art po
+DIST_SUBDIRS = libedataserver libebackend servers camel addressbook calendar libedataserverui mail docs art po
 
 %-$(API_VERSION).pc: %.pc
 	 cp $< $@
diff --git a/configure.ac b/configure.ac
index d38cd85..09e64a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1221,6 +1221,22 @@ AC_SUBST(E_BACKEND_CFLAGS)
 AC_SUBST(E_BACKEND_LIBS)
 
 dnl ******************************
+dnl Email daemon
+dnl ******************************
+PKG_CHECK_MODULES(E_MAIL_FACTORY, glib-2.0 gtk+-2.0 gdbus-codegen)
+
+AC_SUBST(E_MAIL_FACTORY_CFLAGS)
+AC_SUBST(E_MAIL_FACTORY_LIBS)
+
+PKG_CHECK_MODULES(E_MAIL_GDBUS_UTILS, glib-2.0 gtk+-2.0  gdbus-codegen)
+AC_SUBST(E_MAIL_GDBUS_UTILS_CFLAGS)
+AC_SUBST(E_MAIL_GDBUS_UTILS_LIBS)
+
+PKG_CHECK_MODULES(E_MAIL_UTILS, glib-2.0 gtk+-2.0 )
+AC_SUBST(E_MAIL_UTILS_CFLAGS)
+AC_SUBST(E_MAIL_UTILS_LIBS)
+
+dnl ******************************
 dnl evolution-addressbook flags
 dnl ******************************
 EVOLUTION_ADDRESSBOOK_DEPS="gio-2.0 libxml-2.0 gconf-2.0"
@@ -1497,6 +1513,11 @@ libedataserver/eds-version.h
 libedataserver/libedataserver.pc
 libedataserverui/Makefile
 libedataserverui/libedataserverui.pc
+mail/Makefile
+mail/libemailutils/Makefile
+mail/libemailutils/libemail-utils.pc
+mail/libegdbus/Makefile
+mail/daemon/Makefile
 servers/Makefile
 servers/groupwise/Makefile
 servers/groupwise/libegroupwise.pc
diff --git a/mail/Makefile.am b/mail/Makefile.am
new file mode 100644
index 0000000..2d8568b
--- /dev/null
+++ b/mail/Makefile.am
@@ -0,0 +1,7 @@
+SUBDIRS = libemailutils libegdbus daemon
+
+DISTCHECK_CONFIGURE_FLAGS=
+
+CLEANFILES = *~
+
+
diff --git a/mail/daemon/Makefile.am b/mail/daemon/Makefile.am
new file mode 100644
index 0000000..83f0f6f
--- /dev/null
+++ b/mail/daemon/Makefile.am
@@ -0,0 +1,92 @@
+
+bin_PROGRAMS = e-mail-factory
+e_mail_factory_SOURCES = main.c	\
+			 e-mail-local.c	\
+			 e-mail-local.h	\
+			 e-mail-store.c	\
+			 e-mail-store.h	\
+			 e-dbus-manager.c	\
+			 e-dbus-manager.h	\
+			 e-mail-data-store.c	\
+			 e-mail-data-store.h	\
+			 e-mail-data-session.c	\
+			 e-mail-data-session.h	\
+			 e-mail-data-folder.c	\
+			 e-mail-data-folder.h	\
+			 mail-tools.c	\
+			 mail-tools.h	\
+			 mail-ops.c	\
+			 mail-ops.h	\
+			 mail-folder-cache.c	\
+			 mail-folder-cache.h	\
+			 mail-config.c	\
+			 mail-config.h	\
+			 mail-send-recv.c	\
+			 mail-send-recv.h	\
+			 mail-session.c	\
+			 mail-session.h	\
+			 utils.c	\
+			 utils.h
+
+noinst_PROGRAMS = test-email-client
+
+test_email_client_SOURCES = test-email-client.c
+test_email_client_CPPFLAGS = \
+		$(E_MAIL_FACTORY_CFLAGS)	\
+		$(GNOME_PLATFORM_CFLAGS)	\
+		$(CAMEL_CFLAGS)			\
+		-Wall -g3 -O0 -ggdb -DPKGDATADIR="\"$(pkgdatadir)\""	\
+		-I$(top_srcdir)/mail/					\
+		-I$(top_srcdir)/mail/libemailutils				\
+		-I$(top_srcdir)/mail/libegdbus				\
+		-I$(top_srcdir)						\
+		-I$(top_builddir)					
+
+test_email_client_LDADD = \
+		$(top_builddir)/mail/libemailutils/libemail-utils.la	\
+		$(top_builddir)/mail/libegdbus/libegdbus-mail.la	\
+		$(top_builddir)/camel/libcamel-1.2.la			\
+		$(top_builddir)/camel/libcamel-provider-1.2.la		\
+		$(top_builddir)/libedataserver/libedataserver-1.2.la	\
+		$(top_builddir)/libedataserverui/libedataserverui-1.2.la	\
+		$(E_MAIL_FACTORY_LIBS)				\
+		$(GNOME_PLATFORM_LIBS)	\
+		$(CAMEL_LIBS)			\
+		-lffi
+
+
+#desktopentry_DATA = e-mail-factory.desktop
+#icon_DATA = 
+
+#see gcc man page for description: http://www.google.com/search?q=man+gcc
+#AM_CFLAGS = @E_MAIL_FACTORY_CFLAGS@ -Wall -Werror -g3 -O0 -ggdb -DPKGDATADIR="\"$(pkgdatadir)\""
+#AM_LDFLAGS = @E_MAIL_FACTORY_LIBS@
+
+e_mail_factory_CPPFLAGS = \
+		$(E_MAIL_FACTORY_CFLAGS)	\
+		$(CAMEL_CFLAGS)			\
+		$(GNOME_PLATFORM_CFLAGS)	\
+		-Wall -g3 -O0 -ggdb -DPKGDATADIR="\"$(pkgdatadir)\""	\
+		-I$(top_srcdir)/mail/					\
+		-I$(top_srcdir)/mail/libemailutils				\
+		-I$(top_srcdir)/mail/libegdbus				\
+		-I$(top_srcdir)						\
+		-I$(top_builddir)					
+
+e_mail_factory_LDADD = \
+		$(CAMEL_LIBS)		\
+		$(GNOME_PLATFORM_LIBS)	\
+		$(top_builddir)/camel/libcamel-1.2.la			\
+		$(top_builddir)/camel/libcamel-provider-1.2.la		\
+		$(top_builddir)/libedataserver/libedataserver-1.2.la	\
+		$(top_builddir)/libedataserverui/libedataserverui-1.2.la	\
+		$(top_builddir)/mail/libemailutils/libemail-utils.la	\
+		$(top_builddir)/mail/libegdbus/libegdbus-mail.la	\
+		$(E_MAIL_FACTORY_LIBS)				\
+		-lffi
+
+
+EXTRA_DIST = 
+
+CLEANFILES = *~ #e-mail-factory.desktop
+
diff --git a/mail/daemon/e-dbus-manager.c b/mail/daemon/e-dbus-manager.c
new file mode 100644
index 0000000..186e353
--- /dev/null
+++ b/mail/daemon/e-dbus-manager.c
@@ -0,0 +1,173 @@
+/* e-dbus-manager.c */
+
+#include "e-dbus-manager.h"
+#include "e-mail-data-session.h"
+#include <gio/gio.h>
+
+#define E_MAIL_DATA_FACTORY_SERVICE_NAME \
+	"org.gnome.evolution.dataserver.Mail"
+
+
+G_DEFINE_TYPE (EDBusManager, e_dbus_manager, G_TYPE_OBJECT)
+
+#define MANAGER_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EDBUS_TYPE_MANAGER, EDBusManagerPrivate))
+
+typedef struct _EDBusManagerPrivate EDBusManagerPrivate;
+
+/* This needs to be global ala the CamelSession*/
+EMailDataSession *data_session;
+
+struct _EDBusManagerPrivate
+{
+	guint owner_id;	
+
+	GMutex *books_lock;
+	/* A hash of object paths for book URIs to EDataBooks */
+	GHashTable *books;
+
+	GMutex *connections_lock;
+	/* This is a hash of client addresses to GList* of EDataBooks */
+	GHashTable *connections;
+
+	guint exit_timeout;	
+};
+
+/* Convenience function to print an error and exit */
+G_GNUC_NORETURN static void
+die (const gchar *prefix, GError *error)
+{
+	g_error("%s: %s", prefix, error->message);
+	g_error_free (error);
+	exit(1);
+}
+
+static void
+e_dbus_manager_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_dbus_manager_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_dbus_manager_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (e_dbus_manager_parent_class)->dispose (object);
+}
+
+static void
+e_dbus_manager_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (e_dbus_manager_parent_class)->finalize (object);
+}
+
+static void
+e_dbus_manager_class_init (EDBusManagerClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (EDBusManagerPrivate));
+
+  object_class->get_property = e_dbus_manager_get_property;
+  object_class->set_property = e_dbus_manager_set_property;
+  object_class->dispose = e_dbus_manager_dispose;
+  object_class->finalize = e_dbus_manager_finalize;
+}
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+                 const gchar     *name,
+                 gpointer         user_data)
+{
+	EDBusManager *manager = user_data;
+	EDBusManagerPrivate *priv = MANAGER_PRIVATE(manager);
+	guint registration_id;
+	GError *error = NULL;
+
+	registration_id = e_mail_data_session_register_gdbus_object (
+		data_session,
+		connection,
+		"/org/gnome/evolution/dataserver/Mail/Session",
+		&error);
+
+	if (error)
+		die ("Failed to register a Mail Session object", error);
+
+	g_assert (registration_id > 0);
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+                  const gchar     *name,
+                  gpointer         user_data)
+{
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+              const gchar     *name,
+              gpointer         user_data)
+{
+	EDBusManager *manager = user_data;
+	EDBusManagerPrivate *priv = MANAGER_PRIVATE(manager);
+
+	e_mail_data_session_release (data_session, connection, name);
+#if 0
+	g_mutex_lock (factory->priv->connections_lock);
+	while (g_hash_table_lookup_extended (
+		factory->priv->connections, name,
+		(gpointer) &key, (gpointer) &list)) {
+		GList *copy = g_list_copy (list);
+
+		/* this should trigger the book's weak ref notify
+		 * function, which will remove it from the list before
+		 * it's freed, and will remove the connection from
+		 * priv->connections once they're all gone */
+		g_list_foreach (copy, remove_data_book_cb, NULL);
+		g_list_free (copy);
+	}
+
+	g_mutex_unlock (factory->priv->connections_lock);
+#endif	
+}
+
+static void
+e_dbus_manager_init (EDBusManager *self)
+{
+	EDBusManagerPrivate *priv = MANAGER_PRIVATE(self);
+
+	data_session = e_mail_data_session_new ();
+
+	priv->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+				E_MAIL_DATA_FACTORY_SERVICE_NAME,
+				G_BUS_NAME_OWNER_FLAGS_NONE,
+				on_bus_acquired,
+				on_name_acquired,
+				on_name_lost,
+				self,
+				NULL);
+			
+}
+
+EDBusManager*
+e_dbus_manager_new (void)
+{
+  return g_object_new (EDBUS_TYPE_MANAGER, NULL);
+}
+
+
diff --git a/mail/daemon/e-dbus-manager.h b/mail/daemon/e-dbus-manager.h
new file mode 100644
index 0000000..4c64a94
--- /dev/null
+++ b/mail/daemon/e-dbus-manager.h
@@ -0,0 +1,46 @@
+/* e-dbus-manager.h */
+
+#ifndef _E_DBUS_MANAGER_H
+#define _E_DBUS_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EDBUS_TYPE_MANAGER e_dbus_manager_get_type()
+
+#define EDBUS_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  EDBUS_TYPE_MANAGER, EDBusManager))
+
+#define EDBUS_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  EDBUS_TYPE_MANAGER, EDBusManagerClass))
+
+#define EDBUS_IS_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  EDBUS_TYPE_MANAGER))
+
+#define EDBUS_IS_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  EDBUS_TYPE_MANAGER))
+
+#define EDBUS_MANAGER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  EDBUS_TYPE_MANAGER, EDBusManagerClass))
+
+typedef struct {
+  GObject parent;
+} EDBusManager;
+
+typedef struct {
+  GObjectClass parent_class;
+} EDBusManagerClass;
+
+GType e_dbus_manager_get_type (void);
+
+EDBusManager* e_dbus_manager_new (void);
+
+G_END_DECLS
+
+#endif /* _E_DBUS_MANAGER_H */
diff --git a/mail/daemon/e-mail-data-folder.c b/mail/daemon/e-mail-data-folder.c
new file mode 100644
index 0000000..0afbfde
--- /dev/null
+++ b/mail/daemon/e-mail-data-folder.c
@@ -0,0 +1,1611 @@
+/* e-mail-data-folder.c */
+
+#include <glib/gi18n.h>
+#include "e-mail-data-folder.h"
+#include "e-mail-data-session.h"
+#include "e-gdbus-emailfolder.h"
+#include <camel/camel.h>
+#include "mail-ops.h"
+#include "utils.h"
+
+#define micro(x) if (mail_debug_log(EMAIL_DEBUG_FOLDER|EMAIL_DEBUG_MICRO)) x;
+#define ipc(x) if (mail_debug_log(EMAIL_DEBUG_FOLDER|EMAIL_DEBUG_IPC)) x;
+
+
+G_DEFINE_TYPE (EMailDataFolder, e_mail_data_folder, G_TYPE_OBJECT)
+
+#define DATA_FOLDER_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMAIL_TYPE_DATA_FOLDER, EMailDataFolderPrivate))
+
+extern EMailDataSession *data_session;
+	
+typedef struct _EMailDataFolderPrivate EMailDataFolderPrivate;
+
+struct _EMailDataFolderPrivate
+{
+	char *path;
+	EGdbusFolderCF *gdbus_object;
+	
+	CamelFolder *folder;
+};
+
+static void
+e_mail_data_folder_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_folder_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_folder_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_folder_parent_class)->dispose (object);
+}
+
+static void
+e_mail_data_folder_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_folder_parent_class)->finalize (object);
+}
+
+static void
+e_mail_data_folder_class_init (EMailDataFolderClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (EMailDataFolderPrivate));
+
+  object_class->get_property = e_mail_data_folder_get_property;
+  object_class->set_property = e_mail_data_folder_set_property;
+  object_class->dispose = e_mail_data_folder_dispose;
+  object_class->finalize = e_mail_data_folder_finalize;
+}
+
+typedef struct _email_folder_std_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+}EMailFolderStdData;
+
+static void
+handle_refresh_info_done (CamelFolder *folder, gpointer sdata, GError *error)
+{
+	EMailFolderStdData *data = (EMailFolderStdData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Unable to refresh folder: %s\n", error->message);
+
+		g_dbus_method_invocation_return_gerror (data->invocation, error);
+		ipc(printf("Refresh info failed %s : %s \n", priv->path, error->message));
+
+		return;
+	}
+	ipc(printf("Refresh info success: %s \n", priv->path));
+
+	egdbus_folder_cf_complete_refresh_info (data->object, data->invocation, TRUE);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_refreshInfo (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderStdData *data;
+
+	data = g_new0 (EMailFolderStdData, 1);
+	data->mfolder = mfolder;
+	data->invocation = invocation;
+	data->object = object;
+
+	ipc(printf("Mail refresh info %s\n", priv->path));
+
+	mail_refresh_folder (priv->folder, handle_refresh_info_done, data);
+
+	return TRUE;
+}
+
+static void
+handle_sync_done (CamelFolder *folder, gpointer sdata, GError *error)
+{
+	EMailFolderStdData *data = (EMailFolderStdData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Unable to sync folder: %s\n", error->message);
+
+		g_dbus_method_invocation_return_gerror (data->invocation, error);
+		ipc(printf("Sync failed: %s : %s \n", priv->path, error->message));
+	
+		return;
+	}
+
+	ipc(printf("Folder sync success: %s\n", priv->path));
+	
+	egdbus_folder_cf_complete_sync (data->object, data->invocation, TRUE);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_sync (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, gboolean expunge, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderStdData *data;
+
+	data = g_new0 (EMailFolderStdData, 1);
+	data->mfolder = mfolder;
+	data->invocation = invocation;
+	data->object = object;
+
+	ipc(printf("Sync folder %s: exp:%d\n", priv->path, expunge));
+	
+	mail_sync_folder (priv->folder, expunge, handle_sync_done, data);
+
+	return TRUE;
+}  
+
+static void
+handle_expunge_done (CamelFolder *folder, gpointer sdata, GError *error)
+{
+	EMailFolderStdData *data = (EMailFolderStdData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Unable to expunge folder: %s\n", error->message);
+
+		g_dbus_method_invocation_return_gerror (data->invocation, error);
+		ipc(printf("Expunge folder failed: %s : %s \n", priv->path, error->message));
+
+		return;
+	}
+
+	egdbus_folder_cf_complete_expunge (data->object, data->invocation, TRUE);
+	ipc(printf("Expunge folder success: %s\n", priv->path));
+	
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_expunge (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderStdData *data;
+
+	data = g_new0 (EMailFolderStdData, 1);
+	data->mfolder = mfolder;
+	data->invocation = invocation;
+	data->object = object;
+
+	ipc(printf("Expunge folder %s\n", priv->path));
+
+	mail_expunge_folder (priv->folder, handle_expunge_done, data);
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getName (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	egdbus_folder_cf_complete_get_name (object, invocation, camel_folder_get_name (priv->folder));
+	ipc(printf("Get Name %s : %s \n", priv->path, camel_folder_get_name (priv->folder)));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_setName (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *name, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	camel_folder_set_name (priv->folder, name);
+	ipc(printf("Set name %s : %s \n", priv->path, name));
+
+	egdbus_folder_cf_complete_set_name (object, invocation);
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getFullName (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	egdbus_folder_cf_complete_get_full_name (object, invocation, camel_folder_get_full_name (priv->folder));
+	ipc(printf("Get Fullname %s : %s \n", priv->path, camel_folder_get_full_name (priv->folder)));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_setFullName (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *fullname, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	camel_folder_set_full_name (priv->folder, fullname);
+	ipc(printf("Set full name %s : %s \n", priv->path, fullname));
+
+	egdbus_folder_cf_complete_set_full_name (object, invocation);
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getDescription (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	egdbus_folder_cf_complete_get_description (object, invocation, camel_folder_get_description (priv->folder));
+	ipc(printf("Get description %s : %s \n", priv->path, camel_folder_get_description (priv->folder)));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_setDescription (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *description, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	camel_folder_set_description (priv->folder, description);
+	ipc(printf("Set description %s : %s \n", priv->path, description));
+
+	egdbus_folder_cf_complete_set_description (object, invocation);
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_totalMessageCount (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	ipc(printf("Get total message count %s : %d \n", priv->path, camel_folder_get_message_count (priv->folder)));
+
+	egdbus_folder_cf_complete_total_message_count (object, invocation, camel_folder_get_message_count (priv->folder));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_unreadMessageCount (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	ipc(printf("Get unread message count %s : %d \n", priv->path, camel_folder_get_unread_message_count (priv->folder)));
+
+	egdbus_folder_cf_complete_unread_message_count (object, invocation, camel_folder_get_unread_message_count (priv->folder));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_deletedMessageCount (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	ipc(printf("Get deleted message count %s : %d \n", priv->path, camel_folder_get_deleted_message_count (priv->folder)));
+
+	egdbus_folder_cf_complete_deleted_message_count (object, invocation, camel_folder_get_deleted_message_count (priv->folder));
+
+	return TRUE;
+}
+
+/* Get Permanent flags */
+typedef struct _email_folder_gpf_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+	guint32 flags;
+}EMailFolderGPFData;
+
+static gboolean
+gpf_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGPFData *data = (EMailFolderGPFData *)sdata;
+
+	data->flags = camel_folder_get_permanent_flags (folder);
+
+	return TRUE;
+}
+
+static void
+gpf_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGPFData *data = (EMailFolderGPFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("get permanent failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get Permanent flags: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	egdbus_folder_cf_complete_get_message_flags (data->object, data->invocation, data->flags);
+	ipc(printf("Get permanent flags success %s\n", priv->path));
+	
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getPermanentFlags (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGPFData *data = g_new0 (EMailFolderGPFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+
+	ipc(printf("Get Permanent flags %s\n", priv->path));
+
+	mail_operate_on_folder (priv->folder, gpf_operate, gpf_done, data);
+
+	return TRUE;
+}
+
+/* Has Summary capability */
+static gboolean
+hsuc_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	/* EMailFolderStdData *data = (EMailFolderStdData *)sdata; */
+
+	return camel_folder_has_summary_capability (folder);
+}
+
+static void
+hsuc_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderStdData *data = (EMailFolderStdData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Has summary capability failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Has summary capability: %s failed: %s\n", priv->path, error->message));
+		return;
+	}	
+	egdbus_folder_cf_complete_has_summary_capability (data->object, data->invocation, success);
+	ipc(printf("Has Search capability success%s : %d \n", priv->path, success));
+	
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_hasSummaryCapability (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderStdData *data = g_new0 (EMailFolderStdData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+
+	ipc(printf("Has Summary capability %s : \n", priv->path));
+
+	mail_operate_on_folder (priv->folder, hsuc_operate, hsuc_done, data);
+
+	return TRUE;
+}
+
+/* Has Search Capability */
+static gboolean
+hsec_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	/* EMailFolderStdData *data = (EMailFolderStdData *)sdata; */
+
+	return camel_folder_has_search_capability (folder);
+}
+
+static void
+hsec_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderStdData *data = (EMailFolderStdData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Has search capability failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Has search capability: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	ipc(printf("Has Search capability success%s : %d \n", priv->path, success));
+	
+	egdbus_folder_cf_complete_has_search_capability (data->object, data->invocation, success);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_hasSearchCapability (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderStdData *data = g_new0 (EMailFolderStdData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+
+	ipc(printf("Has search capability : %s \n", priv->path));
+
+	mail_operate_on_folder (priv->folder, hsec_operate, hsec_done, data);
+
+	return TRUE;
+}
+
+/* Get Message Flags */
+typedef struct _email_folder_gmf_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+	guint32 flags;
+	guint32 set;
+	char *uid;
+	char *name;
+	char *value;
+}EMailFolderGMFData;
+
+static gboolean
+gmf_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	data->flags = camel_folder_get_message_flags (folder, data->uid);
+
+	return TRUE;
+}
+
+static void
+gmf_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Get message flags failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get message flags: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	ipc(printf("Set message user flag success: %s : %s \n", priv->path, data->uid));
+	
+	egdbus_folder_cf_complete_get_message_flags (data->object, data->invocation, data->flags);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getMessageFlags (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+
+	ipc(printf("Get message flags: %s : %s \n", priv->path, data->uid));
+	
+	mail_operate_on_folder (priv->folder, gmf_operate, gmf_done, data);
+
+	return TRUE;
+}
+
+/* Set Message Flags */
+static gboolean
+smf_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	return camel_folder_set_message_flags (folder, data->uid, data->flags, data->set);
+
+}
+
+static void
+smf_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("set message flags failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Set message flags: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	ipc(printf("Set message flags success: %s : %s \n", priv->path, data->uid));
+	
+	egdbus_folder_cf_complete_set_message_flags (data->object, data->invocation, success);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_setMessageFlags (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, guint32 flags, guint32 set, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+	data->flags = flags;
+	data->set = set;
+
+	ipc(printf("Set message flags: %s : %s \n", priv->path, data->uid));
+	mail_operate_on_folder (priv->folder, smf_operate, smf_done, data);
+
+	return TRUE;
+}
+
+/* Get Message User Flag */
+static gboolean
+gmuf_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	return camel_folder_get_message_user_flag (folder, data->uid, data->name);
+}
+
+static void
+gmuf_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Get message user flag failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get messgae user flag: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	egdbus_folder_cf_complete_get_message_user_flag (data->object, data->invocation, success);
+	ipc(printf("Set message user flag success: %s : %s %s\n", priv->path, data->uid, data->name));
+	
+	g_free (data->name);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getMessageUserFlag (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, char *name, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+	data->name = g_strdup (name);
+
+	ipc(printf("Get message user flag: %s : %s %s\n", priv->path, data->uid, name));
+	
+	mail_operate_on_folder (priv->folder, gmuf_operate, gmuf_done, data);
+
+	return TRUE;
+}
+
+/* Set Message User Flag */
+static gboolean
+smuf_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	camel_folder_set_message_user_flag (folder, data->uid, data->name, (data->flags != 0));
+
+	return TRUE;
+}
+
+static void
+smuf_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Set message user flag failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Set message user flag: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	egdbus_folder_cf_complete_set_message_user_flag (data->object, data->invocation);
+	ipc(printf("Set message user fag success: %s : %s:%s \n", priv->path, data->uid, data->name));
+
+	g_free (data->name);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_setMessageUserFlag (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, const char *name, gboolean flag, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+	data->name = g_strdup (name);
+	data->flags = flag != FALSE;
+
+	ipc(printf("Set message user flag: %s : %s %s\n", priv->path, data->uid, name));
+	
+	mail_operate_on_folder (priv->folder, smuf_operate, smuf_done, data);
+
+	return TRUE;
+}
+
+/* Get Message User Tag */
+static gboolean
+gmut_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	data->value = g_strdup (camel_folder_get_message_user_tag (folder, data->uid, data->name));
+
+	return TRUE;
+}
+
+static void
+gmut_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	
+	if (error && error->message) {
+		g_warning ("Get message user tag failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get message user tag: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	egdbus_folder_cf_complete_get_message_user_tag (data->object, data->invocation, data->value ? data->value : "");
+	ipc(printf("Get message user tag success: %s : %s %s:%s\n", priv->path, data->uid, data->name, data->value));
+	
+	g_free (data->value);
+	g_free (data->name);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getMessageUserTag (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, char *name, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+	data->name = g_strdup (name);
+
+	ipc(printf("Get message user tag: %s : %s %s\n", priv->path, data->uid, name));
+	
+	mail_operate_on_folder (priv->folder, gmut_operate, gmut_done, data);
+
+	return TRUE;
+}
+
+/* Set Message User Tags */
+static gboolean
+smut_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+
+	camel_folder_set_message_user_tag (folder, data->uid, data->name, data->value);
+
+	return TRUE;
+}
+
+static void
+smut_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderGMFData *data = (EMailFolderGMFData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("set message user tag failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("set message user tag: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	ipc(printf("Set message user tag: %s success: %s\n", priv->path, data->uid));
+	
+	egdbus_folder_cf_complete_set_message_user_tag (data->object, data->invocation);
+
+	g_free (data->value);
+	g_free (data->name);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_setMessageUserTag (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, const char *name, const char *value, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderGMFData *data = g_new0 (EMailFolderGMFData, 1);
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->uid = g_strdup (uid);
+	data->name = g_strdup (name);
+	data->value = g_strdup (value);
+
+	ipc(printf("set message user tag: %s : %s %s:%s\n", priv->path, uid, name, value));
+
+	mail_operate_on_folder (priv->folder, smut_operate, smut_done, data);
+
+	return TRUE;
+}
+
+/* Get Parent Store */
+static gboolean
+impl_Mail_getParentStore (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	CamelStore *store;
+	const char *object_path;
+
+	store = camel_folder_get_parent_store (priv->folder);
+	object_path = g_object_get_data ((GObject *)store, "object-path");
+	if (!object_path) {
+		object_path = e_mail_data_session_get_path_from_store (data_session, (gpointer)store);
+	}
+
+	if (object_path == NULL) {
+		/* We are having a strange situation. */
+		ipc(printf("Get ParentStore : %s failed\n", priv->path));
+		
+		g_dbus_method_invocation_return_dbus_error (invocation, G_DBUS_ERROR_FAILED, _("Unable to find the object path of the parent store"));
+		return TRUE;
+	}
+	ipc(printf("Get Parent Store: %s success: %s\n", priv->path, object_path));
+
+	egdbus_folder_cf_complete_get_parent_store (object, invocation, object_path);
+
+	return TRUE;
+}
+
+/* Append Message */
+static CamelMessageInfoBase *
+info_from_variant (CamelFolder *folder, GVariant *vinfo) 
+{
+	CamelMessageInfoBase *info;
+	GVariantIter iter, aiter;
+	GVariant *item, *aitem;
+	int count, i;
+
+	info = (CamelMessageInfoBase *) camel_message_info_new (folder->summary);
+
+         /* Structure of CamelMessageInfoBase
+         ssssss - uid, sub, from, to, cc, mlist
+	 uu - flags, size
+	 tt - date_sent, date_received
+	 t  - message_id
+	 iat - references
+	 as - userflags
+	 a(ss) - usertags
+	 a(ss) - header 
+         NOTE: We aren't now sending content_info*/
+
+	g_variant_iter_init (&iter, vinfo);
+
+	/* Uid, Subject, From, To, CC, mlist */
+	item = g_variant_iter_next_value (&iter);
+	info->uid = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->subject = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->from = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->to = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->cc = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->mlist = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	/* Flags & size */
+	item = g_variant_iter_next_value (&iter);
+	info->flags = g_variant_get_uint32 (item);
+
+	item = g_variant_iter_next_value (&iter);
+	info->size = g_variant_get_uint32 (item);
+
+	/* Date: Sent/Received */
+	item = g_variant_iter_next_value (&iter);
+	info->date_sent = g_variant_get_uint64 (item);
+
+	item = g_variant_iter_next_value (&iter);
+	info->date_received = g_variant_get_uint64 (item);
+
+	/* Message Id */
+	item = g_variant_iter_next_value (&iter);	
+	info->message_id.id.id = g_variant_get_uint64 (item);
+
+	/* References */
+	item = g_variant_iter_next_value (&iter);	
+	count = g_variant_get_int32 (item);
+	if (count) {
+		item = g_variant_iter_next_value (&iter);	
+      		g_variant_iter_init (&aiter, item);
+		
+		info->references = g_malloc(sizeof(*info->references) + ((count-1) * sizeof(info->references->references[0])));
+		i=0;
+      		while ((aitem = g_variant_iter_next_value (&aiter))) {
+			info->references->references[i].id.id = g_variant_get_uint64 (aitem);
+			i++;
+       	 	}
+		info->references->size = count;
+	} else {
+		item = g_variant_iter_next_value (&iter);	
+
+		info->references = NULL;
+	}
+	/* UserFlags */
+	item = g_variant_iter_next_value (&iter);	
+      	g_variant_iter_init (&aiter, item);
+	
+      	while ((aitem = g_variant_iter_next_value (&aiter))) {
+		char *str = g_variant_get_string (aitem, NULL);
+		if (str && *str)
+			camel_flag_set (&info->user_flags, str, TRUE);
+        }
+	
+	/* User Tags */
+	item = g_variant_iter_next_value (&iter);	
+      	g_variant_iter_init (&aiter, item);
+	
+      	while ((aitem = g_variant_iter_next_value (&aiter))) {
+		GVariantIter siter;
+		GVariant *sitem;
+		char *tagname, *tagvalue;
+		
+		g_variant_iter_init (&siter, aitem);
+		sitem = g_variant_iter_next_value (&siter);
+		tagname = g_strdup (g_variant_get_string (sitem, NULL));
+		sitem = g_variant_iter_next_value (&siter);
+		tagvalue = g_strdup (g_variant_get_string (sitem, NULL));
+		if (tagname && *tagname && tagvalue && *tagvalue)
+			camel_tag_set (&info->user_tags, tagname, tagvalue);
+		g_free (tagname);
+		g_free (tagvalue);
+        }
+
+	return info;
+}
+
+typedef struct _email_folder_msg_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+	CamelMessageInfoBase *info;
+	CamelMimeMessage *message;
+	char *uid;
+	char *msg_buf;
+}EMailFolderMessageData;
+
+
+static gboolean
+app_msg_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+
+	return camel_folder_append_message (folder, data->message, (CamelMessageInfo *)data->info, &data->uid, error);
+}
+
+static void
+app_msg_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+
+	if (error && error->message) {
+		g_warning ("Append message failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Append message: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	egdbus_folder_cf_complete_append_message (data->object, data->invocation, data->uid, success);
+	
+	ipc(printf("Apppend message: %s success: %s\n", priv->path, data->uid));
+
+	g_object_unref (data->message);
+	camel_message_info_free (data->info);
+	g_free (data->uid);
+	g_free (data);
+}
+
+
+static gboolean
+impl_Mail_appendMessage (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, GVariant *vinfo, const char *message, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderMessageData *data;
+	CamelStream *stream;
+
+	data = g_new0 (EMailFolderMessageData, 1);
+	data->mfolder = mfolder;	
+	data->object = object;
+	data->invocation = invocation;
+	data->info = info_from_variant (priv->folder, vinfo);
+	data->message = camel_mime_message_new ();
+
+	stream = camel_stream_mem_new_with_buffer (message, strlen (message));
+	camel_data_wrapper_construct_from_stream((CamelDataWrapper *)data->message, stream, NULL);
+	g_object_unref (stream);
+	
+	ipc(printf("Append message: %s: %s\n", priv->path, data->info->uid));
+
+
+	mail_operate_on_folder (priv->folder, app_msg_operate, app_msg_done, data);
+	
+	return TRUE;
+}
+
+/* Get UIDs */
+static gboolean
+impl_Mail_getUids (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	GPtrArray *uids;
+
+	uids = camel_folder_get_uids (priv->folder);
+	g_ptr_array_add (uids, NULL);
+
+	ipc(printf("Get uids: %s: success :%d\n", priv->path, uids->len-1));
+	
+	egdbus_folder_cf_complete_get_uids (object, invocation, (const gchar *const *) uids->pdata);
+
+	g_ptr_array_remove_index_fast (uids, uids->len-1);
+	camel_folder_free_uids (priv->folder, uids);
+
+	
+	return TRUE;
+}
+
+/* Get Message */
+
+static gboolean
+app_getmsg_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+	CamelMimeMessage *msg;
+	CamelStream *stream;
+	GByteArray *array;
+
+	msg = camel_folder_get_message (folder, data->uid, error);
+
+	if (!msg)
+		return FALSE;
+
+	stream = camel_stream_mem_new ();
+
+	camel_data_wrapper_decode_to_stream ((CamelDataWrapper *)msg, stream, NULL);
+	array = camel_stream_mem_get_byte_array ((CamelStreamMem *)stream);
+	data->msg_buf = g_strndup ((gchar *) array->data, array->len);
+
+	g_object_unref (stream);
+	g_object_unref (msg);
+
+	return TRUE;
+}
+
+static void
+app_getmsg_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+
+	if (error && error->message) {
+		g_warning ("Get message failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get message: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	egdbus_folder_cf_complete_get_message (data->object, data->invocation, data->msg_buf);
+	
+	ipc(printf("Get Message: %s success: %s\n", priv->path, data->uid));
+
+	g_free (data->msg_buf);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getMessage (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderMessageData *data;
+
+
+	data = g_new0 (EMailFolderMessageData, 1);
+	data->mfolder = mfolder;	
+	data->object = object;
+	data->invocation = invocation;
+	data->uid = g_strdup (uid);
+	
+	ipc(printf("Get message: %s : %s\n", priv->path, uid));
+
+	mail_operate_on_folder (priv->folder, app_getmsg_operate, app_getmsg_done, data);
+	
+
+	return TRUE;
+}
+
+/* Search by Expression */
+typedef struct _email_folder_search_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+	char *query;
+	GPtrArray *query_uids;
+	GPtrArray *result_uids;
+}EMailFolderSearchData;
+
+static gboolean
+search_expr_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderSearchData *data = (EMailFolderSearchData *)sdata;
+	
+	data->result_uids = camel_folder_search_by_expression (folder, data->query, error);
+
+	return TRUE;
+}
+
+static void
+search_expr_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderSearchData *data = (EMailFolderSearchData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	g_ptr_array_add (data->result_uids, NULL);
+
+	if (error && error->message) {
+		g_warning ("Search by expr failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Search by expr : %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	egdbus_folder_cf_complete_search_by_expression (data->object, data->invocation, (const gchar *const *)data->result_uids->pdata);
+
+	g_ptr_array_remove_index_fast (data->result_uids, data->result_uids->len-1);
+	ipc(printf("Search messages by expr: %s success: %d results\n", priv->path, data->result_uids->len));
+
+	camel_folder_search_free (priv->folder, data->result_uids);
+	g_free (data->query);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_searchByExpression (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *expression, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderSearchData *data;
+
+
+	data = g_new0 (EMailFolderSearchData, 1);
+	data->object = object;
+	data->mfolder = mfolder;	
+	data->invocation = invocation;
+	data->query = g_strdup (expression);
+	
+	ipc(printf("Search by expr : %s : %s\n", priv->path, expression));
+
+	mail_operate_on_folder (priv->folder, search_expr_operate, search_expr_done, data);
+	
+
+	return TRUE;
+}
+
+/* Search by UIDs */
+static gboolean
+search_uids_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderSearchData *data = (EMailFolderSearchData *)sdata;
+	
+	data->result_uids = camel_folder_search_by_uids (folder, data->query, data->query_uids, error);
+
+	return TRUE;
+}
+
+static void
+search_uids_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderSearchData *data = (EMailFolderSearchData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	if (error && error->message) {
+		g_warning ("Search by uids failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Search by uids : %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+	
+	g_ptr_array_add (data->result_uids, NULL);
+
+	egdbus_folder_cf_complete_search_by_uids (data->object, data->invocation, (const gchar *const *)data->result_uids->pdata);
+
+	g_ptr_array_remove_index_fast (data->result_uids, data->result_uids->len-1);
+	ipc(printf("Search messages in  uids: %s success: %d results\n", priv->path, data->result_uids->len));
+
+	camel_folder_search_free (priv->folder, data->query_uids);	
+	camel_folder_search_free (priv->folder, data->result_uids);
+	g_free (data->query);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_searchByUids (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *expression, const char **uids, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderSearchData *data;
+	int i;
+
+	
+	data = g_new0 (EMailFolderSearchData, 1);
+	data->object = object;
+	data->mfolder = mfolder;	
+	data->invocation = invocation;
+	data->query = g_strdup (expression);
+	data->query_uids = g_ptr_array_new ();
+	for (i=0; uids && uids[i]; i++) {
+		g_ptr_array_add (data->query_uids, (gpointer) camel_pstring_strdup(uids[i]));
+	}
+	
+	ipc(printf("Search in uids: %s: %s in %d\n", priv->path, expression, data->query_uids->len));
+
+	mail_operate_on_folder (priv->folder, search_uids_operate, search_uids_done, data);
+	
+
+	return TRUE;
+}
+
+/* Get Message Info */
+static gboolean
+gmi_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+	
+	data->info = (CamelMessageInfoBase *)camel_folder_get_message_info (folder, data->uid);
+
+	return TRUE;
+}
+
+#define VALUE_OR_NULL(x) x?x:""
+static GVariant *
+variant_from_info (CamelMessageInfoBase *info)
+{
+	GVariant *v, *v1;
+	GVariantBuilder *builder, *b1, *b2;
+	int i;
+	CamelFlag *flags;
+	CamelTag *tags;
+
+	builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+	
+	g_variant_builder_add (builder, "s", info->uid);
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->subject));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->from));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->to));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->cc));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->mlist));
+
+
+	g_variant_builder_add (builder, "u", info->flags);
+	g_variant_builder_add (builder, "u", info->size);
+
+	g_variant_builder_add (builder, "t", info->date_sent);
+	g_variant_builder_add (builder, "t", info->date_received);
+
+	g_variant_builder_add (builder, "t", info->message_id.id.id);
+
+
+	
+	/* references */
+
+	if (info->references) {
+		g_variant_builder_add (builder, "i", info->references->size);
+
+		b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+		for (i=0; i<info->references->size; i++) {
+			g_variant_builder_add (b1, "t", info->references->references[i].id.id);
+		}
+		v1 = g_variant_builder_end (b1);
+		g_variant_builder_unref (b1);
+	
+		g_variant_builder_add_value (builder, v1);
+		g_variant_unref (v1);
+	} else {
+		g_variant_builder_add (builder, "i", 0);
+		b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+		g_variant_builder_add (b1, "t", 0);
+		v1 = g_variant_builder_end (b1);
+		g_variant_builder_unref (b1);
+	
+		g_variant_builder_add_value (builder, v1);
+		
+
+	}
+
+	/* User Flags */
+	b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+	flags = info->user_flags;
+	while (flags) {
+		g_variant_builder_add (b1, "s", flags->name);
+		flags = flags->next;
+	}
+	g_variant_builder_add (b1, "s", "");
+	v1 = g_variant_builder_end (b1);
+	g_variant_builder_unref (b1);
+	
+	g_variant_builder_add_value (builder, v1);
+
+	/* User Tags */
+	b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+	tags = info->user_tags;
+	while (tags) {
+		b2 = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+		g_variant_builder_add (b2, "s", tags->name);
+		g_variant_builder_add (b2, "s", tags->value);
+		
+		v1 = g_variant_builder_end (b2);
+		g_variant_builder_unref (b2);
+
+		/* FIXME: Should we handle empty tags? Can it be empty? If it potential crasher ahead*/
+		g_variant_builder_add_value (b1, v1);
+
+		tags = tags->next;
+	}
+
+	b2 = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+	g_variant_builder_add (b2, "s", "");
+	g_variant_builder_add (b2, "s", "");	
+	v1 = g_variant_builder_end (b2);
+	g_variant_builder_unref (b2);
+	g_variant_builder_add_value (b1, v1);
+
+	v1 = g_variant_builder_end (b1);
+	g_variant_builder_unref (b1);
+	
+	g_variant_builder_add_value (builder, v1);
+
+	v = g_variant_builder_end (builder);
+	g_variant_builder_unref (builder);
+
+	return v;
+}
+
+static void
+gmi_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderMessageData *data = (EMailFolderMessageData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);
+	
+	GVariant *variant;
+	
+	if (error && error->message) {
+		g_warning ("Get Message info failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Get message info: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	variant = variant_from_info (data->info);
+
+	egdbus_folder_cf_complete_get_message_info (data->object, data->invocation, variant);
+
+	camel_message_info_free (data->info);
+	g_free (data->uid);
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getMessageInfo (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char *uid, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	EMailFolderMessageData *data;
+
+	
+	data = g_new0 (EMailFolderMessageData, 1);
+	data->mfolder = mfolder;
+	data->object = object;
+	data->invocation = invocation;
+	data->uid = g_strdup (uid);
+
+	ipc(printf("Mail get message info: %s uid: %s\n", priv->path, uid));
+
+	mail_operate_on_folder (priv->folder, gmi_operate, gmi_done, data);
+	
+
+	return TRUE;
+}
+
+/* Transfer Messages to */
+typedef struct _email_folder_transfer_data {
+	EMailDataFolder *mfolder;
+	EGdbusFolderCF *object;
+	GDBusMethodInvocation *invocation;
+	CamelFolder *dest_folder;
+	char *object_path;
+	GPtrArray *uids;
+	GPtrArray *return_uids;
+	gboolean delete_originals;
+}EMailFolderTransferData;
+
+static gboolean
+transfer_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderTransferData *data = (EMailFolderTransferData *)sdata;
+
+	data->dest_folder = e_mail_session_get_folder_from_path (data_session, data->object_path);
+	
+	return camel_folder_transfer_messages_to (folder, data->uids, data->dest_folder, &data->return_uids, data->delete_originals, error);
+}
+
+static void
+transfer_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderTransferData *data = (EMailFolderTransferData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);	
+	
+	if (error && error->message) {
+		g_warning ("Transfer messages failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Mail transfer messages: %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+
+	if (!data->return_uids) {
+		/* It is possible that some providers don't return this.*/
+		data->return_uids = g_ptr_array_new ();
+	}
+	g_ptr_array_add (data->return_uids, NULL);
+
+
+	egdbus_folder_cf_complete_transfer_messages_to (data->object, data->invocation, (const gchar *const *) data->return_uids->pdata);
+
+	ipc(printf("Mail transfer messages: %s success: %d\n", priv->path, data->return_uids->len-1));
+	g_ptr_array_remove_index_fast (data->uids, data->uids->len-1);
+
+	micro(printf("Arrays %p %p: success: %d\n", data->uids, data->return_uids, success));
+
+	g_ptr_array_foreach (data->uids, (GFunc)g_free, NULL);
+	g_ptr_array_free (data->uids, TRUE);
+	g_ptr_array_foreach (data->return_uids, (GFunc)g_free, NULL);
+	g_ptr_array_free (data->return_uids, TRUE);
+	g_free (data->object_path);
+	g_object_unref (data->dest_folder);
+	g_free (data);
+}
+
+
+
+static gboolean
+impl_Mail_transferMessagesTo (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, const char **uids, const char *object_path, gboolean delete_originals, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);	
+	EMailFolderTransferData *data = g_new0 (EMailFolderTransferData, 1);
+	int i;
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+	data->object_path = g_strdup (object_path);
+	data->uids = g_ptr_array_new ();
+	for (i=0; uids && uids[i]; i++) {
+		g_ptr_array_add (data->uids, g_strdup(uids[i]));
+	}
+	data->delete_originals = delete_originals;
+
+	ipc(printf("Transfer messages from %s: to %s: len %d\n", priv->path, object_path, data->uids->len));
+
+	mail_operate_on_folder (priv->folder, transfer_operate, transfer_done, data);
+
+	return TRUE;
+}
+
+/* Prepare Summary */
+static gboolean
+ps_operate (CamelFolder *folder, gpointer sdata, GError **error)
+{
+	EMailFolderTransferData *data = (EMailFolderTransferData *)sdata;
+
+	camel_folder_summary_prepare_fetch_all (folder->summary, error);
+
+	return TRUE;
+}
+
+static void
+ps_done (gboolean success, gpointer sdata, GError *error)
+{
+	EMailFolderTransferData *data = (EMailFolderTransferData *)sdata;
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(data->mfolder);	
+	
+	if (error && error->message) {
+		g_warning ("Preparing summary failed: %s: %s\n", priv->path, error->message);
+		g_dbus_method_invocation_return_gerror (data->invocation, error);		
+		ipc(printf("Preparing summary : %s failed: %s\n", priv->path, error->message));
+		return;
+	}
+
+	egdbus_folder_cf_complete_prepare_summary (data->object, data->invocation);
+
+	ipc(printf("Preparing summary: %s success\n", priv->path));
+
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_prepareSummary (EGdbusFolderCF *object, GDBusMethodInvocation *invocation, EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);	
+	EMailFolderTransferData *data = g_new0 (EMailFolderTransferData, 1);
+	int i;
+
+	data->object = object;
+	data->invocation = invocation;
+	data->mfolder = mfolder;
+
+	ipc(printf("Prepare folder summary %s: \n", priv->path));
+
+	mail_operate_on_folder (priv->folder, ps_operate, ps_done, data);
+
+	return TRUE;
+}
+
+
+/* Class def */
+
+static void
+e_mail_data_folder_init (EMailDataFolder *self)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(self);
+
+	priv->gdbus_object = egdbus_folder_cf_stub_new ();
+	g_signal_connect (priv->gdbus_object, "handle-refresh-info", G_CALLBACK (impl_Mail_refreshInfo), self);
+	g_signal_connect (priv->gdbus_object, "handle-sync", G_CALLBACK (impl_Mail_sync), self);
+	g_signal_connect (priv->gdbus_object, "handle-expunge", G_CALLBACK (impl_Mail_expunge), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-name", G_CALLBACK (impl_Mail_getName), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-name", G_CALLBACK (impl_Mail_setName), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-full-name", G_CALLBACK (impl_Mail_getFullName ), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-full-name", G_CALLBACK (impl_Mail_setFullName ), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-description", G_CALLBACK (impl_Mail_getDescription), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-description", G_CALLBACK (impl_Mail_setDescription), self);
+	g_signal_connect (priv->gdbus_object, "handle-total-message-count", G_CALLBACK (impl_Mail_totalMessageCount), self);
+	g_signal_connect (priv->gdbus_object, "handle-unread-message-count", G_CALLBACK (impl_Mail_unreadMessageCount), self);
+	g_signal_connect (priv->gdbus_object, "handle-deleted-message-count", G_CALLBACK (impl_Mail_deletedMessageCount), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-permanent-flags", G_CALLBACK (impl_Mail_getPermanentFlags), self);
+	g_signal_connect (priv->gdbus_object, "handle-has-summary-capability", G_CALLBACK (impl_Mail_hasSummaryCapability), self);
+	g_signal_connect (priv->gdbus_object, "handle-has-search-capability", G_CALLBACK (impl_Mail_hasSearchCapability), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-message-flags", G_CALLBACK (impl_Mail_getMessageFlags), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-message-flags", G_CALLBACK (impl_Mail_setMessageFlags), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-message-user-flag", G_CALLBACK (impl_Mail_getMessageUserFlag), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-message-user-flag", G_CALLBACK (impl_Mail_setMessageUserFlag), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-message-user-tag", G_CALLBACK (impl_Mail_getMessageUserTag), self);
+	g_signal_connect (priv->gdbus_object, "handle-set-message-user-tag", G_CALLBACK (impl_Mail_setMessageUserTag), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-parent-store", G_CALLBACK (impl_Mail_getParentStore), self);
+	g_signal_connect (priv->gdbus_object, "handle-append-message", G_CALLBACK (impl_Mail_appendMessage), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-uids", G_CALLBACK (impl_Mail_getUids), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-message", G_CALLBACK (impl_Mail_getMessage), self);
+	g_signal_connect (priv->gdbus_object, "handle-search-by-expression", G_CALLBACK (impl_Mail_searchByExpression), self);
+	g_signal_connect (priv->gdbus_object, "handle-search-by-uids", G_CALLBACK (impl_Mail_searchByUids), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-message-info", G_CALLBACK (impl_Mail_getMessageInfo), self);
+	g_signal_connect (priv->gdbus_object, "handle-transfer-messages-to", G_CALLBACK (impl_Mail_transferMessagesTo), self);
+	g_signal_connect (priv->gdbus_object, "handle-prepare-summary", G_CALLBACK (impl_Mail_prepareSummary), self);
+	
+	
+}
+
+EMailDataFolder*
+e_mail_data_folder_new (CamelFolder *folder)
+{
+	EMailDataFolder *efolder;
+	EMailDataFolderPrivate *priv;
+
+  	efolder = g_object_new (EMAIL_TYPE_DATA_FOLDER, NULL);
+	priv = DATA_FOLDER_PRIVATE(efolder);
+	priv->folder = folder;
+
+	return efolder;
+}
+
+static void
+folder_changed_cb (CamelFolder *folder,
+                   CamelFolderChangeInfo *changes,
+                   EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	g_ptr_array_add (changes->uid_added, NULL);
+	g_ptr_array_add (changes->uid_removed, NULL);
+	g_ptr_array_add (changes->uid_changed, NULL);
+	g_ptr_array_add (changes->uid_recent, NULL);
+
+	egdbus_folder_cf_emit_folder_changed (priv->gdbus_object, 
+					(const gchar *const *) changes->uid_added->pdata, 
+					(const gchar *const *) changes->uid_removed->pdata, 
+					(const gchar *const *) changes->uid_changed->pdata, 
+					(const gchar *const *) changes->uid_recent->pdata);
+
+	g_ptr_array_remove_index_fast (changes->uid_added, changes->uid_added->len-1);
+	g_ptr_array_remove_index_fast (changes->uid_removed, changes->uid_removed->len-1);
+	g_ptr_array_remove_index_fast (changes->uid_changed, changes->uid_changed->len-1);
+	g_ptr_array_remove_index_fast (changes->uid_recent, changes->uid_recent->len-1);
+
+}
+
+guint 
+e_mail_data_folder_register_gdbus_object (EMailDataFolder *mfolder, GDBusConnection *connection, const gchar *object_path, GError **error)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+	gboolean ret; 
+	g_return_val_if_fail (connection != NULL, 0);
+	g_return_val_if_fail (object_path != NULL, 0);
+
+	priv->path  = g_strdup (object_path);
+	g_signal_connect (
+		priv->folder, "changed",
+		G_CALLBACK (folder_changed_cb), mfolder);
+	
+ 	ret = g_dbus_interface_register_object (G_DBUS_INTERFACE (priv->gdbus_object),
+               	                     	connection,
+                                    	object_path,
+                                    	error);	
+	
+	ipc(printf("Registering folder %s: %d\n", object_path, ret));
+
+	return ret;
+}
+
+const char *
+e_mail_data_folder_get_path (EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	return priv->path;
+}
+
+CamelFolder *
+e_mail_data_folder_get_camel_folder (EMailDataFolder *mfolder)
+{
+	EMailDataFolderPrivate *priv = DATA_FOLDER_PRIVATE(mfolder);
+
+	return priv->folder;
+}
diff --git a/mail/daemon/e-mail-data-folder.h b/mail/daemon/e-mail-data-folder.h
new file mode 100644
index 0000000..0ecabb1
--- /dev/null
+++ b/mail/daemon/e-mail-data-folder.h
@@ -0,0 +1,50 @@
+/* e-mail-data-folder.h */
+
+#ifndef _E_MAIL_DATA_FOLDER_H
+#define _E_MAIL_DATA_FOLDER_H
+
+#include <glib-object.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+#define EMAIL_TYPE_DATA_FOLDER e_mail_data_folder_get_type()
+
+#define EMAIL_DATA_FOLDER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  EMAIL_TYPE_DATA_FOLDER, EMailDataFolder))
+
+#define EMAIL_DATA_FOLDER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  EMAIL_TYPE_DATA_FOLDER, EMailDataFolderClass))
+
+#define EMAIL_IS_DATA_FOLDER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  EMAIL_TYPE_DATA_FOLDER))
+
+#define EMAIL_IS_DATA_FOLDER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  EMAIL_TYPE_DATA_FOLDER))
+
+#define EMAIL_DATA_FOLDER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  EMAIL_TYPE_DATA_FOLDER, EMailDataFolderClass))
+
+typedef struct {
+  GObject parent;
+} EMailDataFolder;
+
+typedef struct {
+  GObjectClass parent_class;
+} EMailDataFolderClass;
+
+GType e_mail_data_folder_get_type (void);
+
+EMailDataFolder* e_mail_data_folder_new (CamelFolder *folder);
+guint e_mail_data_folder_register_gdbus_object (EMailDataFolder *mfolder, GDBusConnection *connection, const gchar *object_path, GError **error);
+const char * e_mail_data_folder_get_path (EMailDataFolder *mfolder);
+CamelFolder * e_mail_data_folder_get_camel_folder (EMailDataFolder *efolder);
+
+G_END_DECLS
+
+#endif /* _E_MAIL_DATA_FOLDER_H */
diff --git a/mail/daemon/e-mail-data-folder.xml b/mail/daemon/e-mail-data-folder.xml
new file mode 100644
index 0000000..1fdf07f
--- /dev/null
+++ b/mail/daemon/e-mail-data-folder.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node SYSTEM "dbus.dtd">
+
+<!--
+  Author: Srinivasa Ragavan <sragavan gnome org>
+  Copyright (C) 2011 Intel Corporation
+-->
+<node>
+
+  <interface name="org.gnome.evolution.dataserver.mail.Folder">
+    <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EMailDataFolder"/>
+    <annotation name="org.gtk.GDBus.Name" value="CF"/>
+
+    <!-- Sync APIs -->
+    <method name="refreshInfo">
+      <arg name="success" type="b" direction="out"/>	    	    
+    </method>
+    <method name="sync">
+      <arg name="expunge" type="b" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <method name="expunge">
+      <arg name="success" type="b" direction="out"/>	    	    
+    </method>
+    <signal name="FolderChanged">
+      <arg name="uids_added" type="as"/>
+      <arg name="uids_removed" type="as"/>
+      <arg name="uids_changed" type="as"/>
+      <arg name="uids_recent" type="as"/>
+    </signal>
+
+    <!-- Info on Folder -->
+    <method name="getName">
+      <arg name="name" type="s" direction="out"/>	    	    
+    </method>
+    <method name="setName">
+      <arg name="name" type="s" direction="in"/>	    	    
+    </method>
+    <method name="getFullName">
+      <arg name="name" type="s" direction="out"/>	    	    
+    </method>
+    <method name="setFullName">
+      <arg name="name" type="s" direction="in"/>	    	    
+    </method>
+    <method name="getDescription">
+      <arg name="desc" type="s" direction="out"/>	    	    
+    </method>
+    <method name="setDescription">
+      <arg name="desc" type="s" direction="in"/>	    	    
+    </method>    
+
+    <!-- Folder stuff-->
+    <method name="getPermanentFlags">
+      <arg name="flags" type="u" direction="out"/>	    	    
+    </method>
+    <method name="hasSummaryCapability">
+      <arg name="summary" type="b" direction="out"/>	    	    
+    </method>
+    <method name="hasSearchCapability">
+      <arg name="search" type="b" direction="out"/>	    	    
+    </method>    
+    <method name="totalMessageCount">
+      <arg name="count" type="i" direction="out"/>	    	    
+    </method>
+    <method name="unreadMessageCount">
+      <arg name="count" type="i" direction="out"/>	    	    
+    </method>    
+    <method name="deletedMessageCount">
+      <arg name="count" type="i" direction="out"/>	    	    
+    </method>      
+
+    <!-- Message & UID -->
+    <method name="getMessageFlags">
+      <arg name="uid" type="s" direction="in"/>	    	    	    
+      <arg name="flags" type="u" direction="out"/>	    	    
+    </method>    
+    <method name="setMessageFlags">
+      <arg name="uid" type="s" direction="in"/>	    	    	    
+      <arg name="flags" type="u" direction="in"/>	 
+      <arg name="set" type="u" direction="in"/>	    	          
+      <arg name="success" type="b" direction="out"/>	    	          
+    </method>        
+    <method name="getMessageUserFlag">
+      <arg name="uid" type="s" direction="in"/>	    	    	    
+      <arg name="flagname" type="s" direction="in"/>	 
+      <arg name="flag" type="b" direction="out"/>	    	    
+    </method> 
+    <method name="setMessageUserFlag">
+      <arg name="uid" type="s" direction="in"/>	    	
+      <arg name="flagname" type="s" direction="in"/>	 
+      <arg name="set" type="u" direction="in"/>	    	          
+    </method>        
+    <method name="getMessageUserTag">
+      <arg name="uid" type="s" direction="in"/>	   
+      <arg name="param" type="s" direction="in"/>	    	    	    	    
+      <arg name="value" type="s" direction="out"/>	    	    
+    </method> 
+    <method name="setMessageUserTag">
+      <arg name="uid" type="s" direction="in"/>	    	
+      <arg name="param" type="s" direction="in"/>	    	    	    	    
+      <arg name="value" type="s" direction="in"/>	    	    	    	    
+    </method>        
+
+    <!-- Folder operations -->    
+    <method name="getParentStore">
+      <arg name="store" type="o" direction="out"/>	    	    	    	    
+    </method>        
+    <method name="AppendMessage">
+      <!-- Structure of CamelMessageInfoBase
+         ssssss - uid, sub, from, to, cc, mlist
+	 uu - flags, size
+	 tt - date_sent, date_received
+	 t  - message_id
+	 iat - references
+	 as - userflags
+	 a(ss) - usertags
+	 /* We aren't now sending content_info & headers */
+      -->
+      <arg name="info" type="(ssssssuutttiatasa(ss))" direction="in"/>	
+      <arg name="message" type="s" direction="in"/>	    	          	    
+	
+      <arg name="appendeduid" type="s" direction="out"/>	    	          	    
+      <arg name="success" type="b" direction="out"/>	    	                
+    </method>  
+    <method name="getUids">
+      <arg name="uids" type="as" direction="out"/>	    	    	    	    
+    </method>        
+    <method name="getMessage">
+      <arg name="uid" type="s" direction="in"/>	    	    	    	    	    
+      <arg name="message" type="s" direction="out"/>	    	    	    	    
+    </method>        
+    <method name="searchByExpression">
+      <arg name="expression" type="s" direction="in"/>	    	    	    	    	    
+      <arg name="uids" type="as" direction="out"/>	    	    	    	    
+    </method>  
+    <method name="searchByUids">
+      <arg name="expression" type="s" direction="in"/>	    	    	    	    	    
+      <arg name="searchuids" type="as" direction="in"/>	    	    	    	    	    
+      <arg name="resultuids" type="as" direction="out"/>	    	    	    	    
+    </method>  
+    <method name="getMessageInfo">
+      <arg name="uid" type="s" direction="in"/>	    	    	    	    	    
+      <!-- Structure of CamelMessageInfoBase -->
+      <arg name="info" type="(ssssssuutttiatasa(ss))" direction="out"/>	
+    </method>        
+    <method name="transferMessagesTo">
+      <arg name="uids" type="as" direction="in"/>	    	    	    	    	    
+      <arg name="destfolder" type="o" direction="in"/>
+      <arg name="deleteoriginals" type="b" direction="in"/>	    	    	    	    	    
+      <arg name="returnuids" type="as" direction="out"/>	    	    	    	    	    
+    </method>        
+    <method name="prepareSummary">
+    </method>        
+    
+  </interface>
+
+
+</node>
diff --git a/mail/daemon/e-mail-data-session.c b/mail/daemon/e-mail-data-session.c
new file mode 100644
index 0000000..305eb16
--- /dev/null
+++ b/mail/daemon/e-mail-data-session.c
@@ -0,0 +1,409 @@
+/* e-mail-data-session.c */
+
+#include "e-mail-data-session.h"
+#include "e-mail-local.h"
+#include "e-mail-data-store.h"
+#include "e-gdbus-emailsession.h"
+#include <camel/camel.h>
+#include <gio/gio.h>
+#include "mail-ops.h"
+#include "utils.h"
+
+extern CamelSession *session;
+#define micro(x) if (mail_debug_log(EMAIL_DEBUG_SESSION|EMAIL_DEBUG_MICRO)) x;
+#define ipc(x) if (mail_debug_log(EMAIL_DEBUG_SESSION|EMAIL_DEBUG_IPC)) x;
+
+
+G_DEFINE_TYPE (EMailDataSession, e_mail_data_session, G_TYPE_OBJECT)
+
+#define DATA_SESSION_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMAIL_TYPE_DATA_SESSION, EMailDataSessionPrivate))
+
+typedef struct _EMailDataSessionPrivate EMailDataSessionPrivate;
+
+struct _EMailDataSessionPrivate
+{
+	EGdbusSessionCS *gdbus_object;
+
+	GMutex *stores_lock;
+	/* 'uri' -> EBookBackend */
+	GHashTable *stores;
+
+	GMutex *datastores_lock;
+	/* A hash of object paths for book URIs to EDataBooks */
+	GHashTable *datastores;
+
+	GMutex *connections_lock;
+	/* This is a hash of client addresses to GList* of EDataBooks */
+	GHashTable *connections;
+
+	guint exit_timeout;
+	
+};
+
+static gchar *
+construct_mail_session_path (void)
+{
+	static volatile gint counter = 1;
+
+	return g_strdup_printf (
+		"/org/gnome/evolution/dataserver/mail/store/%d/%u",
+		getpid (), g_atomic_int_exchange_and_add (&counter, 1));
+}
+
+typedef struct _email_get_store_data {
+	EMailDataSession *msession;
+	EGdbusSessionCS *object;
+	GDBusMethodInvocation *invocation;
+	
+}EMailGetStoreData;
+
+static void
+process_store (EMailDataSession *msession, const char *url, CamelStore *store, EGdbusSessionCS *object, GDBusMethodInvocation *invocation)
+{
+	char *path;
+	EMailDataStore *estore;
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	const gchar *sender;
+	GList *list = NULL;
+
+	/* Hold store & datastore the lock when you are calling this function */
+	path = construct_mail_session_path ();
+	estore = e_mail_data_store_new (store, url);
+
+	g_hash_table_insert (priv->datastores, store, estore);
+	e_mail_data_store_register_gdbus_object (estore, g_dbus_method_invocation_get_connection (invocation), path, NULL);
+	
+	g_mutex_lock (priv->connections_lock);
+	sender = g_dbus_method_invocation_get_sender (invocation);
+
+	list = g_hash_table_lookup (priv->connections, sender);
+	list = g_list_prepend (list, estore);
+	g_hash_table_insert (priv->connections, g_strdup (sender), list);
+	g_mutex_unlock (priv->connections_lock);
+
+	ipc (printf("EMailDataSession: Get Store: Success %s  for sender: '%s'\n", path, sender));
+
+	egdbus_session_cs_complete_get_store (object, invocation, path);
+}
+
+static void 
+get_store_cb (gchar *uri, CamelStore *store, gpointer data, GError *error)
+{
+	EMailGetStoreData *session_data = (EMailGetStoreData *)data;
+	EMailDataSession *msession = session_data->msession;
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	
+	char *uri_key = g_strdup (uri);
+
+	if (store == NULL) {
+		/* Must handle error now... */
+		g_mutex_unlock (priv->datastores_lock);
+		g_mutex_unlock (priv->stores_lock);
+		g_warning ("Unable to get store %s: %s\n", uri, error->message);
+		ipc(printf("Unable to get store %s: %s\n", uri, error->message));
+		g_dbus_method_invocation_return_gerror (session_data->invocation, error);
+		return;
+	}
+
+	g_mutex_lock (priv->stores_lock);
+	g_mutex_lock (priv->datastores_lock);
+	
+	g_hash_table_insert (priv->stores, uri_key, store);
+
+	process_store (msession, uri, store, session_data->object, session_data->invocation);
+	
+	g_mutex_unlock (priv->datastores_lock);
+	g_mutex_unlock (priv->stores_lock);
+
+	g_free (data);
+}
+
+static gboolean
+impl_Mail_getStore (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, const gchar *url, EMailDataSession *msession)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	CamelStore *store;
+
+	/* Remove a pending exit */
+	if (priv->exit_timeout) {
+		g_source_remove (priv->exit_timeout);
+		priv->exit_timeout = 0;
+	}
+	
+	g_mutex_lock (priv->stores_lock);
+	g_mutex_lock (priv->datastores_lock);
+	store = g_hash_table_lookup (priv->stores, url);
+	
+	if (store == NULL) {
+		EMailGetStoreData *store_data = g_new0 (EMailGetStoreData, 1);
+
+		store_data->object = object;
+		store_data->msession = msession;
+		store_data->invocation = invocation;
+
+		g_mutex_unlock (priv->datastores_lock);
+		g_mutex_unlock (priv->stores_lock);
+
+		mail_get_store (url, NULL, get_store_cb, store_data);
+		return TRUE;
+	}
+
+
+	process_store (msession, url, store, object, invocation);
+	
+	g_mutex_unlock (priv->datastores_lock);
+	g_mutex_unlock (priv->stores_lock);
+	
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getLocalStore (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, EMailDataSession *msession)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	CamelStore *store;
+	EMailDataStore *estore;
+	char *path = NULL;
+	char *url=NULL;
+	GList *list;
+	const gchar *sender;
+
+	/* Remove a pending exit */
+	if (priv->exit_timeout) {
+		g_source_remove (priv->exit_timeout);
+		priv->exit_timeout = 0;
+	}
+	
+	store = e_mail_local_get_store ();
+
+	g_mutex_lock (priv->datastores_lock);
+	estore = g_hash_table_lookup (priv->datastores, store);
+	
+	if (estore == NULL) {
+		url = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_ALL);
+		path = construct_mail_session_path ();
+		estore = e_mail_data_store_new (store, url);
+
+		g_hash_table_insert (priv->datastores, store, estore);
+		e_mail_data_store_register_gdbus_object (estore, g_dbus_method_invocation_get_connection (invocation), path, NULL);
+	
+
+	} else 
+		path = g_strdup (e_mail_data_store_get_path (estore));
+
+	g_mutex_unlock (priv->datastores_lock);
+
+	g_mutex_lock (priv->connections_lock);
+	sender = g_dbus_method_invocation_get_sender (invocation);
+
+	list = g_hash_table_lookup (priv->connections, sender);
+	list = g_list_prepend (list, estore);
+	g_hash_table_insert (priv->connections, g_strdup (sender), list);
+	g_mutex_unlock (priv->connections_lock);
+
+	ipc (printf("EMailDataSession: Get Local Store: Success %s  for sender: '%s'\n", path, sender));
+
+	egdbus_session_cs_complete_get_local_store (object, invocation, path);
+
+	g_free (path);
+	g_free(url);
+	
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getLocalFolder (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, const char *type, EMailDataSession *msession)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	CamelStore *store;
+	CamelFolder *folder;
+	EMailLocalFolder ftype;
+	EMailDataStore *estore;
+	char *fpath, *spath;
+	char *url;
+
+	if (type[0] == 'i' || type[0] == 'I')
+		ftype = E_MAIL_FOLDER_INBOX;
+	else 	if (type[0] == 'd' || type[0] == 'D')
+		ftype = E_MAIL_FOLDER_DRAFTS;
+	else if (type[0] == 'o' || type[0] == 'O')
+		ftype = E_MAIL_FOLDER_OUTBOX;
+	else if (type[0] == 's' || type[0] == 'S')
+		ftype = E_MAIL_FOLDER_SENT;
+	else if (type[0] == 't' || type[0] == 'T')
+		ftype = E_MAIL_FOLDER_TEMPLATES;
+	else 
+		ftype = E_MAIL_FOLDER_LOCAL_INBOX;
+	
+	folder = e_mail_local_get_folder (ftype);
+	store = e_mail_local_get_store ();
+
+	g_mutex_lock (priv->datastores_lock);
+	estore = g_hash_table_lookup (priv->datastores, store);
+	
+	if (estore == NULL) {
+		url = camel_url_to_string(((CamelService *)store)->url, CAMEL_URL_HIDE_ALL);
+		spath = construct_mail_session_path ();
+		estore = e_mail_data_store_new (store, url);
+
+		g_hash_table_insert (priv->datastores, store, estore);
+		e_mail_data_store_register_gdbus_object (estore, g_dbus_method_invocation_get_connection (invocation), spath, NULL);
+		g_free (url);
+		g_free (spath);	
+	}
+
+	g_mutex_unlock (priv->datastores_lock);
+
+	fpath = e_mail_data_store_get_folder_path (estore, g_dbus_method_invocation_get_connection (invocation), folder);
+
+	egdbus_session_cs_complete_get_local_folder (object, invocation, fpath);
+
+	return TRUE;
+}
+
+static void
+e_mail_data_session_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_session_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_session_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_session_parent_class)->dispose (object);
+}
+
+static void
+e_mail_data_session_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_session_parent_class)->finalize (object);
+}
+
+static void
+e_mail_data_session_class_init (EMailDataSessionClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (EMailDataSessionPrivate));
+
+  object_class->get_property = e_mail_data_session_get_property;
+  object_class->set_property = e_mail_data_session_set_property;
+  object_class->dispose = e_mail_data_session_dispose;
+  object_class->finalize = e_mail_data_session_finalize;
+}
+
+static void
+e_mail_data_session_init (EMailDataSession *self)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(self);
+
+	priv->gdbus_object = egdbus_session_cs_stub_new ();
+	g_signal_connect (priv->gdbus_object, "handle-get-store", G_CALLBACK (impl_Mail_getStore), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-local-store", G_CALLBACK (impl_Mail_getLocalStore), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-local-folder", G_CALLBACK (impl_Mail_getLocalFolder), self);
+
+	priv->stores_lock = g_mutex_new ();
+	priv->stores = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+	priv->datastores_lock = g_mutex_new ();
+	priv->datastores = g_hash_table_new_full (
+		g_direct_hash, g_direct_equal,
+		(GDestroyNotify) NULL,
+		(GDestroyNotify) NULL);
+
+	priv->connections_lock = g_mutex_new ();
+	priv->connections = g_hash_table_new_full (
+		g_str_hash, g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) NULL);
+	
+	
+}
+
+EMailDataSession*
+e_mail_data_session_new (void)
+{
+  return g_object_new (EMAIL_TYPE_DATA_SESSION, NULL);
+}
+
+guint
+e_mail_data_session_register_gdbus_object (EMailDataSession *msession, GDBusConnection *connection, const gchar *object_path, GError **error)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	guint ret;
+
+	g_return_val_if_fail (connection != NULL, 0);
+	g_return_val_if_fail (object_path != NULL, 0);
+
+ 	ret = g_dbus_interface_register_object (G_DBUS_INTERFACE (priv->gdbus_object),
+               	                     	connection,
+                                    	object_path,
+                                    	error);
+
+	ipc (printf("EMailDataSession: Registering gdbus object %s\n", object_path));
+
+	return ret;
+}
+
+void 
+e_mail_data_session_release (EMailDataSession *session, GDBusConnection *connection, const char *name)
+{
+
+}
+
+const char *
+e_mail_data_session_get_path_from_store (EMailDataSession *msession, gpointer store)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	EMailDataStore *mstore;
+
+	mstore = g_hash_table_lookup (priv->datastores, store);
+	g_assert (mstore != NULL);
+	
+	micro(printf("e_mail_data_session_get_path_from_store: %p: %s\n", store, e_mail_data_store_get_path(mstore)));
+
+	return e_mail_data_store_get_path (mstore);
+}
+
+CamelFolder *
+e_mail_session_get_folder_from_path (EMailDataSession *msession, const char *path)
+{
+	EMailDataSessionPrivate *priv = DATA_SESSION_PRIVATE(msession);
+	GHashTableIter iter;
+	gpointer key, value;
+	
+	g_hash_table_iter_init (&iter, priv->datastores);
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		EMailDataStore *estore = (EMailDataStore *)value;
+		CamelFolder *folder;
+
+		folder = e_mail_data_store_get_camel_folder (estore, path);
+		if (folder) {
+			micro(printf("e_mail_session_get_folder_from_path: %s %p\n", path, folder));
+
+			return folder;
+		}
+	}	
+
+	micro(printf("e_mail_session_get_folder_from_path: %s %p\n", path, NULL));
+	g_warning ("Unable to find CamelFolder from the object path\n");
+
+	return NULL;	
+}
diff --git a/mail/daemon/e-mail-data-session.h b/mail/daemon/e-mail-data-session.h
new file mode 100644
index 0000000..66a771d
--- /dev/null
+++ b/mail/daemon/e-mail-data-session.h
@@ -0,0 +1,53 @@
+/* e-mail-data-session.h */
+
+#ifndef _E_MAIL_DATA_SESSION_H
+#define _E_MAIL_DATA_SESSION_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+#define EMAIL_TYPE_DATA_SESSION e_mail_data_session_get_type()
+
+#define EMAIL_DATA_SESSION(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  EMAIL_TYPE_DATA_SESSION, EMailDataSession))
+
+#define EMAIL_DATA_SESSION_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  EMAIL_TYPE_DATA_SESSION, EMailDataSessionClass))
+
+#define EMAIL_IS_DATA_SESSION(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  EMAIL_TYPE_DATA_SESSION))
+
+#define EMAIL_IS_DATA_SESSION_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  EMAIL_TYPE_DATA_SESSION))
+
+#define EMAIL_DATA_SESSION_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  EMAIL_TYPE_DATA_SESSION, EMailDataSessionClass))
+
+typedef struct {
+  GObject parent;
+} EMailDataSession;
+
+typedef struct {
+  GObjectClass parent_class;
+} EMailDataSessionClass;
+
+GType e_mail_data_session_get_type (void);
+
+EMailDataSession* e_mail_data_session_new (void);
+guint e_mail_data_session_register_gdbus_object (EMailDataSession *msession, GDBusConnection *connection, const gchar *object_path, GError **error);
+void e_mail_data_session_release (EMailDataSession *session, GDBusConnection *connection, const char *name);
+const char * e_mail_data_session_get_path_from_store (EMailDataSession *msession, gpointer store);
+CamelFolder * e_mail_session_get_folder_from_path (EMailDataSession *msession, const char *path);
+
+
+G_END_DECLS
+
+#endif /* _E_MAIL_DATA_SESSION_H */
diff --git a/mail/daemon/e-mail-data-session.xml b/mail/daemon/e-mail-data-session.xml
new file mode 100644
index 0000000..18219d9
--- /dev/null
+++ b/mail/daemon/e-mail-data-session.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node SYSTEM "dbus.dtd">
+
+<!--
+  Author: Srinivasa Ragavan <sragavan gnome org>
+  Copyright (C) 2011 Intel Corporation
+-->
+<node>
+
+  <interface name="org.gnome.evolution.dataserver.mail.Session">
+    <annotation name="org.gtk.GDBus.Name" value="CS"/>
+    <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EMailDataSession"/>
+
+    <method name="getStore">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Mail_Session_getStore"/>
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg name="uri" type="s" direction="in"/>
+      <arg name="store" type="o" direction="out"/>
+    </method>
+
+    <method name="getLocalStore">
+      <arg name="store" type="o" direction="out"/>
+    </method>
+    <!-- 
+    FolderType should be a string "inbox" "draft" "outbox" "sent" "templates"
+    -->
+    <method name="getLocalFolder">
+      <arg name="type" type="s" direction="in"/>	    
+      <arg name="folder" type="o" direction="out"/>
+    </method>
+
+  </interface>
+
+</node>
diff --git a/mail/daemon/e-mail-data-store.c b/mail/daemon/e-mail-data-store.c
new file mode 100644
index 0000000..ba01739
--- /dev/null
+++ b/mail/daemon/e-mail-data-store.c
@@ -0,0 +1,990 @@
+/* e-mail-data-store.c */
+
+#include <string.h>
+#include "e-mail-data-store.h"
+#include "e-mail-data-folder.h"
+#include "e-gdbus-emailstore.h"
+#include "mail-ops.h"
+#include "utils.h"
+
+#define micro(x) if (mail_debug_log(EMAIL_DEBUG_STORE|EMAIL_DEBUG_MICRO)) x;
+#define ipc(x) if (mail_debug_log(EMAIL_DEBUG_STORE|EMAIL_DEBUG_IPC)) x;
+
+
+G_DEFINE_TYPE (EMailDataStore, e_mail_data_store, G_TYPE_OBJECT)
+
+#define DATA_STORE_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMAIL_TYPE_DATA_STORE, EMailDataStorePrivate))
+
+typedef struct _EMailDataStorePrivate EMailDataStorePrivate;
+
+struct _EMailDataStorePrivate
+{
+	EGdbusStoreMS *gdbus_object;
+
+	CamelStore *store;
+	char *url;
+
+	GMutex *folders_lock;
+	/* 'uri' -> EBookBackend */
+	GHashTable *folders;
+
+	GMutex *datafolders_lock;
+	/* A hash of object paths for book URIs to EDataBooks */
+	GHashTable *datafolders;
+
+	char *object_path;
+
+	
+};
+
+static void
+e_mail_data_store_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_store_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+e_mail_data_store_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_store_parent_class)->dispose (object);
+}
+
+static void
+e_mail_data_store_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (e_mail_data_store_parent_class)->finalize (object);
+}
+
+static void
+e_mail_data_store_class_init (EMailDataStoreClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (EMailDataStorePrivate));
+
+  object_class->get_property = e_mail_data_store_get_property;
+  object_class->set_property = e_mail_data_store_set_property;
+  object_class->dispose = e_mail_data_store_dispose;
+  object_class->finalize = e_mail_data_store_finalize;
+}
+
+static gchar *
+construct_mail_store_path (char *full_name)
+{
+	static volatile gint counter = 1;
+	int i, len;
+	char *path = g_strdup_printf (
+		       "/org/gnome/evolution/dataserver/mail/folder/%s/%d/%u",
+		       full_name, getpid (), g_atomic_int_exchange_and_add (&counter, 1));
+	len = strlen(path);
+	for (i=0; i<len ; i++)
+		if (path[i] == '.')
+			path[i] = '_';
+		else if (path[i] == '#')
+			path[i] = '_';
+		else if (path[i] == '(')
+			path[i] = '_';
+		else if (path[i] == ')')
+			path[i] = '_';
+		else if (path[i] == ' ')
+			path[i] = '_';
+	
+	
+
+	return path;
+}
+
+
+static void
+convert_folder_info (CamelFolderInfo *info, GVariantBuilder *builder)
+{
+	while (info) {
+		g_variant_builder_add (builder, "(sssuii)", 
+					info->uri,
+					info->name,
+					info->full_name,
+					info->flags,
+					info->unread,
+					info->total);
+
+		convert_folder_info (info->child, builder);
+		info = info->next;
+	}
+}
+
+typedef struct _get_folder_info_data {
+	EGdbusStoreMS *object; 
+	GDBusMethodInvocation *invocation; 
+	EMailDataStore *mstore;
+}GFIData;
+
+static gboolean 
+handle_get_folder_info_cb (CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error)
+{
+	GFIData *gfi_data = (GFIData *)data;
+	EMailDataStore *mstore = gfi_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	
+	GVariantBuilder *builder;
+	GVariant *variant;
+
+	if (!info) {
+		g_warning ("Unable to get folder info on Store %p: %s\n", store, error->message);
+		g_dbus_method_invocation_return_gerror (gfi_data->invocation, error);
+		ipc (printf("EMailDataStore: get folder info failed : %s - %s\n", priv->object_path, error->message));
+
+		return FALSE;
+	}
+
+	builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+
+	convert_folder_info (info, builder);
+	/* Added a empty entry */
+	g_variant_builder_add (builder, "(sssuii)", "", "", "", 0, -1, -1);
+	
+	variant = g_variant_builder_end (builder);
+	g_variant_builder_unref (builder);
+	
+	egdbus_store_ms_complete_get_folder_info (gfi_data->object, gfi_data->invocation, variant);
+	g_variant_unref (variant);
+
+	g_free (gfi_data);
+	ipc (printf("EMailDataStore: get folder info success: %s\n", priv->object_path));
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getFolderInfo (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, char *top, guint32 flags, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	GFIData *gfi_data = g_new0 (GFIData, 1);
+
+	gfi_data->object = object;
+	gfi_data->invocation = invocation;
+	gfi_data->mstore = mstore;
+	
+	ipc (printf("EMailDataStore: get folder info: %s - %s: %d\n", priv->object_path, top ? top : "", flags));
+
+	mail_get_folderinfo_full (priv->store, top, flags, NULL, handle_get_folder_info_cb, gfi_data);
+
+	return TRUE;
+}
+
+typedef struct _email_get_folder_data {
+	EMailDataStore *mstore;
+	EGdbusStoreMS *object;
+	GDBusMethodInvocation *invocation;
+	char *folder_name;
+	gboolean junk;
+	gboolean trash;
+	gboolean inbox;
+}EMailGetFolderData;
+
+static void
+handle_mail_get_folder (CamelFolder *folder, gpointer data, GError *error)
+{
+	EMailGetFolderData *send_data = (EMailGetFolderData *)data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	char *new_name;
+	EMailDataFolder *efolder = NULL;
+	char *path;
+
+	if (folder == NULL) {
+		g_mutex_unlock (priv->folders_lock);
+		g_mutex_unlock (priv->datafolders_lock);
+		g_warning ("Unable to get folder : %s\n", error->message);
+		ipc (printf("EMailDataStore: get folder failed : %s - %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+
+	new_name = g_strdup (camel_folder_get_full_name (folder));
+	g_mutex_lock (priv->folders_lock);
+	g_mutex_lock (priv->datafolders_lock);
+
+	g_hash_table_insert (priv->folders, new_name, folder);
+	efolder = e_mail_data_folder_new (folder);
+
+	path = construct_mail_store_path (new_name);
+	e_mail_data_folder_register_gdbus_object (efolder, g_dbus_method_invocation_get_connection (send_data->invocation), path, NULL);
+	g_hash_table_insert (priv->datafolders, g_strdup(new_name), efolder);
+
+	if (send_data->folder_name)
+		egdbus_store_ms_complete_get_folder (send_data->object, send_data->invocation, path);
+	else if (send_data->inbox)
+		egdbus_store_ms_complete_get_inbox (send_data->object, send_data->invocation, path);
+	else if (send_data->junk)
+		egdbus_store_ms_complete_get_junk (send_data->object, send_data->invocation, path);
+	else
+		egdbus_store_ms_complete_get_trash (send_data->object, send_data->invocation, path);
+
+	ipc (printf("EMailDataStore: get folder : %s %s: %s\n", priv->object_path, new_name, path));
+
+	g_mutex_unlock (priv->folders_lock);
+	g_mutex_unlock (priv->datafolders_lock);
+
+	g_free (send_data->folder_name);
+	g_free (send_data);
+	g_free (path);
+}
+
+static gboolean
+impl_Mail_getFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, const gchar *full_name, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	CamelFolder *folder;
+	gchar *path=NULL;
+	EMailGetFolderData *send_data;
+	EMailDataFolder *efolder = NULL;
+
+	folder = g_hash_table_lookup (priv->folders, full_name);
+
+	ipc (printf("EMailDataStore: get folder %s - %s\n", priv->object_path, full_name));
+
+	if (folder == NULL) {
+		char *new_name = g_strdup (full_name);
+
+		send_data = g_new0 (EMailGetFolderData, 1);
+		send_data->mstore = mstore;
+		send_data->object = object;
+		send_data->folder_name = new_name;
+		send_data->invocation = invocation;
+
+		mail_get_folder_from_name (priv->store, new_name, FALSE, FALSE, FALSE, 0,
+					handle_mail_get_folder, send_data, mail_msg_unordered_push);
+
+		return TRUE;
+	}
+
+
+	efolder = g_hash_table_lookup (priv->datafolders, full_name);
+	path = (char *) e_mail_data_folder_get_path (efolder);
+
+	ipc (printf("EMailDataStore: get folder success: %s %s: %s d\n", priv->object_path, full_name, path));
+
+	egdbus_store_ms_complete_get_folder (object, invocation, path);
+
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_getInbox (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailGetFolderData *send_data;
+
+
+	send_data = g_new0 (EMailGetFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->inbox = TRUE;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: get inbox: %s\n", priv->object_path));
+	
+	mail_get_folder_from_name (priv->store, NULL, FALSE, FALSE, TRUE, 0,
+				   handle_mail_get_folder, send_data, mail_msg_unordered_push);
+	
+	return TRUE;
+
+}
+
+static gboolean
+impl_Mail_getTrash (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailGetFolderData *send_data;
+
+
+	send_data = g_new0 (EMailGetFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->trash = TRUE;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: get trash: %s\n", priv->object_path));
+
+	mail_get_folder_from_name (priv->store, NULL, FALSE, TRUE, FALSE, 0,
+				   handle_mail_get_folder, send_data, mail_msg_unordered_push);
+	
+	return TRUE;
+
+}
+
+static gboolean
+impl_Mail_getJunk (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailGetFolderData *send_data;
+
+
+	send_data = g_new0 (EMailGetFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->junk = TRUE;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: get junk: %s\n", priv->object_path));
+
+	mail_get_folder_from_name (priv->store, NULL, TRUE, FALSE, FALSE, 0,
+				   handle_mail_get_folder, send_data, mail_msg_unordered_push);
+	
+	return TRUE;
+
+}
+
+typedef struct _email_cdr_folder_data {
+	EMailDataStore *mstore;
+	EGdbusStoreMS *object;
+	GDBusMethodInvocation *invocation;
+}EMailCDRFolderData;
+
+static void 
+handle_create_folder_cb (CamelFolderInfo *fi, gpointer user_data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)user_data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);	
+	GVariantBuilder *builder;
+	GVariant *variant;
+	
+	if (!fi) {
+		/* Handle error */
+		g_warning ("Unable to create folder: %s\n", error->message);
+		ipc (printf("EMailDataStore: folder create failed : %s - %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+	
+	builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+
+	convert_folder_info (fi, builder);
+	/* Added a empty entry */
+	g_variant_builder_add (builder, "(sssuii)", "", "", "", 0, -1, -1);
+	
+	variant = g_variant_builder_end (builder);
+	g_variant_builder_unref (builder);
+	
+	ipc (printf("EMailDataStore: folder create success: %s\n", priv->object_path));
+
+	egdbus_store_ms_complete_create_folder (send_data->object, send_data->invocation, variant);
+	g_variant_unref (variant);
+
+	g_free (send_data);
+}
+
+static gboolean
+impl_Mail_createFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, const char *parent, const char *folder_name, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+	
+	ipc (printf("EMailDataStore: folder create: %s\n", folder_name));
+
+	mail_create_folder (priv->store, parent, folder_name, handle_create_folder_cb, send_data);
+	return TRUE;
+
+}
+
+static void 
+handle_delete_folder_cb (gpointer user_data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)user_data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	
+	if (error && error->message) {
+		/* Handle error */
+		g_warning ("Unable to delete folder: %s\n", error->message);
+		ipc (printf("EMailDataStore: folder delete failed : %s - %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+	
+	ipc (printf("EMailDataStore: folder delete success: %s\n", priv->object_path));
+
+	egdbus_store_ms_complete_delete_folder (send_data->object, send_data->invocation, TRUE);
+
+	g_free (send_data);
+}
+
+static gboolean
+impl_Mail_deleteFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, const char *folder_name, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: folder delete: %s - %s\n", priv->object_path, folder_name));
+
+	mail_delete_folder (priv->store, folder_name, handle_delete_folder_cb, send_data);
+	return TRUE;
+
+}
+
+static void 
+handle_rename_folder_cb (gpointer user_data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)user_data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	
+	if (error && error->message) {
+		/* Handle error */
+		g_warning ("Unable to rename folder: %s\n", error->message);
+		ipc (printf("EMailDataStore: folder rename failed : %s - %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+	ipc (printf("EMailDataStore: folder rename success: %s\n", priv->object_path));
+	
+	egdbus_store_ms_complete_rename_folder (send_data->object, send_data->invocation, TRUE);
+
+	g_free (send_data);
+}
+
+
+static gboolean
+impl_Mail_renameFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, const char *old_name, const char *new_name, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: folder rename: %s: %s to %s\n", priv->object_path, old_name, new_name));
+
+	mail_rename_folder (priv->store, old_name, new_name, handle_rename_folder_cb, send_data);
+	return TRUE;
+
+}
+
+static gboolean
+impl_Mail_supportsSubscriptions (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	gboolean support;
+
+	support = camel_store_supports_subscriptions (priv->store);
+	
+	ipc (printf("EMailDataStore: supports subscription: %s - %d\n", priv->object_path, support));
+
+	egdbus_store_ms_complete_supports_subscriptions (object, invocation, support);
+
+	return TRUE;
+}
+
+typedef struct _email_folder_sub_data {
+	EMailDataStore *mstore;
+	EGdbusStoreMS *object;
+	GDBusMethodInvocation *invocation;
+	MailFolderSubscription operation;
+}EMailFolderSubData;
+
+static void 
+handle_folder_subscriptions (gboolean success, gpointer data, GError *error)
+{
+	EMailFolderSubData *send_data = (EMailFolderSubData *)data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+
+	if (error && error->message) {
+		g_warning ("folder sub: %s\n", error->message);
+		ipc (printf("EMailDataStore: folder-sub failed : %s - %d: %s\n", priv->object_path, send_data->operation, error->message));
+		
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+
+	if (send_data->operation == FOLDER_IS_SUBSCRIBED)
+		egdbus_store_ms_complete_is_folder_subscribed (send_data->object, send_data->invocation, success);
+	else if (send_data->operation == FOLDER_SUBSCRIBE)
+		egdbus_store_ms_complete_subscribe_folder (send_data->object, send_data->invocation, TRUE);
+	else
+		egdbus_store_ms_complete_unsubscribe_folder (send_data->object, send_data->invocation, TRUE);
+
+	ipc (printf("EMailDataStore: folder-sub success: %s - %d\n", priv->object_path, send_data->operation));
+
+	g_free (send_data);
+}
+
+static gboolean
+impl_Mail_isFolderSubscribed (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, char *folder, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailFolderSubData *send_data;
+
+	send_data = g_new0 (EMailFolderSubData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+	send_data->operation = FOLDER_IS_SUBSCRIBED;
+
+	ipc (printf("EMailDataStore: folder issubscribed: %s\n", priv->object_path));
+
+	mail_folder_subscription (priv->store, folder, send_data->operation, handle_folder_subscriptions, send_data);
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_subscribeFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, char *folder, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailFolderSubData *send_data;
+
+	send_data = g_new0 (EMailFolderSubData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+	send_data->operation = FOLDER_SUBSCRIBE;
+
+	ipc (printf("EMailDataStore: folder subscribe: %s\n", priv->object_path));
+
+	mail_folder_subscription (priv->store, folder, send_data->operation, handle_folder_subscriptions, send_data);
+	return TRUE;
+}
+
+static gboolean
+impl_Mail_unsubscribeFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, char *folder, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailFolderSubData *send_data;
+
+	send_data = g_new0 (EMailFolderSubData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+	send_data->operation = FOLDER_UNSUBSCRIBE;
+
+	ipc (printf("EMailDataStore: folder unsubscribe: %s\n", priv->object_path));
+	
+	mail_folder_subscription (priv->store, folder, send_data->operation, handle_folder_subscriptions, send_data);
+	return TRUE;
+}
+
+static void
+handle_mail_sync (CamelStore *store, gpointer data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+
+	if (error && error->message) {
+		g_warning ("Error while syncing store: %s\n", error->message);
+		ipc (printf("EMailDataStore: sync: failed: %s %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+	ipc (printf("EMailDataStore: sync: success: %s\n", priv->object_path));
+
+	egdbus_store_ms_complete_sync (send_data->object, send_data->invocation, TRUE);
+}
+
+static gboolean
+impl_Mail_sync (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, gboolean expunge, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+	
+	ipc (printf("EMailDataStore: sync: %s\n", priv->object_path));
+
+	mail_sync_store (priv->store, expunge, handle_mail_sync, send_data);
+	return TRUE;
+}
+
+static void
+handle_mail_noop (CamelStore *store, gpointer data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)data;
+	EMailDataStore *mstore = send_data->mstore;
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+
+	if (error && error->message) {
+		g_warning ("Error while noop for store: %s\n", error->message);
+		ipc (printf("EMailDataStore: noop: failed: %s %s\n", priv->object_path, error->message));
+
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+
+	ipc (printf("EMailDataStore: noop: success: %s\n", priv->object_path));
+	egdbus_store_ms_complete_noop (send_data->object, send_data->invocation, TRUE);
+}
+
+
+static gboolean
+impl_Mail_noop (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+
+	ipc (printf("EMailDataStore: noop: %s\n", priv->object_path));
+
+	mail_noop_store (priv->store, handle_mail_noop, send_data);
+	return TRUE;
+}
+
+static void
+handle_mail_can_refresh_folder_cb (gboolean success, gpointer data, GError *error)
+{
+	EMailCDRFolderData *send_data = (EMailCDRFolderData *)data;
+
+	if (error && error->message) {
+		g_warning ("Error while noop for store: %s\n", error->message);
+		ipc (printf("EMailDataStore: Refresh Folder: failed: %s\n", error->message));
+		g_dbus_method_invocation_return_gerror (send_data->invocation, error);
+		return;
+	}
+
+	ipc (printf("EMailDataStore: Can Refresh Folder: success\n"));
+
+	egdbus_store_ms_complete_can_refresh_folder (send_data->object, send_data->invocation, success);
+}
+
+
+
+static gboolean
+impl_Mail_canRefreshFolder (EGdbusStoreMS *object, GDBusMethodInvocation *invocation, GVariant *variant, EMailDataStore *mstore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(mstore);
+	EMailCDRFolderData *send_data;
+	CamelFolderInfo *info = NULL;
+	GVariantIter iter;
+	char *full_name, *name, *uri;
+	guint32 flag;
+	int total, unread;
+
+	send_data = g_new0 (EMailCDRFolderData, 1);
+	send_data->mstore = mstore;
+	send_data->object = object;
+	send_data->invocation = invocation;
+
+	g_variant_iter_init (&iter, variant);
+	while (g_variant_iter_next (&iter, "(sssuii)", &uri, &name, &full_name, &flag, &unread, &total)) {
+		if (uri && *uri) {
+			info = camel_folder_info_new ();
+			info->uri = uri;
+			info->name = name;
+			info->full_name = full_name;
+			info->flags = flag;
+			info->unread = unread;
+			info->total = total;
+			ipc (printf("EMailDataStore: can refresh %s\n", info->full_name));
+
+			break;
+		}
+	}
+
+	mail_can_refresh_folder (priv->store, info, handle_mail_can_refresh_folder_cb, send_data);
+	return TRUE;
+}
+
+
+static void
+e_mail_data_store_init (EMailDataStore *self)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(self);
+
+	priv->object_path = NULL;
+
+	priv->folders_lock = g_mutex_new ();
+	priv->folders = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+	priv->datafolders_lock = g_mutex_new ();
+	priv->datafolders = g_hash_table_new_full (
+		g_str_hash, g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) NULL);
+
+	priv->gdbus_object = egdbus_store_ms_stub_new ();
+	g_signal_connect (priv->gdbus_object, "handle-get-folder", G_CALLBACK (impl_Mail_getFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-folder-info", G_CALLBACK (impl_Mail_getFolderInfo), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-inbox", G_CALLBACK (impl_Mail_getInbox), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-trash", G_CALLBACK (impl_Mail_getTrash), self);
+	g_signal_connect (priv->gdbus_object, "handle-get-junk", G_CALLBACK (impl_Mail_getJunk), self);
+	g_signal_connect (priv->gdbus_object, "handle-create-folder", G_CALLBACK (impl_Mail_createFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-delete-folder", G_CALLBACK (impl_Mail_deleteFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-rename-folder", G_CALLBACK (impl_Mail_renameFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-supports-subscriptions", G_CALLBACK (impl_Mail_supportsSubscriptions), self);
+	g_signal_connect (priv->gdbus_object, "handle-is-folder-subscribed", G_CALLBACK (impl_Mail_isFolderSubscribed), self);
+	g_signal_connect (priv->gdbus_object, "handle-subscribe-folder", G_CALLBACK (impl_Mail_subscribeFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-unsubscribe-folder", G_CALLBACK (impl_Mail_unsubscribeFolder), self);
+	g_signal_connect (priv->gdbus_object, "handle-sync", G_CALLBACK (impl_Mail_sync), self);
+	g_signal_connect (priv->gdbus_object, "handle-noop", G_CALLBACK (impl_Mail_noop), self);
+	g_signal_connect (priv->gdbus_object, "handle-can-refresh-folder", G_CALLBACK (impl_Mail_canRefreshFolder), self);
+
+	
+}
+
+EMailDataStore*
+e_mail_data_store_new (CamelStore *store, const char *url)
+{
+	EMailDataStore *estore;
+	EMailDataStorePrivate *priv;
+
+  	estore = g_object_new (EMAIL_TYPE_DATA_STORE, NULL);
+	priv = DATA_STORE_PRIVATE(estore);
+	priv->store = store;
+	priv->url = g_strdup (url);
+
+	return estore;
+}
+
+static GVariant *
+variant_from_info (CamelFolderInfo *info)
+{
+	GVariantBuilder *builder;
+	GVariant *variant;
+
+	builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+
+	convert_folder_info (info, builder);
+	/* Added a empty entry */
+	g_variant_builder_add (builder, "(sssuii)", "", "", "", 0, -1, -1);
+	
+	variant = g_variant_builder_end (builder);
+	g_variant_ref (variant);
+	g_variant_builder_unref (builder);
+
+	return variant;
+}
+
+static void
+store_folder_subscribed_cb (CamelStore *store,
+                            CamelFolderInfo *info,
+                            EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GVariant *variant;
+
+	variant = variant_from_info (info);
+	egdbus_store_ms_emit_folder_subscribed (priv->gdbus_object, variant);
+
+	g_variant_unref (variant);
+}
+
+static void
+store_folder_unsubscribed_cb (CamelStore *store,
+                              CamelFolderInfo *info,
+                              EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GVariant *variant;
+
+	variant = variant_from_info (info);
+	egdbus_store_ms_emit_folder_unsubscribed (priv->gdbus_object, variant);
+
+	g_variant_unref (variant);
+	
+}
+
+static void
+store_folder_created_cb (CamelStore *store,
+                         CamelFolderInfo *info,
+                         EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GVariant *variant;
+
+	variant = variant_from_info (info);
+	egdbus_store_ms_emit_folder_created (priv->gdbus_object, variant);
+
+	g_variant_unref (variant);
+	
+}
+
+static void
+store_folder_opened_cb (CamelStore *store,
+                        CamelFolder *folder,
+                        EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	const char *path;
+	char *full_name;
+	EMailDataFolder *efolder;
+
+	full_name = camel_folder_get_full_name (folder);
+	efolder = g_hash_table_lookup (priv->datafolders, full_name);
+	if (!efolder) /* Don't bother to return about folders that aren't being used by the client. */
+		return;
+	path = e_mail_data_folder_get_path (efolder);
+	egdbus_store_ms_emit_folder_opened (priv->gdbus_object, path);
+}
+
+static void
+store_folder_deleted_cb (CamelStore *store,
+                         CamelFolderInfo *info,
+                         EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GVariant *variant;
+
+	variant = variant_from_info (info);
+	egdbus_store_ms_emit_folder_deleted (priv->gdbus_object, variant);
+
+	g_variant_unref (variant);	
+}
+
+static void
+store_folder_renamed_cb (CamelStore *store,
+                         const gchar *old_name,
+                         CamelFolderInfo *info,
+                         EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GVariant *variant;
+
+	variant = variant_from_info (info);
+	egdbus_store_ms_emit_folder_renamed (priv->gdbus_object, old_name, variant);
+
+	g_variant_unref (variant);	
+}
+
+
+guint 
+e_mail_data_store_register_gdbus_object (EMailDataStore *estore, GDBusConnection *connection, const gchar *object_path, GError **error)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+
+	g_return_val_if_fail (connection != NULL, 0);
+	g_return_val_if_fail (object_path != NULL, 0);
+
+	priv->object_path = g_strdup (object_path);
+	g_object_set_data ((GObject *)priv->store, "object-path", priv->object_path);
+
+	ipc (printf("EMailDataStore: Registering gdbus path: %s: %p\n", object_path, priv->store));
+
+	g_signal_connect (
+		priv->store, "folder-opened",
+		G_CALLBACK (store_folder_opened_cb), estore);
+	g_signal_connect (
+		priv->store, "folder-created",
+		G_CALLBACK (store_folder_created_cb), estore);
+	g_signal_connect (
+		priv->store, "folder-deleted",
+		G_CALLBACK (store_folder_deleted_cb), estore);
+	g_signal_connect (
+		priv->store, "folder-renamed",
+		G_CALLBACK (store_folder_renamed_cb), estore);
+	g_signal_connect (
+		priv->store, "folder-subscribed",
+		G_CALLBACK (store_folder_subscribed_cb), estore);
+	g_signal_connect (
+		priv->store, "folder-unsubscribed",
+		G_CALLBACK (store_folder_unsubscribed_cb), estore);
+
+ 	return g_dbus_interface_register_object (G_DBUS_INTERFACE (priv->gdbus_object),
+               	                     	connection,
+                                    	object_path,
+                                    	error);	
+}
+
+const char *
+e_mail_data_store_get_path (EMailDataStore *estore)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+
+	return priv->object_path;
+}
+
+CamelFolder *
+e_mail_data_store_get_camel_folder (EMailDataStore *estore, const char *path)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	GHashTableIter iter;
+	gpointer key, value;
+
+	g_hash_table_iter_init (&iter, priv->datafolders);
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		EMailDataFolder *efolder = (EMailDataFolder *)value;
+		const char *opath = e_mail_data_folder_get_path (efolder);
+
+		if (strcmp (opath, path) == 0) {
+			CamelFolder *f = e_mail_data_folder_get_camel_folder (efolder);
+			micro(printf("e_mail_data_store_get_camel_folder: %s %p\n", path, f));
+
+			return f;
+		}
+	}
+
+	micro(printf("e_mail_data_store_get_camel_folder: %s NULL\n", path));
+	return NULL;
+}
+
+const char *
+e_mail_data_store_get_folder_path (EMailDataStore *estore, GDBusConnection *connection, CamelFolder *folder)
+{
+	EMailDataStorePrivate *priv = DATA_STORE_PRIVATE(estore);
+	const char *full_name;
+	EMailDataFolder *efolder;
+	gchar *path;
+
+	full_name = camel_folder_get_full_name (folder);
+
+
+	g_mutex_lock (priv->folders_lock);
+	g_mutex_lock (priv->datafolders_lock);
+	
+	efolder = g_hash_table_lookup (priv->datafolders, full_name);
+	if (!efolder) {
+
+		g_hash_table_insert (priv->folders, g_strdup(full_name), folder);
+		efolder = e_mail_data_folder_new (folder);
+		path = construct_mail_store_path (full_name);
+		e_mail_data_folder_register_gdbus_object (efolder, connection, path, NULL);
+		g_hash_table_insert (priv->datafolders, g_strdup(full_name), efolder);
+		micro (printf("EMailDataStore: Created object from folder : %s %s: %s\n", priv->object_path, full_name, path));
+		g_free (path);
+	}
+
+	g_mutex_unlock (priv->folders_lock);
+	g_mutex_unlock (priv->datafolders_lock);
+
+	return e_mail_data_folder_get_path (efolder);
+}
diff --git a/mail/daemon/e-mail-data-store.h b/mail/daemon/e-mail-data-store.h
new file mode 100644
index 0000000..c1783d2
--- /dev/null
+++ b/mail/daemon/e-mail-data-store.h
@@ -0,0 +1,52 @@
+/* e-mail-data-store.h */
+
+#ifndef _E_MAIL_DATA_STORE_H
+#define _E_MAIL_DATA_STORE_H
+
+#include <glib-object.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+#define EMAIL_TYPE_DATA_STORE e_mail_data_store_get_type()
+
+#define EMAIL_DATA_STORE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  EMAIL_TYPE_DATA_STORE, EMailDataStore))
+
+#define EMAIL_DATA_STORE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  EMAIL_TYPE_DATA_STORE, EMailDataStoreClass))
+
+#define EMAIL_IS_DATA_STORE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  EMAIL_TYPE_DATA_STORE))
+
+#define EMAIL_IS_DATA_STORE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  EMAIL_TYPE_DATA_STORE))
+
+#define EMAIL_DATA_STORE_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  EMAIL_TYPE_DATA_STORE, EMailDataStoreClass))
+
+typedef struct {
+  GObject parent;
+} EMailDataStore;
+
+typedef struct {
+  GObjectClass parent_class;
+} EMailDataStoreClass;
+
+GType e_mail_data_store_get_type (void);
+
+EMailDataStore* e_mail_data_store_new (CamelStore *store, const char *url);
+guint e_mail_data_store_register_gdbus_object (EMailDataStore *estore, GDBusConnection *connection, const gchar *object_path, GError **error);
+const char * e_mail_data_store_get_path (EMailDataStore *estore);
+CamelFolder * e_mail_data_store_get_camel_folder (EMailDataStore *estore, const char *path);
+const char * e_mail_data_store_get_folder_path (EMailDataStore *estore, GDBusConnection *connection, CamelFolder *folder);
+
+
+G_END_DECLS
+
+#endif /* _E_MAIL_DATA_STORE_H */
diff --git a/mail/daemon/e-mail-data-store.xml b/mail/daemon/e-mail-data-store.xml
new file mode 100644
index 0000000..3fd9189
--- /dev/null
+++ b/mail/daemon/e-mail-data-store.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node SYSTEM "dbus.dtd">
+
+<!--
+  Author: Srinivasa Ragavan <sragavan gnome org>
+  Copyright (C) 2011 Intel Corporation
+-->
+<node>
+
+  <interface name="org.gnome.evolution.dataserver.mail.Store">
+    <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EMailDataStore"/>
+    <annotation name="org.gtk.GDBus.Name" value="MS"/>
+
+
+    <method name="getFolder">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Mail_Store_getFolder"/>
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg name="full_name" type="s" direction="in"/>
+      <arg name="folder" type="o" direction="out"/>
+    </method>
+
+    <!--
+    GetFolderInfo: returns information about the folder, without opening the actual folder.
+                   Helps to keep the unread count shown on the folder tree, without loading
+		   the folder contents to memory.
+
+		   It returns the following in the Variant.
+		   string:uri,
+		   string:folder_name,
+		   string:full_name, /* parent/child_name*/
+		   uint32:flags,
+		   int:unread_count,
+		   int:total_mail_count
+    -->
+    <method name="getFolderInfo">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Mail_Store_getFolderInfo"/>
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg name="full_name" type="s" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="infos" type="a(sssuii)" direction="out"/>
+    </method>
+
+    <!-- getInbox isn't implemented by non-local providers. Prevent using it. -->
+    <method name="getInbox">
+      <arg name="folder" type="o" direction="out"/>
+    </method>
+    <method name="getJunk">
+      <arg name="folder" type="o" direction="out"/>
+    </method>
+    <method name="getTrash">
+      <arg name="folder" type="o" direction="out"/>
+    </method>
+
+    <signal name="FolderOpened">
+    	<arg name="folder" type="o"/>
+    </signal>
+
+    <method name="createFolder">
+      <arg name="parent_name" type="s" direction="in"/>
+      <arg name="folder_name" type="s" direction="in"/>
+      <arg name="info" type="a(sssuii)" direction="out"/>	    
+    </method>
+    <signal name="FolderCreated">
+    	<arg name="info" type="a(sssuii)"/>
+    </signal>
+
+    <method name="deleteFolder">
+      <arg name="folder_name" type="s" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <signal name="FolderDeleted">
+    	<arg name="info" type="a(sssuii)"/>
+    </signal>
+    
+    <method name="renameFolder">
+      <arg name="old_folder_name" type="s" direction="in"/>
+      <arg name="new_folder_name" type="s" direction="in"/>	    
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <signal name="FolderRenamed">
+    	<arg name="old_name" type="s"/>	    
+    	<arg name="info" type="a(sssuii)"/>
+    </signal>
+
+    <method name="supportsSubscriptions">
+      <arg name="success" type="b" direction="out"/>	    
+    </method>    
+    <method name="isFolderSubscribed">
+      <arg name="folder_name" type="s" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <method name="subscribeFolder">
+      <arg name="folder_name" type="s" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <signal name="FolderSubscribed">
+    	<arg name="info" type="a(sssuii)"/>
+    </signal>    
+    <method name="unsubscribeFolder">
+      <arg name="folder_name" type="s" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <signal name="FolderUnsubscribed">
+    	<arg name="info" type="a(sssuii)"/>
+    </signal>
+
+    <method name="sync">
+      <arg name="expunge" type="b" direction="in"/>
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <method name="noop">
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+    <method name="canRefreshFolder">
+      <arg name="info" type="a(sssuii)" direction="in"/>	    	    
+      <arg name="success" type="b" direction="out"/>	    
+    </method>
+      
+  </interface>
+
+</node>
diff --git a/mail/daemon/e-mail-local.c b/mail/daemon/e-mail-local.c
new file mode 100644
index 0000000..72c8d8a
--- /dev/null
+++ b/mail/daemon/e-mail-local.c
@@ -0,0 +1,128 @@
+/*
+ * e-mail-local.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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-mail-local.h"
+
+#include <glib/gi18n.h>
+
+#include "mail-session.h"
+
+#define CHECK_LOCAL_FOLDER_TYPE(type) \
+	((type) < G_N_ELEMENTS (default_local_folders))
+
+/* The array elements correspond to EMailLocalFolder. */
+static struct {
+	const gchar *display_name;
+	CamelFolder *folder;
+	gchar *folder_uri;
+} default_local_folders[] = {
+	{ N_("Inbox") },
+	{ N_("Drafts") },
+	{ N_("Outbox") },
+	{ N_("Sent") },
+	{ N_("Templates") },
+	{ "Inbox" }  /* "always local" inbox */
+};
+
+static CamelStore *local_store;
+
+void
+e_mail_local_init (const gchar *data_dir)
+{
+	static gboolean initialized = FALSE;
+	CamelService *service;
+	CamelURL *url;
+	gchar *temp;
+	gint ii;
+	GError *local_error = NULL;
+
+	g_return_if_fail (!initialized);
+	g_return_if_fail (data_dir != NULL);
+
+	url = camel_url_new ("mbox:", NULL);
+	temp = g_build_filename (data_dir, "local", NULL);
+	camel_url_set_path (url, temp);
+	g_free (temp);
+
+	temp = camel_url_to_string (url, 0);
+	service = camel_session_get_service (
+		session, temp, CAMEL_PROVIDER_STORE, &local_error);
+	g_free (temp);
+
+	if (local_error != NULL)
+		goto fail;
+
+	/* Populate the rest of the default_local_folders array. */
+	for (ii = 0; ii < G_N_ELEMENTS (default_local_folders); ii++) {
+		const gchar *display_name;
+		gchar *folder_uri;
+
+		display_name = default_local_folders[ii].display_name;
+
+		/* XXX Should this URI be account relative? */
+		camel_url_set_fragment (url, display_name);
+		folder_uri = camel_url_to_string (url, 0);
+
+		default_local_folders[ii].folder_uri = folder_uri;
+		default_local_folders[ii].folder = camel_store_get_folder (
+			CAMEL_STORE (service), display_name,
+			CAMEL_STORE_FOLDER_CREATE, NULL);
+	}
+
+	camel_url_free (url);
+
+	g_object_ref (service);
+	local_store = CAMEL_STORE (service);
+
+	return;
+
+fail:
+	g_warning (
+		"Could not initialize local store/folder: %s",
+		local_error->message);
+
+	g_error_free (local_error);
+	camel_url_free (url);
+}
+
+CamelFolder *
+e_mail_local_get_folder (EMailLocalFolder type)
+{
+	g_return_val_if_fail (CHECK_LOCAL_FOLDER_TYPE (type), NULL);
+
+	return default_local_folders[type].folder;
+}
+
+const gchar *
+e_mail_local_get_folder_uri (EMailLocalFolder type)
+{
+	g_return_val_if_fail (CHECK_LOCAL_FOLDER_TYPE (type), NULL);
+
+	return default_local_folders[type].folder_uri;
+}
+
+CamelStore *
+e_mail_local_get_store (void)
+{
+	g_return_val_if_fail (CAMEL_IS_STORE (local_store), NULL);
+
+	return local_store;
+}
diff --git a/mail/daemon/e-mail-local.h b/mail/daemon/e-mail-local.h
new file mode 100644
index 0000000..b5b7e8a
--- /dev/null
+++ b/mail/daemon/e-mail-local.h
@@ -0,0 +1,50 @@
+/*
+ * e-mail-local.h
+ *
+ * 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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_MAIL_LOCAL_H
+#define E_MAIL_LOCAL_H
+
+#include <glib.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+/* XXX E_MAIL_FOLDER_TEMPLATES is a prime example of why templates
+ *     should be a core feature: the mailer now has to know about
+ *     this specific plugin, which defeats the purpose of plugins. */
+typedef enum {
+	E_MAIL_FOLDER_INBOX,
+	E_MAIL_FOLDER_DRAFTS,
+	E_MAIL_FOLDER_OUTBOX,
+	E_MAIL_FOLDER_SENT,
+	E_MAIL_FOLDER_TEMPLATES,
+	E_MAIL_FOLDER_LOCAL_INBOX,
+	E_MAIL_NUM_LOCAL_FOLDERS
+} EMailLocalFolder;
+
+void		e_mail_local_init		(const gchar *data_dir);
+CamelFolder *	e_mail_local_get_folder		(EMailLocalFolder type);
+const gchar *	e_mail_local_get_folder_uri	(EMailLocalFolder type);
+CamelStore *	e_mail_local_get_store		(void);
+
+G_END_DECLS
+
+#endif /* E_MAIL_LOCAL_H */
diff --git a/mail/daemon/e-mail-store.c b/mail/daemon/e-mail-store.c
new file mode 100644
index 0000000..9779a59
--- /dev/null
+++ b/mail/daemon/e-mail-store.c
@@ -0,0 +1,418 @@
+/*
+ * e-mail-store.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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-mail-store.h"
+
+#include <glib/gi18n.h>
+#include <camel/camel.h>
+#include <libedataserver/e-account.h>
+#include <libedataserver/e-account-list.h>
+
+#include "e-account-utils.h"
+
+#include "e-mail-local.h"
+#include "mail-folder-cache.h"
+#include "mail-mt.h"
+#include "mail-session.h"
+
+typedef struct _StoreInfo StoreInfo;
+
+typedef void	(*AddStoreCallback)	(CamelStore *store,
+					 CamelFolderInfo *info,
+					 StoreInfo *store_info);
+
+struct _StoreInfo {
+	gint ref_count;
+
+	CamelStore *store;
+	gchar *display_name;
+
+	/* Hold a reference to keep them alive. */
+	CamelFolder *vtrash;
+	CamelFolder *vjunk;
+
+	AddStoreCallback callback;
+
+	guint removed : 1;
+};
+
+CamelStore *vfolder_store;  /* XXX write a get() function for this */
+static GHashTable *store_table;
+
+static MailAsyncEvent *async_event;
+
+static StoreInfo *
+store_info_new (CamelStore *store,
+                const gchar *display_name)
+{
+	CamelService *service;
+	StoreInfo *store_info;
+
+	g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+
+	service = CAMEL_SERVICE (store);
+
+	store_info = g_slice_new0 (StoreInfo);
+	store_info->ref_count = 1;
+
+	g_object_ref (store);
+	store_info->store = store;
+
+	if (display_name == NULL)
+		store_info->display_name =
+			camel_service_get_name (service, TRUE);
+	else
+		store_info->display_name = g_strdup (display_name);
+
+	/* If these are vfolders then they need to be opened now,
+	 * otherwise they won't keep track of all folders. */
+	if (store->flags & CAMEL_STORE_VTRASH)
+		store_info->vtrash = camel_store_get_trash (store, NULL);
+	if (store->flags & CAMEL_STORE_VJUNK)
+		store_info->vjunk = camel_store_get_junk (store, NULL);
+
+	return store_info;
+}
+
+static StoreInfo *
+store_info_ref (StoreInfo *store_info)
+{
+	g_return_val_if_fail (store_info != NULL, store_info);
+	g_return_val_if_fail (store_info->ref_count > 0, store_info);
+
+	g_atomic_int_add (&store_info->ref_count, 1);
+
+	return store_info;
+}
+
+static void
+store_info_unref (StoreInfo *store_info)
+{
+	g_return_if_fail (store_info != NULL);
+	g_return_if_fail (store_info->ref_count > 0);
+
+	if (g_atomic_int_exchange_and_add (&store_info->ref_count, -1) > 1)
+		return;
+
+	g_object_unref (store_info->store);
+	g_free (store_info->display_name);
+
+	if (store_info->vtrash != NULL)
+		g_object_unref (store_info->vtrash);
+
+	if (store_info->vjunk != NULL)
+		g_object_unref (store_info->vjunk);
+
+	g_slice_free (StoreInfo, store_info);
+}
+
+static void
+store_table_free (StoreInfo *store_info)
+{
+	store_info->removed = 1;
+	store_info_unref (store_info);
+}
+
+static gboolean
+mail_store_note_store_cb (CamelStore *store,
+                          CamelFolderInfo *info,
+                          gpointer user_data)
+{
+	StoreInfo *store_info = user_data;
+
+	if (store_info->callback != NULL)
+		store_info->callback (store, info, store_info);
+
+	if (!store_info->removed) {
+		/* This keeps message counters up-to-date. */
+		if (store_info->vtrash != NULL)
+			mail_folder_cache_note_folder (
+				mail_folder_cache_get_default (),
+				store_info->vtrash);
+		if (store_info->vjunk != NULL)
+			mail_folder_cache_note_folder (
+				mail_folder_cache_get_default (),
+				store_info->vjunk);
+	}
+
+	store_info_unref (store_info);
+
+	return TRUE;
+}
+
+static void
+mail_store_add (CamelStore *store,
+                const gchar *display_name,
+                AddStoreCallback callback)
+{
+	StoreInfo *store_info;
+
+	g_return_if_fail (store_table != NULL);
+	g_return_if_fail (store != NULL);
+	g_return_if_fail (CAMEL_IS_STORE (store));
+	g_return_if_fail ((CAMEL_SERVICE (store)->provider->flags & CAMEL_PROVIDER_IS_STORAGE) != 0);
+
+	store_info = store_info_new (store, display_name);
+	store_info->callback = callback;
+
+	g_hash_table_insert (store_table, store, store_info);
+
+	mail_folder_cache_note_store (mail_folder_cache_get_default (),
+		store, NULL,
+		mail_store_note_store_cb,
+		store_info_ref (store_info));
+}
+
+static void
+mail_store_add_local_done_cb (CamelStore *store,
+                              CamelFolderInfo *info,
+                              StoreInfo *store_info)
+{
+	CamelFolder *folder;
+	gint ii;
+
+	for (ii = 0; ii < E_MAIL_NUM_LOCAL_FOLDERS; ii++) {
+		folder = e_mail_local_get_folder (ii);
+		if (folder != NULL)
+			mail_folder_cache_note_folder (mail_folder_cache_get_default (), folder);
+	}
+}
+
+static void
+mail_store_add_local_cb (CamelStore *local_store,
+                         const gchar *display_name)
+{
+	mail_store_add (
+		local_store, display_name,
+		(AddStoreCallback) mail_store_add_local_done_cb);
+}
+
+static void
+mail_store_load_accounts (const gchar *data_dir)
+{
+	CamelStore *local_store;
+	EAccountList *account_list;
+	EIterator *iter;
+
+	/* Set up the local store. */
+
+	e_mail_local_init (data_dir);
+	local_store = e_mail_local_get_store ();
+
+	mail_async_event_emit (
+		async_event, MAIL_ASYNC_GUI,
+		(MailAsyncFunc) mail_store_add_local_cb,
+		local_store, _("On This Computer"), NULL);
+
+	/* Set up remote stores. */
+
+	account_list = e_get_account_list ();
+
+	for (iter = e_list_get_iterator ((EList *) account_list);
+		e_iterator_is_valid (iter); e_iterator_next (iter)) {
+
+		EAccountService *service;
+		EAccount *account;
+		const gchar *display_name;
+		const gchar *uri;
+
+		account = (EAccount *) e_iterator_get (iter);
+		display_name = account->name;
+		service = account->source;
+		uri = service->url;
+
+		if (!account->enabled)
+			continue;
+
+		if (uri == NULL || *uri == '\0')
+			continue;
+
+		/* HACK: mbox URI's are handled by the local store setup
+		 *       above.  Any that come through as account sources
+		 *       are really movemail sources! */
+		if (g_str_has_prefix (uri, "mbox:"))
+			continue;
+
+		e_mail_store_add_by_uri (uri, display_name);
+	}
+
+	g_object_unref (iter);
+}
+
+void
+e_mail_store_init (const gchar *data_dir)
+{
+	static gboolean initialized = FALSE;
+
+	g_return_if_fail (data_dir != NULL);
+
+	/* This function is idempotent, but there should
+	 * be no need to call it more than once. */
+	if (initialized)
+		return;
+
+	/* Initialize global variables. */
+
+	store_table = g_hash_table_new_full (
+		g_direct_hash, g_direct_equal,
+		(GDestroyNotify) NULL,
+		(GDestroyNotify) store_table_free);
+
+	async_event = mail_async_event_new ();
+
+	mail_store_load_accounts (data_dir);
+
+	initialized = TRUE;
+}
+
+void
+e_mail_store_add (CamelStore *store,
+                  const gchar *display_name)
+{
+	g_return_if_fail (CAMEL_IS_STORE (store));
+	g_return_if_fail (display_name != NULL);
+
+	mail_store_add (store, display_name, NULL);
+}
+
+CamelStore *
+e_mail_store_add_by_uri (const gchar *uri,
+                         const gchar *display_name)
+{
+	CamelService *service;
+	CamelProvider *provider;
+	GError *local_error = NULL;
+
+	g_return_val_if_fail (uri != NULL, NULL);
+	g_return_val_if_fail (display_name != NULL, NULL);
+
+	/* Load the service, but don't connect.  Check its provider,
+	 * and if this belongs in the folder tree model, add it. */
+
+	provider = camel_provider_get (uri, &local_error);
+	if (provider == NULL)
+		goto fail;
+
+	if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE))
+		return NULL;
+
+	service = camel_session_get_service (
+		session, uri, CAMEL_PROVIDER_STORE, &local_error);
+	if (service == NULL)
+		goto fail;
+
+	e_mail_store_add (CAMEL_STORE (service), display_name);
+
+	g_object_unref (service);
+
+	return CAMEL_STORE (service);
+
+fail:
+	/* FIXME: Show an error dialog. */
+	g_warning (
+		"Couldn't get service: %s: %s", uri,
+		local_error->message);
+	g_error_free (local_error);
+
+	return NULL;
+}
+
+/* Helper for e_mail_store_remove() */
+static void
+mail_store_remove_cb (CamelStore *store)
+{
+	camel_service_disconnect (CAMEL_SERVICE (store), TRUE, NULL);
+	g_object_unref (store);
+}
+
+void
+e_mail_store_remove (CamelStore *store)
+{
+	g_return_if_fail (CAMEL_IS_STORE (store));
+	g_return_if_fail (store_table != NULL);
+	g_return_if_fail (async_event != NULL);
+
+	/* Because the store table holds a reference to each store used
+	 * as a key in it, none of them will ever be gc'ed, meaning any
+	 * call to camel_session_get_{service,store} with the same URL
+	 * will always return the same object.  So this works. */
+
+	if (g_hash_table_lookup (store_table, store) == NULL)
+		return;
+
+	g_object_ref (store);
+
+	g_hash_table_remove (store_table, store);
+	mail_folder_cache_note_store_remove (mail_folder_cache_get_default (), store);
+
+	mail_async_event_emit (
+		async_event, MAIL_ASYNC_THREAD,
+		(MailAsyncFunc) mail_store_remove_cb,
+		store, NULL, NULL);
+}
+
+void
+e_mail_store_remove_by_uri (const gchar *uri)
+{
+	CamelService *service;
+	CamelProvider *provider;
+
+	g_return_if_fail (uri != NULL);
+
+	provider = camel_provider_get (uri, NULL);
+	if (provider == NULL)
+		return;
+
+	if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE))
+		return;
+
+	service = camel_session_get_service (
+		session, uri, CAMEL_PROVIDER_STORE, NULL);
+	if (service == NULL)
+		return;
+
+	e_mail_store_remove (CAMEL_STORE (service));
+
+	g_object_unref (service);
+}
+
+void
+e_mail_store_foreach (GHFunc func,
+                      gpointer user_data)
+{
+	GHashTableIter iter;
+	gpointer key, value;
+
+	g_return_if_fail (func != NULL);
+	g_return_if_fail (store_table != NULL);
+
+	g_hash_table_iter_init (&iter, store_table);
+
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		StoreInfo *store_info = value;
+
+		/* Just being paranoid. */
+		g_return_if_fail (CAMEL_IS_STORE (key));
+		g_return_if_fail (store_info != NULL);
+
+		func (key, store_info->display_name, user_data);
+	}
+}
diff --git a/mail/daemon/e-mail-store.h b/mail/daemon/e-mail-store.h
new file mode 100644
index 0000000..7d42fc3
--- /dev/null
+++ b/mail/daemon/e-mail-store.h
@@ -0,0 +1,42 @@
+/*
+ * e-mail-store.h
+ *
+ * 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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_MAIL_STORE_H
+#define E_MAIL_STORE_H
+
+#include <glib.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+void		e_mail_store_init		(const gchar *data_dir);
+void		e_mail_store_add		(CamelStore *store,
+						 const gchar *display_name);
+CamelStore *	e_mail_store_add_by_uri		(const gchar *uri,
+						 const gchar *display_name);
+void		e_mail_store_remove		(CamelStore *store);
+void		e_mail_store_remove_by_uri	(const gchar *uri);
+void		e_mail_store_foreach		(GHFunc func,
+						 gpointer user_data);
+
+G_END_DECLS
+
+#endif /* E_MAIL_STORE_H */
diff --git a/mail/daemon/mail-config.c b/mail/daemon/mail-config.c
new file mode 100644
index 0000000..db03459
--- /dev/null
+++ b/mail/daemon/mail-config.c
@@ -0,0 +1,714 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *   Jeffrey Stedfast <fejj ximian com>
+ *   Radek Doulik <rodo ximian com>
+ *   Jonathon Jongsma <jonathon jongsma collabora co uk>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <glib/gstdio.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include "e-account-utils.h"
+
+#include <gconf/gconf-client.h>
+
+#include "e-mail-local.h"
+#include "mail-config.h"
+#include "mail-folder-cache.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+
+typedef struct {
+	GConfClient *gconf;
+
+	gchar *gtkrc;
+
+	GSList *labels;
+
+	gboolean address_compress;
+	gint address_count;
+
+	GSList *jh_header;
+	gboolean jh_check;
+	gboolean book_lookup;
+	gboolean book_lookup_local_only;
+	gboolean scripts_disabled;
+} MailConfig;
+
+extern gint camel_header_param_encode_filenames_in_rfc_2047;
+
+static MailConfig *config = NULL;
+
+static void
+config_write_style (void)
+{
+	GConfClient *client;
+	gboolean custom;
+	gchar *fix_font;
+	gchar *var_font;
+	gchar *citation_color;
+	gchar *spell_color;
+	const gchar *key;
+	FILE *rc;
+
+	if (!(rc = g_fopen (config->gtkrc, "wt"))) {
+		g_warning ("unable to open %s", config->gtkrc);
+		return;
+	}
+
+	client = config->gconf;
+
+	key = "/apps/evolution/mail/display/fonts/use_custom";
+	custom = gconf_client_get_bool (client, key, NULL);
+
+	key = "/apps/evolution/mail/display/fonts/variable";
+	var_font = gconf_client_get_string (client, key, NULL);
+
+	key = "/apps/evolution/mail/display/fonts/monospace";
+	fix_font = gconf_client_get_string (client, key, NULL);
+
+	key = "/apps/evolution/mail/display/citation_colour";
+	citation_color = gconf_client_get_string (client, key, NULL);
+
+	key = "/apps/evolution/mail/composer/spell_color";
+	spell_color = gconf_client_get_string (client, key, NULL);
+
+	fprintf (rc, "style \"evolution-mail-custom-fonts\" {\n");
+	fprintf (rc, "        GtkHTML::spell_error_color = \"%s\"\n", spell_color);
+	g_free (spell_color);
+
+	if (gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/mark_citations", NULL))
+		fprintf (rc, "        GtkHTML::cite_color = \"%s\"\n",
+			 citation_color);
+	g_free (citation_color);
+
+	if (custom && var_font && fix_font) {
+		fprintf (rc,
+			 "        GtkHTML::fixed_font_name = \"%s\"\n"
+			 "        font_name = \"%s\"\n",
+			 fix_font, var_font);
+	}
+	g_free (fix_font);
+	g_free (var_font);
+
+	fprintf (rc, "}\n\n");
+
+	fprintf (rc, "class \"EWebView\" style \"evolution-mail-custom-fonts\"\n");
+	fflush (rc);
+	fclose (rc);
+
+	gtk_rc_reparse_all ();
+}
+
+static void
+gconf_style_changed (GConfClient *client, guint cnxn_id,
+		     GConfEntry *entry, gpointer user_data)
+{
+	config_write_style ();
+}
+
+static void
+gconf_outlook_filenames_changed (GConfClient *client, guint cnxn_id,
+				 GConfEntry *entry, gpointer user_data)
+{
+	g_return_if_fail (client != NULL);
+
+	/* pass option to the camel */
+	if (gconf_client_get_bool (client, "/apps/evolution/mail/composer/outlook_filenames", NULL)) {
+		camel_header_param_encode_filenames_in_rfc_2047 = 1;
+	} else {
+		camel_header_param_encode_filenames_in_rfc_2047 = 0;
+	}
+}
+
+static void
+gconf_jh_headers_changed (GConfClient *client, guint cnxn_id,
+                          GConfEntry *entry, gpointer user_data)
+{
+	GSList *node;
+	GPtrArray *name, *value;
+
+	g_slist_foreach (config->jh_header, (GFunc) g_free, NULL);
+	g_slist_free (config->jh_header);
+
+	config->jh_header = gconf_client_get_list (config->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL);
+
+	node = config->jh_header;
+	name = g_ptr_array_new ();
+	value = g_ptr_array_new ();
+	while (node && node->data) {
+		gchar **tok = g_strsplit (node->data, "=", 2);
+		g_ptr_array_add (name, g_strdup(tok[0]));
+		g_ptr_array_add (value, g_strdup(tok[1]));
+		node = node->next;
+		g_strfreev (tok);
+	}
+	mail_session_set_junk_headers ((const gchar **)name->pdata, (const gchar **)value->pdata, name->len);
+
+	g_ptr_array_foreach (name, (GFunc) g_free, NULL);
+	g_ptr_array_foreach (value, (GFunc) g_free, NULL);
+	g_ptr_array_free (name, TRUE);
+	g_ptr_array_free (value, TRUE);
+}
+
+static void
+gconf_jh_check_changed (GConfClient *client, guint cnxn_id,
+		     GConfEntry *entry, gpointer user_data)
+{
+	config->jh_check = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL);
+	if (!config->jh_check) {
+		mail_session_set_junk_headers (NULL, NULL, 0);
+	} else {
+		gconf_jh_headers_changed (NULL, 0, NULL, NULL);
+	}
+}
+
+static void
+gconf_bool_value_changed (GConfClient *client,
+                          guint cnxn_id,
+                          GConfEntry *entry,
+                          gboolean *save_location)
+{
+	GError *error = NULL;
+
+	*save_location = gconf_client_get_bool (client, entry->key, &error);
+	if (error != NULL) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+}
+
+static void
+gconf_int_value_changed (GConfClient *client,
+                         guint cnxn_id,
+                         GConfEntry *entry,
+                         gint *save_location)
+{
+	GError *error = NULL;
+
+	*save_location = gconf_client_get_int (client, entry->key, &error);
+	if (error != NULL) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+}
+
+void
+mail_config_write (void)
+{
+	EAccountList *account_list;
+
+	if (!config)
+		return;
+
+	account_list = e_get_account_list ();
+
+	e_account_list_save (account_list);
+
+	gconf_client_suggest_sync (config->gconf, NULL);
+}
+
+/* Accessor functions */
+GConfClient *
+mail_config_get_gconf_client (void)
+{
+	if (!config)
+		mail_config_init ();
+
+	return config->gconf;
+}
+
+gint
+mail_config_get_address_count (void)
+{
+	if (!config->address_compress)
+		return -1;
+
+	return config->address_count;
+}
+
+/* timeout interval, in seconds, when to call server update */
+gint
+mail_config_get_sync_timeout (void)
+{
+	GConfClient *gconf = mail_config_get_gconf_client ();
+	gint res = 60;
+
+	if (gconf) {
+		GError *error = NULL;
+
+		res = gconf_client_get_int (gconf, "/apps/evolution/mail/sync_interval", &error);
+
+		/* do not allow recheck sooner than every 30 seconds */
+		if (error || res == 0)
+			res = 60;
+		else if (res < 30)
+			res = 30;
+
+		if (error)
+			g_error_free (error);
+	}
+
+	return res;
+}
+
+static EAccount *
+mc_get_account_by (const gchar *given_url, const gchar * (get_url_string)(EAccount *account))
+{
+	EAccountList *account_list;
+	EAccount *account = NULL;
+	EIterator *iter;
+	CamelURL *url;
+	CamelProvider *provider;
+
+	g_return_val_if_fail (given_url != NULL, NULL);
+	g_return_val_if_fail (get_url_string != NULL, NULL);
+
+	url = camel_url_new (given_url, NULL);
+	g_return_val_if_fail (url != NULL, NULL);
+
+	provider = camel_provider_get (given_url, NULL);
+	g_return_val_if_fail (provider != NULL && provider->url_equal != NULL, NULL);
+
+	account_list = e_get_account_list ();
+	iter = e_list_get_iterator ((EList *) account_list);
+	while (account == NULL && e_iterator_is_valid (iter)) {
+		CamelURL *account_url;
+		const gchar *account_url_string;
+
+		account = (EAccount *) e_iterator_get (iter);
+
+		e_iterator_next (iter);
+
+		account_url_string = get_url_string (account);
+
+		if ( !account_url_string || !*account_url_string) {
+			account = NULL;
+			continue;
+		}
+
+		account_url = camel_url_new (account_url_string, NULL);
+		if (account_url == NULL) {
+			account = NULL;
+			continue;
+		}
+
+		if (!provider->url_equal (url, account_url))
+			account = NULL;  /* not a match */
+
+		camel_url_free (account_url);
+	}
+
+	g_object_unref (iter);
+	camel_url_free (url);
+
+	return account;
+}
+
+static const gchar *
+get_source_url_string (EAccount *account)
+{
+	if (account && account->source && account->source->url && *account->source->url)
+		return account->source->url;
+	return NULL;
+}
+
+static const gchar *
+get_transport_url_string (EAccount *account)
+{
+	if (account && account->transport && account->transport->url && *account->transport->url)
+		return account->transport->url;
+	return NULL;
+}
+
+EAccount *
+mail_config_get_account_by_source_url (const gchar *source_url)
+{
+	return mc_get_account_by (source_url, get_source_url_string);
+}
+
+EAccount *
+mail_config_get_account_by_transport_url (const gchar *transport_url)
+{
+	return mc_get_account_by (transport_url, get_transport_url_string);
+}
+
+EAccountService *
+mail_config_get_default_transport (void)
+{
+	EAccountList *account_list;
+	EAccount *account;
+	EIterator *iter;
+
+	account_list = e_get_account_list ();
+	account = e_get_default_account ();
+
+	if (account && account->enabled && account->transport && account->transport->url && account->transport->url[0])
+		return account->transport;
+
+	/* return the first account with a transport? */
+	iter = e_list_get_iterator ((EList *) account_list);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->enabled && account->transport && account->transport->url && account->transport->url[0]) {
+			g_object_unref (iter);
+
+			return account->transport;
+		}
+
+		e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	return NULL;
+}
+
+static gchar *
+uri_to_evname (const gchar *uri, const gchar *prefix)
+{
+	const gchar *data_dir;
+	gchar *safe;
+	gchar *tmp;
+
+	data_dir = mail_session_get_data_dir ();
+
+	safe = g_strdup (uri);
+	e_filename_make_safe (safe);
+	/* blah, easiest thing to do */
+	if (prefix[0] == '*')
+		tmp = g_strdup_printf ("%s/%s%s.xml", data_dir, prefix + 1, safe);
+	else
+		tmp = g_strdup_printf ("%s/%s%s", data_dir, prefix, safe);
+	g_free (safe);
+	return tmp;
+}
+
+static void
+mail_config_uri_renamed (GCompareFunc uri_cmp, const gchar *old, const gchar *new)
+{
+	EAccountList *account_list;
+	EAccount *account;
+	EIterator *iter;
+	gint i, work = 0;
+	gchar *oldname, *newname;
+	const gchar *cachenames[] = {
+		"config/hidestate-",
+		"config/et-expanded-",
+		"config/et-header-",
+		"*views/current_view-",
+		"*views/custom_view-",
+		NULL };
+
+	account_list = e_get_account_list ();
+	iter = e_list_get_iterator ((EList *) account_list);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, old)) {
+			g_free (account->sent_folder_uri);
+			account->sent_folder_uri = g_strdup (new);
+			work = 1;
+		}
+
+		if (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, old)) {
+			g_free (account->drafts_folder_uri);
+			account->drafts_folder_uri = g_strdup (new);
+			work = 1;
+		}
+
+		e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	/* ignore return values or if the files exist or
+	 * not, doesn't matter */
+
+	for (i = 0; cachenames[i]; i++) {
+		oldname = uri_to_evname (old, cachenames[i]);
+		newname = uri_to_evname (new, cachenames[i]);
+		/*printf ("** renaming %s to %s\n", oldname, newname);*/
+		g_rename (oldname, newname);
+		g_free (oldname);
+		g_free (newname);
+	}
+
+	/* nasty ... */
+	if (work)
+		mail_config_write ();
+}
+
+static void
+mail_config_uri_deleted (GCompareFunc uri_cmp, const gchar *uri)
+{
+	EAccountList *account_list;
+	EAccount *account;
+	EIterator *iter;
+	gint work = 0;
+	const gchar *local_drafts_folder_uri;
+	const gchar *local_sent_folder_uri;
+
+	/* assumes these can't be removed ... */
+	local_drafts_folder_uri =
+		e_mail_local_get_folder_uri (E_MAIL_FOLDER_DRAFTS);
+	local_sent_folder_uri =
+		e_mail_local_get_folder_uri (E_MAIL_FOLDER_SENT);
+
+	account_list = e_get_account_list ();
+	iter = e_list_get_iterator ((EList *) account_list);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, uri)) {
+			g_free (account->sent_folder_uri);
+			account->sent_folder_uri = g_strdup (local_sent_folder_uri);
+			work = 1;
+		}
+
+		if (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, uri)) {
+			g_free (account->drafts_folder_uri);
+			account->drafts_folder_uri = g_strdup (local_drafts_folder_uri);
+			work = 1;
+		}
+
+		e_iterator_next (iter);
+	}
+
+	/* nasty again */
+	if (work)
+		mail_config_write ();
+}
+
+void
+mail_config_service_set_save_passwd (EAccountService *service, gboolean save_passwd)
+{
+	service->save_passwd = save_passwd;
+}
+
+gchar *
+mail_config_folder_to_safe_url (CamelFolder *folder)
+{
+	gchar *url;
+
+	url = mail_tools_folder_to_url (folder);
+	e_filename_make_safe (url);
+
+	return url;
+}
+
+gchar *
+mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix)
+{
+	gchar *url, *basename, *filename;
+	const gchar *config_dir;
+
+	config_dir = mail_session_get_config_dir ();
+	url = mail_config_folder_to_safe_url (folder);
+	basename = g_strdup_printf ("%s%s", prefix, url);
+	filename = g_build_filename (config_dir, "folders", basename, NULL);
+	g_free (basename);
+	g_free (url);
+
+	return filename;
+}
+
+void
+mail_config_reload_junk_headers (void)
+{
+	/* It automatically sets in the session */
+	if (config == NULL)
+		mail_config_init ();
+	else
+		gconf_jh_check_changed (config->gconf, 0, NULL, config);
+
+}
+
+gboolean
+mail_config_get_lookup_book (void)
+{
+	/* It automatically sets in the session */
+	if (config == NULL)
+		mail_config_init ();
+
+	return config->book_lookup;
+}
+
+gboolean
+mail_config_get_lookup_book_local_only (void)
+{
+	/* It automatically sets in the session */
+	if (config == NULL)
+		mail_config_init ();
+
+	return config->book_lookup_local_only;
+}
+
+static void
+folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data)
+{
+	mail_config_uri_deleted(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name, uri);
+}
+
+static void
+folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *olduri, const gchar *newuri, gpointer user_data)
+{
+	mail_config_uri_renamed(CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name,
+				olduri, newuri);
+}
+
+/* Config struct routines */
+void
+mail_config_init (void)
+{
+	GConfClientNotifyFunc func;
+	const gchar *key;
+
+	if (config)
+		return;
+
+	config = g_new0 (MailConfig, 1);
+	config->gconf = gconf_client_get_default ();
+	config->gtkrc = g_build_filename (
+		mail_session_get_config_dir (),
+		"gtkrc-mail-fonts", NULL);
+
+	gtk_rc_parse (config->gtkrc);
+
+	gconf_client_add_dir (
+		config->gconf, "/apps/evolution/mail/prompts",
+		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+	/* Composer Configuration */
+
+	gconf_client_add_dir (
+		config->gconf, "/apps/evolution/mail/composer",
+		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+	key = "/apps/evolution/mail/composer/spell_color";
+	func = (GConfClientNotifyFunc) gconf_style_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	key = "/apps/evolution/mail/composer/outlook_filenames";
+	func = (GConfClientNotifyFunc) gconf_outlook_filenames_changed;
+	gconf_outlook_filenames_changed (config->gconf, 0, NULL, NULL);
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	/* Display Configuration */
+
+	gconf_client_add_dir (
+		config->gconf, "/apps/evolution/mail/display",
+		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+	key = "/apps/evolution/mail/display/address_compress";
+	func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func,
+		&config->address_compress, NULL, NULL);
+	config->address_compress =
+		gconf_client_get_bool (config->gconf, key, NULL);
+
+	key = "/apps/evolution/mail/display/address_count";
+	func = (GConfClientNotifyFunc) gconf_int_value_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func,
+		&config->address_count, NULL, NULL);
+	config->address_count =
+		gconf_client_get_int (config->gconf, key, NULL);
+
+	key = "/apps/evolution/mail/display/citation_colour";
+	func = (GConfClientNotifyFunc) gconf_style_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	key = "/apps/evolution/mail/display/mark_citations";
+	func = (GConfClientNotifyFunc) gconf_style_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	/* Font Configuration */
+
+	gconf_client_add_dir (
+		config->gconf, "/apps/evolution/mail/display/fonts",
+		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+	key = "/apps/evolution/mail/display/fonts";
+	func = (GConfClientNotifyFunc) gconf_style_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	/* Junk Configuration */
+
+	gconf_client_add_dir (
+		config->gconf, "/apps/evolution/mail/junk",
+		GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+	key = "/apps/evolution/mail/junk/check_custom_header";
+	func = (GConfClientNotifyFunc) gconf_jh_check_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+	config->jh_check =
+		gconf_client_get_bool (config->gconf, key, NULL);
+
+	key = "/apps/evolution/mail/junk/custom_header";
+	func = (GConfClientNotifyFunc) gconf_jh_headers_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func, NULL, NULL, NULL);
+
+	key = "/apps/evolution/mail/junk/lookup_addressbook";
+	func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func,
+		&config->book_lookup, NULL, NULL);
+	config->book_lookup =
+		gconf_client_get_bool (config->gconf, key, NULL);
+
+	key = "/apps/evolution/mail/junk/lookup_addressbook_local_only";
+	func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func,
+		&config->book_lookup_local_only, NULL, NULL);
+	config->book_lookup_local_only =
+		gconf_client_get_bool (config->gconf, key, NULL);
+
+	key = "/desktop/gnome/lockdown/disable_command_line";
+	func = (GConfClientNotifyFunc) gconf_bool_value_changed;
+	gconf_client_notify_add (
+		config->gconf, key, func,
+		&config->scripts_disabled, NULL, NULL);
+	config->scripts_disabled =
+		gconf_client_get_bool (config->gconf, key, NULL);
+
+	gconf_jh_check_changed (config->gconf, 0, NULL, config);
+
+	g_signal_connect (mail_folder_cache_get_default (), "folder-deleted",
+			  (GCallback) folder_deleted_cb, NULL);
+	g_signal_connect (mail_folder_cache_get_default (), "folder-renamed",
+			  (GCallback) folder_renamed_cb, NULL);
+}
diff --git a/mail/daemon/mail-config.h b/mail/daemon/mail-config.h
new file mode 100644
index 0000000..68b1dc1
--- /dev/null
+++ b/mail/daemon/mail-config.h
@@ -0,0 +1,104 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Jeffrey Stedfast <fejj ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef MAIL_CONFIG_H
+#define MAIL_CONFIG_H
+
+#include <gtk/gtk.h>
+#include <camel/camel.h>
+#include <libedataserver/e-account.h>
+#include <libedataserver/e-account-list.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+	MAIL_CONFIG_HTTP_NEVER,
+	MAIL_CONFIG_HTTP_SOMETIMES,
+	MAIL_CONFIG_HTTP_ALWAYS
+} MailConfigHTTPMode;
+
+typedef enum {
+	MAIL_CONFIG_FORWARD_ATTACHED,
+	MAIL_CONFIG_FORWARD_INLINE,
+	MAIL_CONFIG_FORWARD_QUOTED
+} MailConfigForwardStyle;
+
+typedef enum {
+	MAIL_CONFIG_REPLY_QUOTED,
+	MAIL_CONFIG_REPLY_DO_NOT_QUOTE,
+	MAIL_CONFIG_REPLY_ATTACH,
+	MAIL_CONFIG_REPLY_OUTLOOK
+} MailConfigReplyStyle;
+
+typedef enum {
+	MAIL_CONFIG_DISPLAY_NORMAL,
+	MAIL_CONFIG_DISPLAY_FULL_HEADERS,
+	MAIL_CONFIG_DISPLAY_SOURCE,
+	MAIL_CONFIG_DISPLAY_MAX
+} MailConfigDisplayStyle;
+
+typedef enum {
+	MAIL_CONFIG_XMAILER_NONE            = 0,
+	MAIL_CONFIG_XMAILER_EVO             = 1,
+	MAIL_CONFIG_XMAILER_OTHER           = 2,
+	MAIL_CONFIG_XMAILER_RUPERT_APPROVED = 4
+} MailConfigXMailerDisplayStyle;
+
+GType		evolution_mail_config_get_type	(void);
+
+/* Configuration */
+void		mail_config_init		(void);
+void		mail_config_write		(void);
+
+GConfClient *	mail_config_get_gconf_client	(void);
+
+/* General Accessor functions */
+
+void		mail_config_service_set_save_passwd
+						(EAccountService *service,
+						 gboolean save_passwd);
+
+/* accounts */
+EAccount *	mail_config_get_account_by_source_url
+						(const gchar *url);
+EAccount *	mail_config_get_account_by_transport_url
+						(const gchar *url);
+
+gint		mail_config_get_address_count	(void);
+
+EAccountService *
+		mail_config_get_default_transport (void);
+
+/* static utility functions */
+gchar *		mail_config_folder_to_cachename	(CamelFolder *folder,
+						 const gchar *prefix);
+gchar *		mail_config_folder_to_safe_url	(CamelFolder *folder);
+
+gint		mail_config_get_sync_timeout	(void);
+
+void		mail_config_reload_junk_headers	(void);
+gboolean	mail_config_get_lookup_book	(void);
+gboolean	mail_config_get_lookup_book_local_only (void);
+
+G_END_DECLS
+
+#endif /* MAIL_CONFIG_H */
diff --git a/mail/daemon/mail-folder-cache.c b/mail/daemon/mail-folder-cache.c
new file mode 100644
index 0000000..8de42a8
--- /dev/null
+++ b/mail/daemon/mail-folder-cache.c
@@ -0,0 +1,1373 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *   Peter Williams <peterw ximian com>
+ *   Michael Zucchi <notzed ximian com>
+ *   Jonathon Jongsma <jonathon jongsma collabora co uk>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
+ *
+ */
+
+/**
+ * SECTION: mail-folder-cache
+ * @short_description: Stores information about open folders
+ **/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <time.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <glib/gstdio.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include "libemailutils/e-marshal.h"
+
+#include "mail-mt.h"
+#include "mail-folder-cache.h"
+#include "mail-ops.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+
+#include "e-mail-local.h"
+
+#define w(x)
+#define d(x) 
+
+/* This code is a mess, there is no reason it should be so complicated. */
+
+#define MAIL_FOLDER_CACHE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), MAIL_TYPE_FOLDER_CACHE, MailFolderCachePrivate))
+
+struct _MailFolderCachePrivate {
+	/* source id for the ping timeout callback */
+	guint ping_id;
+	/* Store to storeinfo table, active stores */
+	GHashTable *stores;
+	/* mutex to protect access to the stores hash */
+	GMutex *stores_mutex;
+	/* List of folder changes to be executed in gui thread */
+	GQueue updates;
+	/* event id for the async event of flushing all pending updates */
+	gint update_id;
+	/* hack for people who LIKE to have unsent count */
+	gint count_sent;
+	gint count_trash;
+};
+
+enum {
+	FOLDER_AVAILABLE,
+	FOLDER_UNAVAILABLE,
+	FOLDER_DELETED,
+	FOLDER_RENAMED,
+	FOLDER_UNREAD_UPDATED,
+	FOLDER_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+struct _folder_info {
+	struct _store_info *store_info;	/* 'parent' link */
+
+	gchar *full_name;	/* full name of folder/folderinfo */
+	gchar *uri;		/* uri of folder */
+
+	guint32 flags;
+	gboolean has_children;
+
+	gpointer folder;	/* if known (weak pointer) */
+};
+
+/* pending list of updates */
+struct _folder_update {
+	guint remove:1;	/* removing from vfolders */
+	guint delete:1;	/* deleting as well? */
+	guint add:1;	/* add to vfolder */
+	guint unsub:1;   /* unsubcribing? */
+	guint new;     /* new mail arrived? */
+
+	gchar *full_name;
+	gchar *uri;
+	gchar *oldfull;
+	gchar *olduri;
+
+	gint unread;
+	CamelStore *store;
+
+	/* for only one new message... */
+	gchar *msg_uid;     /* ... its uid ... */
+	gchar *msg_sender;  /* ... its sender ... */
+	gchar *msg_subject; /* ... and its subject. */
+};
+
+struct _store_info {
+	GHashTable *folders;	/* by full_name */
+	GHashTable *folders_uri; /* by uri */
+
+	CamelStore *store;	/* the store for these folders */
+
+	/* Outstanding folderinfo requests */
+	GQueue folderinfo_updates;
+};
+
+G_DEFINE_TYPE (MailFolderCache, mail_folder_cache, G_TYPE_OBJECT)
+
+static void
+free_update(struct _folder_update *up)
+{
+	g_free (up->full_name);
+	g_free (up->uri);
+	if (up->store)
+		g_object_unref (up->store);
+	g_free (up->oldfull);
+	g_free (up->olduri);
+	g_free (up->msg_uid);
+	g_free (up->msg_sender);
+	g_free (up->msg_subject);
+	g_free (up);
+}
+
+static void
+real_flush_updates (gpointer o, gpointer event_data, gpointer data)
+{
+	struct _folder_update *up;
+	MailFolderCache *self = (MailFolderCache*) o;
+
+	g_mutex_lock (self->priv->stores_mutex);
+	while ((up = g_queue_pop_head (&self->priv->updates)) != NULL) {
+		g_mutex_unlock (self->priv->stores_mutex);
+
+		if (up->remove) {
+			if (up->delete) {
+				g_signal_emit (self, signals[FOLDER_DELETED], 0, up->store, up->uri);
+			} else
+				g_signal_emit (self, signals[FOLDER_UNAVAILABLE], 0, up->store, up->uri);
+		} else {
+			if (up->olduri && up->add) {
+				g_signal_emit (self, signals[FOLDER_RENAMED], 0, up->store, up->olduri, up->uri);
+			}
+
+			if (!up->olduri && up->add)
+				g_signal_emit (self, signals[FOLDER_AVAILABLE], 0, up->store, up->uri);
+		}
+
+		/* update unread counts */
+		g_signal_emit (self, signals[FOLDER_UNREAD_UPDATED], 0,
+			       up->store, up->full_name, up->unread);
+
+		/* indicate that the folder has changed (new mail received, etc) */
+		if (up->uri) {
+			g_signal_emit (
+				self, signals[FOLDER_CHANGED], 0, up->store,
+				up->uri, up->full_name, up->new, up->msg_uid,
+				up->msg_sender, up->msg_subject);
+		}
+
+		if (CAMEL_IS_VEE_STORE (up->store) && !up->remove) {
+			/* Normally the vfolder store takes care of the folder_opened event itself,
+			   but we add folder to the noting system later, thus we do not know about
+			   search folders to update them in a tree, thus ensure their changes will
+			   be tracked correctly. */
+			CamelFolder *folder = camel_store_get_folder (up->store, up->full_name, 0, NULL);
+
+			if (folder) {
+				mail_folder_cache_note_folder (self, folder);
+				g_object_unref (folder);
+			}
+		}
+
+		free_update(up);
+
+		g_mutex_lock (self->priv->stores_mutex);
+	}
+	self->priv->update_id = -1;
+	g_mutex_unlock (self->priv->stores_mutex);
+}
+
+static void
+flush_updates (MailFolderCache *self)
+{
+	if (self->priv->update_id == -1 && !g_queue_is_empty (&self->priv->updates))
+		self->priv->update_id = mail_async_event_emit (
+			mail_async_event, MAIL_ASYNC_GUI,
+			(MailAsyncFunc) real_flush_updates,
+			self, NULL, NULL);
+}
+
+/* This is how unread counts work (and don't work):
+ *
+ * camel_folder_unread_message_count() only gives a correct answer if
+ * the store is paying attention to the folder. (Some stores always
+ * pay attention to all folders, but IMAP can only pay attention to
+ * one folder at a time.) But it doesn't have any way to know when
+ * it's lying, so it's only safe to call it when you know for sure
+ * that the store is paying attention to the folder, such as when it's
+ * just been created, or you get a folder_changed signal on it.
+ *
+ * camel_store_get_folder_info() always gives correct answers for the
+ * folders it checks, but it can also return -1 for a folder, meaning
+ * it didn't check, and so you should stick with your previous answer.
+ *
+ * update_1folder is called from three places: with info != NULL when
+ * the folder is created (or get_folder_info), with info == NULL when
+ * a folder changed event is emitted.
+ *
+ * So if info is NULL, camel_folder_unread_message_count is correct,
+ * and if it's not NULL and its unread_message_count isn't -1, then
+ * it's correct.  */
+
+static void
+update_1folder (MailFolderCache *self,
+                struct _folder_info *mfi,
+                gint new,
+                const gchar *msg_uid,
+                const gchar *msg_sender,
+                const gchar *msg_subject,
+                CamelFolderInfo *info)
+{
+	struct _folder_update *up;
+	CamelFolder *folder;
+	gint unread = -1;
+	gint deleted;
+
+	folder = mfi->folder;
+	if (folder) {
+		gboolean is_drafts = FALSE, is_outbox = FALSE;
+
+		d(printf("update 1 folder '%s'\n", camel_folder_get_full_name(folder)));
+		if ((self->priv->count_trash && (CAMEL_IS_VTRASH_FOLDER (folder)))
+		    || (is_drafts = em_utils_folder_is_drafts (
+			folder, info ? info->uri : NULL))
+		    || (is_outbox = em_utils_folder_is_outbox (
+			folder, info ? info->uri : NULL))
+		    || (self->priv->count_sent && em_utils_folder_is_sent (
+			folder, info ? info->uri : NULL))) {
+			d(printf(" total count\n"));
+			unread = camel_folder_get_message_count (folder);
+			if (is_drafts || is_outbox) {
+				guint32 junked = 0;
+
+				if ((deleted = camel_folder_get_deleted_message_count (folder)) > 0)
+					unread -= deleted;
+
+				junked = folder->summary->junk_count;
+				if (junked > 0)
+					unread -= junked;
+			}
+		} else {
+			d(printf(" unread count\n"));
+			if (info)
+				unread = info->unread;
+			else
+				unread = camel_folder_get_unread_message_count (folder);
+		}
+	} else if (info && !em_utils_folder_is_drafts (NULL, info->uri) && !em_utils_folder_is_outbox (NULL, info->uri))
+		unread = info->unread;
+
+	d(printf("folder updated: unread %d: '%s'\n", unread, mfi->full_name));
+
+	if (unread == -1)
+		return;
+
+	up = g_malloc0(sizeof(*up));
+	up->full_name = g_strdup(mfi->full_name);
+	up->unread = unread;
+	up->new = new;
+	up->store = g_object_ref (mfi->store_info->store);
+	up->uri = g_strdup(mfi->uri);
+	up->msg_uid = g_strdup (msg_uid);
+	up->msg_sender = g_strdup (msg_sender);
+	up->msg_subject = g_strdup (msg_subject);
+	g_queue_push_tail (&self->priv->updates, up);
+	flush_updates(self);
+}
+
+static void
+folder_changed_cb (CamelFolder *folder,
+                   CamelFolderChangeInfo *changes,
+                   MailFolderCache *self)
+{
+	static GHashTable *last_newmail_per_folder = NULL;
+	time_t latest_received;
+	CamelFolder *local_drafts;
+	CamelFolder *local_outbox;
+	CamelFolder *local_sent;
+	CamelStore *parent_store;
+	CamelMessageInfo *info;
+	struct _store_info *si;
+	struct _folder_info *mfi;
+	const gchar *full_name;
+	gint new = 0;
+	gint i;
+	guint32 flags;
+	gchar *uid = NULL, *sender = NULL, *subject = NULL;
+
+	full_name = camel_folder_get_full_name (folder);
+	parent_store = camel_folder_get_parent_store (folder);
+
+	if (!last_newmail_per_folder)
+		last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+	/* it's fine to hash them by folder pointer here */
+	latest_received = GPOINTER_TO_INT (
+		g_hash_table_lookup (last_newmail_per_folder, folder));
+
+	local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS);
+	local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+	local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
+
+	if (!CAMEL_IS_VEE_FOLDER(folder)
+	    && folder != local_drafts
+	    && folder != local_outbox
+	    && folder != local_sent
+	    && changes && (changes->uid_added->len > 0)) {
+		/* for each added message, check to see that it is
+		   brand new, not junk and not already deleted */
+		for (i = 0; i < changes->uid_added->len; i++) {
+			info = camel_folder_get_message_info (folder, changes->uid_added->pdata[i]);
+			if (info) {
+				flags = camel_message_info_flags (info);
+				if (((flags & CAMEL_MESSAGE_SEEN) == 0) &&
+				    ((flags & CAMEL_MESSAGE_JUNK) == 0) &&
+				    ((flags & CAMEL_MESSAGE_DELETED) == 0) &&
+				    (camel_message_info_date_received (info) > latest_received)) {
+					latest_received = camel_message_info_date_received (info);
+					new++;
+					if (new == 1) {
+						uid = g_strdup (camel_message_info_uid (info));
+						sender = g_strdup (camel_message_info_from (info));
+						subject = g_strdup (camel_message_info_subject (info));
+					} else {
+						g_free (uid);
+						g_free (sender);
+						g_free (subject);
+
+						uid = NULL;
+						sender = NULL;
+						subject = NULL;
+					}
+				}
+				camel_folder_free_message_info (folder, info);
+			}
+		}
+	}
+
+	if (new > 0)
+		g_hash_table_insert (
+			last_newmail_per_folder, folder,
+			GINT_TO_POINTER (latest_received));
+
+	g_mutex_lock (self->priv->stores_mutex);
+	if (self->priv->stores != NULL
+	    && (si = g_hash_table_lookup(self->priv->stores, parent_store)) != NULL
+	    && (mfi = g_hash_table_lookup(si->folders, full_name)) != NULL
+	    && mfi->folder == folder) {
+		update_1folder (self, mfi, new, uid, sender, subject, NULL);
+	}
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	g_free (uid);
+	g_free (sender);
+	g_free (subject);
+}
+
+static void
+unset_folder_info (MailFolderCache *self,
+                   struct _folder_info *mfi,
+                   gint delete,
+                   gint unsub)
+{
+	struct _folder_update *up;
+
+	d(printf("unset folderinfo '%s'\n", mfi->uri));
+
+	if (mfi->folder) {
+		CamelFolder *folder = mfi->folder;
+
+		g_signal_handlers_disconnect_by_func (
+			folder, folder_changed_cb, self);
+
+		g_object_remove_weak_pointer (
+			G_OBJECT (mfi->folder), &mfi->folder);
+	}
+
+	if ((mfi->flags & CAMEL_FOLDER_NOSELECT) == 0) {
+		up = g_malloc0(sizeof(*up));
+
+		up->remove = TRUE;
+		up->delete = delete;
+		up->unsub = unsub;
+		up->store = g_object_ref (mfi->store_info->store);
+		up->full_name = g_strdup (mfi->full_name);
+		up->uri = g_strdup(mfi->uri);
+
+		g_queue_push_tail (&self->priv->updates, up);
+		flush_updates(self);
+	}
+}
+
+static void
+free_folder_info(struct _folder_info *mfi)
+{
+	g_free(mfi->full_name);
+	g_free(mfi->uri);
+	g_free(mfi);
+}
+
+static void
+setup_folder(MailFolderCache *self, CamelFolderInfo *fi, struct _store_info *si)
+{
+	struct _folder_info *mfi;
+	struct _folder_update *up;
+
+	mfi = g_hash_table_lookup(si->folders, fi->full_name);
+	if (mfi) {
+		update_1folder (self, mfi, 0, NULL, NULL, NULL, fi);
+	} else {
+		d(printf("Adding new folder: %s (%s)\n", fi->full_name, fi->uri));
+		mfi = g_malloc0(sizeof(*mfi));
+		mfi->full_name = g_strdup(fi->full_name);
+		mfi->uri = g_strdup(fi->uri);
+		mfi->store_info = si;
+		mfi->flags = fi->flags;
+		mfi->has_children = fi->child != NULL;
+
+		g_hash_table_insert(si->folders, mfi->full_name, mfi);
+		g_hash_table_insert(si->folders_uri, mfi->uri, mfi);
+
+		up = g_malloc0(sizeof(*up));
+		up->full_name = g_strdup(mfi->full_name);
+		up->uri = g_strdup(fi->uri);
+		up->unread = fi->unread;
+		up->store = g_object_ref (si->store);
+
+		if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0)
+			up->add = TRUE;
+
+		g_queue_push_tail (&self->priv->updates, up);
+		flush_updates(self);
+	}
+}
+
+static void
+create_folders(MailFolderCache *self, CamelFolderInfo *fi, struct _store_info *si)
+{
+	d(printf("Setup new folder: %s\n  %s\n", fi->uri, fi->full_name));
+
+	while (fi) {
+		setup_folder(self, fi, si);
+
+		if (fi->child)
+			create_folders(self, fi->child, si);
+
+		fi = fi->next;
+	}
+}
+
+static void
+store_folder_subscribed_cb (CamelStore *store,
+                            CamelFolderInfo *info,
+                            MailFolderCache *self)
+{
+	struct _store_info *si;
+
+	g_mutex_lock (self->priv->stores_mutex);
+	si = g_hash_table_lookup (self->priv->stores, store);
+	if (si)
+		setup_folder (self, info, si);
+	g_mutex_unlock (self->priv->stores_mutex);
+}
+
+static void
+store_folder_created_cb (CamelStore *store,
+                         CamelFolderInfo *info,
+                         MailFolderCache *cache)
+{
+	/* We only want created events to do more work
+	 * if we dont support subscriptions. */
+	if (!camel_store_supports_subscriptions (store))
+		store_folder_subscribed_cb (store, info, cache);
+}
+
+static void
+store_folder_opened_cb (CamelStore *store,
+                        CamelFolder *folder,
+                        MailFolderCache *self)
+{
+	mail_folder_cache_note_folder (self, folder);
+}
+
+static void
+store_folder_unsubscribed_cb (CamelStore *store,
+                              CamelFolderInfo *info,
+                              MailFolderCache *self)
+{
+	struct _store_info *si;
+	struct _folder_info *mfi;
+
+	g_mutex_lock (self->priv->stores_mutex);
+	si = g_hash_table_lookup (self->priv->stores, store);
+	if (si) {
+		mfi = g_hash_table_lookup(si->folders, info->full_name);
+		if (mfi) {
+			g_hash_table_remove (si->folders, mfi->full_name);
+			g_hash_table_remove (si->folders_uri, mfi->uri);
+			unset_folder_info (self, mfi, TRUE, TRUE);
+			free_folder_info (mfi);
+		}
+	}
+	g_mutex_unlock (self->priv->stores_mutex);
+}
+
+static void
+store_folder_deleted_cb (CamelStore *store,
+                         CamelFolderInfo *info,
+                         MailFolderCache *self)
+{
+	/* We only want deleted events to do more work
+	 * if we dont support subscriptions. */
+	if (!camel_store_supports_subscriptions (store))
+		store_folder_unsubscribed_cb (store, info, self);
+}
+
+static gchar *
+folder_to_url(CamelStore *store, const gchar *full_name)
+{
+	CamelURL *url;
+	gchar *out;
+
+	url = camel_url_copy(((CamelService *)store)->url);
+	if (((CamelService *)store)->provider->url_flags  & CAMEL_URL_FRAGMENT_IS_PATH) {
+		camel_url_set_fragment(url, full_name);
+	} else {
+		gchar *name = g_alloca(strlen(full_name)+2);
+
+		sprintf(name, "/%s", full_name);
+		camel_url_set_path(url, name);
+	}
+
+	out = camel_url_to_string(url, CAMEL_URL_HIDE_ALL);
+	camel_url_free(url);
+
+	return out;
+}
+
+static void
+rename_folders (MailFolderCache *self,
+                struct _store_info *si,
+                const gchar *oldbase,
+                const gchar *newbase,
+                CamelFolderInfo *fi)
+{
+	gchar *old, *olduri, *oldfile, *newuri, *newfile;
+	struct _folder_info *mfi;
+	struct _folder_update *up;
+	const gchar *config_dir;
+
+	up = g_malloc0(sizeof(*up));
+
+	d(printf("oldbase '%s' newbase '%s' new '%s'\n", oldbase, newbase, fi->full_name));
+
+	/* Form what was the old name, and try and look it up */
+	old = g_strdup_printf("%s%s", oldbase, fi->full_name + strlen(newbase));
+	mfi = g_hash_table_lookup(si->folders, old);
+	if (mfi) {
+		d(printf("Found old folder '%s' renaming to '%s'\n", mfi->full_name, fi->full_name));
+
+		up->oldfull = mfi->full_name;
+		up->olduri = mfi->uri;
+
+		/* Its a rename op */
+		g_hash_table_remove(si->folders, mfi->full_name);
+		g_hash_table_remove(si->folders_uri, mfi->uri);
+		mfi->full_name = g_strdup(fi->full_name);
+		mfi->uri = g_strdup(fi->uri);
+		mfi->flags = fi->flags;
+		mfi->has_children = fi->child != NULL;
+
+		g_hash_table_insert(si->folders, mfi->full_name, mfi);
+		g_hash_table_insert(si->folders_uri, mfi->uri, mfi);
+	} else {
+		d(printf("Rename found a new folder? old '%s' new '%s'\n", old, fi->full_name));
+		/* Its a new op */
+		mfi = g_malloc0(sizeof(*mfi));
+		mfi->full_name = g_strdup(fi->full_name);
+		mfi->uri = g_strdup(fi->uri);
+		mfi->store_info = si;
+		mfi->flags = fi->flags;
+		mfi->has_children = fi->child != NULL;
+
+		g_hash_table_insert(si->folders, mfi->full_name, mfi);
+		g_hash_table_insert(si->folders_uri, mfi->uri, mfi);
+	}
+
+	up->full_name = g_strdup(mfi->full_name);
+	up->uri = g_strdup(mfi->uri);
+	up->unread = fi->unread==-1?0:fi->unread;
+	up->store = g_object_ref (si->store);
+
+	if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0)
+		up->add = TRUE;
+
+	g_queue_push_tail (&self->priv->updates, up);
+	flush_updates(self);
+#if 0
+	if (fi->sibling)
+		rename_folders(self, si, oldbase, newbase, fi->sibling, folders);
+	if (fi->child)
+		rename_folders(self, si, oldbase, newbase, fi->child, folders);
+#endif
+
+	/* rename the meta-data we maintain ourselves */
+	config_dir = mail_session_get_config_dir ();
+	olduri = folder_to_url(si->store, old);
+	e_filename_make_safe(olduri);
+	newuri = folder_to_url(si->store, fi->full_name);
+	e_filename_make_safe(newuri);
+	oldfile = g_strdup_printf("%s/custom_view-%s.xml", config_dir, olduri);
+	newfile = g_strdup_printf("%s/custom_view-%s.xml", config_dir, newuri);
+	g_rename(oldfile, newfile);
+	g_free(oldfile);
+	g_free(newfile);
+	oldfile = g_strdup_printf("%s/current_view-%s.xml", config_dir, olduri);
+	newfile = g_strdup_printf("%s/current_view-%s.xml", config_dir, newuri);
+	g_rename(oldfile, newfile);
+	g_free(oldfile);
+	g_free(newfile);
+	g_free(olduri);
+	g_free(newuri);
+
+	g_free(old);
+}
+
+static void
+get_folders(CamelFolderInfo *fi, GPtrArray *folders)
+{
+	while (fi) {
+		g_ptr_array_add(folders, fi);
+
+		if (fi->child)
+			get_folders(fi->child, folders);
+
+		fi = fi->next;
+	}
+}
+
+static gint
+folder_cmp(gconstpointer ap, gconstpointer bp)
+{
+	const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0];
+	const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0];
+
+	return strcmp(a->full_name, b->full_name);
+}
+
+static void
+store_folder_renamed_cb (CamelStore *store,
+                         const gchar *old_name,
+                         CamelFolderInfo *info,
+                         MailFolderCache *self)
+{
+	struct _store_info *si;
+
+	g_mutex_lock (self->priv->stores_mutex);
+	si = g_hash_table_lookup(self->priv->stores, store);
+	if (si) {
+		GPtrArray *folders = g_ptr_array_new();
+		CamelFolderInfo *top;
+		gint i;
+
+		/* Ok, so for some reason the folderinfo we have comes in all messed up from
+		   imap, should find out why ... this makes it workable */
+		get_folders(info, folders);
+		qsort(folders->pdata, folders->len, sizeof(folders->pdata[0]), folder_cmp);
+
+		top = folders->pdata[0];
+		for (i=0;i<folders->len;i++) {
+			rename_folders(self, si, old_name, top->full_name, folders->pdata[i]);
+		}
+
+		g_ptr_array_free(folders, TRUE);
+
+	}
+	g_mutex_unlock (self->priv->stores_mutex);
+}
+
+struct _update_data {
+	gint id;			/* id for cancellation */
+	guint cancel:1;		/* also tells us we're cancelled */
+
+	gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data);
+	gpointer data;
+	MailFolderCache *cache;
+};
+
+static void
+unset_folder_info_hash(gchar *path, struct _folder_info *mfi, gpointer data)
+{
+	MailFolderCache *self = (MailFolderCache*) data;
+	unset_folder_info(self, mfi, FALSE, FALSE);
+}
+
+static void
+free_folder_info_hash(gchar *path, struct _folder_info *mfi, gpointer data)
+{
+	free_folder_info(mfi);
+}
+
+static gboolean
+update_folders(CamelStore *store, CamelFolderInfo *fi, gpointer data, GError *error)
+{
+	struct _update_data *ud = data;
+	struct _store_info *si;
+	gboolean res = TRUE;
+
+	d(printf("Got folderinfo for store %s\n", store->parent.provider->protocol));
+
+	g_mutex_lock (ud->cache->priv->stores_mutex);
+	si = g_hash_table_lookup(ud->cache->priv->stores, store);
+	if (si && !ud->cancel) {
+		/* the 'si' is still there, so we can remove ourselves from its list */
+		/* otherwise its not, and we're on our own and free anyway */
+		g_queue_remove (&si->folderinfo_updates, ud);
+
+		if (fi)
+			create_folders(ud->cache, fi, si);
+	}
+	g_mutex_unlock (ud->cache->priv->stores_mutex);
+
+	if (ud->done)
+		res = ud->done (store, fi, ud->data);
+	g_free(ud);
+
+	return res;
+}
+
+struct _ping_store_msg {
+	MailMsg base;
+	CamelStore *store;
+};
+
+static gchar *
+ping_store_desc (struct _ping_store_msg *m)
+{
+	gchar *service_name;
+	gchar *msg;
+
+	service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
+	msg = g_strdup_printf (_("Pinging %s"), service_name);
+	g_free (service_name);
+
+	return msg;
+}
+
+static void
+ping_store_exec (struct _ping_store_msg *m)
+{
+	gboolean online = FALSE;
+
+	if (CAMEL_SERVICE (m->store)->status == CAMEL_SERVICE_CONNECTED) {
+		if (CAMEL_IS_DISCO_STORE (m->store) &&
+			camel_disco_store_status (
+			CAMEL_DISCO_STORE (m->store)) !=CAMEL_DISCO_STORE_OFFLINE)
+			online = TRUE;
+		else if (CAMEL_IS_OFFLINE_STORE (m->store) &&
+			CAMEL_OFFLINE_STORE (m->store)->state !=
+			CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+			online = TRUE;
+	}
+	if (online)
+		camel_store_noop (m->store, &m->base.error);
+}
+
+static void
+ping_store_free (struct _ping_store_msg *m)
+{
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo ping_store_info = {
+	sizeof (struct _ping_store_msg),
+	(MailMsgDescFunc) ping_store_desc,
+	(MailMsgExecFunc) ping_store_exec,
+	(MailMsgDoneFunc) NULL,
+	(MailMsgFreeFunc) ping_store_free
+};
+
+static void
+ping_store (CamelStore *store)
+{
+	struct _ping_store_msg *m;
+
+	if (CAMEL_SERVICE (store)->status != CAMEL_SERVICE_CONNECTED)
+		return;
+
+	m = mail_msg_new (&ping_store_info);
+	m->store = g_object_ref (store);
+
+	mail_msg_slow_ordered_push (m);
+}
+
+static gboolean
+ping_cb (MailFolderCache *self)
+{
+	g_mutex_lock (self->priv->stores_mutex);
+
+	g_hash_table_foreach (self->priv->stores, (GHFunc) ping_store, NULL);
+
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	return TRUE;
+}
+
+static void
+store_online_cb (CamelStore *store, gpointer data)
+{
+	struct _update_data *ud = data;
+
+	g_mutex_lock (ud->cache->priv->stores_mutex);
+
+	if (g_hash_table_lookup(ud->cache->priv->stores, store) != NULL && !ud->cancel) {
+		/* re-use the cancel id.  we're already in the store update list too */
+		ud->id = mail_get_folderinfo(store, NULL, update_folders, ud);
+	} else {
+		/* the store vanished, that means we were probably cancelled, or at any rate,
+		   need to clean ourselves up */
+		g_free(ud);
+	}
+
+	g_mutex_unlock (ud->cache->priv->stores_mutex);
+}
+
+struct _find_info {
+	const gchar *uri;
+	struct _folder_info *fi;
+	CamelURL *url;
+};
+
+/* look up on each storeinfo using proper hash function for that stores uri's */
+static void
+storeinfo_find_folder_info (CamelStore *store,
+                            struct _store_info *si,
+                            struct _find_info *fi)
+{
+	if (fi->fi == NULL) {
+		if (((CamelService *)store)->provider->url_equal (
+			fi->url, ((CamelService *)store)->url)) {
+			gchar *path = fi->url->fragment?fi->url->fragment:fi->url->path;
+
+			if (path[0] == '/')
+				path++;
+			fi->fi = g_hash_table_lookup(si->folders, path);
+		}
+	}
+}
+
+static void
+mail_folder_cache_finalize (GObject *object)
+{
+	MailFolderCache *cache = (MailFolderCache*) object;
+
+	g_hash_table_destroy (cache->priv->stores);
+	g_mutex_free (cache->priv->stores_mutex);
+
+	if (cache->priv->ping_id > 0) {
+		g_source_remove (cache->priv->ping_id);
+		cache->priv->ping_id = 0;
+	}
+
+	if (cache->priv->update_id > 0) {
+		g_source_remove (cache->priv->update_id);
+		cache->priv->update_id = 0;
+	}
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (mail_folder_cache_parent_class)->finalize (object);
+}
+
+static void
+mail_folder_cache_class_init (MailFolderCacheClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (MailFolderCachePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = mail_folder_cache_finalize;
+
+	/**
+	 * MailFolderCache::folder-available
+	 * @store: the #CamelStore containing the folder
+	 * @uri: the uri of the folder
+	 *
+	 * Emitted when a folder becomes available
+	 **/
+	signals[FOLDER_AVAILABLE] =
+		g_signal_new ("folder-available",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING,
+			      G_TYPE_NONE, 2,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING);
+
+	/**
+	 * MailFolderCache::folder-unavailable
+	 * @store: the #CamelStore containing the folder
+	 * @uri: the uri of the folder
+	 *
+	 * Emitted when a folder becomes unavailable.  This represents a
+	 * transient condition.  See MailFolderCache::folder-deleted to be
+	 * notified when a folder is permanently removed.
+	 **/
+	signals[FOLDER_UNAVAILABLE] =
+		g_signal_new ("folder-unavailable",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING,
+			      G_TYPE_NONE, 2,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING);
+
+	/**
+	 * MailFolderCache::folder-deleted
+	 * @store: the #CamelStore containing the folder
+	 * @uri: the uri of the folder
+	 *
+	 * Emitted when a folder is deleted
+	 **/
+	signals[FOLDER_DELETED] =
+		g_signal_new ("folder-deleted",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING,
+			      G_TYPE_NONE, 2,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING);
+
+	/**
+	 * MailFolderCache::folder-renamed
+	 * @store: the #CamelStore containing the folder
+	 * @old_uri: the old uri of the folder
+	 * @new_uri: the new uri of the folder
+	 *
+	 * Emitted when a folder is renamed
+	 **/
+	signals[FOLDER_RENAMED] =
+		g_signal_new ("folder-renamed",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING_STRING,
+			      G_TYPE_NONE, 3,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING);
+
+	/**
+	 * MailFolderCache::folder-unread-updated
+	 * @store: the #CamelStore containing the folder
+	 * @name: the name of the folder
+	 * @unread: the number of unread mails in the folder
+	 *
+	 * Emitted when a we receive an update to the unread count for a folder
+	 **/
+	signals[FOLDER_UNREAD_UPDATED] =
+		g_signal_new ("folder-unread-updated",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING_INT,
+			      G_TYPE_NONE, 3,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_INT);
+
+	/**
+	 * MailFolderCache::folder-changed
+	 * @store: the #CamelStore containing the folder
+	 * @folder_uri: the uri of the folder
+	 * @folder_fullname: the full name of the folder
+	 * @new_messages: the number of new messages for the folder
+	 * @msg_uid: uid of the new message, or NULL
+	 * @msg_sender: sender of the new message, or NULL
+	 * @msg_subject: subject of the new message, or NULL
+	 *
+	 * Emitted when a folder has changed.  If @new_messages is not exactly 1,
+	 * @msgt_uid, @msg_sender, and @msg_subject will be NULL.
+	 **/
+	signals[FOLDER_CHANGED] =
+		g_signal_new ("folder-changed",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      0, /* struct offset */
+			      NULL, NULL, /* accumulator */
+			      e_marshal_VOID__OBJECT_STRING_STRING_INT_STRING_STRING_STRING,
+			      G_TYPE_NONE, 7,
+			      CAMEL_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT,
+			      G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+}
+
+static void
+mail_folder_cache_init (MailFolderCache *self)
+{
+	const gchar *buf;
+	guint timeout;
+
+	self->priv = MAIL_FOLDER_CACHE_GET_PRIVATE (self);
+
+	/* initialize values */
+	self->priv->stores = g_hash_table_new(NULL, NULL);
+	self->priv->stores_mutex = g_mutex_new ();
+
+	g_queue_init (&self->priv->updates);
+	self->priv->update_id = -1;
+	self->priv->count_sent = getenv("EVOLUTION_COUNT_SENT") != NULL;
+	self->priv->count_trash = getenv("EVOLUTION_COUNT_TRASH") != NULL;
+
+	buf = getenv ("EVOLUTION_PING_TIMEOUT");
+	timeout = buf ? strtoul (buf, NULL, 10) : 600;
+	self->priv->ping_id = g_timeout_add_seconds (
+		timeout, (GSourceFunc) ping_cb, self);
+}
+
+static MailFolderCache *default_cache = NULL;
+G_LOCK_DEFINE_STATIC (default_cache);
+
+/**
+ * mail_folder_cache_get_default:
+ *
+ * Get the default folder cache object
+ */
+MailFolderCache *
+mail_folder_cache_get_default (void)
+{
+	G_LOCK (default_cache);
+	if (!default_cache)
+		default_cache = g_object_new (MAIL_TYPE_FOLDER_CACHE, NULL);
+	G_UNLOCK (default_cache);
+
+	return default_cache;
+}
+
+/**
+ * mail_folder_cache_note_store:
+ *
+ * Add a store whose folders should appear in the shell The folders are scanned
+ * from the store, and/or added at runtime via the folder_created event.  The
+ * @done function returns if we can free folder info.
+ */
+void
+mail_folder_cache_note_store (MailFolderCache *self,
+                              CamelStore *store,
+                              CamelOperation *op,
+                              NoteDoneFunc done,
+                              gpointer data)
+{
+	struct _store_info *si;
+	struct _update_data *ud;
+	gint hook = 0;
+
+	g_return_if_fail (CAMEL_IS_STORE(store));
+	g_return_if_fail (mail_in_main_thread());
+
+	g_mutex_lock (self->priv->stores_mutex);
+
+	si = g_hash_table_lookup (self->priv->stores, store);
+	if (si == NULL) {
+		si = g_malloc0(sizeof(*si));
+		si->folders = g_hash_table_new(g_str_hash, g_str_equal);
+		si->folders_uri = g_hash_table_new (
+			CAMEL_STORE_CLASS (
+			CAMEL_OBJECT_GET_CLASS(store))->hash_folder_name,
+			CAMEL_STORE_CLASS (
+			CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name);
+		si->store = g_object_ref (store);
+		g_hash_table_insert(self->priv->stores, store, si);
+		g_queue_init (&si->folderinfo_updates);
+		hook = TRUE;
+	}
+
+	ud = g_malloc(sizeof(*ud));
+	ud->done = done;
+	ud->data = data;
+	ud->cancel = 0;
+	ud->cache = self;
+
+	/* We might get a race when setting up a store, such that it is
+	 * still left in offline mode, after we've gone online.  This
+	 * catches and fixes it up when the shell opens us. */
+	if (CAMEL_IS_DISCO_STORE (store)) {
+		if (camel_session_get_online (session) &&
+			 camel_disco_store_status (CAMEL_DISCO_STORE (store)) ==
+			CAMEL_DISCO_STORE_OFFLINE) {
+			/* Note: we use the 'id' here, even though its not the right id, its still ok */
+			ud->id = mail_store_set_offline (store, FALSE, store_online_cb, ud);
+		} else {
+			goto normal_setup;
+		}
+	} else if (CAMEL_IS_OFFLINE_STORE (store)) {
+		if (camel_session_get_online (session) &&
+			CAMEL_OFFLINE_STORE (store)->state ==
+			CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+			/* Note: we use the 'id' here, even though its not the right id, its still ok */
+			ud->id = mail_store_set_offline (store, FALSE, store_online_cb, ud);
+		} else {
+			goto normal_setup;
+		}
+	} else {
+	normal_setup:
+		ud->id = mail_get_folderinfo (store, op, update_folders, ud);
+	}
+
+	g_queue_push_tail (&si->folderinfo_updates, ud);
+
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	/* there is potential for race here, but it is safe as we check
+	 * for the store anyway */
+	if (hook) {
+		g_signal_connect (
+			store, "folder-opened",
+			G_CALLBACK (store_folder_opened_cb), self);
+		g_signal_connect (
+			store, "folder-created",
+			G_CALLBACK (store_folder_created_cb), self);
+		g_signal_connect (
+			store, "folder-deleted",
+			G_CALLBACK (store_folder_deleted_cb), self);
+		g_signal_connect (
+			store, "folder-renamed",
+			G_CALLBACK (store_folder_renamed_cb), self);
+		g_signal_connect (
+			store, "folder-subscribed",
+			G_CALLBACK (store_folder_subscribed_cb), self);
+		g_signal_connect (
+			store, "folder-unsubscribed",
+			G_CALLBACK (store_folder_unsubscribed_cb), self);
+	}
+}
+
+/**
+ * mail_folder_cache_note_store_remove:
+ *
+ * Notify the cache that the specified @store can be removed from the cache
+ */
+void
+mail_folder_cache_note_store_remove (MailFolderCache *self,
+                                     CamelStore *store)
+{
+	struct _store_info *si;
+
+	g_return_if_fail (CAMEL_IS_STORE(store));
+
+	if (self->priv->stores == NULL)
+		return;
+
+	d(printf("store removed!!\n"));
+	g_mutex_lock (self->priv->stores_mutex);
+	si = g_hash_table_lookup (self->priv->stores, store);
+	if (si) {
+		GList *link;
+
+		g_hash_table_remove(self->priv->stores, store);
+
+		g_signal_handlers_disconnect_matched (
+			store, G_SIGNAL_MATCH_DATA,
+			0, 0, NULL, NULL, self);
+
+		g_hash_table_foreach (
+			si->folders, (GHFunc)
+			unset_folder_info_hash, self);
+
+		link = g_queue_peek_head_link (&si->folderinfo_updates);
+
+		while (link != NULL) {
+			struct _update_data *ud = link->data;
+
+			d(printf("Cancelling outstanding folderinfo update %d\n", ud->id));
+			mail_msg_cancel(ud->id);
+			ud->cancel = 1;
+
+			link = g_list_next (link);
+		}
+
+		g_object_unref (si->store);
+		g_hash_table_foreach(si->folders, (GHFunc)free_folder_info_hash, NULL);
+		g_hash_table_destroy(si->folders);
+		g_hash_table_destroy(si->folders_uri);
+		g_free(si);
+	}
+
+	g_mutex_unlock (self->priv->stores_mutex);
+}
+
+/**
+ * mail_folder_cache_note_folder:
+ *
+ * When a folder has been opened, notify it for watching.  The folder must have
+ * already been created on the store (which has already been noted) before the
+ * folder can be opened
+ */
+void
+mail_folder_cache_note_folder (MailFolderCache *self,
+                               CamelFolder *folder)
+{
+	CamelStore *parent_store;
+	struct _store_info *si;
+	struct _folder_info *mfi;
+	const gchar *full_name;
+
+	full_name = camel_folder_get_full_name (folder);
+	parent_store = camel_folder_get_parent_store (folder);
+
+	g_mutex_lock (self->priv->stores_mutex);
+	if (self->priv->stores == NULL
+	    || (si = g_hash_table_lookup(self->priv->stores, parent_store)) == NULL
+	    || (mfi = g_hash_table_lookup(si->folders, full_name)) == NULL) {
+		w(g_warning("Noting folder before store initialised"));
+		g_mutex_unlock (self->priv->stores_mutex);
+		return;
+	}
+
+	/* dont do anything if we already have this */
+	if (mfi->folder == folder) {
+		g_mutex_unlock (self->priv->stores_mutex);
+		return;
+	}
+
+	mfi->folder = folder;
+
+	g_object_add_weak_pointer (G_OBJECT (folder), &mfi->folder);
+
+	update_1folder (self, mfi, 0, NULL, NULL, NULL, NULL);
+
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	g_signal_connect (
+		folder, "changed",
+		G_CALLBACK (folder_changed_cb), self);
+}
+
+/**
+ * mail_folder_cache_get_folder_from_uri:
+ *
+ * Gets the #CamelFolder for the supplied @uri.
+ *
+ * Returns: %TRUE if the URI is available, folderp is set to a reffed
+ *          folder if the folder has also already been opened
+ */
+gboolean
+mail_folder_cache_get_folder_from_uri (MailFolderCache *self,
+                                       const gchar *uri,
+                                       CamelFolder **folderp)
+{
+	struct _find_info fi = { uri, NULL, NULL };
+
+	if (self->priv->stores == NULL)
+		return FALSE;
+
+	fi.url = camel_url_new (uri, NULL);
+
+	g_mutex_lock (self->priv->stores_mutex);
+	g_hash_table_foreach (
+		self->priv->stores, (GHFunc)
+		storeinfo_find_folder_info, &fi);
+	if (folderp) {
+		if (fi.fi && fi.fi->folder)
+			*folderp = g_object_ref (fi.fi->folder);
+		else
+			*folderp = NULL;
+	}
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	camel_url_free (fi.url);
+
+	return fi.fi != NULL;
+}
+
+gboolean
+mail_folder_cache_get_folder_info_flags (MailFolderCache *self,
+                                         CamelFolder *folder,
+                                         gint *flags)
+{
+	gchar *uri = mail_tools_folder_to_url (folder);
+	struct _find_info fi = { uri, NULL, NULL };
+
+	if (self->priv->stores == NULL)
+		return FALSE;
+
+	fi.url = camel_url_new (uri, NULL);
+
+	g_mutex_lock (self->priv->stores_mutex);
+	g_hash_table_foreach (
+		self->priv->stores, (GHFunc)
+		storeinfo_find_folder_info, &fi);
+	if (flags) {
+		if (fi.fi)
+			*flags = fi.fi->flags;
+		else
+			*flags = 0;
+	}
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	camel_url_free (fi.url);
+	g_free (uri);
+
+	return fi.fi != NULL;
+}
+
+/* Returns whether folder 'folder' has children based on folder_info->child property.
+   If not found returns FALSE and sets 'found' to FALSE, if not NULL. */
+gboolean
+mail_folder_cache_get_folder_has_children (MailFolderCache *self,
+                                           CamelFolder *folder,
+                                           gboolean *found)
+{
+	gchar *uri = mail_tools_folder_to_url (folder);
+	struct _find_info fi = { uri, NULL, NULL };
+
+	g_return_val_if_fail (self != NULL, FALSE);
+	g_return_val_if_fail (folder != NULL, FALSE);
+
+	if (self->priv->stores == NULL)
+		return FALSE;
+
+	fi.url = camel_url_new (uri, NULL);
+
+	g_mutex_lock (self->priv->stores_mutex);
+	g_hash_table_foreach (
+		self->priv->stores, (GHFunc)
+		storeinfo_find_folder_info, &fi);
+	if (found)
+		*found = fi.fi != NULL;
+	g_mutex_unlock (self->priv->stores_mutex);
+
+	camel_url_free (fi.url);
+	g_free (uri);
+
+	return fi.fi != NULL && fi.fi->has_children;
+}
diff --git a/mail/daemon/mail-folder-cache.h b/mail/daemon/mail-folder-cache.h
new file mode 100644
index 0000000..55aaeb9
--- /dev/null
+++ b/mail/daemon/mail-folder-cache.h
@@ -0,0 +1,110 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *   Peter Williams <peterw ximian com>
+ *   Michael Zucchi <notzed ximian com>
+ *   Jonathon Jongsma <jonathon jongsma collabora co uk>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
+ *
+ */
+
+#ifndef MAIL_FOLDER_CACHE_H
+#define MAIL_FOLDER_CACHE_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define MAIL_TYPE_FOLDER_CACHE \
+	(mail_folder_cache_get_type ())
+#define MAIL_FOLDER_CACHE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), MAIL_TYPE_FOLDER_CACHE, MailFolderCache))
+#define MAIL_FOLDER_CACHE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), MAIL_TYPE_FOLDER_CACHE, MailFolderCacheClass))
+#define MAIL_IS_FOLDER_CACHE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), MAIL_TYPE_FOLDER_CACHE))
+#define MAIL_IS_FOLDER_CACHE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), MAIL_TYPE_FOLDER_CACHE))
+#define MAIL_FOLDER_CACHE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), MAIL_TYPE_FOLDER_CACHE, MailFolderCacheClass))
+
+G_BEGIN_DECLS
+
+typedef struct _MailFolderCache MailFolderCache;
+typedef struct _MailFolderCacheClass MailFolderCacheClass;
+typedef struct _MailFolderCachePrivate MailFolderCachePrivate;
+
+/**
+ * NoteDoneFunc:
+ *
+ * The signature of a function to be registered as a callback for
+ * mail_folder_cache_note_store()
+ */
+typedef gboolean	(*NoteDoneFunc)		(CamelStore *store,
+						 CamelFolderInfo *info,
+						 gpointer data);
+
+/**
+ * MailFolderCache:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ */
+struct _MailFolderCache {
+	GObject parent;
+	MailFolderCachePrivate *priv;
+};
+
+struct _MailFolderCacheClass {
+	GObjectClass parent_class;
+};
+
+GType		mail_folder_cache_get_type	(void) G_GNUC_CONST;
+MailFolderCache *
+		mail_folder_cache_get_default	(void);
+void		mail_folder_cache_note_store	(MailFolderCache *self,
+						 CamelStore *store,
+						 CamelOperation *op,
+						 NoteDoneFunc done,
+						 gpointer data);
+void		mail_folder_cache_note_store_remove
+						(MailFolderCache *self,
+						 CamelStore *store);
+void		mail_folder_cache_note_folder	(MailFolderCache *self,
+						 CamelFolder *folder);
+gboolean	mail_folder_cache_get_folder_from_uri
+						(MailFolderCache *self,
+						 const gchar *uri,
+						 CamelFolder **folderp);
+gboolean	mail_folder_cache_get_folder_info_flags
+						(MailFolderCache *self,
+						 CamelFolder *folder,
+						 gint *flags);
+
+gboolean	mail_folder_cache_get_folder_has_children
+						(MailFolderCache *self,
+						 CamelFolder *folder,
+						 gboolean *found);
+
+G_END_DECLS
+
+#endif /* MAIL_FOLDER_CACHE_H */
diff --git a/mail/daemon/mail-ops.c b/mail/daemon/mail-ops.c
new file mode 100644
index 0000000..3b2cac3
--- /dev/null
+++ b/mail/daemon/mail-ops.c
@@ -0,0 +1,3286 @@
+/*
+ * mail-ops.c: callbacks for the mail toolbar/menus
+ *
+ * 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/>
+ *
+ *
+ * Authors:
+ *      Dan Winship <danw ximian com>
+ *      Jeffrey Stedfast <fejj ximian com>
+ *      Peter Williams <peterw ximian com>
+ *      Michael Zucchi <notzed ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include <config.h>
+
+#include <errno.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include "e-account-utils.h"
+
+#include "mail-mt.h"
+#include "mail-ops.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+
+#include "e-mail-local.h"
+
+#define w(x)
+#define d(x)
+
+/* XXX Make this a preprocessor definition. */
+const gchar *x_mailer = "Evolution Mail Data Server 0.1 ";
+
+/* used for both just filtering a folder + uid's, and for filtering a whole folder */
+/* used both for fetching mail, and for filtering mail */
+struct _filter_mail_msg {
+	MailMsg base;
+
+	CamelFolder *source_folder; /* where they come from */
+	GPtrArray *source_uids;	/* uids to copy, or NULL == copy all */
+	CamelUIDCache *cache;  /* UID cache if we are to cache the uids, NULL otherwise */
+	CamelOperation *cancel;
+	CamelFilterDriver *driver;
+	gint delete;		/* delete messages after filtering them? */
+	CamelFolder *destination; /* default destination for any messages, NULL for none */
+};
+
+/* since fetching also filters, we subclass the data here */
+struct _fetch_mail_msg {
+	struct _filter_mail_msg fmsg;
+
+	CamelOperation *cancel;	/* we have our own cancellation struct, the other should be empty */
+	gint keep;		/* keep on server? */
+
+	gchar *source_uri;
+
+	void (*done)(const gchar *source, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+em_filter_folder_element_desc (struct _filter_mail_msg *m)
+{
+	return g_strdup (_("Filtering Selected Messages"));
+}
+
+/* filter a folder, or a subset thereof, uses source_folder/source_uids */
+/* this is shared with fetch_mail */
+static void
+em_filter_folder_element_exec (struct _filter_mail_msg *m)
+{
+	CamelFolder *folder;
+	GPtrArray *uids, *folder_uids = NULL;
+
+	if (m->cancel)
+		camel_operation_register (m->cancel);
+
+	folder = m->source_folder;
+
+	if (folder == NULL || camel_folder_get_message_count (folder) == 0) {
+		if (m->cancel)
+			camel_operation_unregister (m->cancel);
+		return;
+	}
+
+	if (m->destination) {
+		camel_folder_freeze (m->destination);
+		camel_filter_driver_set_default_folder (m->driver, m->destination);
+	}
+
+	camel_folder_freeze (folder);
+
+	if (m->source_uids)
+		uids = m->source_uids;
+	else
+		folder_uids = uids = camel_folder_get_uids (folder);
+
+	camel_filter_driver_filter_folder (
+		m->driver, folder, m->cache, uids,
+		m->delete, &m->base.error);
+	camel_filter_driver_flush (m->driver, &m->base.error);
+
+	if (folder_uids)
+		camel_folder_free_uids (folder, folder_uids);
+
+	/* sync our source folder */
+	if (!m->cache)
+		camel_folder_sync (folder, FALSE, &m->base.error);
+	camel_folder_thaw (folder);
+
+	if (m->destination)
+		camel_folder_thaw (m->destination);
+
+	/* this may thaw/unref source folders, do it here so we dont do it in the main thread
+	   see also fetch_mail_fetch() below */
+	g_object_unref (m->driver);
+	m->driver = NULL;
+
+	if (m->cancel)
+		camel_operation_unregister (m->cancel);
+}
+
+static void
+em_filter_folder_element_done (struct _filter_mail_msg *m)
+{
+}
+
+static void
+em_filter_folder_element_free (struct _filter_mail_msg *m)
+{
+	if (m->source_folder)
+		g_object_unref (m->source_folder);
+
+	if (m->source_uids)
+		em_utils_uids_free (m->source_uids);
+
+	if (m->cancel)
+		camel_operation_unref (m->cancel);
+
+	if (m->destination)
+		g_object_unref (m->destination);
+
+	if (m->driver)
+		g_object_unref (m->driver);
+
+	mail_session_flush_filter_log ();
+}
+
+static MailMsgInfo em_filter_folder_element_info = {
+	sizeof (struct _filter_mail_msg),
+	(MailMsgDescFunc) em_filter_folder_element_desc,  /* we do our own progress reporting? */
+	(MailMsgExecFunc) em_filter_folder_element_exec,
+	(MailMsgDoneFunc) em_filter_folder_element_done,
+	(MailMsgFreeFunc) em_filter_folder_element_free
+};
+
+void
+mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids,
+		    const gchar *type, gboolean notify,
+		    CamelOperation *cancel)
+{
+	struct _filter_mail_msg *m;
+
+	m = mail_msg_new (&em_filter_folder_element_info);
+	m->source_folder = source_folder;
+	g_object_ref (source_folder);
+	m->source_uids = uids;
+	m->cache = NULL;
+	m->delete = FALSE;
+	if (cancel) {
+		m->cancel = cancel;
+		camel_operation_ref (cancel);
+	}
+
+	m->driver = camel_session_get_filter_driver (session, type, NULL);
+
+	if (!notify) {
+		/* FIXME: have a #define NOTIFY_FILTER_NAME macro? */
+		/* the filter name has to stay in sync with mail-session::get_filter_driver */
+		camel_filter_driver_remove_rule_by_name (m->driver, "new-mail-notification");
+	}
+
+	mail_msg_unordered_push (m);
+}
+
+#if 0
+/* convenience functions for it */
+void
+mail_filter_on_demand (CamelFolder *folder, GPtrArray *uids)
+{
+	mail_filter_folder (folder, uids, E_FILTER_SOURCE_DEMAND, FALSE, NULL);
+}
+
+void
+mail_filter_junk (CamelFolder *folder, GPtrArray *uids)
+{
+	mail_filter_folder (folder, uids, E_FILTER_SOURCE_JUNKTEST, FALSE, NULL);
+}
+#endif
+
+/* ********************************************************************** */
+
+/* Temporary workaround for various issues. Gone before 0.11 */
+static gchar *
+uid_cachename_hack (CamelStore *store)
+{
+	CamelURL *url = CAMEL_SERVICE (store)->url;
+	gchar *encoded_url, *filename;
+	const gchar *data_dir;
+
+	encoded_url = g_strdup_printf ("%s%s%s %s", url->user,
+				       url->authmech ? ";auth=" : "",
+				       url->authmech ? url->authmech : "",
+				       url->host);
+	e_filename_make_safe (encoded_url);
+
+	data_dir = mail_session_get_data_dir ();
+	filename = g_build_filename (data_dir, "pop", encoded_url, "uid-cache", NULL);
+	g_free (encoded_url);
+
+	return filename;
+}
+
+static gchar *
+fetch_mail_desc (struct _fetch_mail_msg *m)
+{
+	return g_strdup (_("Fetching Mail"));
+}
+
+static void
+fetch_mail_exec (struct _fetch_mail_msg *m)
+{
+	struct _filter_mail_msg *fm = (struct _filter_mail_msg *)m;
+	gint i;
+
+	if (m->cancel)
+		camel_operation_register (m->cancel);
+
+	fm->destination = e_mail_local_get_folder (E_MAIL_FOLDER_LOCAL_INBOX);
+	if (fm->destination == NULL)
+		goto fail;
+	g_object_ref (fm->destination);
+
+	/* FIXME: this should support keep_on_server too, which would then perform a spool
+	   access thingy, right?  problem is matching raw messages to uid's etc. */
+	if (!strncmp (m->source_uri, "mbox:", 5)) {
+		gchar *path = mail_tool_do_movemail (m->source_uri, &fm->base.error);
+
+		if (path && fm->base.error == NULL) {
+			camel_folder_freeze (fm->destination);
+			camel_filter_driver_set_default_folder (
+				fm->driver, fm->destination);
+			camel_filter_driver_filter_mbox (
+				fm->driver, path, m->source_uri,
+				&fm->base.error);
+			camel_folder_thaw (fm->destination);
+
+			if (fm->base.error == NULL)
+				g_unlink (path);
+		}
+		g_free (path);
+	} else {
+		CamelFolder *folder;
+
+		folder = fm->source_folder =
+			mail_tool_get_inbox (m->source_uri, &fm->base.error);
+
+		if (folder) {
+			/* this handles 'keep on server' stuff, if we have any new uid's to copy
+			   across, we need to copy them to a new array 'cause of the way fetch_mail_free works */
+			CamelUIDCache *cache = NULL;
+			CamelStore *parent_store;
+			gchar *cachename;
+
+			parent_store = camel_folder_get_parent_store (folder);
+			cachename = uid_cachename_hack (parent_store);
+			cache = camel_uid_cache_new (cachename);
+			g_free (cachename);
+
+			if (cache) {
+				GPtrArray *folder_uids, *cache_uids, *uids;
+
+				folder_uids = camel_folder_get_uids (folder);
+				cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
+				if (cache_uids) {
+					/* need to copy this, sigh */
+					fm->source_uids = uids = g_ptr_array_new ();
+					g_ptr_array_set_size (uids, cache_uids->len);
+					for (i = 0; i < cache_uids->len; i++)
+						uids->pdata[i] = g_strdup (cache_uids->pdata[i]);
+					camel_uid_cache_free_uids (cache_uids);
+
+					fm->cache = cache;
+					em_filter_folder_element_exec (fm);
+
+					/* need to uncancel so writes/etc. don't fail */
+					if (g_error_matches (fm->base.error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+						camel_operation_uncancel(NULL);
+
+					/* save the cache of uids that we've just downloaded */
+					camel_uid_cache_save (cache);
+				}
+
+				if (fm->delete && fm->base.error == NULL) {
+					/* not keep on server - just delete all the actual messages on the server */
+					for (i=0;i<folder_uids->len;i++) {
+						d(printf("force delete uid '%s'\n", (gchar *)folder_uids->pdata[i]));
+						camel_folder_delete_message(folder, folder_uids->pdata[i]);
+					}
+				}
+
+				if ((fm->delete || cache_uids) && fm->base.error == NULL) {
+					/* expunge messages (downloaded so far) */
+					camel_folder_sync(folder, fm->delete, NULL);
+				}
+
+				camel_uid_cache_destroy (cache);
+				camel_folder_free_uids (folder, folder_uids);
+			} else {
+				em_filter_folder_element_exec (fm);
+			}
+
+			/* we unref the source folder here since we
+			   may now block in finalize (we try to
+			   disconnect cleanly) */
+			g_object_unref (fm->source_folder);
+			fm->source_folder = NULL;
+		}
+	}
+fail:
+	if (m->cancel)
+		camel_operation_unregister (m->cancel);
+
+	/* we unref this here as it may have more work to do (syncing
+	   folders and whatnot) before we are really done */
+	/* should this be cancellable too? (i.e. above unregister above) */
+	if (fm->driver) {
+		g_object_unref (fm->driver);
+		fm->driver = NULL;
+	}
+}
+
+static void
+fetch_mail_done (struct _fetch_mail_msg *m)
+{
+	if (m->done)
+		m->done (m->source_uri, m->data);
+}
+
+static void
+fetch_mail_free (struct _fetch_mail_msg *m)
+{
+	g_free (m->source_uri);
+	if (m->cancel)
+		camel_operation_unref (m->cancel);
+
+	em_filter_folder_element_free ((struct _filter_mail_msg *) m);
+}
+
+static MailMsgInfo fetch_mail_info = {
+	sizeof (struct _fetch_mail_msg),
+	(MailMsgDescFunc) fetch_mail_desc,
+	(MailMsgExecFunc) fetch_mail_exec,
+	(MailMsgDoneFunc) fetch_mail_done,
+	(MailMsgFreeFunc) fetch_mail_free
+};
+
+/* ouch, a 'do everything' interface ... */
+void
+mail_fetch_mail (const gchar *source, gint keep, const gchar *type, CamelOperation *cancel,
+		 CamelFilterGetFolderFunc get_folder, gpointer get_data,
+		 CamelFilterStatusFunc *status, gpointer status_data,
+		 void (*done)(const gchar *source, gpointer data), gpointer data)
+{
+	struct _fetch_mail_msg *m;
+	struct _filter_mail_msg *fm;
+
+	m = mail_msg_new (&fetch_mail_info);
+	fm = (struct _filter_mail_msg *)m;
+	m->source_uri = g_strdup (source);
+	fm->delete = !keep;
+	fm->cache = NULL;
+	if (cancel) {
+		m->cancel = cancel;
+		camel_operation_ref (cancel);
+	}
+	m->done = done;
+	m->data = data;
+
+	fm->driver = camel_session_get_filter_driver (session, type, NULL);
+	camel_filter_driver_set_folder_func (fm->driver, get_folder, get_data);
+	if (status)
+		camel_filter_driver_set_status_func (fm->driver, status, status_data);
+
+	mail_msg_unordered_push (m);
+}
+
+static gchar *
+escape_percent_sign (const gchar *str)
+{
+	GString *res;
+
+	if (!str)
+		return NULL;
+
+	res = g_string_sized_new (strlen (str));
+	while (*str) {
+		if (*str == '%') {
+			g_string_append (res, "%%");
+		} else {
+			g_string_append_c (res, *str);
+		}
+
+		str++;
+	}
+
+	return g_string_free (res, FALSE);
+}
+
+/* ********************************************************************** */
+/* sending stuff */
+/* ** SEND MAIL *********************************************************** */
+
+static const gchar *normal_recipients[] = {
+	CAMEL_RECIPIENT_TYPE_TO,
+	CAMEL_RECIPIENT_TYPE_CC,
+	CAMEL_RECIPIENT_TYPE_BCC
+};
+
+static const gchar *resent_recipients[] = {
+	CAMEL_RECIPIENT_TYPE_RESENT_TO,
+	CAMEL_RECIPIENT_TYPE_RESENT_CC,
+	CAMEL_RECIPIENT_TYPE_RESENT_BCC
+};
+
+struct _send_queue_msg;
+static void report_status (struct _send_queue_msg *m, enum camel_filter_status_t status, gint pc, const gchar *desc, ...);
+
+/* send 1 message to a specific transport */
+static void
+mail_send_message (struct _send_queue_msg *m,
+                   CamelFolder *queue,
+                   const gchar *uid,
+                   const gchar *destination,
+                   CamelFilterDriver *driver,
+                   GError **error)
+{
+	EAccount *account = NULL;
+	const CamelInternetAddress *iaddr;
+	CamelAddress *from, *recipients;
+	CamelMessageInfo *info = NULL;
+	CamelTransport *xport = NULL;
+	gchar *transport_url = NULL;
+	gchar *sent_folder_uri = NULL;
+	const gchar *resent_from, *tmp;
+	CamelFolder *folder = NULL;
+	GString *err = NULL;
+	struct _camel_header_raw *xev, *header;
+	CamelMimeMessage *message;
+	gint i;
+	GError *local_error = NULL;
+
+	message = camel_folder_get_message(queue, uid, error);
+	if (!message)
+		return;
+
+	camel_medium_set_header (CAMEL_MEDIUM (message), "X-Mailer", x_mailer);
+
+	err = g_string_new("");
+	xev = mail_tool_remove_xevolution_headers (message);
+
+	tmp = camel_header_raw_find(&xev, "X-Evolution-Account", NULL);
+	if (tmp) {
+		gchar *name;
+
+		name = g_strstrip(g_strdup(tmp));
+		if ((account = e_get_account_by_uid (name))
+		    /* 'old' x-evolution-account stored the name, how silly */
+		    || (account = e_get_account_by_name (name))) {
+			if (account->transport && account->transport->url) {
+				transport_url = g_strdup (account->transport->url);
+
+				/* to reprompt password on sending if needed */
+				account->transport->get_password_canceled = FALSE;
+			}
+
+			sent_folder_uri = g_strdup (account->sent_folder_uri);
+		}
+		g_free(name);
+	}
+
+	if (!account) {
+		/* default back to these headers */
+		tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL);
+		if (tmp)
+			transport_url = g_strstrip(g_strdup(tmp));
+
+		tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL);
+		if (tmp)
+			sent_folder_uri = g_strstrip(g_strdup(tmp));
+	}
+
+	if (transport_url || destination) {
+		gchar *escaped = escape_percent_sign (transport_url ? transport_url : destination);
+
+		/* let the dialog know the right account it is using; percentage is ignored */
+		report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, escaped);
+
+		g_free (escaped);
+	}
+
+	/* Check for email sending */
+	from = (CamelAddress *) camel_internet_address_new ();
+	resent_from = camel_medium_get_header (CAMEL_MEDIUM (message), "Resent-From");
+	if (resent_from) {
+		camel_address_decode (from, resent_from);
+	} else {
+		iaddr = camel_mime_message_get_from (message);
+		camel_address_copy (from, CAMEL_ADDRESS (iaddr));
+	}
+
+	recipients = (CamelAddress *) camel_internet_address_new ();
+	for (i = 0; i < 3; i++) {
+		const gchar *type;
+
+		type = resent_from ? resent_recipients[i] : normal_recipients[i];
+		iaddr = camel_mime_message_get_recipients (message, type);
+		camel_address_cat (recipients, CAMEL_ADDRESS (iaddr));
+	}
+
+	if (camel_address_length(recipients) > 0) {
+		xport = camel_session_get_transport (
+			session, transport_url ? transport_url :
+			destination, error);
+		if (xport == NULL)
+			goto exit;
+
+		if (!camel_transport_send_to (xport, message, from, recipients, error))
+			goto exit;
+	}
+
+	/* Now check for posting, failures are ignored */
+	info = camel_message_info_new(NULL);
+	camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0);
+
+	for (header = xev;header;header=header->next) {
+		gchar *uri;
+
+		if (strcmp(header->name, "X-Evolution-PostTo") != 0)
+			continue;
+
+		/* TODO: don't lose errors */
+
+		uri = g_strstrip(g_strdup(header->value));
+		folder = mail_tool_uri_to_folder(uri, 0, NULL);
+		if (folder) {
+			camel_folder_append_message(folder, message, info, NULL, NULL);
+			g_object_unref (folder);
+			folder = NULL;
+		}
+		g_free(uri);
+	}
+
+	/* post process */
+	mail_tool_restore_xevolution_headers (message, xev);
+
+	if (driver) {
+		camel_filter_driver_filter_message (
+			driver, message, info, NULL,
+			NULL, NULL, "", &local_error);
+
+		if (local_error != NULL) {
+			if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+				goto exit;
+
+			/* sending mail, filtering failed */
+			g_string_append_printf (
+				err, _("Failed to apply outgoing filters: %s"),
+				local_error->message);
+
+			g_clear_error (&local_error);
+		}
+	}
+
+	if (xport == NULL
+	    || !( ((CamelService *)xport)->provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) {
+		GError *local_error = NULL;
+
+		if (sent_folder_uri) {
+			folder = mail_tool_uri_to_folder (
+				sent_folder_uri, 0, &local_error);
+			if (folder == NULL) {
+				g_string_append_printf (
+					err, _("Failed to append to %s: %s\n"
+					"Appending to local 'Sent' folder instead."),
+					sent_folder_uri, local_error ? local_error->message : _("Unknown error"));
+				if (local_error)
+					g_clear_error (&local_error);
+			}
+		}
+
+		if (!folder) {
+			folder = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
+			g_object_ref (folder);
+		}
+
+		if (!camel_folder_append_message (folder, message, info, NULL, &local_error)) {
+			CamelFolder *sent_folder;
+
+			if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+				goto exit;
+
+			sent_folder = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
+
+			if (folder != sent_folder) {
+				const gchar *description;
+
+				description = camel_folder_get_description (folder);
+				if (err->len)
+					g_string_append(err, "\n\n");
+				g_string_append_printf (
+					err, _("Failed to append to %s: %s\n"
+					"Appending to local 'Sent' folder instead."),
+					description, local_error->message);
+				g_object_ref (sent_folder);
+				g_object_unref (folder);
+				folder = sent_folder;
+
+				g_clear_error (&local_error);
+				camel_folder_append_message (
+					folder, message, info, NULL, &local_error);
+			}
+
+			if (local_error != NULL) {
+				if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+					goto exit;
+
+				if (err->len)
+					g_string_append(err, "\n\n");
+				g_string_append_printf (
+					err, _("Failed to append to local 'Sent' folder: %s"),
+					local_error->message);
+			}
+		}
+	}
+
+	if (local_error == NULL) {
+		camel_folder_set_message_flags (
+			queue, uid, CAMEL_MESSAGE_DELETED |
+			CAMEL_MESSAGE_SEEN, ~0);
+		/* Sync it to disk, since if it crashes in between,
+		 * we keep sending it again on next start. */
+		camel_folder_sync (queue, FALSE, NULL);
+	}
+
+	if (err->len) {
+		/* set the culmulative exception report */
+		g_set_error (
+			&local_error, CAMEL_ERROR,
+			CAMEL_ERROR_GENERIC, "%s", err->str);
+	}
+
+exit:
+	if (local_error != NULL)
+		g_propagate_error (error, local_error);
+
+	if (folder) {
+		camel_folder_sync(folder, FALSE, NULL);
+		g_object_unref (folder);
+	}
+	if (info)
+		camel_message_info_free(info);
+	g_object_unref (recipients);
+	g_object_unref (from);
+	if (xport)
+		g_object_unref (xport);
+	g_free(sent_folder_uri);
+	g_free(transport_url);
+	camel_header_raw_clear(&xev);
+	g_string_free(err, TRUE);
+	g_object_unref (message);
+
+	return;
+}
+
+/* ** SEND MAIL QUEUE ***************************************************** */
+
+struct _send_queue_msg {
+	MailMsg base;
+
+	CamelFolder *queue;
+	gchar *destination;
+
+	CamelFilterDriver *driver;
+	CamelOperation *cancel;
+
+	/* we use camelfilterstatusfunc, even though its not the filter doing it */
+	CamelFilterStatusFunc *status;
+	gpointer status_data;
+
+	void (*done)(const gchar *destination, gpointer data);
+	gpointer data;
+};
+
+static void
+report_status (struct _send_queue_msg *m, enum camel_filter_status_t status, gint pc, const gchar *desc, ...)
+{
+	va_list ap;
+	gchar *str;
+
+	if (m->status) {
+		va_start (ap, desc);
+		str = g_strdup_vprintf (desc, ap);
+		va_end (ap);
+		m->status (m->driver, status, pc, str, m->status_data);
+		g_free (str);
+	}
+}
+
+static void
+send_queue_exec (struct _send_queue_msg *m)
+{
+	CamelFolder *sent_folder;
+	GPtrArray *uids, *send_uids = NULL;
+	gint i, j;
+	GError *local_error = NULL;
+
+	d(printf("sending queue\n"));
+
+	sent_folder = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
+
+	if (!(uids = camel_folder_get_uids (m->queue)))
+		return;
+
+	send_uids = g_ptr_array_sized_new (uids->len);
+	for (i = 0, j = 0; i < uids->len; i++) {
+		CamelMessageInfo *info;
+
+		info = camel_folder_get_message_info (m->queue, uids->pdata[i]);
+		if (info) {
+			if ((camel_message_info_flags(info) & CAMEL_MESSAGE_DELETED) == 0)
+				send_uids->pdata[j++] = uids->pdata[i];
+			camel_folder_free_message_info(m->queue, info);
+		}
+	}
+
+	send_uids->len = j;
+	if (send_uids->len == 0) {
+		/* nothing to send */
+		camel_folder_free_uids (m->queue, uids);
+		g_ptr_array_free (send_uids, TRUE);
+		return;
+	}
+
+	if (m->cancel)
+		camel_operation_register (m->cancel);
+	else
+		camel_operation_register (m->base.cancel);
+
+	if (!m->cancel)
+		camel_operation_start (NULL, _("Sending message"));
+
+	/* NB: This code somewhat abuses the 'exception' stuff.  Apart from fatal problems, it is also
+	   used as a mechanism to accumualte warning messages and present them back to the user. */
+
+	for (i = 0, j = 0; i < send_uids->len; i++) {
+		gint pc = (100 * i) / send_uids->len;
+
+		report_status (m, CAMEL_FILTER_STATUS_START, pc, _("Sending message %d of %d"), i+1, send_uids->len);
+		if (!m->cancel)
+			camel_operation_progress (NULL, (i+1) * 100 / send_uids->len);
+
+		mail_send_message (
+			m, m->queue, send_uids->pdata[i],
+			m->destination, m->driver, &local_error);
+		if (local_error != NULL) {
+			if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+				/* merge exceptions into one */
+				if (m->base.error != NULL) {
+					gchar *old_message;
+
+					old_message = g_strdup (
+						m->base.error->message);
+					g_clear_error (&m->base.error);
+					g_set_error (
+						&m->base.error, CAMEL_ERROR,
+						CAMEL_ERROR_GENERIC,
+						"%s\n\n%s", old_message,
+						local_error->message);
+					g_free (old_message);
+
+					g_clear_error (&local_error);
+				} else {
+					g_propagate_error (&m->base.error, local_error);
+					local_error = NULL;
+				}
+
+				/* keep track of the number of failures */
+				j++;
+			} else {
+				/* transfer the USER_CANCEL error to the
+				 * async op exception and then break */
+				g_propagate_error (&m->base.error, local_error);
+				local_error = NULL;
+				break;
+			}
+		}
+	}
+
+	j += (send_uids->len - i);
+
+	if (j > 0)
+		report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Failed to send %d of %d messages"), j, send_uids->len);
+	else if (g_error_matches (m->base.error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+		report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Canceled."));
+	else
+		report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Complete."));
+
+	if (m->driver) {
+		g_object_unref (m->driver);
+		m->driver = NULL;
+	}
+
+	camel_folder_free_uids (m->queue, uids);
+	g_ptr_array_free (send_uids, TRUE);
+
+	if (j <= 0 && m->base.error == NULL)
+		camel_folder_sync (m->queue, TRUE, NULL);
+
+	if (sent_folder)
+		camel_folder_sync (sent_folder, FALSE, NULL);
+
+	if (!m->cancel)
+		camel_operation_end (NULL);
+
+	if (m->cancel)
+		camel_operation_unregister (m->cancel);
+	else
+		camel_operation_unregister (m->base.cancel);
+
+}
+
+static void
+send_queue_done (struct _send_queue_msg *m)
+{
+	if (m->done)
+		m->done(m->destination, m->data);
+}
+
+static gchar *
+send_queue_desc (struct _send_queue_msg *m)
+{
+	return g_strdup (_("Sending message"));
+}
+
+static void
+send_queue_free (struct _send_queue_msg *m)
+{
+	if (m->driver)
+		g_object_unref (m->driver);
+	g_object_unref (m->queue);
+	g_free(m->destination);
+	if (m->cancel)
+		camel_operation_unref(m->cancel);
+}
+
+static MailMsgInfo send_queue_info = {
+	sizeof (struct _send_queue_msg),
+	(MailMsgDescFunc) send_queue_desc,
+	(MailMsgExecFunc) send_queue_exec,
+	(MailMsgDoneFunc) send_queue_done,
+	(MailMsgFreeFunc) send_queue_free
+};
+
+/* same interface as fetch_mail, just 'cause i'm lazy today (and we need to run it from the same spot?) */
+void
+mail_send_queue(CamelFolder *queue, const gchar *destination,
+		const gchar *type, CamelOperation *cancel,
+		CamelFilterGetFolderFunc get_folder, gpointer get_data,
+		CamelFilterStatusFunc *status, gpointer status_data,
+		void (*done)(const gchar *destination, gpointer data), gpointer data)
+{
+	struct _send_queue_msg *m;
+
+	m = mail_msg_new(&send_queue_info);
+	m->queue = queue;
+	g_object_ref (queue);
+	m->destination = g_strdup(destination);
+	if (cancel) {
+		m->cancel = cancel;
+		camel_operation_ref(cancel);
+		camel_operation_unref (m->base.cancel);
+		mail_msg_set_cancelable (m, FALSE);
+
+		m->base.cancel = NULL;
+	}
+	m->status = status;
+	m->status_data = status_data;
+	m->done = done;
+	m->data = data;
+
+	m->driver = camel_session_get_filter_driver (session, type, NULL);
+	camel_filter_driver_set_folder_func (m->driver, get_folder, get_data);
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** APPEND MESSAGE TO FOLDER ******************************************** */
+
+struct _append_msg {
+	MailMsg base;
+
+        CamelFolder *folder;
+	CamelMimeMessage *message;
+        CamelMessageInfo *info;
+	gchar *appended_uid;
+
+	void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, gint ok, const gchar *appended_uid, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+append_mail_desc (struct _append_msg *m)
+{
+	return g_strdup_printf (_("Saving message to folder '%s'"), camel_folder_get_full_name (m->folder));
+}
+
+static void
+append_mail_exec (struct _append_msg *m)
+{
+	camel_mime_message_set_date(m->message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+	camel_folder_append_message(m->folder, m->message, m->info, &m->appended_uid, &m->base.error);
+}
+
+static void
+append_mail_done (struct _append_msg *m)
+{
+	if (m->done)
+		m->done (
+			m->folder, m->message,
+			m->info, m->base.error == NULL,
+			m->appended_uid, m->data);
+}
+
+static void
+append_mail_free (struct _append_msg *m)
+{
+	g_object_unref (m->message);
+	g_object_unref (m->folder);
+	g_free (m->appended_uid);
+}
+
+static MailMsgInfo append_mail_info = {
+	sizeof (struct _append_msg),
+	(MailMsgDescFunc) append_mail_desc,
+	(MailMsgExecFunc) append_mail_exec,
+	(MailMsgDoneFunc) append_mail_done,
+	(MailMsgFreeFunc) append_mail_free
+};
+
+void
+mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info,
+		  void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, gint ok, const gchar *appended_uid, gpointer data),
+		  gpointer data)
+{
+	struct _append_msg *m;
+
+	g_return_if_fail (CAMEL_IS_FOLDER (folder));
+	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+
+	if (!camel_medium_get_header (CAMEL_MEDIUM (message), "X-Mailer"))
+		camel_medium_set_header (CAMEL_MEDIUM (message), "X-Mailer", x_mailer);
+
+	m = mail_msg_new (&append_mail_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->message = message;
+	g_object_ref (message);
+	m->info = info;
+
+	m->done = done;
+	m->data = data;
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** TRANSFER MESSAGES **************************************************** */
+
+struct _transfer_msg {
+	MailMsg base;
+
+	CamelFolder *source;
+	GPtrArray *uids;
+	gboolean delete;
+	gchar *dest_uri;
+	guint32 dest_flags;
+
+	void (*done)(gboolean ok, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+transfer_messages_desc (struct _transfer_msg *m)
+{
+	return g_strdup_printf (m->delete ? _("Moving messages to '%s'") : _("Copying messages to '%s'"),
+				m->dest_uri);
+
+}
+
+static void
+transfer_messages_exec (struct _transfer_msg *m)
+{
+	CamelFolder *dest;
+
+	dest = mail_tool_uri_to_folder (m->dest_uri, m->dest_flags, &m->base.error);
+	if (dest == NULL)
+		return;
+
+	if (dest == m->source) {
+		g_object_unref (dest);
+		/* no-op */
+		return;
+	}
+
+	camel_folder_freeze (m->source);
+	camel_folder_freeze (dest);
+
+	camel_folder_transfer_messages_to (m->source, m->uids, dest, NULL, m->delete, &m->base.error);
+
+	/* make sure all deleted messages are marked as seen */
+
+	if (m->delete) {
+		gint i;
+
+		for (i = 0; i < m->uids->len; i++)
+			camel_folder_set_message_flags (m->source, m->uids->pdata[i],
+							CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+	}
+
+	camel_folder_thaw (m->source);
+	camel_folder_thaw (dest);
+	camel_folder_sync (dest, FALSE, NULL);
+	g_object_unref (dest);
+}
+
+static void
+transfer_messages_done (struct _transfer_msg *m)
+{
+	if (m->done)
+		m->done (m->base.error == NULL, m->data);
+}
+
+static void
+transfer_messages_free (struct _transfer_msg *m)
+{
+	g_object_unref (m->source);
+	g_free (m->dest_uri);
+	em_utils_uids_free (m->uids);
+}
+
+static MailMsgInfo transfer_messages_info = {
+	sizeof (struct _transfer_msg),
+	(MailMsgDescFunc) transfer_messages_desc,
+	(MailMsgExecFunc) transfer_messages_exec,
+	(MailMsgDoneFunc) transfer_messages_done,
+	(MailMsgFreeFunc) transfer_messages_free
+};
+
+void
+mail_transfer_messages (CamelFolder *source, GPtrArray *uids,
+			gboolean delete_from_source,
+			const gchar *dest_uri,
+			guint32 dest_flags,
+			void (*done) (gboolean ok, gpointer data),
+			gpointer data)
+{
+	struct _transfer_msg *m;
+
+	g_return_if_fail (CAMEL_IS_FOLDER (source));
+	g_return_if_fail (uids != NULL);
+	g_return_if_fail (dest_uri != NULL);
+
+	m = mail_msg_new(&transfer_messages_info);
+	m->source = source;
+	g_object_ref (source);
+	m->uids = uids;
+	m->delete = delete_from_source;
+	m->dest_uri = g_strdup (dest_uri);
+	m->dest_flags = dest_flags;
+	m->done = done;
+	m->data = data;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ** SCAN SUBFOLDERS ***************************************************** */
+
+struct _get_folderinfo_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	CamelFolderInfo *info;
+	gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error);
+	gpointer data;
+	char *top;
+	guint32 flags;
+	gboolean can_clear; /* whether we can clear folder info */
+};
+
+static gchar *
+get_folderinfo_desc (struct _get_folderinfo_msg *m)
+{
+	gchar *ret, *name;
+
+	name = camel_service_get_name((CamelService *)m->store, TRUE);
+	ret = g_strdup_printf (_("Scanning folders in '%s'"), name);
+	g_free(name);
+	return ret;
+}
+
+static void
+get_folderinfo_exec (struct _get_folderinfo_msg *m)
+{
+	m->info = camel_store_get_folder_info (m->store, m->top,  m->flags, &m->base.error);
+}
+
+static void
+get_folderinfo_done (struct _get_folderinfo_msg *m)
+{
+	if (!m->info && m->base.error != NULL) {
+		gchar *url;
+
+		url = camel_service_get_url (CAMEL_SERVICE (m->store));
+		w(g_warning ("Error getting folder info from store at %s: %s",
+			     url, m->base.error->message));
+		g_free (url);
+	}
+
+	if (m->done)
+		m->can_clear = m->done (m->store, m->info, m->data, m->base.error);
+	else
+		m->can_clear = TRUE;
+}
+
+static void
+get_folderinfo_free (struct _get_folderinfo_msg *m)
+{
+	g_free (m->top);
+	if (m->info && m->can_clear)
+		camel_store_free_folder_info(m->store, m->info);
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo get_folderinfo_info = {
+	sizeof (struct _get_folderinfo_msg),
+	(MailMsgDescFunc) get_folderinfo_desc,
+	(MailMsgExecFunc) get_folderinfo_exec,
+	(MailMsgDoneFunc) get_folderinfo_done,
+	(MailMsgFreeFunc) get_folderinfo_free
+};
+
+gint
+mail_get_folderinfo (CamelStore *store, CamelOperation *op, gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error), gpointer data)
+{
+	struct _get_folderinfo_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_folderinfo_info);
+	if (op) {
+		camel_operation_unref(m->base.cancel);
+		m->base.cancel = op;
+		camel_operation_ref(op);
+	}
+	m->top = NULL;
+	m->flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+	m->store = store;
+	g_object_ref (store);
+	m->done = done;
+	m->data = data;
+	id = m->base.seq;
+
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+gint
+mail_get_folderinfo_full (CamelStore *store, const char *top, guint32 flags, CamelOperation *op, gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error), gpointer data)
+{
+	struct _get_folderinfo_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_folderinfo_info);
+	if (op) {
+		camel_operation_unref(m->base.cancel);
+		m->base.cancel = op;
+		camel_operation_ref(op);
+	}
+
+	m->top = g_strdup (top);
+	m->flags = flags;
+	m->store = store;
+	g_object_ref (store);
+	m->done = done;
+	m->data = data;
+	id = m->base.seq;
+
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** ATTACH MESSAGES ****************************************************** */
+
+struct _build_data {
+	void (*done)(CamelFolder *folder, GPtrArray *uids, CamelMimePart *part, gchar *subject, gpointer data);
+	gpointer data;
+};
+
+static void
+do_build_attachment (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, gpointer data)
+{
+	struct _build_data *d = data;
+	CamelMultipart *multipart;
+	CamelMimePart *part;
+	gchar *subject;
+	gint i;
+
+	if (messages->len == 0) {
+		d->done(folder, messages, NULL, NULL, d->data);
+		g_free(d);
+		return;
+	}
+
+	if (messages->len == 1) {
+		part = mail_tool_make_message_attachment(messages->pdata[0]);
+	} else {
+		multipart = camel_multipart_new();
+		camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER (multipart), "multipart/digest");
+		camel_multipart_set_boundary(multipart, NULL);
+
+		for (i=0;i<messages->len;i++) {
+			part = mail_tool_make_message_attachment(messages->pdata[i]);
+			camel_multipart_add_part(multipart, part);
+			g_object_unref (part);
+		}
+		part = camel_mime_part_new();
+		camel_medium_set_content (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER(multipart));
+		g_object_unref (multipart);
+
+		camel_mime_part_set_description(part, _("Forwarded messages"));
+	}
+
+	subject = mail_tool_generate_forward_subject(messages->pdata[0]);
+	d->done(folder, messages, part, subject, d->data);
+	g_free(subject);
+	g_object_unref (part);
+
+	g_free(d);
+}
+
+void
+mail_build_attachment(CamelFolder *folder, GPtrArray *uids,
+		      void (*done)(CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, gchar *subject, gpointer data), gpointer data)
+{
+	struct _build_data *d;
+
+	d = g_malloc(sizeof(*d));
+	d->done = done;
+	d->data = data;
+	mail_get_messages(folder, uids, do_build_attachment, d);
+}
+
+/* ** LOAD FOLDER ********************************************************* */
+
+/* there should be some way to merge this and create folder, since both can
+   presumably create a folder ... */
+
+struct _get_folder_msg {
+	MailMsg base;
+
+	gchar *uri;
+	guint32 flags;
+	CamelFolder *folder;
+	void (*done) (gchar *uri, CamelFolder *folder, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+get_folder_desc (struct _get_folder_msg *m)
+{
+	return g_strdup_printf (_("Opening folder '%s'"), m->uri);
+}
+
+static void
+get_folder_exec (struct _get_folder_msg *m)
+{
+	m->folder = mail_tool_uri_to_folder (m->uri, m->flags, &m->base.error);
+}
+
+static void
+get_folder_done (struct _get_folder_msg *m)
+{
+	if (m->done)
+		m->done (m->uri, m->folder, m->data, m->base.error);
+}
+
+static void
+get_folder_free (struct _get_folder_msg *m)
+{
+	g_free (m->uri);
+	if (m->folder)
+		g_object_unref (m->folder);
+}
+
+static MailMsgInfo get_folder_info = {
+	sizeof (struct _get_folder_msg),
+	(MailMsgDescFunc) get_folder_desc,
+	(MailMsgExecFunc) get_folder_exec,
+	(MailMsgDoneFunc) get_folder_done,
+	(MailMsgFreeFunc) get_folder_free
+};
+
+gint
+mail_get_folder (const gchar *uri, guint32 flags,
+		 void (*done)(gchar *uri, CamelFolder *folder, gpointer data, GError *error),
+		 gpointer data, MailMsgDispatchFunc dispatch)
+{
+	struct _get_folder_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_folder_info);
+	m->uri = g_strdup (uri);
+	m->flags = flags;
+	m->data = data;
+	m->done = done;
+
+	id = m->base.seq;
+	dispatch (m);
+	return id;
+}
+
+/* Get Folder from name */
+struct _get_folder_name_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	gchar *folder_name;
+	gboolean junk;
+	gboolean trash;
+	gboolean inbox;
+	guint32 flags;
+
+	CamelFolder *folder;
+
+	void (*done) (CamelFolder *folder, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+get_folder_name_desc (struct _get_folder_name_msg *m)
+{
+	return g_strdup_printf (_("Opening folder %s"), m->folder_name ? m->folder_name : (m->inbox ? "INBOX" : (m->junk ? "Junk" : "Trash")));
+}
+
+static void
+get_folder_name_exec (struct _get_folder_name_msg *m)
+{
+	if (m->folder_name)
+		m->folder = camel_store_get_folder (m->store, m->folder_name, m->flags, &m->base.error);
+	else if (m->junk)
+		m->folder = camel_store_get_junk (m->store, &m->base.error);
+	else if (m->trash)
+		m->folder = camel_store_get_trash (m->store, &m->base.error);
+	else 
+		m->folder = camel_store_get_inbox (m->store, &m->base.error);
+}
+
+static void
+get_folder_name_done (struct _get_folder_name_msg *m)
+{
+	if (m->done)
+		m->done (m->folder, m->data, m->base.error);
+}
+
+static void
+get_folder_name_free (struct _get_folder_name_msg *m)
+{
+	g_free (m->folder_name);
+}
+
+static MailMsgInfo get_folder_by_name = {
+	sizeof (struct _get_folder_name_msg),
+	(MailMsgDescFunc) get_folder_name_desc,
+	(MailMsgExecFunc) get_folder_name_exec,
+	(MailMsgDoneFunc) get_folder_name_done,
+	(MailMsgFreeFunc) get_folder_name_free
+};
+
+gint
+mail_get_folder_from_name (CamelStore *store, const gchar *folder_name, 
+		 gboolean junk, gboolean trash, gboolean inbox, guint32 flags,
+		 void (*done)(CamelFolder *folder, gpointer data, GError *error),
+		 gpointer data, MailMsgDispatchFunc dispatch)
+{
+	struct _get_folder_name_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_folder_by_name);
+	m->folder_name = NULL;
+	m->junk = FALSE;
+	m->trash = FALSE;
+	m->inbox = FALSE;
+
+	if (folder_name)
+		m->folder_name = g_strdup (folder_name);
+	else if (junk)
+		m->junk = TRUE;
+	else if (trash)
+		m->trash = TRUE;
+	else if (inbox)
+		m->inbox = TRUE;
+	else
+		return FALSE;
+
+	m->store = store;
+	m->flags = flags;
+	m->data = data;
+	m->done = done;
+
+	id = m->base.seq;
+	dispatch (m);
+	return id;
+}
+/* ** GET FOLDER'S QUOTA ********************************************************* */
+
+struct _get_quota_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	CamelFolderQuotaInfo *quota;
+	void (*done) (CamelFolder *folder, const gchar *folder_uri, CamelFolderQuotaInfo *quota, gpointer data);
+	gchar *folder_uri;
+	gpointer data;
+};
+
+static gchar *
+get_quota_desc (struct _get_quota_msg *m)
+{
+	return g_strdup_printf (_("Retrieving quota information for folder '%s'"), camel_folder_get_name (m->folder));
+}
+
+static void
+get_quota_exec (struct _get_quota_msg *m)
+{
+	m->quota = camel_folder_get_quota_info (m->folder);
+}
+
+static void
+get_quota_done (struct _get_quota_msg *m)
+{
+	if (m->done)
+		m->done (m->folder, m->folder_uri, m->quota, m->data);
+}
+
+static void
+get_quota_free (struct _get_quota_msg *m)
+{
+	if (m->folder)
+		g_object_unref (m->folder);
+	if (m->quota)
+		camel_folder_quota_info_free (m->quota);
+	g_free (m->folder_uri);
+}
+
+static MailMsgInfo get_quota_info = {
+	sizeof (struct _get_quota_msg),
+	(MailMsgDescFunc) get_quota_desc,
+	(MailMsgExecFunc) get_quota_exec,
+	(MailMsgDoneFunc) get_quota_done,
+	(MailMsgFreeFunc) get_quota_free
+};
+
+gint
+mail_get_folder_quota (CamelFolder *folder,
+		 const gchar *folder_uri,
+		 void (*done)(CamelFolder *folder, const gchar *uri, CamelFolderQuotaInfo *quota, gpointer data),
+		 gpointer data, MailMsgDispatchFunc dispatch)
+{
+	struct _get_quota_msg *m;
+	gint id;
+
+	g_return_val_if_fail (folder != NULL, -1);
+
+	m = mail_msg_new (&get_quota_info);
+	m->folder = folder;
+	m->folder_uri = g_strdup (folder_uri);
+	m->data = data;
+	m->done = done;
+
+	g_object_ref (m->folder);
+
+	id = m->base.seq;
+	dispatch (m);
+	return id;
+}
+
+/* ** GET STORE ******************************************************* */
+
+struct _get_store_msg {
+	MailMsg base;
+
+	gchar *uri;
+	CamelStore *store;
+	void (*done) (gchar *uri, CamelStore *store, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+get_store_desc (struct _get_store_msg *m)
+{
+	return g_strdup_printf (_("Opening store '%s'"), m->uri);
+}
+
+static void
+get_store_exec (struct _get_store_msg *m)
+{
+	/*camel_session_get_store connects us, which we don't want to do on startup. */
+
+	m->store = (CamelStore *) camel_session_get_service (session, m->uri,
+							     CAMEL_PROVIDER_STORE,
+							     &m->base.error);
+}
+
+static void
+get_store_done (struct _get_store_msg *m)
+{
+	if (m->done)
+		m->done (m->uri, m->store, m->data, m->base.error);
+}
+
+static void
+get_store_free (struct _get_store_msg *m)
+{
+	g_free (m->uri);
+	if (m->store)
+		g_object_unref (m->store);
+}
+
+static MailMsgInfo get_store_info = {
+	sizeof (struct _get_store_msg),
+	(MailMsgDescFunc) get_store_desc,
+	(MailMsgExecFunc) get_store_exec,
+	(MailMsgDoneFunc) get_store_done,
+	(MailMsgFreeFunc) get_store_free
+};
+
+gint
+mail_get_store (const gchar *uri, CamelOperation *op, void (*done) (gchar *uri, CamelStore *store, gpointer data, GError *error), gpointer data)
+{
+	struct _get_store_msg *m;
+	gint id;
+
+	m = mail_msg_new (&get_store_info);
+	if (op) {
+		camel_operation_unref(m->base.cancel);
+		m->base.cancel = op;
+		camel_operation_ref(op);
+	}
+	m->uri = g_strdup (uri);
+	m->data = data;
+	m->done = done;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+	return id;
+}
+
+/* ** REMOVE FOLDER ******************************************************* */
+
+struct _remove_folder_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	gboolean removed;
+	void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+remove_folder_desc (struct _remove_folder_msg *m)
+{
+	return g_strdup_printf (_("Removing folder '%s'"), camel_folder_get_full_name (m->folder));
+}
+
+static gboolean
+remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, GError **error)
+{
+	while (fi) {
+		CamelFolder *folder;
+
+		if (fi->child) {
+			if (!remove_folder_rec (store, fi->child, error))
+				return FALSE;
+		}
+
+		d(printf ("deleting folder '%s'\n", fi->full_name));
+
+		folder = camel_store_get_folder (store, fi->full_name, 0, error);
+		if (folder == NULL)
+			return FALSE;
+
+		if (!CAMEL_IS_VEE_FOLDER (folder)) {
+			GPtrArray *uids = camel_folder_get_uids (folder);
+			gint i;
+
+			/* Delete every message in this folder, then expunge it */
+			camel_folder_freeze (folder);
+			for (i = 0; i < uids->len; i++)
+				camel_folder_delete_message (folder, uids->pdata[i]);
+
+			camel_folder_free_uids (folder, uids);
+
+			camel_folder_sync (folder, TRUE, NULL);
+			camel_folder_thaw (folder);
+		}
+
+		/* if the store supports subscriptions, unsubscribe from this folder... */
+		if (camel_store_supports_subscriptions (store))
+			camel_store_unsubscribe_folder (store, fi->full_name, NULL);
+
+		/* Then delete the folder from the store */
+		if (!camel_store_delete_folder (store, fi->full_name, error))
+			return FALSE;
+
+		fi = fi->next;
+	}
+
+	return TRUE;
+}
+
+static void
+remove_folder_exec (struct _remove_folder_msg *m)
+{
+	CamelFolderInfo *fi;
+	CamelStore *parent_store;
+	const gchar *full_name;
+
+	m->removed = FALSE;
+
+	full_name = camel_folder_get_full_name (m->folder);
+	parent_store = camel_folder_get_parent_store (m->folder);
+
+	fi = camel_store_get_folder_info (
+		parent_store, full_name,
+		CAMEL_STORE_FOLDER_INFO_RECURSIVE |
+		CAMEL_STORE_FOLDER_INFO_FAST |
+		CAMEL_STORE_FOLDER_INFO_SUBSCRIBED,
+		&m->base.error);
+	if (fi == NULL)
+		return;
+
+	m->removed = remove_folder_rec (parent_store, fi, &m->base.error);
+	camel_store_free_folder_info (parent_store, fi);
+}
+
+static void
+remove_folder_done (struct _remove_folder_msg *m)
+{
+	if (m->done)
+		m->done (m->folder, m->removed, &m->base.error, m->data);
+}
+
+static void
+remove_folder_free (struct _remove_folder_msg *m)
+{
+	g_object_unref (m->folder);
+}
+
+static MailMsgInfo remove_folder_info = {
+	sizeof (struct _remove_folder_msg),
+	(MailMsgDescFunc) remove_folder_desc,
+	(MailMsgExecFunc) remove_folder_exec,
+	(MailMsgDoneFunc) remove_folder_done,
+	(MailMsgFreeFunc) remove_folder_free
+};
+
+void
+mail_remove_folder (CamelFolder *folder, void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data), gpointer data)
+{
+	struct _remove_folder_msg *m;
+
+	g_return_if_fail (folder != NULL);
+
+	m = mail_msg_new (&remove_folder_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** SYNC FOLDER ********************************************************* */
+
+struct _sync_folder_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	gboolean expunge;
+	void (*done) (CamelFolder *folder, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+sync_folder_desc (struct _sync_folder_msg *m)
+{
+	return g_strdup_printf (_("Storing folder '%s'"),
+			       camel_folder_get_full_name (m->folder));
+}
+
+static void
+sync_folder_exec (struct _sync_folder_msg *m)
+{
+	camel_folder_sync(m->folder, m->expunge, &m->base.error);
+}
+
+static void
+sync_folder_done (struct _sync_folder_msg *m)
+{
+	if (m->done)
+		m->done(m->folder, m->data, m->base.error);
+}
+
+static void
+sync_folder_free (struct _sync_folder_msg *m)
+{
+	g_object_unref ((CamelObject *)m->folder);
+}
+
+static MailMsgInfo sync_folder_info = {
+	sizeof (struct _sync_folder_msg),
+	(MailMsgDescFunc) sync_folder_desc,
+	(MailMsgExecFunc) sync_folder_exec,
+	(MailMsgDoneFunc) sync_folder_done,
+	(MailMsgFreeFunc) sync_folder_free
+};
+
+void
+mail_sync_folder(CamelFolder *folder, gboolean expunge, void (*done) (CamelFolder *folder, gpointer data, GError *error), gpointer data)
+{
+	struct _sync_folder_msg *m;
+
+	m = mail_msg_new(&sync_folder_info);
+	m->folder = folder;
+	m->expunge = expunge;
+	g_object_ref (folder);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ** SYNC STORE ********************************************************* */
+
+struct _sync_store_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	gint expunge;
+	void (*done) (CamelStore *store, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+sync_store_desc (struct _sync_store_msg *m)
+{
+	gchar *uri, *res;
+
+	uri = camel_url_to_string(((CamelService *)m->store)->url, CAMEL_URL_HIDE_ALL);
+	res = g_strdup_printf(m->expunge
+			      ?_("Expunging and storing account '%s'")
+			      :_("Storing account '%s'"),
+			      uri);
+	g_free(uri);
+
+	return res;
+}
+
+static void
+sync_store_exec (struct _sync_store_msg *m)
+{
+	camel_store_sync(m->store, m->expunge, &m->base.error);
+}
+
+static void
+sync_store_done (struct _sync_store_msg *m)
+{
+	if (m->done)
+		m->done(m->store, m->data, m->base.error);
+}
+
+static void
+sync_store_free (struct _sync_store_msg *m)
+{
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo sync_store_info = {
+	sizeof (struct _sync_store_msg),
+	(MailMsgDescFunc) sync_store_desc,
+	(MailMsgExecFunc) sync_store_exec,
+	(MailMsgDoneFunc) sync_store_done,
+	(MailMsgFreeFunc) sync_store_free
+};
+
+void
+mail_sync_store(CamelStore *store, gint expunge, void (*done) (CamelStore *store, gpointer data, GError *error), gpointer data)
+{
+	struct _sync_store_msg *m;
+
+	m = mail_msg_new(&sync_store_info);
+	m->store = store;
+	m->expunge = expunge;
+	g_object_ref (store);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ******************************************************************************** */
+
+static gchar *
+refresh_folder_desc (struct _sync_folder_msg *m)
+{
+	return g_strdup_printf (_("Refreshing folder '%s'"), camel_folder_get_full_name (m->folder));
+}
+
+static void
+refresh_folder_exec (struct _sync_folder_msg *m)
+{
+	/* camel_folder_sync (m->folder, FALSE, &m->base.error); */
+
+	/* if (!camel_exception_is_set (&m->base.error)) */
+		camel_folder_refresh_info(m->folder, &m->base.error);
+}
+
+/* we just use the sync stuff where we can, since it would be the same */
+static MailMsgInfo refresh_folder_info = {
+	sizeof (struct _sync_folder_msg),
+	(MailMsgDescFunc) refresh_folder_desc,
+	(MailMsgExecFunc) refresh_folder_exec,
+	(MailMsgDoneFunc) sync_folder_done,
+	(MailMsgFreeFunc) sync_folder_free
+};
+
+void
+mail_refresh_folder(CamelFolder *folder, void (*done) (CamelFolder *folder, gpointer data, GError *error), gpointer data)
+{
+	struct _sync_folder_msg *m;
+
+	m = mail_msg_new(&refresh_folder_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ******************************************************************************** */
+
+static gchar *
+expunge_folder_desc (struct _sync_folder_msg *m)
+{
+	return g_strdup_printf (_("Expunging folder '%s'"), camel_folder_get_full_name (m->folder));
+}
+
+static void
+expunge_folder_exec (struct _sync_folder_msg *m)
+{
+	camel_folder_expunge(m->folder, &m->base.error);
+}
+
+/* we just use the sync stuff where we can, since it would be the same */
+static MailMsgInfo expunge_folder_info = {
+	sizeof (struct _sync_folder_msg),
+	(MailMsgDescFunc) expunge_folder_desc,
+	(MailMsgExecFunc) expunge_folder_exec,
+	(MailMsgDoneFunc) sync_folder_done,
+	(MailMsgFreeFunc) sync_folder_free
+};
+
+void
+mail_expunge_folder(CamelFolder *folder, void (*done) (CamelFolder *folder, gpointer data, GError *error), gpointer data)
+{
+	struct _sync_folder_msg *m;
+
+	m = mail_msg_new(&expunge_folder_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ******************************************************************************** */
+
+struct _empty_trash_msg {
+	MailMsg base;
+
+	EAccount *account;
+	void (*done) (EAccount *account, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+empty_trash_desc (struct _empty_trash_msg *m)
+{
+	return g_strdup_printf (_("Emptying trash in '%s'"),
+				m->account ? m->account->name : _("Local Folders"));
+}
+
+static void
+empty_trash_exec (struct _empty_trash_msg *m)
+{
+	const gchar *data_dir;
+	CamelFolder *trash;
+	gchar *uri;
+
+	if (m->account) {
+		trash = mail_tool_get_trash (m->account->source->url, FALSE, &m->base.error);
+	} else {
+		data_dir = mail_session_get_data_dir ();
+		uri = g_strdup_printf ("mbox:%s/local", data_dir);
+		trash = mail_tool_get_trash (uri, TRUE, &m->base.error);
+		g_free (uri);
+	}
+
+	if (trash) {
+		camel_folder_expunge (trash, &m->base.error);
+		g_object_unref (trash);
+	}
+}
+
+static void
+empty_trash_done (struct _empty_trash_msg *m)
+{
+	if (m->done)
+		m->done(m->account, m->data);
+}
+
+static void
+empty_trash_free (struct _empty_trash_msg *m)
+{
+	if (m->account)
+		g_object_unref(m->account);
+}
+
+static MailMsgInfo empty_trash_info = {
+	sizeof (struct _empty_trash_msg),
+	(MailMsgDescFunc) empty_trash_desc,
+	(MailMsgExecFunc) empty_trash_exec,
+	(MailMsgDoneFunc) empty_trash_done,
+	(MailMsgFreeFunc) empty_trash_free
+};
+
+void
+mail_empty_trash(EAccount *account, void (*done) (EAccount *account, gpointer data), gpointer data)
+{
+	struct _empty_trash_msg *m;
+
+	m = mail_msg_new(&empty_trash_info);
+	m->account = account;
+	if (account)
+		g_object_ref(account);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ** GET MESSAGE(s) ***************************************************** */
+
+struct _get_message_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	gchar *uid;
+	void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data);
+	gpointer data;
+	CamelMimeMessage *message;
+	CamelOperation *cancel;
+};
+
+static gchar *
+get_message_desc (struct _get_message_msg *m)
+{
+	return g_strdup_printf (_("Retrieving message '%s'"), m->uid);
+}
+
+static void
+get_message_exec (struct _get_message_msg *m)
+{
+	if (m->base.cancel && camel_operation_cancel_check (m->base.cancel))
+		m->message = NULL;
+	else
+		m->message = camel_folder_get_message (m->folder, m->uid, &m->base.error);
+}
+
+static void
+get_message_done (struct _get_message_msg *m)
+{
+	if (m->done)
+		m->done(m->folder, m->uid, m->message, m->data);
+}
+
+static void
+get_message_free (struct _get_message_msg *m)
+{
+	g_free (m->uid);
+	g_object_unref (m->folder);
+	camel_operation_unref (m->cancel);
+
+	if (m->message)
+		g_object_unref (m->message);
+}
+
+static MailMsgInfo get_message_info = {
+	sizeof (struct _get_message_msg),
+	(MailMsgDescFunc) get_message_desc,
+	(MailMsgExecFunc) get_message_exec,
+	(MailMsgDoneFunc) get_message_done,
+	(MailMsgFreeFunc) get_message_free
+};
+
+gint
+mail_get_message(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolder *folder, const gchar *uid,
+								     CamelMimeMessage *msg, gpointer data),
+		 gpointer data, MailMsgDispatchFunc dispatch)
+{
+	struct _get_message_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_message_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->uid = g_strdup(uid);
+	m->data = data;
+	m->done = (void (*) (CamelFolder *, const gchar *, CamelMimeMessage *, gpointer )) done;
+	m->cancel = camel_operation_new(NULL, NULL);
+	id = m->base.seq;
+
+	dispatch (m);
+
+	return id;
+}
+
+typedef void (*get_done)(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, GError **error);
+
+static void
+get_messagex_done (struct _get_message_msg *m)
+{
+	if (m->done && !camel_operation_cancel_check (m->cancel)) {
+		get_done done = (get_done)m->done;
+		done(m->folder, m->uid, m->message, m->data, &m->base.error);
+	}
+}
+
+static MailMsgInfo get_messagex_info = {
+	sizeof (struct _get_message_msg),
+	(MailMsgDescFunc) get_message_desc,
+	(MailMsgExecFunc) get_message_exec,
+	(MailMsgDoneFunc) get_messagex_done,
+	(MailMsgFreeFunc) get_message_free
+};
+
+/* This is temporary, to avoid having to rewrite everything that uses
+   mail_get_message; it adds an exception argument to the callback */
+gint
+mail_get_messagex (CamelFolder *folder,
+                   const gchar *uid,
+                   void (*done) (CamelFolder *folder,
+                                 const gchar *uid,
+                                 CamelMimeMessage *msg,
+                                 gpointer data,
+                                 GError **error),
+                   gpointer data,
+                   MailMsgDispatchFunc dispatch)
+{
+	struct _get_message_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_messagex_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->uid = g_strdup(uid);
+	m->data = data;
+	m->done = (void (*) (CamelFolder *, const gchar *, CamelMimeMessage *, gpointer )) done;
+	m->cancel = camel_operation_new(NULL, NULL);
+	id = m->base.seq;
+
+	dispatch (m);
+
+	return id;
+}
+
+/* ********************************************************************** */
+
+struct _get_messages_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	GPtrArray *uids;
+	GPtrArray *messages;
+
+	void (*done) (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+get_messages_desc (struct _get_messages_msg *m)
+{
+	return g_strdup_printf(ngettext("Retrieving %d message",
+					"Retrieving %d messages", m->uids->len),
+			       m->uids->len);
+}
+
+static void
+get_messages_exec (struct _get_messages_msg *m)
+{
+	gint i;
+	CamelMimeMessage *message;
+
+	for (i=0; i<m->uids->len; i++) {
+		gint pc = ((i+1) * 100) / m->uids->len;
+
+		message = camel_folder_get_message(m->folder, m->uids->pdata[i], &m->base.error);
+		camel_operation_progress(m->base.cancel, pc);
+		if (message == NULL)
+			break;
+
+		g_ptr_array_add(m->messages, message);
+	}
+}
+
+static void
+get_messages_done (struct _get_messages_msg *m)
+{
+	if (m->done)
+		m->done(m->folder, m->uids, m->messages, m->data);
+}
+
+static void
+get_messages_free (struct _get_messages_msg *m)
+{
+	gint i;
+
+	em_utils_uids_free (m->uids);
+	for (i=0;i<m->messages->len;i++) {
+		if (m->messages->pdata[i])
+			g_object_unref (m->messages->pdata[i]);
+	}
+	g_ptr_array_free(m->messages, TRUE);
+	g_object_unref (m->folder);
+}
+
+static MailMsgInfo get_messages_info = {
+	sizeof (struct _get_messages_msg),
+	(MailMsgDescFunc) get_messages_desc,
+	(MailMsgExecFunc) get_messages_exec,
+	(MailMsgDoneFunc) get_messages_done,
+	(MailMsgFreeFunc) get_messages_free
+};
+
+gint
+mail_get_messages(CamelFolder *folder, GPtrArray *uids,
+		  void (*done) (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer data),
+		  gpointer data)
+{
+	struct _get_messages_msg *m;
+	gint id;
+
+	m = mail_msg_new(&get_messages_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->uids = uids;
+	m->messages = g_ptr_array_new();
+	m->data = data;
+	m->done = done;
+	id = m->base.seq;
+
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** SAVE MESSAGES ******************************************************* */
+
+struct _save_messages_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	GPtrArray *uids;
+	gchar *path;
+	void (*done)(CamelFolder *folder, GPtrArray *uids, gchar *path, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+save_messages_desc (struct _save_messages_msg *m)
+{
+	return g_strdup_printf(ngettext("Saving %d message",
+					"Saving %d messages", m->uids->len),
+			       m->uids->len);
+}
+
+static void
+save_prepare_part (CamelMimePart *mime_part)
+{
+	CamelDataWrapper *wrapper;
+	gint parts, i;
+
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
+	if (!wrapper)
+		return;
+
+	if (CAMEL_IS_MULTIPART (wrapper)) {
+		parts = camel_multipart_get_number (CAMEL_MULTIPART (wrapper));
+		for (i = 0; i < parts; i++) {
+			CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (wrapper), i);
+
+			save_prepare_part (part);
+		}
+	} else {
+		if (CAMEL_IS_MIME_MESSAGE (wrapper)) {
+			/* prepare the message parts' subparts */
+			save_prepare_part (CAMEL_MIME_PART (wrapper));
+		} else {
+			CamelContentType *type;
+
+			/* We want to save textual parts as 8bit instead of encoded */
+			type = camel_data_wrapper_get_mime_type_field (wrapper);
+			if (camel_content_type_is (type, "text", "*"))
+				camel_mime_part_set_encoding (mime_part, CAMEL_TRANSFER_ENCODING_8BIT);
+		}
+	}
+}
+
+static void
+save_messages_exec (struct _save_messages_msg *m)
+{
+	CamelStream *filtered_stream;
+	CamelMimeFilter *from_filter;
+	CamelStream *stream;
+	gint i;
+	gchar *from, *path;
+
+	if (strstr (m->path, "://"))
+		path = m->path;
+	else
+		path = g_filename_to_uri (m->path, NULL, NULL);
+
+	stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE);
+	from_filter = camel_mime_filter_from_new();
+	filtered_stream = camel_stream_filter_new (stream);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), from_filter);
+	g_object_unref (from_filter);
+
+	if (path != m->path)
+		g_free (path);
+
+	for (i=0; i<m->uids->len; i++) {
+		CamelMimeMessage *message;
+		gint pc = ((i+1) * 100) / m->uids->len;
+
+		message = camel_folder_get_message(m->folder, m->uids->pdata[i], &m->base.error);
+		camel_operation_progress(m->base.cancel, pc);
+		if (message == NULL)
+			break;
+
+		save_prepare_part (CAMEL_MIME_PART (message));
+
+		/* we need to flush after each stream write since we are writing to the same fd */
+		from = camel_mime_message_build_mbox_from(message);
+		if (camel_stream_write_string (
+			stream, from, &m->base.error) == -1
+		    || camel_stream_flush(stream, &m->base.error) == -1
+		    || camel_data_wrapper_write_to_stream (
+			(CamelDataWrapper *) message,
+			(CamelStream *)filtered_stream, &m->base.error) == -1
+		    || camel_stream_flush (
+			(CamelStream *)filtered_stream, &m->base.error) == -1
+		    || camel_stream_write_string (
+			stream, "\n", &m->base.error) == -1
+		    || camel_stream_flush(stream, &m->base.error) == -1) {
+			g_prefix_error (
+				&m->base.error,
+				_("Error saving messages to: %s:\n"),
+				m->path);
+			g_free(from);
+			g_object_unref ((CamelObject *)message);
+			break;
+		}
+		g_free(from);
+		g_object_unref (message);
+	}
+
+	g_object_unref (filtered_stream);
+	g_object_unref (stream);
+}
+
+static void
+save_messages_done (struct _save_messages_msg *m)
+{
+	if (m->done)
+		m->done(m->folder, m->uids, m->path, m->data);
+}
+
+static void
+save_messages_free (struct _save_messages_msg *m)
+{
+	em_utils_uids_free (m->uids);
+	g_object_unref (m->folder);
+	g_free(m->path);
+}
+
+static MailMsgInfo save_messages_info = {
+	sizeof (struct _save_messages_msg),
+	(MailMsgDescFunc) save_messages_desc,
+	(MailMsgExecFunc) save_messages_exec,
+	(MailMsgDoneFunc) save_messages_done,
+	(MailMsgFreeFunc) save_messages_free
+};
+
+gint
+mail_save_messages(CamelFolder *folder, GPtrArray *uids, const gchar *path,
+		   void (*done) (CamelFolder *folder, GPtrArray *uids, gchar *path, gpointer data), gpointer data)
+{
+	struct _save_messages_msg *m;
+	gint id;
+
+	m = mail_msg_new(&save_messages_info);
+	m->folder = folder;
+	g_object_ref (folder);
+	m->uids = uids;
+	m->path = g_strdup(path);
+	m->data = data;
+	m->done = done;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** SAVE PART ******************************************************* */
+
+struct _save_part_msg {
+	MailMsg base;
+
+	CamelMimePart *part;
+	gchar *path;
+	void (*done)(CamelMimePart *part, gchar *path, gint saved, gpointer data);
+	gpointer data;
+	gboolean readonly;
+};
+
+static gchar *
+save_part_desc (struct _save_part_msg *m)
+{
+	return g_strdup(_("Saving attachment"));
+}
+
+static void
+save_part_exec (struct _save_part_msg *m)
+{
+	CamelDataWrapper *content;
+	CamelStream *stream;
+	gchar *path;
+
+	if (strstr (m->path, "://"))
+		path = m->path;
+	else
+		path = g_filename_to_uri (m->path, NULL, NULL);
+
+	if (!m->readonly) {
+		if (!(stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE))) {
+			g_set_error (
+				&m->base.error, G_FILE_ERROR,
+				g_file_error_from_errno (errno),
+				_("Cannot create output file: %s:\n %s"),
+				path, g_strerror (errno));
+			if (path != m->path)
+				g_free (path);
+			return;
+		}
+	} else if (!(stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE))) {
+		g_set_error (
+			&m->base.error, G_FILE_ERROR,
+			g_file_error_from_errno (errno),
+			_("Cannot create output file: %s:\n %s"),
+			path, g_strerror (errno));
+		if (path != m->path)
+			g_free (path);
+		return;
+	}
+
+	if (path != m->path)
+		g_free (path);
+
+	content = camel_medium_get_content (CAMEL_MEDIUM (m->part));
+
+	if (camel_data_wrapper_decode_to_stream (
+		content, stream, &m->base.error) == -1
+	    || camel_stream_flush (stream, &m->base.error) == -1)
+		g_prefix_error (&m->base.error, _("Could not write data: "));
+
+	g_object_unref (stream);
+}
+
+static void
+save_part_done (struct _save_part_msg *m)
+{
+	if (m->done)
+		m->done (m->part, m->path, m->base.error == NULL, m->data);
+}
+
+static void
+save_part_free (struct _save_part_msg *m)
+{
+	g_object_unref (m->part);
+	g_free (m->path);
+}
+
+static MailMsgInfo save_part_info = {
+	sizeof (struct _save_part_msg),
+	(MailMsgDescFunc) save_part_desc,
+	(MailMsgExecFunc) save_part_exec,
+	(MailMsgDoneFunc) save_part_done,
+	(MailMsgFreeFunc) save_part_free
+};
+
+gint
+mail_save_part (CamelMimePart *part, const gchar *path,
+		void (*done)(CamelMimePart *part, gchar *path, gint saved, gpointer data), gpointer data, gboolean readonly)
+{
+	struct _save_part_msg *m;
+	gint id;
+	m = mail_msg_new (&save_part_info);
+	m->part = part;
+	g_object_ref (part);
+	m->path = g_strdup (path);
+	m->data = data;
+	m->done = done;
+	m->readonly = readonly;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** PREPARE OFFLINE ***************************************************** */
+
+struct _prep_offline_msg {
+	MailMsg base;
+
+	CamelOperation *cancel;
+	gchar *uri;
+	void (*done)(const gchar *uri, gpointer data);
+	gpointer data;
+};
+
+static void
+prep_offline_exec (struct _prep_offline_msg *m)
+{
+	CamelFolder *folder;
+
+	if (m->cancel)
+		camel_operation_register(m->cancel);
+
+	folder = mail_tool_uri_to_folder(m->uri, 0, &m->base.error);
+	if (folder) {
+		if (CAMEL_IS_DISCO_FOLDER(folder)) {
+			camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder,
+							       "(match-all)",
+							       &m->base.error);
+		} else if (CAMEL_IS_OFFLINE_FOLDER (folder)) {
+			camel_offline_folder_downsync ((CamelOfflineFolder *) folder, "(match-all)", &m->base.error);
+		}
+		/* prepare_for_offline should do this? */
+		/* of course it should all be atomic, but ... */
+		camel_folder_sync(folder, FALSE, NULL);
+		g_object_unref (folder);
+	}
+
+	if (m->cancel)
+		camel_operation_unregister(m->cancel);
+}
+
+static void
+prep_offline_done (struct _prep_offline_msg *m)
+{
+	if (m->done)
+		m->done(m->uri, m->data);
+}
+
+static void
+prep_offline_free (struct _prep_offline_msg *m)
+{
+	if (m->cancel)
+		camel_operation_unref(m->cancel);
+	g_free(m->uri);
+}
+
+static MailMsgInfo prep_offline_info = {
+	sizeof (struct _prep_offline_msg),
+	(MailMsgDescFunc) NULL, /* DO NOT CHANGE THIS, IT MUST BE NULL FOR CANCELLATION TO WORK */
+	(MailMsgExecFunc) prep_offline_exec,
+	(MailMsgDoneFunc) prep_offline_done,
+	(MailMsgFreeFunc) prep_offline_free
+};
+
+void
+mail_prep_offline(const gchar *uri,
+		  CamelOperation *cancel,
+		  void (*done)(const gchar *, gpointer data),
+		  gpointer data)
+{
+	struct _prep_offline_msg *m;
+
+	m = mail_msg_new(&prep_offline_info);
+	m->cancel = cancel;
+	if (cancel)
+		camel_operation_ref(cancel);
+	m->uri = g_strdup(uri);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ** GO OFFLINE ***************************************************** */
+
+struct _set_offline_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	gboolean offline;
+	void (*done)(CamelStore *store, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+set_offline_desc (struct _set_offline_msg *m)
+{
+	gchar *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
+	gchar *msg;
+
+	msg = g_strdup_printf (m->offline ? _("Disconnecting from '%s'") : _("Reconnecting to '%s'"),
+			       service_name);
+	g_free(service_name);
+	return msg;
+}
+
+static void
+set_offline_exec (struct _set_offline_msg *m)
+{
+	if (CAMEL_IS_DISCO_STORE (m->store)) {
+		if (!m->offline) {
+			camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store),
+						      CAMEL_DISCO_STORE_ONLINE,
+						      &m->base.error);
+			return;
+		} else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (m->store))) {
+			camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store),
+						      CAMEL_DISCO_STORE_OFFLINE,
+						      &m->base.error);
+			return;
+		}
+	} else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
+		if (!m->offline) {
+			camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (m->store),
+							       CAMEL_OFFLINE_STORE_NETWORK_AVAIL,
+							       &m->base.error);
+			return;
+		} else {
+			camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (m->store),
+							       CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL,
+							       &m->base.error);
+			return;
+		}
+	}
+
+	if (m->offline)
+		camel_service_disconnect (CAMEL_SERVICE (m->store),
+					  TRUE, &m->base.error);
+}
+
+static void
+set_offline_done (struct _set_offline_msg *m)
+{
+	if (m->done)
+		m->done(m->store, m->data);
+}
+
+static void
+set_offline_free (struct _set_offline_msg *m)
+{
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo set_offline_info = {
+	sizeof (struct _set_offline_msg),
+	(MailMsgDescFunc) set_offline_desc,
+	(MailMsgExecFunc) set_offline_exec,
+	(MailMsgDoneFunc) set_offline_done,
+	(MailMsgFreeFunc) set_offline_free
+};
+
+gint
+mail_store_set_offline (CamelStore *store, gboolean offline,
+			void (*done)(CamelStore *, gpointer data),
+			gpointer data)
+{
+	struct _set_offline_msg *m;
+	gint id;
+
+	/* Cancel any pending connect first so the set_offline_op
+	 * thread won't get queued behind a hung connect op.
+	 */
+	if (offline)
+		camel_service_cancel_connect (CAMEL_SERVICE (store));
+
+	m = mail_msg_new(&set_offline_info);
+	m->store = store;
+	g_object_ref (store);
+	m->offline = offline;
+	m->data = data;
+	m->done = done;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** Prepare OFFLINE ***************************************************** */
+
+static gchar *
+prepare_offline_desc (struct _set_offline_msg *m)
+{
+	gchar *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
+	gchar *msg;
+
+	msg = g_strdup_printf (_("Preparing account '%s' for offline"), service_name);
+	g_free(service_name);
+
+	return msg;
+}
+
+static void
+prepare_offline_exec (struct _set_offline_msg *m)
+{
+	if (CAMEL_IS_DISCO_STORE (m->store)) {
+		camel_disco_store_prepare_for_offline (CAMEL_DISCO_STORE (m->store),
+					       &m->base.error);
+	} else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
+		camel_offline_store_prepare_for_offline (CAMEL_OFFLINE_STORE (m->store),
+							 &m->base.error);
+	}
+}
+
+static void
+prepare_offline_done (struct _set_offline_msg *m)
+{
+	if (m->done)
+		m->done (m->store, m->data);
+}
+
+static void
+prepare_offline_free (struct _set_offline_msg *m)
+{
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo prepare_offline_info = {
+	sizeof (struct _set_offline_msg),
+	(MailMsgDescFunc) prepare_offline_desc,
+	(MailMsgExecFunc) prepare_offline_exec,
+	(MailMsgDoneFunc) prepare_offline_done,
+	(MailMsgFreeFunc) prepare_offline_free
+};
+
+gint
+mail_store_prepare_offline (CamelStore *store)
+{
+	struct _set_offline_msg *m;
+	gint id;
+
+	/* Cancel any pending connect first so the set_offline_op
+	 * thread won't get queued behind a hung connect op.
+	 */
+
+	m = mail_msg_new(&prepare_offline_info);
+	m->store = store;
+	g_object_ref (store);
+	m->data = NULL;
+	m->done = NULL;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+/* ** Execute Shell Command ***************************************************** */
+
+void
+mail_execute_shell_command (CamelFilterDriver *driver, gint argc, gchar **argv, gpointer data)
+{
+	if (argc <= 0)
+		return;
+
+	g_spawn_async (NULL, argv, NULL, 0, NULL, data, NULL, NULL);
+}
+
+/* Async service-checking/authtype-lookup code. */
+struct _check_msg {
+	MailMsg base;
+
+	gchar *url;
+	CamelProviderType type;
+	GList *authtypes;
+
+	void (*done)(const gchar *url, CamelProviderType type, GList *types, gpointer data);
+	gpointer data;
+};
+
+static gchar *
+check_service_desc (struct _check_msg *m)
+{
+	return g_strdup(_("Checking Service"));
+}
+
+static void
+check_service_exec (struct _check_msg *m)
+{
+	CamelService *service;
+
+	service = camel_session_get_service(session, m->url, m->type, &m->base.error);
+	if (!service) {
+		camel_operation_unregister(m->base.cancel);
+		return;
+	}
+
+	m->authtypes = camel_service_query_auth_types(service, &m->base.error);
+	g_object_unref (service);
+}
+
+static void
+check_service_done (struct _check_msg *m)
+{
+	if (m->done)
+		m->done(m->url, m->type, m->authtypes, m->data);
+}
+
+static void
+check_service_free (struct _check_msg *m)
+{
+	g_free(m->url);
+	g_list_free(m->authtypes);
+}
+
+static MailMsgInfo check_service_info = {
+	sizeof (struct _check_msg),
+	(MailMsgDescFunc) check_service_desc,
+	(MailMsgExecFunc) check_service_exec,
+	(MailMsgDoneFunc) check_service_done,
+	(MailMsgFreeFunc) check_service_free
+};
+
+gint
+mail_check_service(const gchar *url, CamelProviderType type, void (*done)(const gchar *url, CamelProviderType type, GList *authtypes, gpointer data), gpointer data)
+{
+	struct _check_msg *m;
+	gint id;
+
+	m = mail_msg_new (&check_service_info);
+	m->url = g_strdup(url);
+	m->type = type;
+	m->done = done;
+	m->data = data;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* Create Folder */
+struct _mail_create_folder {
+	MailMsg base;
+
+	/* input data */
+	CamelStore *store;
+	gchar *parent;
+	gchar *folder_name;
+
+	/* output data */
+	CamelFolderInfo *fi;
+
+	/* callback data */
+	void (* done) (CamelFolderInfo *fi, gpointer user_data, GError *error);
+	gpointer user_data;
+};
+
+
+static gchar *
+mail_create_folder__desc (struct _mail_create_folder *m)
+{
+	return g_strdup_printf (_("Creating folder '%s'"), m->folder_name);
+}
+
+static void
+mail_create_folder__exec (struct _mail_create_folder *m)
+{
+	d(printf ("creating folder parent='%s' name='%s' full_name='%s'\n", m->parent, m->folder_name));
+
+	m->fi = camel_store_create_folder (m->store, m->parent, m->folder_name, &m->base.error);
+}
+
+static void
+mail_create_folder__done (struct _mail_create_folder *m)
+{
+	if (m->done)
+		m->done (m->fi, m->user_data, m->base.error);
+}
+
+static void
+mail_create_folder__free (struct _mail_create_folder *m)
+{
+	camel_store_free_folder_info (m->store, m->fi);
+	g_object_unref (m->store);
+	g_free (m->parent);
+	g_free (m->folder_name);
+}
+
+static MailMsgInfo create_folder_info = {
+	sizeof (struct _mail_create_folder),
+	(MailMsgDescFunc) mail_create_folder__desc,
+	(MailMsgExecFunc) mail_create_folder__exec,
+	(MailMsgDoneFunc) mail_create_folder__done,
+	(MailMsgFreeFunc) mail_create_folder__free
+};
+
+gint
+mail_create_folder (CamelStore *store, const char *parent, const char *folder_name, void (* done) (CamelFolderInfo *fi, gpointer user_data, GError *error), gpointer user_data)
+{
+	struct _mail_create_folder *m;
+	gint id;
+
+	m = mail_msg_new (&create_folder_info);
+	g_object_ref (store);
+	m->store = store;
+	m->parent = g_strdup (parent);
+	m->folder_name = g_strdup (folder_name);
+	m->user_data = user_data;
+	m->done = done;
+
+	id = m->base.seq;
+	mail_msg_unordered_push (m);
+
+	return id;
+}
+
+/* ** Delete FOLDER ******************************************************* */
+
+struct _delete_folder_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	char *folder;
+	void (*done) (gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+delete_folder_desc (struct _delete_folder_msg *m)
+{
+	return g_strdup_printf (_("Deleting folder '%s'"), m->folder);
+}
+
+static void
+delete_folder_exec (struct _delete_folder_msg *m)
+{
+	camel_store_delete_folder (m->store, m->folder, &m->base.error);
+}
+
+static void
+delete_folder_done (struct _delete_folder_msg *m)
+{
+	if (m->done)
+		m->done (m->data, m->base.error);
+}
+
+static void
+delete_folder_free (struct _delete_folder_msg *m)
+{
+	g_object_unref (m->store);
+	g_free (m->folder);
+}
+
+static MailMsgInfo delete_folder_info = {
+	sizeof (struct _delete_folder_msg),
+	(MailMsgDescFunc) delete_folder_desc,
+	(MailMsgExecFunc) delete_folder_exec,
+	(MailMsgDoneFunc) delete_folder_done,
+	(MailMsgFreeFunc) delete_folder_free
+};
+
+void
+mail_delete_folder (CamelStore *store, const char *folder, void (*done) (gpointer data, GError *error), gpointer data)
+{
+	struct _delete_folder_msg *m;
+
+	g_return_if_fail (folder != NULL);
+
+	m = mail_msg_new (&delete_folder_info);
+	m->folder = g_strdup (folder);
+	g_object_ref (store);
+	m->store = store;
+	m->data = data;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** Rename FOLDER ******************************************************* */
+
+struct _rename_folder_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	char *oldname;
+	char *newname;
+	void (*done) (gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+rename_folder_desc (struct _rename_folder_msg *m)
+{
+	return g_strdup_printf (_("Renaming folder '%s' to '%s'"), m->oldname, m->newname);
+}
+
+static void
+rename_folder_exec (struct _rename_folder_msg *m)
+{
+	camel_store_rename_folder (m->store, m->oldname, m->newname, &m->base.error);
+}
+
+static void
+rename_folder_done (struct _rename_folder_msg *m)
+{
+	if (m->done)
+		m->done (m->data, m->base.error);
+}
+
+static void
+rename_folder_free (struct _rename_folder_msg *m)
+{
+	g_object_unref (m->store);
+	g_free (m->oldname);
+	g_free (m->newname);
+}
+
+static MailMsgInfo rename_folder_info = {
+	sizeof (struct _rename_folder_msg),
+	(MailMsgDescFunc) rename_folder_desc,
+	(MailMsgExecFunc) rename_folder_exec,
+	(MailMsgDoneFunc) rename_folder_done,
+	(MailMsgFreeFunc) rename_folder_free
+};
+
+void
+mail_rename_folder (CamelStore *store, const char *oldname, const char *newname, void (*done) (gpointer data, GError *error), gpointer data)
+{
+	struct _rename_folder_msg *m;
+
+	m = mail_msg_new (&rename_folder_info);
+	m->oldname = g_strdup (oldname);
+	m->newname = g_strdup (newname);
+	g_object_ref (store);
+	m->store = store;
+	m->data = data;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** FOLDER Subscription ******************************************************* */
+
+struct _sub_folder_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	gboolean ret;
+	char *folder;
+	MailFolderSubscription operation;
+
+	void (*done) (gboolean success, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+sub_folder_desc (struct _sub_folder_msg *m)
+{
+	return g_strdup_printf (_("Folder subscription '%s'"), m->folder);
+}
+
+static void
+sub_folder_exec (struct _sub_folder_msg *m)
+{
+	if (m->operation == FOLDER_SUBSCRIBE)
+		m->ret = camel_store_subscribe_folder (m->store, m->folder, &m->base.error);
+	else if (m->operation == FOLDER_UNSUBSCRIBE)
+		m->ret = camel_store_folder_is_subscribed (m->store, m->folder);
+	else
+		m->ret = camel_store_unsubscribe_folder (m->store, m->folder, &m->base.error);
+}
+
+static void
+sub_folder_done (struct _sub_folder_msg *m)
+{
+	if (m->done)
+		m->done (m->ret, m->data, m->base.error);
+}
+
+static void
+sub_folder_free (struct _sub_folder_msg *m)
+{
+	g_object_unref (m->store);
+	g_free (m->folder);
+}
+
+static MailMsgInfo sub_folder_info = {
+	sizeof (struct _sub_folder_msg),
+	(MailMsgDescFunc) sub_folder_desc,
+	(MailMsgExecFunc) sub_folder_exec,
+	(MailMsgDoneFunc) sub_folder_done,
+	(MailMsgFreeFunc) sub_folder_free
+};
+
+void
+mail_folder_subscription (CamelStore *store, const char *folder, MailFolderSubscription operation, void (*done) (gboolean ret, gpointer data, GError *error), gpointer data)
+{
+	struct _sub_folder_msg *m;
+
+	m = mail_msg_new (&sub_folder_info);
+	m->folder = g_strdup (folder);
+	g_object_ref (store);
+	m->operation = operation;
+	m->store = store;
+	m->data = data;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
+
+/* ** NOOP STORE ********************************************************* */
+
+struct _noop_store_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	void (*done) (CamelStore *store, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+noop_store_desc (struct _noop_store_msg *m)
+{
+	gchar *uri, *res;
+
+	uri = camel_url_to_string(((CamelService *)m->store)->url, CAMEL_URL_HIDE_ALL);
+	res = g_strdup_printf(_("Pinging account '%s'"), uri);
+	g_free(uri);
+
+	return res;
+}
+
+static void
+noop_store_exec (struct _noop_store_msg *m)
+{
+	camel_store_noop (m->store, &m->base.error);
+}
+
+static void
+noop_store_done (struct _noop_store_msg *m)
+{
+	if (m->done)
+		m->done(m->store, m->data, m->base.error);
+}
+
+static void
+noop_store_free (struct _noop_store_msg *m)
+{
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo noop_store_info = {
+	sizeof (struct _noop_store_msg),
+	(MailMsgDescFunc) noop_store_desc,
+	(MailMsgExecFunc) noop_store_exec,
+	(MailMsgDoneFunc) noop_store_done,
+	(MailMsgFreeFunc) noop_store_free
+};
+
+void
+mail_noop_store(CamelStore *store, void (*done) (CamelStore *store, gpointer data, GError *error), gpointer data)
+{
+	struct _noop_store_msg *m;
+
+	m = mail_msg_new(&noop_store_info);
+	m->store = store;
+	g_object_ref (store);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* ** can_refresh_folder STORE ********************************************************* */
+
+struct _can_refresh_folder_msg {
+	MailMsg base;
+
+	CamelStore *store;
+	CamelFolderInfo *info;
+	gboolean ret;
+	void (*done) (gboolean success, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+can_refresh_folder_desc (struct _can_refresh_folder_msg *m)
+{
+	gchar *res;
+
+	res = g_strdup_printf(_("Can Refrsh Folder '%s'"), m->info->full_name);
+
+	return res;
+}
+
+static void
+can_refresh_folder_exec (struct _can_refresh_folder_msg *m)
+{
+	m->ret = camel_store_can_refresh_folder (m->store, m->info, &m->base.error);
+}
+
+static void
+can_refresh_folder_done (struct _can_refresh_folder_msg *m)
+{
+	if (m->done)
+		m->done(m->ret, m->data, m->base.error);
+}
+
+static void
+can_refresh_folder_free (struct _can_refresh_folder_msg *m)
+{
+	g_object_unref (m->store);
+	camel_folder_info_free (m->info);
+}
+
+static MailMsgInfo can_refresh_folder_info = {
+	sizeof (struct _can_refresh_folder_msg),
+	(MailMsgDescFunc) can_refresh_folder_desc,
+	(MailMsgExecFunc) can_refresh_folder_exec,
+	(MailMsgDoneFunc) can_refresh_folder_done,
+	(MailMsgFreeFunc) can_refresh_folder_free
+};
+
+void
+mail_can_refresh_folder(CamelStore *store, CamelFolderInfo *info, void (*done) (gboolean ret, gpointer data, GError *error), gpointer data)
+{
+	struct _can_refresh_folder_msg *m;
+
+	m = mail_msg_new(&can_refresh_folder_info);
+	m->store = store;
+	m->info = info;
+	g_object_ref (store);
+	m->data = data;
+	m->done = done;
+
+	mail_msg_slow_ordered_push (m);
+}
+
+/* Multi Operation holder */
+
+
+struct _multi_op_folder_msg {
+	MailMsg base;
+
+	CamelFolder *folder;
+	gboolean ret;
+	gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error);	
+	void (*done) (gboolean success, gpointer data, GError *error);
+	gpointer data;
+};
+
+static gchar *
+multi_op_folder_desc (struct _multi_op_folder_msg *m)
+{
+	gchar *res;
+
+	res = g_strdup_printf(_("Operating on Folder '%s'"), camel_folder_get_full_name (m->folder));
+
+	return res;
+}
+
+static void
+multi_op_folder_exec (struct _multi_op_folder_msg *m)
+{
+	m->ret = m->do_op (m->folder, m->data, &m->base.error);
+}
+
+static void
+multi_op_folder_done (struct _multi_op_folder_msg *m)
+{
+	if (m->done)
+		m->done(m->ret, m->data, m->base.error);
+}
+
+static void
+multi_op_folder_free (struct _multi_op_folder_msg *m)
+{
+	g_object_unref (m->folder);
+}
+
+static MailMsgInfo multi_op_folder = {
+	sizeof (struct _multi_op_folder_msg),
+	(MailMsgDescFunc) multi_op_folder_desc,
+	(MailMsgExecFunc) multi_op_folder_exec,
+	(MailMsgDoneFunc) multi_op_folder_done,
+	(MailMsgFreeFunc) multi_op_folder_free
+};
+
+void
+mail_operate_on_folder(CamelFolder *folder, 
+		       gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error),
+		       void (*done) (gboolean ret, gpointer data, GError *error), 
+		       gpointer data)
+{
+	struct _multi_op_folder_msg *m;
+
+	m = mail_msg_new(&multi_op_folder);
+	m->folder= folder;
+	g_object_ref (folder);
+	m->data = data;
+	m->do_op = do_op;
+	m->done = done;
+
+	mail_msg_unordered_push (m);
+}
diff --git a/mail/daemon/mail-ops.h b/mail/daemon/mail-ops.h
new file mode 100644
index 0000000..99a371c
--- /dev/null
+++ b/mail/daemon/mail-ops.h
@@ -0,0 +1,198 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Peter Williams <peterw ximian com>
+ *		Michael Zucchi <notzed ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef MAIL_OPS_H
+#define MAIL_OPS_H
+
+G_BEGIN_DECLS
+
+#include <camel/camel.h>
+#include <libedataserver/e-account.h>
+
+#include "mail-mt.h"
+
+void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info,
+		       void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, gint ok,
+				    const gchar *appended_uid, gpointer data),
+		       gpointer data);
+
+void mail_transfer_messages (CamelFolder *source, GPtrArray *uids,
+			     gboolean delete_from_source,
+			     const gchar *dest_uri,
+			     guint32 dest_flags,
+			     void (*done) (gboolean ok, gpointer data),
+			     gpointer data);
+
+/* get a single message, asynchronously */
+gint mail_get_message (CamelFolder *folder, const gchar *uid,
+		       void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data),
+		       gpointer data,
+		       MailMsgDispatchFunc dispatch);
+
+gint
+mail_get_messagex(CamelFolder *folder, const gchar *uid,
+		  void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, GError **error),
+		  gpointer data, MailMsgDispatchFunc dispatch);
+
+/* get several messages */
+gint mail_get_messages (CamelFolder *folder, GPtrArray *uids,
+			void (*done) (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer data),
+			gpointer data);
+
+/* same for a folder */
+gint mail_get_folder (const gchar *uri, guint32 flags,
+		     void (*done) (char *uri, CamelFolder *folder, gpointer data, GError *error), gpointer data,
+		     MailMsgDispatchFunc dispatch);
+
+/* Get a folder from Store by name, or junk/trash/inbox */
+gint mail_get_folder_from_name (CamelStore *store, const gchar *folder_name, 
+		 		gboolean junk, gboolean trash, gboolean inbox, guint32 flags,
+		 		void (*done)(CamelFolder *folder, gpointer data, GError *error),
+		 		gpointer data, MailMsgDispatchFunc dispatch);
+
+/* get quota information for a folder */
+gint mail_get_folder_quota (CamelFolder *folder,
+		 const gchar *folder_uri,
+		 void (*done)(CamelFolder *folder, const gchar *folder_uri, CamelFolderQuotaInfo *quota, gpointer data),
+		 gpointer data, MailMsgDispatchFunc dispatch);
+
+/* and for a store */
+gint mail_get_store (const gchar *uri, CamelOperation *op,
+		    void (*done) (gchar *uri, CamelStore *store, gpointer data, GError *error), gpointer data);
+
+/* build an attachment */
+void mail_build_attachment (CamelFolder *folder, GPtrArray *uids,
+			    void (*done)(CamelFolder *folder, GPtrArray *messages,
+					 CamelMimePart *part, gchar *subject, gpointer data),
+			    gpointer data);
+
+void mail_sync_folder (CamelFolder *folder, gboolean expunge,
+		       void (*done) (CamelFolder *folder, gpointer data, GError *error), gpointer data);
+
+void mail_sync_store(CamelStore *store, gint expunge,
+		     void (*done) (CamelStore *store, gpointer data, GError *error), gpointer data);
+
+void mail_refresh_folder (CamelFolder *folder,
+			  void (*done) (CamelFolder *folder, gpointer data, GError *error),
+			  gpointer data);
+
+void mail_expunge_folder (CamelFolder *folder,
+			  void (*done) (CamelFolder *folder, gpointer data, GError *error),
+			  gpointer data);
+
+void mail_empty_trash (EAccount *account,
+		       void (*done) (EAccount *account, gpointer data),
+		       gpointer data);
+
+/* get folder info asynchronously */
+gint mail_get_folderinfo (CamelStore *store, CamelOperation *op,
+			 gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error),
+			 gpointer data);
+gint mail_get_folderinfo_full (CamelStore *store, const char *top, guint32 flags, CamelOperation *op, gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data, GError *error), gpointer data);
+
+/* remove an existing folder */
+void mail_remove_folder (CamelFolder *folder,
+			 void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data),
+			 gpointer data);
+
+/* transfer (copy/move) a folder */
+void mail_xfer_folder (const gchar *src_uri, const gchar *dest_uri, gboolean remove_source,
+		       void (*done) (gchar *src_uri, gchar *dest_uri, gboolean remove_source,
+				     CamelFolder *folder, gpointer data),
+		       gpointer data);
+
+/* save messages */
+gint mail_save_messages (CamelFolder *folder, GPtrArray *uids, const gchar *path,
+			void (*done) (CamelFolder *folder, GPtrArray *uids, gchar *path, gpointer data),
+			gpointer data);
+
+gint mail_save_part (CamelMimePart *part, const gchar *path,
+		    void (*done)(CamelMimePart *part, gchar *path, gint saved, gpointer data),
+		    gpointer data, gboolean readonly);
+
+/* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */
+void mail_send_queue (CamelFolder *queue, const gchar *destination,
+		      const gchar *type, CamelOperation *cancel,
+		      CamelFilterGetFolderFunc get_folder, gpointer get_data,
+		      CamelFilterStatusFunc *status, gpointer status_data,
+		      void (*done)(const gchar *destination, gpointer data),
+		      gpointer data);
+
+void mail_fetch_mail (const gchar *source, gint keep,
+		      const gchar *type, CamelOperation *cancel,
+		      CamelFilterGetFolderFunc get_folder, gpointer get_data,
+		      CamelFilterStatusFunc *status, gpointer status_data,
+		      void (*done)(const gchar *source, gpointer data),
+		      gpointer data);
+
+void mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids,
+			 const gchar *type, gboolean notify,
+			 CamelOperation *cancel);
+
+/* convenience functions for above */
+void mail_filter_on_demand (CamelFolder *folder, GPtrArray *uids);
+void mail_filter_junk (CamelFolder *folder, GPtrArray *uids);
+
+/* Work Offline */
+void mail_prep_offline(const gchar *uri, CamelOperation *cancel,
+		       void (*done)(const gchar *, gpointer data),
+		       gpointer data);
+gint mail_store_set_offline(CamelStore *store, gboolean offline,
+			   void (*done)(CamelStore *, gpointer data),
+			   gpointer data);
+gint mail_store_prepare_offline (CamelStore *store);
+
+/* filter driver execute shell command async callback */
+void mail_execute_shell_command (CamelFilterDriver *driver, gint argc, gchar **argv, gpointer data);
+
+gint mail_check_service(const gchar *url, CamelProviderType type,
+		       void (*done)(const gchar *url, CamelProviderType type, GList *authtypes, gpointer data), gpointer data);
+
+gint mail_create_folder (CamelStore *store, const char *parent, const char *folder_name, 
+		         void (* done) (CamelFolderInfo *fi, gpointer user_data, GError *error), gpointer user_data);
+void mail_delete_folder (CamelStore *store, const char *folder, 
+			 void (*done) (gpointer data, GError *error), gpointer data);
+void mail_rename_folder (CamelStore *store, const char *oldname, const char *newname, 
+			 void (*done) (gpointer data, GError *error), gpointer data);
+
+typedef enum {
+	FOLDER_SUBSCRIBE=0,
+	FOLDER_UNSUBSCRIBE=1,
+	FOLDER_IS_SUBSCRIBED=2,
+}MailFolderSubscription;
+
+void mail_folder_subscription (CamelStore *store, const char *folder, MailFolderSubscription operation, 
+			 void (*done) (gboolean ret, gpointer data, GError *error), gpointer data);
+void mail_noop_store(CamelStore *store, 
+			 void (*done) (CamelStore *store, gpointer data, GError *error), gpointer data);
+void mail_can_refresh_folder(CamelStore *store, CamelFolderInfo *info, 
+			 void (*done) (gboolean ret, gpointer data, GError *error), gpointer data);
+
+void mail_operate_on_folder(CamelFolder *folder, 
+		       	    gboolean (*do_op) (CamelFolder *folder, gpointer data, GError **error),
+		            void (*done) (gboolean ret, gpointer data, GError *error), 
+		            gpointer data);
+
+G_END_DECLS
+
+#endif /* MAIL_OPS_H */
diff --git a/mail/daemon/mail-send-recv.c b/mail/daemon/mail-send-recv.c
new file mode 100644
index 0000000..28177a3
--- /dev/null
+++ b/mail/daemon/mail-send-recv.c
@@ -0,0 +1,1313 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Michael Zucchi <NotZed ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include <glib/gi18n.h>
+
+#include "libedataserver/e-account-list.h"
+
+#include "e-account-utils.h"
+
+#include "e-mail-local.h"
+#include "mail-config.h"
+#include "mail-folder-cache.h"
+#include "mail-mt.h"
+#include "mail-ops.h"
+#include "mail-send-recv.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+
+#define d(x) x
+
+/* ms between status updates to the gui */
+#define STATUS_TIMEOUT (250)
+
+/* pseudo-uri to key the send task on */
+#define SEND_URI_KEY "send-task:"
+
+/* Prefix for window size GConf keys */
+#define GCONF_KEY_PREFIX "/apps/evolution/mail/send_recv"
+
+/* send/receive email */
+
+/* ********************************************************************** */
+/*  This stuff below is independent of the stuff above */
+
+/* this stuff is used to keep track of which folders filters have accessed, and
+   what not. the thaw/refreeze thing doesn't really seem to work though */
+struct _folder_info {
+	gchar *uri;
+	CamelFolder *folder;
+	time_t update;
+	gint count;		/* how many times updated, to slow it down as we go, if we have lots */
+};
+
+struct _send_data {
+	GList *infos;
+
+	GtkDialog *gd;
+	gint cancelled;
+
+	CamelFolder *inbox;	/* since we're never asked to update this one, do it ourselves */
+	time_t inbox_update;
+
+	GMutex *lock;
+	GHashTable *folders;
+
+	GHashTable *active;	/* send_info's by uri */
+};
+
+typedef enum {
+	SEND_RECEIVE,		/* receiver */
+	SEND_SEND,		/* sender */
+	SEND_UPDATE,		/* imap-like 'just update folder info' */
+	SEND_INVALID
+} send_info_t;
+
+typedef enum {
+	SEND_ACTIVE,
+	SEND_CANCELLED,
+	SEND_COMPLETE
+} send_state_t;
+
+struct _send_info {
+	send_info_t type;		/* 0 = fetch, 1 = send */
+	CamelOperation *cancel;
+	gchar *uri;
+	gboolean keep_on_server;
+	send_state_t state;
+	GtkWidget *progress_bar;
+	GtkWidget *cancel_button;
+	GtkWidget *status_label;
+
+	gint again;		/* need to run send again */
+
+	gint timeout_id;
+	gchar *what;
+	gint pc;
+
+	GtkWidget *send_account_label;
+	gchar *send_url;
+
+	/*time_t update;*/
+	struct _send_data *data;
+};
+
+static CamelFolder *
+		receive_get_folder		(CamelFilterDriver *d,
+						 const gchar *uri,
+						 gpointer data,
+						 GError **error);
+
+static struct _send_data *send_data = NULL;
+static GtkWidget *send_recv_dialog = NULL;
+
+static void
+free_folder_info(struct _folder_info *info)
+{
+	/*camel_folder_thaw (info->folder);	*/
+	mail_sync_folder(info->folder, FALSE, NULL, NULL);
+	g_object_unref (info->folder);
+	g_free(info->uri);
+	g_free(info);
+}
+
+static void
+free_send_info(struct _send_info *info)
+{
+	g_free(info->uri);
+	if (info->cancel)
+		camel_operation_unref(info->cancel);
+	if (info->timeout_id != 0)
+		g_source_remove(info->timeout_id);
+	g_free(info->what);
+	g_free (info->send_url);
+	g_free(info);
+}
+
+static struct _send_data *
+setup_send_data(void)
+{
+	struct _send_data *data;
+
+	if (send_data == NULL) {
+		send_data = data = g_malloc0(sizeof(*data));
+		data->lock = g_mutex_new();
+		data->folders = g_hash_table_new_full (
+			g_str_hash, g_str_equal,
+			(GDestroyNotify) NULL,
+			(GDestroyNotify) free_folder_info);
+		data->inbox = e_mail_local_get_folder (
+			E_MAIL_FOLDER_LOCAL_INBOX);
+		g_object_ref (data->inbox);
+		data->active = g_hash_table_new_full (
+			g_str_hash, g_str_equal,
+			(GDestroyNotify) NULL,
+			(GDestroyNotify) free_send_info);
+	}
+	return send_data;
+}
+
+static void
+receive_cancel(GtkButton *button, struct _send_info *info)
+{
+	if (info->state == SEND_ACTIVE) {
+		camel_operation_cancel(info->cancel);
+		if (info->status_label)
+			gtk_label_set_text (
+				GTK_LABEL (info->status_label),
+				_("Canceling..."));
+		info->state = SEND_CANCELLED;
+	}
+	if (info->cancel_button)
+		gtk_widget_set_sensitive(info->cancel_button, FALSE);
+}
+
+static void
+free_send_data(void)
+{
+	struct _send_data *data = send_data;
+
+	g_return_if_fail (g_hash_table_size(data->active) == 0);
+
+	if (data->inbox) {
+		mail_sync_folder(data->inbox, FALSE, NULL, NULL);
+		/*camel_folder_thaw (data->inbox);		*/
+		g_object_unref (data->inbox);
+	}
+
+	g_list_free(data->infos);
+	g_hash_table_destroy(data->active);
+	g_hash_table_destroy(data->folders);
+	g_mutex_free(data->lock);
+	g_free(data);
+	send_data = NULL;
+}
+
+static void
+cancel_send_info(gpointer key, struct _send_info *info, gpointer data)
+{
+	receive_cancel (GTK_BUTTON (info->cancel_button), info);
+}
+
+static void
+hide_send_info(gpointer key, struct _send_info *info, gpointer data)
+{
+	info->cancel_button = NULL;
+	info->progress_bar = NULL;
+	info->status_label = NULL;
+
+	if (info->timeout_id != 0) {
+		g_source_remove (info->timeout_id);
+		info->timeout_id = 0;
+	}
+}
+
+static void
+dialog_destroy_cb (struct _send_data *data, GObject *deadbeef)
+{
+	g_hash_table_foreach (data->active, (GHFunc) hide_send_info, NULL);
+	data->gd = NULL;
+	send_recv_dialog = NULL;
+}
+
+static void
+dialog_response(GtkDialog *gd, gint button, struct _send_data *data)
+{
+	switch (button) {
+	case GTK_RESPONSE_CANCEL:
+		d(printf("cancelled whole thing\n"));
+		if (!data->cancelled) {
+			data->cancelled = TRUE;
+			g_hash_table_foreach(data->active, (GHFunc)cancel_send_info, NULL);
+		}
+		gtk_dialog_set_response_sensitive(gd, GTK_RESPONSE_CANCEL, FALSE);
+		break;
+	default:
+		d(printf("hiding dialog\n"));
+		g_hash_table_foreach(data->active, (GHFunc)hide_send_info, NULL);
+		data->gd = NULL;
+		/*gtk_widget_destroy((GtkWidget *)gd);*/
+		break;
+	}
+}
+
+static GStaticMutex status_lock = G_STATIC_MUTEX_INIT;
+static gchar *format_url (const gchar *internal_url, const gchar *account_name);
+
+static gint
+operation_status_timeout(gpointer data)
+{
+	struct _send_info *info = data;
+
+	if (info->progress_bar) {
+		g_static_mutex_lock (&status_lock);
+
+		gtk_progress_bar_set_fraction (
+			GTK_PROGRESS_BAR (info->progress_bar),
+			info->pc / 100.0);
+		if (info->what)
+			gtk_label_set_text (
+				GTK_LABEL (info->status_label),
+				info->what);
+		if (info->send_url && info->send_account_label) {
+			gchar *tmp = format_url (info->send_url, NULL);
+
+			g_free (info->send_url);
+			info->send_url = NULL;
+
+			gtk_label_set_markup (
+				GTK_LABEL (info->send_account_label),
+				tmp);
+
+			g_free (tmp);
+		}
+
+		g_static_mutex_unlock (&status_lock);
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static void
+set_send_status(struct _send_info *info, const gchar *desc, gint pc)
+{
+	g_static_mutex_lock (&status_lock);
+
+	g_free(info->what);
+	info->what = g_strdup(desc);
+	info->pc = pc;
+
+	g_static_mutex_unlock (&status_lock);
+}
+
+static void
+set_send_account (struct _send_info *info, const gchar *account_url)
+{
+	g_static_mutex_lock (&status_lock);
+
+	g_free (info->send_url);
+	info->send_url = g_strdup (account_url);
+
+	g_static_mutex_unlock (&status_lock);
+}
+
+/* for camel operation status */
+static void
+operation_status(CamelOperation *op, const gchar *what, gint pc, gpointer data)
+{
+	struct _send_info *info = data;
+
+	/*printf("Operation '%s', percent %d\n");*/
+	switch (pc) {
+	case CAMEL_OPERATION_START:
+		pc = 0;
+		break;
+	case CAMEL_OPERATION_END:
+		pc = 100;
+		break;
+	}
+
+	set_send_status(info, what, pc);
+}
+
+static gchar *
+format_url (const gchar *internal_url, const gchar *account_name)
+{
+	CamelURL *url;
+	gchar *pretty_url = NULL;
+
+	url = camel_url_new (internal_url, NULL);
+
+	if (account_name) {
+		if (url->host && *url->host)
+			pretty_url = g_strdup_printf (
+				"<b>%s (%s)</b>: %s",
+				account_name, url->protocol, url->host);
+		else if (url->path)
+			pretty_url = g_strdup_printf (
+				"<b>%s (%s)</b>: %s",
+				account_name, url->protocol, url->path);
+		else
+			pretty_url = g_strdup_printf (
+				"<b>%s (%s)</b>",
+				account_name, url->protocol);
+
+	} else if (url) {
+		if (url->host && *url->host)
+			pretty_url = g_strdup_printf (
+				"<b>%s</b>: %s",
+				url->protocol, url->host);
+		else if (url->path)
+			pretty_url = g_strdup_printf (
+				"<b>%s</b>: %s",
+				url->protocol, url->path);
+		else
+			pretty_url = g_strdup_printf (
+				"<b>%s</b>", url->protocol);
+	}
+
+	if (url)
+		camel_url_free (url);
+
+	return pretty_url;
+}
+
+static send_info_t
+get_receive_type(const gchar *url)
+{
+	CamelProvider *provider;
+
+	/* HACK: since mbox is ALSO used for native evolution trees now, we need to
+	   fudge this to treat it as a special 'movemail' source */
+	if (!strncmp(url, "mbox:", 5))
+		return SEND_RECEIVE;
+
+	provider = camel_provider_get(url, NULL);
+
+	if (!provider)
+		return SEND_INVALID;
+
+	if (provider->object_types[CAMEL_PROVIDER_STORE]) {
+		if (provider->flags & CAMEL_PROVIDER_IS_STORAGE)
+			return SEND_UPDATE;
+		else
+			return SEND_RECEIVE;
+	} else if (provider->object_types[CAMEL_PROVIDER_TRANSPORT]) {
+		return SEND_SEND;
+	}
+
+	return SEND_INVALID;
+}
+
+static struct _send_data *
+build_dialog (GtkWindow *parent,
+              EAccountList *accounts,
+              CamelFolder *outbox,
+              const gchar *destination)
+{
+	GtkDialog *gd;
+	GtkWidget *table;
+	gint row, num_sources;
+	GList *list = NULL;
+	struct _send_data *data;
+	GtkWidget *container;
+        GtkWidget *send_icon;
+	GtkWidget *recv_icon;
+	GtkWidget *scrolled_window;
+	GtkWidget *label;
+	GtkWidget *status_label;
+	GtkWidget *progress_bar;
+	GtkWidget *cancel_button;
+	struct _send_info *info;
+	gchar *pretty_url;
+	EAccount *account;
+	EIterator *iter;
+
+	send_recv_dialog = gtk_dialog_new_with_buttons (
+		_("Send & Receive Mail"), parent,
+		GTK_DIALOG_NO_SEPARATOR, NULL);
+	gd = GTK_DIALOG (send_recv_dialog);
+	gtk_window_set_modal ((GtkWindow *) gd, FALSE);
+
+	gtk_widget_ensure_style ((GtkWidget *)gd);
+
+	container = gtk_dialog_get_action_area (gd);
+	gtk_container_set_border_width (GTK_CONTAINER (container), 6);
+
+	container = gtk_dialog_get_content_area (gd);
+	gtk_container_set_border_width (GTK_CONTAINER (container), 0);
+
+	cancel_button = gtk_button_new_with_mnemonic (_("Cancel _All"));
+	gtk_button_set_image (
+		GTK_BUTTON (cancel_button),
+		gtk_image_new_from_stock (
+			GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+	gtk_widget_show (cancel_button);
+	gtk_dialog_add_action_widget (gd, cancel_button, GTK_RESPONSE_CANCEL);
+
+	gtk_window_set_icon_name (GTK_WINDOW (gd), "mail-send-receive");
+
+	num_sources = 0;
+
+	iter = e_list_get_iterator ((EList *) accounts);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->source->url)
+			num_sources++;
+
+		e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	/* Check to see if we have to send any mails.
+	 * If we don't, don't display the SMTP row in the table. */
+	if (outbox && destination
+	 && (camel_folder_get_message_count(outbox) -
+		camel_folder_get_deleted_message_count(outbox)) == 0)
+		num_sources--;
+
+	table = gtk_table_new (num_sources, 4, FALSE);
+	gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+	gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+	gtk_table_set_col_spacings (GTK_TABLE (table), 6);
+
+	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+	gtk_container_set_border_width (
+		GTK_CONTAINER (scrolled_window), 6);
+	gtk_scrolled_window_set_policy (
+		GTK_SCROLLED_WINDOW (scrolled_window),
+		GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+	container = gtk_dialog_get_content_area (gd);
+	gtk_scrolled_window_add_with_viewport (
+		GTK_SCROLLED_WINDOW (scrolled_window), table);
+	gtk_box_pack_start (
+		GTK_BOX (container), scrolled_window, TRUE, TRUE, 0);
+	gtk_widget_show (scrolled_window);
+
+	/* must bet setup after send_recv_dialog as it may re-trigger send-recv button */
+	data = setup_send_data ();
+
+	row = 0;
+	iter = e_list_get_iterator ((EList *) accounts);
+	while (e_iterator_is_valid (iter)) {
+		EAccountService *source;
+
+		account = (EAccount *) e_iterator_get (iter);
+
+		source = account->source;
+		if (!account->enabled || !source->url) {
+			e_iterator_next (iter);
+			continue;
+		}
+
+		/* see if we have an outstanding download active */
+		info = g_hash_table_lookup (data->active, source->url);
+		if (info == NULL) {
+			send_info_t type;
+
+			type = get_receive_type (source->url);
+			if (type == SEND_INVALID || type == SEND_SEND) {
+				e_iterator_next (iter);
+				continue;
+			}
+
+			info = g_malloc0 (sizeof (*info));
+			info->type = type;
+
+			d(printf("adding source %s\n", source->url));
+
+			info->uri = g_strdup (source->url);
+			info->keep_on_server = source->keep_on_server;
+			info->cancel = camel_operation_new (operation_status, info);
+			info->state = SEND_ACTIVE;
+			info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info);
+
+			g_hash_table_insert (data->active, info->uri, info);
+			list = g_list_prepend (list, info);
+		} else if (info->progress_bar != NULL) {
+			/* incase we get the same source pop up again */
+			e_iterator_next (iter);
+			continue;
+		} else if (info->timeout_id == 0)
+			info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info);
+
+		recv_icon = gtk_image_new_from_icon_name (
+			"mail-inbox", GTK_ICON_SIZE_LARGE_TOOLBAR);
+		pretty_url = format_url (source->url, account->name);
+		label = gtk_label_new (NULL);
+		gtk_label_set_ellipsize (
+			GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+		gtk_label_set_markup (GTK_LABEL (label), pretty_url);
+		g_free (pretty_url);
+
+		progress_bar = gtk_progress_bar_new ();
+
+		cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+
+		status_label = gtk_label_new (
+			(info->type == SEND_UPDATE) ?
+			_("Updating...") : _("Waiting..."));
+		gtk_label_set_ellipsize (
+			GTK_LABEL (status_label), PANGO_ELLIPSIZE_END);
+
+		/* g_object_set(data->label, "bold", TRUE, NULL); */
+		gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
+		gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5);
+
+		gtk_table_attach (
+			GTK_TABLE (table), recv_icon,
+			0, 1, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), label,
+			1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), progress_bar,
+			2, 3, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), cancel_button,
+			3, 4, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), status_label,
+			1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+
+		info->progress_bar = progress_bar;
+		info->status_label = status_label;
+		info->cancel_button = cancel_button;
+		info->data = data;
+
+		g_signal_connect (
+			cancel_button, "clicked",
+			G_CALLBACK (receive_cancel), info);
+		e_iterator_next (iter);
+		row = row + 2;
+	}
+
+	g_object_unref (iter);
+
+	/* we also need gd during emition to be able to catch Cancel All */
+	data->gd = gd;
+
+	/* Skip displaying the SMTP row if we've got no outbox, destination or unsent mails */
+	if (outbox && destination
+	 && (camel_folder_get_message_count(outbox) -
+		camel_folder_get_deleted_message_count(outbox)) != 0) {
+		info = g_hash_table_lookup (data->active, SEND_URI_KEY);
+		if (info == NULL) {
+			info = g_malloc0 (sizeof (*info));
+			info->type = SEND_SEND;
+			d(printf("adding dest %s\n", destination));
+
+			info->uri = g_strdup (destination);
+			info->keep_on_server = FALSE;
+			info->cancel = camel_operation_new (operation_status, info);
+			info->state = SEND_ACTIVE;
+			info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info);
+
+			g_hash_table_insert (data->active, (gpointer) SEND_URI_KEY, info);
+			list = g_list_prepend (list, info);
+		} else if (info->timeout_id == 0)
+			info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info);
+
+		send_icon = gtk_image_new_from_icon_name (
+			"mail-outbox", GTK_ICON_SIZE_LARGE_TOOLBAR);
+		pretty_url = format_url (destination, NULL);
+		label = gtk_label_new (NULL);
+		gtk_label_set_ellipsize (
+			GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+		gtk_label_set_markup (GTK_LABEL (label), pretty_url);
+
+		g_free (pretty_url);
+
+		progress_bar = gtk_progress_bar_new ();
+		cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+
+		status_label = gtk_label_new (_("Waiting..."));
+		gtk_label_set_ellipsize (
+			GTK_LABEL (status_label), PANGO_ELLIPSIZE_END);
+
+		gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
+		gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5);
+
+		gtk_table_attach (
+			GTK_TABLE (table), send_icon,
+			0, 1, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), label,
+			1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), progress_bar,
+			2, 3, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), cancel_button,
+			3, 4, row, row+2, 0, 0, 0, 0);
+		gtk_table_attach (
+			GTK_TABLE (table), status_label,
+			1, 2, row+1, row+2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+
+		info->progress_bar = progress_bar;
+		info->cancel_button = cancel_button;
+		info->data = data;
+		info->status_label = status_label;
+		info->send_account_label = label;
+
+		g_signal_connect (
+			cancel_button, "clicked",
+			G_CALLBACK (receive_cancel), info);
+	}
+
+	gtk_widget_show_all (table);
+
+	if (parent != NULL)
+		gtk_widget_show (GTK_WIDGET (gd));
+
+	g_signal_connect (gd, "response", G_CALLBACK (dialog_response), data);
+
+	g_object_weak_ref ((GObject *) gd, (GWeakNotify) dialog_destroy_cb, data);
+
+	data->infos = list;
+
+	return data;
+}
+
+static void
+update_folders(gchar *uri, struct _folder_info *info, gpointer data)
+{
+	time_t now = *((time_t *)data);
+
+	d(printf("checking update for folder: %s\n", info->uri));
+
+	/* let it flow through to the folders every 10 seconds */
+	/* we back off slowly as we progress */
+	if (now > info->update+10+info->count*5) {
+		d(printf("upating a folder: %s\n", info->uri));
+		/*camel_folder_thaw(info->folder);
+		  camel_folder_freeze(info->folder);*/
+		info->update = now;
+		info->count++;
+	}
+}
+
+static void
+receive_status (CamelFilterDriver *driver,
+                enum camel_filter_status_t status,
+                gint pc,
+                const gchar *desc,
+                gpointer data)
+{
+	struct _send_info *info = data;
+	time_t now = time(NULL);
+
+	/* let it flow through to the folder, every now and then too? */
+	g_hash_table_foreach(info->data->folders, (GHFunc)update_folders, &now);
+
+	if (info->data->inbox && now > info->data->inbox_update+20) {
+		d(printf("updating inbox too\n"));
+		/* this doesn't seem to work right :( */
+		/*camel_folder_thaw(info->data->inbox);
+		  camel_folder_freeze(info->data->inbox);*/
+		info->data->inbox_update = now;
+	}
+
+	/* we just pile them onto the port, assuming it can handle it.
+	   We could also have a receiver port and see if they've been processed
+	   yet, so if this is necessary its not too hard to add */
+	/* the mail_gui_port receiver will free everything for us */
+	switch (status) {
+	case CAMEL_FILTER_STATUS_START:
+	case CAMEL_FILTER_STATUS_END:
+		set_send_status(info, desc, pc);
+		break;
+	case CAMEL_FILTER_STATUS_ACTION:
+		set_send_account (info, desc);
+		break;
+	default:
+		break;
+	}
+}
+
+/* when receive/send is complete */
+static void
+receive_done (const gchar *uri, gpointer data)
+{
+	struct _send_info *info = data;
+
+	/* if we've been called to run again - run again */
+	if (info->type == SEND_SEND && info->state == SEND_ACTIVE && info->again) {
+		CamelFolder *local_outbox;
+
+		local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+
+		info->again = 0;
+		mail_send_queue (local_outbox,
+				 info->uri,
+				 E_FILTER_SOURCE_OUTGOING,
+				 info->cancel,
+				 receive_get_folder, info,
+				 receive_status, info,
+				 receive_done, info);
+		return;
+	}
+
+	if (info->progress_bar) {
+		const gchar *text;
+
+		gtk_progress_bar_set_fraction(
+			GTK_PROGRESS_BAR (info->progress_bar), 1.0);
+
+		if (info->state == SEND_CANCELLED)
+			text = _("Canceled.");
+		else {
+			text = _("Complete.");
+			info->state = SEND_COMPLETE;
+		}
+
+		gtk_label_set_text (GTK_LABEL (info->status_label), text);
+	}
+
+	if (info->cancel_button)
+		gtk_widget_set_sensitive (info->cancel_button, FALSE);
+
+	/* remove/free this active download */
+	d(printf("%s: freeing info %p\n", G_STRFUNC, info));
+	if (info->type == SEND_SEND)
+		g_hash_table_steal(info->data->active, SEND_URI_KEY);
+	else
+		g_hash_table_steal(info->data->active, info->uri);
+	info->data->infos = g_list_remove(info->data->infos, info);
+
+	if (g_hash_table_size(info->data->active) == 0) {
+		if (info->data->gd)
+			gtk_widget_destroy((GtkWidget *)info->data->gd);
+		free_send_data();
+	}
+
+	free_send_info(info);
+}
+
+/* although we dont do anythign smart here yet, there is no need for this interface to
+   be available to anyone else.
+   This can also be used to hook into which folders are being updated, and occasionally
+   let them refresh */
+static CamelFolder *
+receive_get_folder (CamelFilterDriver *d,
+                    const gchar *uri,
+                    gpointer data,
+                    GError **error)
+{
+	struct _send_info *info = data;
+	CamelFolder *folder;
+	struct _folder_info *oldinfo;
+	gpointer oldkey, oldinfoptr;
+
+	g_mutex_lock(info->data->lock);
+	oldinfo = g_hash_table_lookup(info->data->folders, uri);
+	g_mutex_unlock(info->data->lock);
+	if (oldinfo) {
+		g_object_ref (oldinfo->folder);
+		return oldinfo->folder;
+	}
+	folder = mail_tool_uri_to_folder (uri, 0, error);
+	if (!folder)
+		return NULL;
+
+	/* we recheck that the folder hasn't snuck in while we were loading it... */
+	/* and we assume the newer one is the same, but unref the old one anyway */
+	g_mutex_lock(info->data->lock);
+
+	if (g_hash_table_lookup_extended (info->data->folders, uri, &oldkey, &oldinfoptr)) {
+		oldinfo = (struct _folder_info *) oldinfoptr;
+		g_object_unref (oldinfo->folder);
+		oldinfo->folder = folder;
+	} else {
+		/*camel_folder_freeze (folder);		*/
+		oldinfo = g_malloc0(sizeof(*oldinfo));
+		oldinfo->folder = folder;
+		oldinfo->uri = g_strdup(uri);
+		g_hash_table_insert(info->data->folders, oldinfo->uri, oldinfo);
+	}
+
+	g_object_ref (folder);
+
+	g_mutex_unlock(info->data->lock);
+
+	return folder;
+}
+
+/* ********************************************************************** */
+
+static void
+get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info)
+{
+	while (info) {
+		if (camel_store_can_refresh_folder (store, info, NULL)) {
+			CamelURL *url = camel_url_new (info->uri, NULL);
+
+			if (url && (!camel_url_get_param (url, "noselect") ||
+				!g_str_equal (camel_url_get_param (
+				url, "noselect"), "yes")))
+				g_ptr_array_add (folders, g_strdup (info->uri));
+
+			if (url)
+				camel_url_free (url);
+		}
+
+		get_folders (store, folders, info->child);
+		info = info->next;
+	}
+}
+
+struct _refresh_folders_msg {
+	MailMsg base;
+
+	struct _send_info *info;
+	GPtrArray *folders;
+	CamelStore *store;
+	CamelFolderInfo *finfo;
+};
+
+static gchar *
+refresh_folders_desc (struct _refresh_folders_msg *m)
+{
+	return g_strdup_printf(_("Checking for new mail"));
+}
+
+static void
+refresh_folders_exec (struct _refresh_folders_msg *m)
+{
+	gint i;
+	CamelFolder *folder;
+	GError *local_error = NULL;
+
+	get_folders (m->store, m->folders, m->finfo);
+
+	for (i=0;i<m->folders->len;i++) {
+		folder = mail_tool_uri_to_folder(m->folders->pdata[i], 0, &local_error);
+		if (folder) {
+			camel_folder_sync (folder, FALSE, NULL);
+			camel_folder_refresh_info(folder, NULL);
+			g_object_unref (folder);
+		} else if (local_error != NULL) {
+			g_warning ("Failed to refresh folders: %s", local_error->message);
+			g_clear_error (&local_error);
+		}
+
+		if (camel_operation_cancel_check(m->info->cancel))
+			break;
+	}
+}
+
+static void
+refresh_folders_done (struct _refresh_folders_msg *m)
+{
+	receive_done("", m->info);
+}
+
+static void
+refresh_folders_free (struct _refresh_folders_msg *m)
+{
+	gint i;
+
+	for (i=0;i<m->folders->len;i++)
+		g_free(m->folders->pdata[i]);
+	g_ptr_array_free(m->folders, TRUE);
+
+	camel_store_free_folder_info (m->store, m->finfo);
+	g_object_unref (m->store);
+}
+
+static MailMsgInfo refresh_folders_info = {
+	sizeof (struct _refresh_folders_msg),
+	(MailMsgDescFunc) refresh_folders_desc,
+	(MailMsgExecFunc) refresh_folders_exec,
+	(MailMsgDoneFunc) refresh_folders_done,
+	(MailMsgFreeFunc) refresh_folders_free
+};
+
+static gboolean
+receive_update_got_folderinfo(CamelStore *store, CamelFolderInfo *info, gpointer data)
+{
+	if (info) {
+		GPtrArray *folders = g_ptr_array_new();
+		struct _refresh_folders_msg *m;
+		struct _send_info *sinfo = data;
+
+		m = mail_msg_new(&refresh_folders_info);
+		m->store = store;
+		g_object_ref (store);
+		m->folders = folders;
+		m->info = sinfo;
+		m->finfo = info;
+
+		mail_msg_unordered_push (m);
+
+		/* do not free folder info, we will free it later */
+		return FALSE;
+	} else {
+		receive_done ("", data);
+	}
+
+	return TRUE;
+}
+
+static void
+receive_update_got_store (gchar *uri, CamelStore *store, gpointer data, GError *error)
+{
+	struct _send_info *info = data;
+
+	if (store) {
+		mail_folder_cache_note_store(mail_folder_cache_get_default (),
+			store, info->cancel,
+			receive_update_got_folderinfo, info);
+	} else {
+		receive_done("", info);
+	}
+}
+
+GtkWidget *
+mail_send_receive (GtkWindow *parent)
+{
+	CamelFolder *local_outbox;
+	struct _send_data *data;
+	EAccountList *accounts;
+	EAccount *account;
+	GList *scan;
+
+	if (send_recv_dialog != NULL) {
+		if (parent != NULL && gtk_widget_get_realized (send_recv_dialog)) {
+			gtk_window_present (GTK_WINDOW (send_recv_dialog));
+		}
+		return send_recv_dialog;
+	}
+
+	if (!camel_session_get_online (session))
+		return send_recv_dialog;
+
+	account = e_get_default_account ();
+	if (!account || !account->transport->url)
+		return send_recv_dialog;
+
+	accounts = e_get_account_list ();
+
+	local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+	data = build_dialog (
+		parent, accounts, local_outbox, account->transport->url);
+	scan = data->infos;
+	while (scan) {
+		struct _send_info *info = scan->data;
+
+		switch (info->type) {
+		case SEND_RECEIVE:
+			mail_fetch_mail(info->uri, info->keep_on_server,
+					E_FILTER_SOURCE_INCOMING,
+					info->cancel,
+					receive_get_folder, info,
+					receive_status, info,
+					receive_done, info);
+			break;
+		case SEND_SEND:
+			/* todo, store the folder in info? */
+			mail_send_queue(local_outbox, info->uri,
+					E_FILTER_SOURCE_OUTGOING,
+					info->cancel,
+					receive_get_folder, info,
+					receive_status, info,
+					receive_done, info);
+			break;
+		case SEND_UPDATE:
+			mail_get_store(info->uri, info->cancel, receive_update_got_store, info);
+			break;
+		default:
+			break;
+		}
+		scan = scan->next;
+	}
+
+	return send_recv_dialog;
+}
+
+struct _auto_data {
+	EAccount *account;
+	gint period;		/* in seconds */
+	gint timeout_id;
+};
+
+static GHashTable *auto_active;
+
+static gboolean
+auto_timeout(gpointer data)
+{
+	struct _auto_data *info = data;
+
+	if (camel_session_get_online (session)) {
+		const gchar *uri;
+		gboolean keep_on_server;
+
+		uri = e_account_get_string (
+			info->account, E_ACCOUNT_SOURCE_URL);
+		keep_on_server = e_account_get_bool (
+			info->account, E_ACCOUNT_SOURCE_KEEP_ON_SERVER);
+		mail_receive_uri (uri, keep_on_server);
+	}
+
+	return TRUE;
+}
+
+static void
+auto_account_removed(EAccountList *eal, EAccount *ea, gpointer dummy)
+{
+	struct _auto_data *info = g_object_get_data((GObject *)ea, "mail-autoreceive");
+
+	g_return_if_fail(info != NULL);
+
+	if (info->timeout_id) {
+		g_source_remove(info->timeout_id);
+		info->timeout_id = 0;
+	}
+}
+
+static void
+auto_account_finalised(struct _auto_data *info)
+{
+	if (info->timeout_id)
+		g_source_remove(info->timeout_id);
+	g_free(info);
+}
+
+static void
+auto_account_commit(struct _auto_data *info)
+{
+	gint period, check;
+
+	check = info->account->enabled
+		&& e_account_get_bool(info->account, E_ACCOUNT_SOURCE_AUTO_CHECK)
+		&& e_account_get_string(info->account, E_ACCOUNT_SOURCE_URL);
+	period = e_account_get_int(info->account, E_ACCOUNT_SOURCE_AUTO_CHECK_TIME)*60;
+	period = MAX(60, period);
+
+	if (info->timeout_id
+	    && (!check
+		|| period != info->period)) {
+		g_source_remove(info->timeout_id);
+		info->timeout_id = 0;
+	}
+	info->period = period;
+	if (check && info->timeout_id == 0)
+		info->timeout_id = g_timeout_add_seconds(info->period, auto_timeout, info);
+}
+
+static void
+auto_account_added(EAccountList *eal, EAccount *ea, gpointer dummy)
+{
+	struct _auto_data *info;
+
+	info = g_malloc0(sizeof(*info));
+	info->account = ea;
+	g_object_set_data_full (
+		G_OBJECT (ea), "mail-autoreceive", info,
+		(GDestroyNotify) auto_account_finalised);
+	auto_account_commit (info);
+}
+
+static void
+auto_account_changed(EAccountList *eal, EAccount *ea, gpointer dummy)
+{
+	struct _auto_data *info = g_object_get_data((GObject *)ea, "mail-autoreceive");
+
+	g_return_if_fail(info != NULL);
+
+	auto_account_commit(info);
+}
+
+static void
+auto_online ()
+{
+	EIterator *iter;
+	EAccountList *accounts;
+	struct _auto_data *info;
+
+	accounts = e_get_account_list ();
+	for (iter = e_list_get_iterator ((EList *)accounts);
+	     e_iterator_is_valid (iter);
+	     e_iterator_next (iter)) {
+		info = g_object_get_data (
+			G_OBJECT (e_iterator_get (iter)),
+			"mail-autoreceive");
+		if (info && info->timeout_id)
+			auto_timeout(info);
+	}
+}
+
+/* call to setup initial, and after changes are made to the config */
+/* FIXME: Need a cleanup funciton for when object is deactivated */
+void
+mail_autoreceive_init (CamelSession *session)
+{
+	EAccountList *accounts;
+	EIterator *iter;
+
+	g_return_if_fail (CAMEL_IS_SESSION (session));
+
+	if (auto_active)
+		return;
+
+	accounts = e_get_account_list ();
+	auto_active = g_hash_table_new (g_str_hash, g_str_equal);
+
+	g_signal_connect (
+		accounts, "account-added",
+		G_CALLBACK (auto_account_added), NULL);
+	g_signal_connect (
+		accounts, "account-removed",
+		G_CALLBACK (auto_account_removed), NULL);
+	g_signal_connect (
+		accounts, "account-changed",
+		G_CALLBACK (auto_account_changed), NULL);
+
+	for (iter = e_list_get_iterator ((EList *)accounts);
+	     e_iterator_is_valid(iter);
+	     e_iterator_next(iter))
+		auto_account_added (
+			accounts, (EAccount *) e_iterator_get (iter), NULL);
+
+
+	auto_online ();
+/*
+	g_signal_connect (
+		shell, "notify::online",
+		G_CALLBACK (auto_online), NULL);
+*/		
+}
+
+/* We setup the download info's in a hashtable, if we later
+ * need to build the gui, we insert them in to add them. */
+void
+mail_receive_uri (const gchar *uri, gboolean keep_on_server)
+{
+	struct _send_info *info;
+	struct _send_data *data;
+	CamelFolder *local_outbox;
+	send_info_t type;
+
+	data = setup_send_data();
+	info = g_hash_table_lookup(data->active, uri);
+	if (info != NULL) {
+		d(printf("download of %s still in progress\n", uri));
+		return;
+	}
+
+	d(printf("starting non-interactive download of '%s'\n", uri));
+
+	type = get_receive_type (uri);
+	if (type == SEND_INVALID || type == SEND_SEND) {
+		d(printf ("unsupported provider: '%s'\n", uri));
+		return;
+	}
+
+	info = g_malloc0 (sizeof (*info));
+	info->type = type;
+	info->progress_bar = NULL;
+	info->status_label = NULL;
+	info->uri = g_strdup (uri);
+	info->keep_on_server = keep_on_server;
+	info->cancel = camel_operation_new (operation_status, info);
+	info->cancel_button = NULL;
+	info->data = data;
+	info->state = SEND_ACTIVE;
+	info->timeout_id = 0;
+
+	d(printf("Adding new info %p\n", info));
+
+	g_hash_table_insert (data->active, info->uri, info);
+
+	switch (info->type) {
+	case SEND_RECEIVE:
+		mail_fetch_mail (info->uri, info->keep_on_server,
+				 E_FILTER_SOURCE_INCOMING,
+				 info->cancel,
+				 receive_get_folder, info,
+				 receive_status, info,
+				 receive_done, info);
+		break;
+	case SEND_SEND:
+		/* todo, store the folder in info? */
+		local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+		mail_send_queue (local_outbox, info->uri,
+				 E_FILTER_SOURCE_OUTGOING,
+				 info->cancel,
+				 receive_get_folder, info,
+				 receive_status, info,
+				 receive_done, info);
+		break;
+	case SEND_UPDATE:
+		mail_get_store (info->uri, info->cancel, receive_update_got_store, info);
+		break;
+	default:
+		g_return_if_reached();
+	}
+}
+
+void
+mail_send (void)
+{
+	CamelFolder *local_outbox;
+	EAccountService *transport;
+	struct _send_info *info;
+	struct _send_data *data;
+	send_info_t type;
+
+	transport = mail_config_get_default_transport ();
+	if (!transport || !transport->url)
+		return;
+
+	data = setup_send_data ();
+	info = g_hash_table_lookup (data->active, SEND_URI_KEY);
+	if (info != NULL) {
+		info->again++;
+		d(printf("send of %s still in progress\n", transport->url));
+		return;
+	}
+
+	d(printf("starting non-interactive send of '%s'\n", transport->url));
+
+	type = get_receive_type (transport->url);
+	if (type == SEND_INVALID) {
+		d(printf ("unsupported provider: '%s'\n", transport->url));
+		return;
+	}
+
+	info = g_malloc0 (sizeof (*info));
+	info->type = SEND_SEND;
+	info->progress_bar = NULL;
+	info->status_label = NULL;
+	info->uri = g_strdup (transport->url);
+	info->keep_on_server = FALSE;
+	info->cancel = NULL;
+	info->cancel_button = NULL;
+	info->data = data;
+	info->state = SEND_ACTIVE;
+	info->timeout_id = 0;
+
+	d(printf("Adding new info %p\n", info));
+
+	g_hash_table_insert (data->active, (gpointer) SEND_URI_KEY, info);
+
+	/* todo, store the folder in info? */
+	local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+	mail_send_queue (local_outbox, info->uri,
+			 E_FILTER_SOURCE_OUTGOING,
+			 info->cancel,
+			 receive_get_folder, info,
+			 receive_status, info,
+			 receive_done, info);
+}
diff --git a/mail/daemon/mail-send-recv.h b/mail/daemon/mail-send-recv.h
new file mode 100644
index 0000000..81c9cfb
--- /dev/null
+++ b/mail/daemon/mail-send-recv.h
@@ -0,0 +1,45 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Michael Zucchi <NotZed ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef MAIL_SEND_RECV_H
+#define MAIL_SEND_RECV_H
+
+#include <gtk/gtk.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+/* send/receive all uri's */
+GtkWidget *	mail_send_receive		(GtkWindow *parent);
+
+/* receive a single uri */
+void		mail_receive_uri		(const gchar *uri,
+						 gboolean keep_on_server);
+
+void		mail_send			(void);
+
+/* setup auto receive stuff */
+void		mail_autoreceive_init		(CamelSession *session);
+
+G_END_DECLS
+
+#endif /* MAIL_SEND_RECV_H */
diff --git a/mail/daemon/mail-session.c b/mail/daemon/mail-session.c
new file mode 100644
index 0000000..f00000c
--- /dev/null
+++ b/mail/daemon/mail-session.c
@@ -0,0 +1,1027 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *   Jonathon Jongsma <jonathon jongsma collabora co uk>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
+ *
+ */
+
+/* mail-session.c: handles the session information and resource manipulation */
+
+#include <config.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+
+#include <gtk/gtk.h>
+
+#include <gconf/gconf-client.h>
+
+#ifdef HAVE_CANBERRA
+#include <canberra-gtk.h>
+#endif
+
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserverui/e-passwords.h>
+#include <libedataserver/e-flag.h>
+
+#include "e-mail-local.h"
+#include "mail-config.h"
+#include "mail-mt.h"
+#include "mail-ops.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+#include "mail-send-recv.h"
+
+#define d(x)
+
+CamelSession *session;
+static guint session_check_junk_notify_id;
+static guint session_gconf_proxy_id;
+
+#define MAIL_TYPE_SESSION \
+	(mail_session_get_type ())
+
+typedef struct _MailSession MailSession;
+typedef struct _MailSessionClass MailSessionClass;
+
+struct _MailSession {
+	CamelSession parent_object;
+
+	gboolean interactive;
+	FILE *filter_logfile;
+	GList *junk_plugins;
+
+	MailAsyncEvent *async;
+};
+
+struct _MailSessionClass {
+	CamelSessionClass parent_class;
+};
+
+static gchar *mail_data_dir;
+static gchar *mail_config_dir;
+
+static gchar *get_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *prompt, const gchar *item, guint32 flags, GError **error);
+static gboolean forget_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, GError **error);
+static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const gchar *prompt, gboolean cancel);
+static CamelFilterDriver *get_filter_driver(CamelSession *session, const gchar *type, GError **error);
+static gboolean lookup_addressbook(CamelSession *session, const gchar *name);
+
+static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const gchar *text, gint pc);
+static gpointer ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, guint size);
+static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m);
+static gboolean ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *message, const gchar *address, GError **error);
+
+GType mail_session_get_type (void);
+
+G_DEFINE_TYPE (MailSession, mail_session, CAMEL_TYPE_SESSION)
+
+static void
+mail_session_finalize (GObject *object)
+{
+	MailSession *session = (MailSession *) object;
+	GConfClient *client;
+
+	client = mail_config_get_gconf_client ();
+
+	if (session_check_junk_notify_id != 0) {
+		gconf_client_notify_remove (client, session_check_junk_notify_id);
+		session_check_junk_notify_id = 0;
+	}
+
+	if (session_gconf_proxy_id != 0) {
+		gconf_client_notify_remove (client, session_gconf_proxy_id);
+		session_gconf_proxy_id = 0;
+	}
+
+	mail_async_event_destroy(session->async);
+
+	g_free (mail_data_dir);
+	g_free (mail_config_dir);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (mail_session_parent_class)->finalize (object);
+}
+
+static void
+mail_session_class_init (MailSessionClass *class)
+{
+	GObjectClass *object_class;
+	CamelSessionClass *session_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = mail_session_finalize;
+
+	session_class = CAMEL_SESSION_CLASS (class);
+	session_class->get_password = get_password;
+	session_class->forget_password = forget_password;
+	session_class->alert_user = alert_user;
+	session_class->get_filter_driver = get_filter_driver;
+	session_class->lookup_addressbook = lookup_addressbook;
+	session_class->thread_msg_new = ms_thread_msg_new;
+	session_class->thread_msg_free = ms_thread_msg_free;
+	session_class->thread_status = ms_thread_status;
+	session_class->forward_to = ms_forward_to;
+}
+
+static void
+mail_session_init (MailSession *session)
+{
+	session->async = mail_async_event_new();
+	session->junk_plugins = NULL;
+}
+
+static gchar *
+make_key (CamelService *service, const gchar *item)
+{
+	gchar *key;
+
+	if (service)
+		key = camel_url_to_string (service->url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+	else
+		key = g_strdup (item);
+
+	return key;
+}
+
+/* ********************************************************************** */
+
+static gchar *
+get_password (CamelSession *session,
+              CamelService *service,
+              const gchar *domain,
+              const gchar *prompt,
+              const gchar *item,
+              guint32 flags,
+              GError **error)
+{
+	gchar *url;
+	gchar *ret = NULL;
+	EAccount *account = NULL;
+
+	url = service?camel_url_to_string(service->url, CAMEL_URL_HIDE_ALL):NULL;
+
+	if (!strcmp(item, "popb4smtp_uri")) {
+		/* not 100% mt safe, but should be ok */
+		if (url
+		    && (account = mail_config_get_account_by_transport_url(url)))
+			ret = g_strdup(account->source->url);
+		else
+			ret = g_strdup(url);
+	} else {
+		gchar *key = make_key(service, item);
+		EAccountService *config_service = NULL;
+
+		if (domain == NULL)
+			domain = "Mail";
+
+		ret = e_passwords_get_password(domain, key);
+		if (ret == NULL || (flags & CAMEL_SESSION_PASSWORD_REPROMPT)) {
+			gboolean remember;
+
+			g_free (ret);
+			ret = NULL;
+
+			if (url) {
+				if  ((account = mail_config_get_account_by_source_url(url)))
+					config_service = account->source;
+				else if ((account = mail_config_get_account_by_transport_url(url)))
+					config_service = account->transport;
+			}
+
+			remember = config_service?config_service->save_passwd:FALSE;
+
+			if (!config_service || (config_service && !config_service->get_password_canceled)) {
+				guint32 eflags;
+				gchar *title;
+
+				if (flags & CAMEL_SESSION_PASSPHRASE) {
+					if (account)
+						title = g_strdup_printf (_("Enter Passphrase for %s"), account->name);
+					else
+						title = g_strdup (_("Enter Passphrase"));
+				} else {
+					if (account)
+						title = g_strdup_printf (_("Enter Password for %s"), account->name);
+					else
+						title = g_strdup (_("Enter Password"));
+				}
+				if ((flags & CAMEL_SESSION_PASSWORD_STATIC) != 0)
+					eflags = E_PASSWORDS_REMEMBER_NEVER;
+				else if (config_service == NULL)
+					eflags = E_PASSWORDS_REMEMBER_SESSION;
+				else
+					eflags = E_PASSWORDS_REMEMBER_FOREVER;
+
+				if (flags & CAMEL_SESSION_PASSWORD_REPROMPT)
+					eflags |= E_PASSWORDS_REPROMPT;
+
+				if (flags & CAMEL_SESSION_PASSWORD_SECRET)
+					eflags |= E_PASSWORDS_SECRET;
+
+				if (flags & CAMEL_SESSION_PASSPHRASE)
+					eflags |= E_PASSWORDS_PASSPHRASE;
+
+				/* HACK: breaks abstraction ...
+				   e_account_writable doesn't use the eaccount, it also uses the same writable key for
+				   source and transport */
+				if (!e_account_writable(NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD))
+					eflags |= E_PASSWORDS_DISABLE_REMEMBER;
+
+				ret = e_passwords_ask_password(title, domain, key, prompt, eflags, &remember, NULL);
+
+				if (!ret)
+					e_passwords_forget_password (domain, key);
+
+				g_free(title);
+
+				if (ret && config_service)
+					mail_config_service_set_save_passwd(config_service, remember);
+
+				if (config_service)
+					config_service->get_password_canceled = ret == NULL;
+			}
+		}
+
+		g_free(key);
+	}
+
+	g_free(url);
+
+	if (ret == NULL)
+		g_set_error (
+			error, G_IO_ERROR,
+			G_IO_ERROR_CANCELLED,
+			_("User canceled operation."));
+
+	return ret;
+}
+
+static gboolean
+forget_password (CamelSession *session,
+                 CamelService *service,
+                 const gchar *domain,
+                 const gchar *item,
+                 GError **error)
+{
+	gchar *key = make_key (service, item);
+
+	e_passwords_forget_password (domain?domain:"Mail", key);
+	g_free (key);
+
+	return TRUE;
+}
+
+/* ********************************************************************** */
+
+static gpointer user_message_dialog;
+static GQueue user_message_queue = { NULL, NULL, 0 };
+
+struct _user_message_msg {
+	MailMsg base;
+
+	CamelSessionAlertType type;
+	gchar *prompt;
+	EFlag *done;
+
+	guint allow_cancel:1;
+	guint result:1;
+	guint ismain:1;
+};
+
+static void user_message_exec (struct _user_message_msg *m);
+
+#if 0
+static void
+user_message_response_free (GtkDialog *dialog, gint button, struct _user_message_msg *m)
+{
+	gtk_widget_destroy ((GtkWidget *) dialog);
+
+	user_message_dialog = NULL;
+
+	/* check for pendings */
+	if (!g_queue_is_empty (&user_message_queue)) {
+		m = g_queue_pop_head (&user_message_queue);
+		user_message_exec (m);
+		mail_msg_unref (m);
+	}
+}
+
+/* clicked, send back the reply */
+static void
+user_message_response (GtkDialog *dialog, gint button, struct _user_message_msg *m)
+{
+	/* if !allow_cancel, then we've already replied */
+	if (m->allow_cancel) {
+		m->result = button == GTK_RESPONSE_OK;
+		e_flag_set (m->done);
+	}
+
+	user_message_response_free (dialog, button, m);
+}
+#endif
+
+static void
+user_message_exec (struct _user_message_msg *m)
+{
+	const gchar *error_type;
+
+	if (!m->ismain && user_message_dialog != NULL) {
+		g_queue_push_tail (&user_message_queue, mail_msg_ref (m));
+		return;
+	}
+
+	switch (m->type) {
+		case CAMEL_SESSION_ALERT_INFO:
+			error_type = m->allow_cancel ?
+				"mail:session-message-info-cancel" :
+				"mail:session-message-info";
+			break;
+		case CAMEL_SESSION_ALERT_WARNING:
+			error_type = m->allow_cancel ?
+				"mail:session-message-warning-cancel" :
+				"mail:session-message-warning";
+			break;
+		case CAMEL_SESSION_ALERT_ERROR:
+			error_type = m->allow_cancel ?
+				"mail:session-message-error-cancel" :
+				"mail:session-message-error";
+			break;
+		default:
+			error_type = NULL;
+			g_return_if_reached ();
+	}
+
+	g_warning ("ALERT ALERT! Camel needs a prompt: %s\n", m->prompt);
+#if 0
+	/* Pull in the active window from the shell to get a parent window */
+	user_message_dialog =
+		e_alert_dialog_new_for_args (NULL, error_type, m->prompt, NULL);
+	g_object_set (
+		user_message_dialog, "allow_shrink", TRUE,
+		"allow_grow", TRUE, NULL);
+
+	/* Use the number of dialog buttons as a heuristic for whether to
+	 * emit a status bar message or present the dialog immediately, the
+	 * thought being if there's more than one button then something is
+	 * probably blocked until the user responds. */
+	if (e_alert_dialog_count_buttons (user_message_dialog) > 1) {
+		if (m->ismain) {
+			gint response;
+
+			response = gtk_dialog_run (user_message_dialog);
+			user_message_response (
+				user_message_dialog, response, m);
+		} else {
+			g_signal_connect (
+				user_message_dialog, "response",
+				G_CALLBACK (user_message_response), m);
+			gtk_widget_show (user_message_dialog);
+		}
+	} else {
+		g_signal_connect (
+			user_message_dialog, "response",
+			G_CALLBACK (user_message_response_free), m);
+		g_object_set_data (
+			user_message_dialog, "response-handled",
+			GINT_TO_POINTER (TRUE));
+		em_utils_show_error_silent (user_message_dialog);
+	}
+#endif	
+}
+
+static void
+user_message_free (struct _user_message_msg *m)
+{
+	g_free (m->prompt);
+	e_flag_free (m->done);
+}
+
+static MailMsgInfo user_message_info = {
+	sizeof (struct _user_message_msg),
+	(MailMsgDescFunc) NULL,
+	(MailMsgExecFunc) user_message_exec,
+	(MailMsgDoneFunc) NULL,
+	(MailMsgFreeFunc) user_message_free
+};
+
+static gboolean
+lookup_addressbook(CamelSession *session, const gchar *name)
+{
+/* 	
+	CamelInternetAddress *addr;
+	gboolean ret;
+
+	if (!mail_config_get_lookup_book ())
+		return FALSE;
+
+	addr = camel_internet_address_new ();
+	camel_address_decode ((CamelAddress *)addr, name);
+	ret = em_utils_in_addressbook (addr, mail_config_get_lookup_book_local_only ());
+	g_object_unref (addr);
+
+	return ret;
+*/
+	return FALSE;
+}
+
+static gboolean
+alert_user(CamelSession *session, CamelSessionAlertType type, const gchar *prompt, gboolean cancel)
+{
+	struct _user_message_msg *m;
+	gboolean result = TRUE;
+
+	m = mail_msg_new (&user_message_info);
+	m->ismain = mail_in_main_thread ();
+	m->type = type;
+	m->prompt = g_strdup (prompt);
+	m->done = e_flag_new ();
+	m->allow_cancel = cancel;
+
+	if (cancel)
+		mail_msg_ref (m);
+
+	if (m->ismain)
+		user_message_exec (m);
+	else
+		mail_msg_main_loop_push (m);
+
+	if (cancel) {
+		e_flag_wait (m->done);
+		result = m->result;
+		mail_msg_unref (m);
+	} else if (m->ismain)
+		mail_msg_unref (m);
+
+	return result;
+}
+/*
+static CamelFolder *
+get_folder (CamelFilterDriver *d,
+            const gchar *uri,
+            gpointer data,
+            GError **error)
+{
+	return mail_tool_uri_to_folder (uri, 0, error);
+}
+
+static void
+main_play_sound (CamelFilterDriver *driver, gchar *filename, gpointer user_data)
+{
+	if (filename && *filename) {
+#ifdef HAVE_CANBERRA
+		ca_context_play(ca_gtk_context_get(), 0,
+				CA_PROP_MEDIA_FILENAME, filename,
+				NULL);
+#endif
+	} else
+		gdk_beep ();
+
+	g_free (filename);
+	g_object_unref (session);
+}
+*/
+
+#if 0
+static void
+session_play_sound (CamelFilterDriver *driver, const gchar *filename, gpointer user_data)
+{
+	MailSession *ms = (MailSession *) session;
+
+	g_object_ref (session);
+
+	mail_async_event_emit (ms->async, MAIL_ASYNC_GUI, (MailAsyncFunc) main_play_sound,
+			       driver, g_strdup (filename), user_data);
+}
+
+static void
+main_system_beep (CamelFilterDriver *driver, gpointer user_data)
+{
+	gdk_beep ();
+	g_object_unref (session);
+}
+
+static void
+session_system_beep (CamelFilterDriver *driver, gpointer user_data)
+{
+	MailSession *ms = (MailSession *) session;
+
+	g_object_ref (session);
+
+	mail_async_event_emit (ms->async, MAIL_ASYNC_GUI, (MailAsyncFunc) main_system_beep,
+			       driver, user_data, NULL);
+}
+
+static CamelFilterDriver *
+main_get_filter_driver (CamelSession *session, const gchar *type, GError **error)
+{
+	CamelFilterDriver *driver;
+	EFilterRule *rule = NULL;
+	const gchar *config_dir;
+	gchar *user, *system;
+	GConfClient *gconf;
+	ERuleContext *fc;
+
+	gconf = mail_config_get_gconf_client ();
+
+	config_dir = mail_session_get_config_dir ();
+	user = g_build_filename (config_dir, "filters.xml", NULL);
+	system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
+	fc = (ERuleContext *) em_filter_context_new ();
+	e_rule_context_load (fc, system, user);
+	g_free (system);
+	g_free (user);
+
+	driver = camel_filter_driver_new (session);
+	camel_filter_driver_set_folder_func (driver, get_folder, NULL);
+
+	if (gconf_client_get_bool (gconf, "/apps/evolution/mail/filters/log", NULL)) {
+		MailSession *ms = (MailSession *) session;
+
+		if (ms->filter_logfile == NULL) {
+			gchar *filename;
+
+			filename = gconf_client_get_string (gconf, "/apps/evolution/mail/filters/logfile", NULL);
+			if (filename) {
+				ms->filter_logfile = g_fopen (filename, "a+");
+				g_free (filename);
+			}
+		}
+
+		if (ms->filter_logfile)
+			camel_filter_driver_set_logfile (driver, ms->filter_logfile);
+	}
+
+	camel_filter_driver_set_shell_func (driver, mail_execute_shell_command, NULL);
+	camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL);
+	camel_filter_driver_set_system_beep_func (driver, session_system_beep, NULL);
+
+	if ((!strcmp (type, E_FILTER_SOURCE_INCOMING) || !strcmp (type, E_FILTER_SOURCE_JUNKTEST))
+	    && camel_session_get_check_junk (session)) {
+		/* implicit junk check as 1st rule */
+		camel_filter_driver_add_rule (driver, "Junk check", "(junk-test)", "(begin (set-system-flag \"junk\"))");
+	}
+
+	if (strcmp (type, E_FILTER_SOURCE_JUNKTEST) != 0) {
+		GString *fsearch, *faction;
+
+		fsearch = g_string_new ("");
+		faction = g_string_new ("");
+
+		if (!strcmp (type, E_FILTER_SOURCE_DEMAND))
+			type = E_FILTER_SOURCE_INCOMING;
+
+		/* add the user-defined rules next */
+		while ((rule = e_rule_context_next_rule (fc, rule, type))) {
+			g_string_truncate (fsearch, 0);
+			g_string_truncate (faction, 0);
+
+			/* skip disabled rules */
+			if (!rule->enabled)
+				continue;
+
+			e_filter_rule_build_code (rule, fsearch);
+			em_filter_rule_build_action ((EMFilterRule *) rule, faction);
+			camel_filter_driver_add_rule (driver, rule->name, fsearch->str, faction->str);
+		}
+
+		g_string_free (fsearch, TRUE);
+		g_string_free (faction, TRUE);
+	}
+
+	g_object_unref (fc);
+
+	return driver;
+}
+#endif 
+
+static CamelFilterDriver *
+get_filter_driver (CamelSession *session, const gchar *type, GError **error)
+{
+	/* Filtering needs more attention to be built */	
+	return NULL;
+/*	
+	return (CamelFilterDriver *) mail_call_main (
+		MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver,
+		session, type, error);
+*/
+}
+
+/* TODO: This is very temporary, until we have a better way to do the progress reporting,
+   we just borrow a dummy mail-mt thread message and hook it onto out camel thread message */
+
+static MailMsgInfo ms_thread_info_dummy = { sizeof (MailMsg) };
+
+static gpointer ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, guint size)
+{
+	CamelSessionThreadMsg *msg;
+	CamelSessionClass *session_class;
+
+	session_class = CAMEL_SESSION_CLASS (mail_session_parent_class);
+	msg = session_class->thread_msg_new (session, ops, size);
+
+	/* We create a dummy mail_msg, and then copy its cancellation port over to ours, so
+	   we get cancellation and progress in common with hte existing mail code, for free */
+	if (msg) {
+		MailMsg *m = mail_msg_new(&ms_thread_info_dummy);
+
+		msg->data = m;
+		camel_operation_unref(msg->op);
+		msg->op = m->cancel;
+		camel_operation_ref(msg->op);
+	}
+
+	return msg;
+}
+
+static void
+ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m)
+{
+	CamelSessionClass *session_class;
+
+	session_class = CAMEL_SESSION_CLASS (mail_session_parent_class);
+
+	mail_msg_unref(m->data);
+	session_class->thread_msg_free(session, m);
+}
+
+static void
+ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const gchar *text, gint pc)
+{
+	/* This should never be called since we bypass it in alloc! */
+	printf("Thread status '%s' %d%%\n", text, pc);
+}
+
+static gboolean
+forward_to_flush_outbox_cb (gpointer data)
+{
+	guint *preparing_flush = data;
+
+	g_return_val_if_fail (preparing_flush != NULL, FALSE);
+
+	*preparing_flush = 0;
+	mail_send ();
+
+	return FALSE;
+}
+
+static void
+ms_forward_to_cb (CamelFolder *folder,
+                  CamelMimeMessage *msg,
+                  CamelMessageInfo *info,
+                  gint queued,
+                  const gchar *appended_uid,
+                  gpointer data)
+{
+	static guint preparing_flush = 0;
+
+	camel_message_info_free (info);
+
+	/* do not call mail send immediately, just pile them all in the outbox */
+	if (preparing_flush ||
+	    gconf_client_get_bool (mail_config_get_gconf_client (), "/apps/evolution/mail/filters/flush-outbox", NULL)) {
+		if (preparing_flush)
+			g_source_remove (preparing_flush);
+
+		preparing_flush = g_timeout_add_seconds (60, forward_to_flush_outbox_cb, &preparing_flush);
+	}
+}
+
+static gboolean
+ms_forward_to (CamelSession *session,
+               CamelFolder *folder,
+               CamelMimeMessage *message,
+               const gchar *address,
+               GError **error)
+{
+	EAccount *account;
+	CamelMimeMessage *forward;
+	CamelStream *mem;
+	CamelInternetAddress *addr;
+	CamelFolder *out_folder;
+	CamelMessageInfo *info;
+	struct _camel_header_raw *xev;
+	gchar *subject;
+
+	g_return_val_if_fail (folder != NULL, FALSE);
+	g_return_val_if_fail (message != NULL, FALSE);
+	g_return_val_if_fail (address != NULL, FALSE);
+
+	if (!*address) {
+		g_set_error (
+			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+			_("No destination address provided, forward "
+			  "of the message has been cancelled."));
+		return FALSE;
+	}
+
+	account = em_utils_guess_account_with_recipients (message, folder);
+	if (!account) {
+		g_set_error (
+			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+			_("No account found to use, forward of the "
+			  "message has been cancelled."));
+		return FALSE;
+	}
+
+	forward = camel_mime_message_new ();
+
+	/* make copy of the message, because we are going to modify it */
+	mem = camel_stream_mem_new ();
+	camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem, NULL);
+	camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET, NULL);
+	camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem, NULL);
+	g_object_unref (mem);
+
+	/* clear previous recipients */
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_TO, NULL);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_CC, NULL);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_BCC, NULL);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_TO, NULL);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_CC, NULL);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_BCC, NULL);
+
+	/* remove all delivery and notification headers */
+	while (camel_medium_get_header (CAMEL_MEDIUM (forward), "Disposition-Notification-To"))
+		camel_medium_remove_header (CAMEL_MEDIUM (forward), "Disposition-Notification-To");
+
+	while (camel_medium_get_header (CAMEL_MEDIUM (forward), "Delivered-To"))
+		camel_medium_remove_header (CAMEL_MEDIUM (forward), "Delivered-To");
+
+	/* remove any X-Evolution-* headers that may have been set */
+	xev = mail_tool_remove_xevolution_headers (forward);
+	camel_header_raw_clear (&xev);
+
+	/* from */
+	addr = camel_internet_address_new ();
+	camel_internet_address_add (addr, account->id->name, account->id->address);
+	camel_mime_message_set_from (forward, addr);
+	g_object_unref (addr);
+
+	/* to */
+	addr = camel_internet_address_new ();
+	camel_address_decode (CAMEL_ADDRESS (addr), address);
+	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_TO, addr);
+	g_object_unref (addr);
+
+	/* subject */
+	subject = mail_tool_generate_forward_subject (message);
+	camel_mime_message_set_subject (forward, subject);
+	g_free (subject);
+
+	/* and send it */
+	info = camel_message_info_new (NULL);
+	out_folder = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+	camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+	mail_append_mail (out_folder, forward, info, ms_forward_to_cb, NULL);
+
+	return TRUE;
+}
+
+gchar *
+mail_session_get_password (const gchar *url_string)
+{
+	CamelURL *url;
+	gchar *simple_url;
+	gchar *passwd;
+
+	url = camel_url_new (url_string, NULL);
+	simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+	camel_url_free (url);
+
+	passwd = e_passwords_get_password ("Mail", simple_url);
+
+	g_free (simple_url);
+
+	return passwd;
+}
+
+void
+mail_session_add_password (const gchar *url_string,
+			   const gchar *passwd)
+{
+	CamelURL *url;
+	gchar *simple_url;
+
+	url = camel_url_new (url_string, NULL);
+	simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+	camel_url_free (url);
+
+	e_passwords_add_password (simple_url, passwd);
+
+	g_free (simple_url);
+}
+
+void
+mail_session_remember_password (const gchar *url_string)
+{
+	CamelURL *url;
+	gchar *simple_url;
+
+	url = camel_url_new (url_string, NULL);
+	simple_url = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+	camel_url_free (url);
+
+	e_passwords_remember_password ("Mail", simple_url);
+
+	g_free (simple_url);
+}
+
+void
+mail_session_forget_password (const gchar *key)
+{
+	e_passwords_forget_password ("Mail", key);
+}
+
+static void
+mail_session_check_junk_notify (GConfClient *gconf, guint id, GConfEntry *entry, CamelSession *session)
+{
+	gchar *key;
+
+	g_return_if_fail (gconf_entry_get_key (entry) != NULL);
+	g_return_if_fail (gconf_entry_get_value (entry) != NULL);
+
+	key = strrchr (gconf_entry_get_key (entry), '/');
+	if (key) {
+		key++;
+		if (!strcmp (key, "check_incoming"))
+			camel_session_set_check_junk (session, gconf_value_get_bool (gconf_entry_get_value (entry)));
+	}
+}
+
+#define DIR_PROXY "/system/proxy"
+#define MODE_PROXY "/system/proxy/mode"
+#define KEY_SOCKS_HOST "/system/proxy/socks_host"
+#define KEY_SOCKS_PORT "/system/proxy/socks_port"
+
+static void
+set_socks_proxy_from_gconf (void)
+{
+	GConfClient *client;
+	gchar *mode, *host;
+	gint port;
+
+	client = mail_config_get_gconf_client ();
+
+	mode = gconf_client_get_string (client, MODE_PROXY, NULL);
+	if (!g_strcmp0(mode, "manual")) {
+		host = gconf_client_get_string (client, KEY_SOCKS_HOST, NULL); /* NULL-GError */
+		port = gconf_client_get_int (client, KEY_SOCKS_PORT, NULL); /* NULL-GError */
+		camel_session_set_socks_proxy (session, host, port);
+		g_free (host);
+	}
+	g_free (mode);
+}
+
+static void
+proxy_gconf_notify_cb (GConfClient* client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+{
+	const gchar *key;
+
+	key = gconf_entry_get_key (entry);
+
+	if (strcmp (entry->key, KEY_SOCKS_HOST) == 0
+	    || strcmp (entry->key, KEY_SOCKS_PORT) == 0)
+		set_socks_proxy_from_gconf ();
+}
+
+static void
+set_socks_proxy_gconf_watch (void)
+{
+	GConfClient *client;
+
+	client = mail_config_get_gconf_client ();
+
+	gconf_client_add_dir (client, DIR_PROXY, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); /* NULL-GError */
+	session_gconf_proxy_id = gconf_client_notify_add (client, DIR_PROXY, proxy_gconf_notify_cb, NULL, NULL, NULL); /* NULL-GError */
+}
+
+static void
+init_socks_proxy (void)
+{
+	set_socks_proxy_gconf_watch ();
+	set_socks_proxy_from_gconf ();
+}
+
+void
+mail_session_start (void)
+{
+	GConfClient *gconf;
+
+	if (camel_init (e_get_user_data_dir (), TRUE) != 0)
+		exit (0);
+
+	camel_provider_init();
+
+	session = g_object_new (MAIL_TYPE_SESSION, NULL);
+	e_account_writable(NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD); /* Init the EAccount Setup */
+
+	camel_session_construct (session, mail_session_get_data_dir ());
+
+	gconf = mail_config_get_gconf_client ();
+	gconf_client_add_dir (gconf, "/apps/evolution/mail/junk", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+	camel_session_set_check_junk (session, gconf_client_get_bool (gconf, "/apps/evolution/mail/junk/check_incoming", NULL));
+	session_check_junk_notify_id = gconf_client_notify_add (gconf, "/apps/evolution/mail/junk",
+								(GConfClientNotifyFunc) mail_session_check_junk_notify,
+								session, NULL, NULL);
+	session->junk_plugin = NULL;
+
+	mail_config_reload_junk_headers ();
+
+	init_socks_proxy ();
+}
+
+void
+mail_session_shutdown (void)
+{
+	camel_shutdown ();
+}
+
+void
+mail_session_flush_filter_log (void)
+{
+	MailSession *ms = (MailSession *) session;
+
+	if (ms->filter_logfile)
+		fflush (ms->filter_logfile);
+}
+
+void
+mail_session_add_junk_plugin (const gchar *plugin_name, CamelJunkPlugin *junk_plugin)
+{
+	MailSession *ms = (MailSession *) session;
+	GConfClient *gconf;
+	gchar *def_plugin;
+
+	gconf = mail_config_get_gconf_client ();
+	def_plugin = gconf_client_get_string (gconf, "/apps/evolution/mail/junk/default_plugin", NULL);
+
+	ms->junk_plugins = g_list_append(ms->junk_plugins, junk_plugin);
+	if (def_plugin && plugin_name) {
+		if (!strcmp(def_plugin, plugin_name)) {
+			d(printf ("Loading %s as the default junk plugin\n", def_plugin));
+			session->junk_plugin = junk_plugin;
+			camel_junk_plugin_init (junk_plugin);
+		}
+	}
+
+	g_free (def_plugin);
+}
+
+const GList *
+mail_session_get_junk_plugins (void)
+{
+	MailSession *ms = (MailSession *) session;
+	return ms->junk_plugins;
+}
+
+void
+mail_session_set_junk_headers (const gchar **name, const gchar **value, gint len)
+{
+	if (!session)
+		return;
+
+	camel_session_set_junk_headers (session, name, value, len);
+}
+
+const gchar *
+mail_session_get_data_dir (void)
+{
+	if (G_UNLIKELY (mail_data_dir == NULL))
+		mail_data_dir = g_build_filename (
+			e_get_user_data_dir (), "mail", NULL);
+
+	return mail_data_dir;
+}
+
+const gchar *
+mail_session_get_config_dir (void)
+{
+	if (G_UNLIKELY (mail_config_dir == NULL))
+		mail_config_dir = g_build_filename (
+			e_get_user_config_dir (), "mail", NULL);
+
+	return mail_config_dir;
+}
+
diff --git a/mail/daemon/mail-session.h b/mail/daemon/mail-session.h
new file mode 100644
index 0000000..4984a58
--- /dev/null
+++ b/mail/daemon/mail-session.h
@@ -0,0 +1,57 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Jeffrey Stedfast <fejj ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef MAIL_SESSION_H
+#define MAIL_SESSION_H
+
+#include <glib.h>
+#include <camel/camel.h>
+
+G_BEGIN_DECLS
+
+void mail_session_start (void);
+void mail_session_shutdown (void);
+gchar *mail_session_request_dialog (const gchar *prompt, gboolean secret,
+				   const gchar *key, gboolean async);
+gboolean mail_session_accept_dialog (const gchar *prompt, const gchar *key,
+				     gboolean async);
+gchar *mail_session_get_password (const gchar *url);
+void mail_session_add_password (const gchar *url, const gchar *passwd);
+void mail_session_remember_password (const gchar *url);
+
+void mail_session_forget_password (const gchar *key);
+
+void mail_session_flush_filter_log (void);
+
+void mail_session_add_junk_plugin (const gchar *plugin_name, CamelJunkPlugin *junk_plugin);
+
+const GList * mail_session_get_junk_plugins (void);
+void mail_session_set_junk_headers (const gchar **name, const gchar **value, gint len);
+
+const gchar * mail_session_get_data_dir (void);
+const gchar * mail_session_get_config_dir (void);
+
+extern CamelSession *session;
+
+G_END_DECLS
+
+#endif /* MAIL_SESSION_H */
diff --git a/mail/daemon/mail-tools.c b/mail/daemon/mail-tools.c
new file mode 100644
index 0000000..bcf20b7
--- /dev/null
+++ b/mail/daemon/mail-tools.c
@@ -0,0 +1,938 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Dan Winship <danw ximian com>
+ *		Peter Williams <peterw ximian com>
+ *		Jeffrey Stedfast <fejj ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <glib/gi18n.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-account-list.h>
+#include "mail-folder-cache.h"
+#include "mail-session.h"
+#include "mail-tools.h"
+#include "e-account-utils.h"
+#include "e-mail-local.h"
+#include "mail-config.h"
+
+#define d(x)
+
+/* **************************************** */
+
+CamelFolder *
+mail_tool_get_inbox (const gchar *url, GError **error)
+{
+	CamelStore *store;
+	CamelFolder *folder;
+
+	store = camel_session_get_store (session, url, error);
+	if (!store)
+		return NULL;
+
+	folder = camel_store_get_inbox (store, error);
+	g_object_unref (store);
+
+	return folder;
+}
+
+static gboolean
+is_local_provider (CamelStore *store)
+{
+	CamelProvider *provider;
+
+	g_return_val_if_fail (store != NULL, FALSE);
+
+	provider = camel_service_get_provider (CAMEL_SERVICE (store));
+
+	g_return_val_if_fail (provider != NULL, FALSE);
+
+	return (provider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
+}
+
+CamelFolder *
+mail_tool_get_trash (const gchar *url,
+                     gint connect,
+                     GError **error)
+{
+	CamelStore *store;
+	CamelFolder *trash;
+
+	if (connect)
+		store = camel_session_get_store (session, url, error);
+	else
+		store = (CamelStore *) camel_session_get_service (
+			session, url, CAMEL_PROVIDER_STORE, error);
+
+	if (!store)
+		return NULL;
+
+	if (connect ||
+		(CAMEL_SERVICE (store)->status == CAMEL_SERVICE_CONNECTED ||
+		is_local_provider (store)))
+		trash = camel_store_get_trash (store, error);
+	else
+		trash = NULL;
+
+	g_object_unref (store);
+
+	return trash;
+}
+
+#ifndef G_OS_WIN32
+
+static gchar *
+mail_tool_get_local_movemail_path (const guchar *uri,
+                                   GError **error)
+{
+	guchar *safe_uri, *c;
+	const gchar *data_dir;
+	gchar *path, *full;
+	struct stat st;
+
+	safe_uri = (guchar *)g_strdup ((const gchar *)uri);
+	for (c = safe_uri; *c; c++)
+		if (strchr("/:;=|%&#!*^()\\, ", *c) || !isprint((gint) *c))
+			*c = '_';
+
+	data_dir = mail_session_get_data_dir ();
+	path = g_build_filename (data_dir, "spool", NULL);
+
+	if (g_stat(path, &st) == -1 && g_mkdir_with_parents(path, 0700) == -1) {
+		g_set_error (
+			error, G_FILE_ERROR,
+			g_file_error_from_errno (errno),
+			_("Could not create spool directory '%s': %s"),
+			path, g_strerror(errno));
+		g_free(path);
+		return NULL;
+	}
+
+	full = g_strdup_printf("%s/movemail.%s", path, safe_uri);
+	g_free(path);
+	g_free(safe_uri);
+
+	return full;
+}
+
+#endif
+
+gchar *
+mail_tool_do_movemail (const gchar *source_url, GError **error)
+{
+#ifndef G_OS_WIN32
+	gchar *dest_path;
+	struct stat sb;
+	CamelURL *uri;
+	gboolean success;
+
+	uri = camel_url_new(source_url, error);
+	if (uri == NULL)
+		return NULL;
+
+	if (strcmp(uri->protocol, "mbox") != 0) {
+		/* This is really only an internal error anyway */
+		g_set_error (
+			error, CAMEL_SERVICE_ERROR,
+			CAMEL_SERVICE_ERROR_URL_INVALID,
+			_("Trying to movemail a non-mbox source '%s'"),
+			source_url);
+		camel_url_free(uri);
+		return NULL;
+	}
+
+	/* Set up our destination. */
+	dest_path = mail_tool_get_local_movemail_path (
+		(guchar *) source_url, error);
+	if (dest_path == NULL)
+		return NULL;
+
+	/* Movemail from source (source_url) to dest_path */
+	success = camel_movemail (uri->path, dest_path, error) != -1;
+	camel_url_free(uri);
+
+	if (g_stat (dest_path, &sb) < 0 || sb.st_size == 0) {
+		g_unlink (dest_path); /* Clean up the movemail.foo file. */
+		g_free (dest_path);
+		return NULL;
+	}
+
+	if (!success) {
+		g_free (dest_path);
+		return NULL;
+	}
+
+	return dest_path;
+#else
+	/* Unclear yet whether camel-movemail etc makes any sense on
+	 * Win32, at least it is not ported yet.
+	 */
+	g_warning("%s: Not implemented", __FUNCTION__);
+	return NULL;
+#endif
+}
+
+gchar *
+mail_tool_generate_forward_subject (CamelMimeMessage *msg)
+{
+	const gchar *subject;
+	gchar *fwd_subj;
+	const gint max_subject_length = 1024;
+
+	subject = camel_mime_message_get_subject(msg);
+
+	if (subject && *subject) {
+		/* Truncate insanely long subjects */
+		if (strlen (subject) < max_subject_length) {
+			fwd_subj = g_strdup_printf ("[Fwd: %s]", subject);
+		} else {
+			/* We can't use %.*s because it depends on the locale being C/POSIX
+			   or UTF-8 to work correctly in glibc */
+			/*fwd_subj = g_strdup_printf ("[Fwd: %.*s...]", max_subject_length, subject);*/
+			fwd_subj = g_malloc (max_subject_length + 11);
+			memcpy (fwd_subj, "[Fwd: ", 6);
+			memcpy (fwd_subj + 6, subject, max_subject_length);
+			memcpy (fwd_subj + 6 + max_subject_length, "...]", 5);
+		}
+	} else {
+		const CamelInternetAddress *from;
+		gchar *fromstr;
+
+		from = camel_mime_message_get_from (msg);
+		if (from) {
+			fromstr = camel_address_format (CAMEL_ADDRESS (from));
+			fwd_subj = g_strdup_printf ("[Fwd: %s]", fromstr);
+			g_free (fromstr);
+		} else
+			fwd_subj = g_strdup ("[Fwd: No Subject]");
+	}
+
+	return fwd_subj;
+}
+
+struct _camel_header_raw *
+mail_tool_remove_xevolution_headers (CamelMimeMessage *message)
+{
+	struct _camel_header_raw *scan, *list = NULL;
+
+	for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next)
+		if (!strncmp(scan->name, "X-Evolution", 11))
+			camel_header_raw_append(&list, scan->name, scan->value, scan->offset);
+
+	for (scan=list;scan;scan=scan->next)
+		camel_medium_remove_header((CamelMedium *)message, scan->name);
+
+	return list;
+}
+
+void
+mail_tool_restore_xevolution_headers (CamelMimeMessage *message,
+                                      struct _camel_header_raw *xev)
+{
+	CamelMedium *medium;
+
+	medium = CAMEL_MEDIUM (message);
+
+	for (;xev;xev=xev->next)
+		camel_medium_add_header (medium, xev->name, xev->value);
+}
+
+CamelMimePart *
+mail_tool_make_message_attachment (CamelMimeMessage *message)
+{
+	CamelMimePart *part;
+	const gchar *subject;
+	struct _camel_header_raw *xev;
+	gchar *desc;
+
+	subject = camel_mime_message_get_subject (message);
+	if (subject)
+		desc = g_strdup_printf (_("Forwarded message - %s"), subject);
+	else
+		desc = g_strdup (_("Forwarded message"));
+
+	/* rip off the X-Evolution headers */
+	xev = mail_tool_remove_xevolution_headers (message);
+	camel_header_raw_clear(&xev);
+
+	/* remove Bcc headers */
+	camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc");
+
+	part = camel_mime_part_new ();
+	camel_mime_part_set_disposition (part, "inline");
+	camel_mime_part_set_description (part, desc);
+	camel_medium_set_content (
+		CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (message));
+	camel_mime_part_set_content_type (part, "message/rfc822");
+	g_free (desc);
+
+	return part;
+}
+
+CamelFolder *
+mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error)
+{
+	CamelURL *url;
+	CamelStore *store = NULL;
+	CamelFolder *folder = NULL;
+	gint offset = 0;
+	gchar *curi = NULL;
+
+	g_return_val_if_fail (uri != NULL, NULL);
+
+	/* TODO: vtrash and vjunk are no longer used for these uri's */
+	if (!strncmp (uri, "vtrash:", 7))
+		offset = 7;
+	else if (!strncmp (uri, "vjunk:", 6))
+		offset = 6;
+	else if (!strncmp(uri, "email:", 6)) {
+		/* FIXME?: the filter:get_folder callback should do this itself? */
+		curi = em_uri_to_camel(uri);
+		if (uri == NULL) {
+			g_set_error (
+				error,
+				CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+				_("Invalid folder: '%s'"), uri);
+			return NULL;
+		}
+		uri = curi;
+	}
+
+	url = camel_url_new (uri + offset, error);
+	if (!url) {
+		g_free(curi);
+		return NULL;
+	}
+
+	store = (CamelStore *) camel_session_get_service (
+		session, uri + offset, CAMEL_PROVIDER_STORE, error);
+	if (store) {
+		const gchar *name;
+
+		/* if we have a fragment, then the path is actually used by the store,
+		   so the fragment is the path to the folder instead */
+		if (url->fragment) {
+			name = url->fragment;
+		} else {
+			if (url->path && *url->path)
+				name = url->path + 1;
+			else
+				name = "";
+		}
+
+		if (offset) {
+			if (offset == 7)
+				folder = camel_store_get_trash (store, error);
+			else if (offset == 6)
+				folder = camel_store_get_junk (store, error);
+		} else
+			folder = camel_store_get_folder (store, name, flags, error);
+		g_object_unref (store);
+	}
+
+	if (folder)
+		mail_folder_cache_note_folder (mail_folder_cache_get_default (), folder);
+
+	camel_url_free (url);
+	g_free(curi);
+
+	return folder;
+}
+
+/**
+ * mail_tools_x_evolution_message_parse:
+ * @in: GtkSelectionData->data
+ * @inlen: GtkSelectionData->length
+ * @uids: pointer to a gptrarray that will be filled with uids on success
+ *
+ * Parses the GtkSelectionData and returns a CamelFolder and a list of
+ * UIDs specified by the selection.
+ **/
+CamelFolder *
+mail_tools_x_evolution_message_parse (gchar *in, guint inlen, GPtrArray **uids)
+{
+	/* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */
+	gchar *inptr, *inend;
+	CamelFolder *folder;
+
+	if (in == NULL)
+		return NULL;
+
+	folder = mail_tool_uri_to_folder (in, 0, NULL);
+
+	if (!folder)
+		return NULL;
+
+	/* split the uids */
+	inend = in + inlen;
+	inptr = in + strlen (in) + 1;
+	*uids = g_ptr_array_new ();
+	while (inptr < inend) {
+		gchar *start = inptr;
+
+		while (inptr < inend && *inptr)
+			inptr++;
+
+		g_ptr_array_add (*uids, g_strndup (start, inptr - start));
+		inptr++;
+	}
+
+	return folder;
+}
+
+/* FIXME: This should be a property on CamelFolder */
+gchar *
+mail_tools_folder_to_url (CamelFolder *folder)
+{
+	CamelService *service;
+	CamelStore *parent_store;
+	const gchar *full_name;
+	CamelURL *url;
+	gchar *out;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+	full_name = camel_folder_get_full_name (folder);
+	parent_store = camel_folder_get_parent_store (folder);
+	service = CAMEL_SERVICE (parent_store);
+
+	url = camel_url_copy (service->url);
+	if (service->provider->url_flags  & CAMEL_URL_FRAGMENT_IS_PATH) {
+		camel_url_set_fragment(url, full_name);
+	} else {
+		gchar *name = g_alloca(strlen(full_name)+2);
+
+		sprintf(name, "/%s", full_name);
+		camel_url_set_path(url, name);
+	}
+
+	out = camel_url_to_string(url, CAMEL_URL_HIDE_ALL);
+	camel_url_free(url);
+
+	return out;
+}
+/* Utility functions */
+
+gchar *em_uri_to_camel(const gchar *euri)
+{
+	EAccountList *accounts;
+	const EAccount *account;
+	EAccountService *service;
+	CamelProvider *provider;
+	CamelURL *eurl, *curl;
+	gchar *uid, *curi;
+
+	if (strncmp(euri, "email:", 6) != 0) {
+		d(printf("em uri to camel not euri '%s'\n", euri));
+		return g_strdup(euri);
+	}
+
+	eurl = camel_url_new(euri, NULL);
+	if (eurl == NULL)
+		return g_strdup(euri);
+
+	g_return_val_if_fail (eurl->host != NULL, g_strdup(euri));
+
+	if (eurl->user != NULL) {
+		/* Sigh, shoul'dve used mbox local for mailboxes, not local local */
+		if (strcmp(eurl->host, "local") == 0
+		    && (strcmp(eurl->user, "local") == 0 || strcmp(eurl->user, "vfolder") == 0)) {
+			gchar *base;
+
+			if (strcmp(eurl->user, "vfolder") == 0)
+				curl = camel_url_new("vfolder:", NULL);
+			else
+				curl = camel_url_new("mbox:", NULL);
+
+			base = g_strdup_printf("%s/mail/%s", e_get_user_data_dir(), eurl->user);
+#ifdef G_OS_WIN32
+			/* Turn backslashes into slashes to avoid URI encoding */
+			{
+				gchar *p = base;
+				while ((p = strchr (p, '\\')))
+					*p++ = '/';
+			}
+#endif
+			camel_url_set_path(curl, base);
+			g_free(base);
+			camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
+			curi = camel_url_to_string(curl, 0);
+			camel_url_free(curl);
+			camel_url_free(eurl);
+
+			d(printf("em uri to camel local '%s' -> '%s'\n", euri, curi));
+			return curi;
+		}
+
+		uid = g_strdup_printf("%s %s", eurl->user, eurl->host);
+	} else {
+		uid = g_strdup(eurl->host);
+	}
+
+	accounts = e_get_account_list ();
+	account = e_account_list_find(accounts, E_ACCOUNT_FIND_UID, uid);
+	g_free(uid);
+
+	if (account == NULL) {
+		camel_url_free(eurl);
+		d(printf("em uri to camel no account '%s' -> '%s'\n", euri, euri));
+		return g_strdup(euri);
+	}
+
+	service = account->source;
+	provider = camel_provider_get (service->url, NULL);
+	if (provider == NULL)
+		return g_strdup (euri);
+
+	curl = camel_url_new(service->url, NULL);
+	if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
+		camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
+	else
+		camel_url_set_path(curl, eurl->path);
+
+	curi = camel_url_to_string(curl, 0);
+
+	camel_url_free(eurl);
+	camel_url_free(curl);
+
+	d(printf("em uri to camel '%s' -> '%s'\n", euri, curi));
+
+	return curi;
+}
+
+/**
+ * em_utils_uids_free:
+ * @uids: array of uids
+ *
+ * Frees the array of uids pointed to by @uids back to the system.
+ **/
+void
+em_utils_uids_free (GPtrArray *uids)
+{
+	gint i;
+
+	for (i = 0; i < uids->len; i++)
+		g_free (uids->pdata[i]);
+
+	g_ptr_array_free (uids, TRUE);
+}
+
+/** em_utils_folder_is_templates:
+ * @folder: folder
+ * @uri: uri for this folder, if known
+ *
+ * Decides if @folder is a Templates folder.
+ *
+ * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
+ **/
+
+gboolean
+em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri)
+{
+	CamelFolder *local_templates_folder;
+	CamelStore *parent_store;
+	EAccountList *accounts;
+	EAccount *account;
+	EIterator *iter;
+	gint is = FALSE;
+	gchar *templates_uri;
+
+	local_templates_folder =
+		e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES);
+
+	if (folder == local_templates_folder)
+		return TRUE;
+
+	if (folder == NULL || uri == NULL)
+		return FALSE;
+
+	parent_store = camel_folder_get_parent_store (folder);
+
+	accounts = e_get_account_list ();
+	iter = e_list_get_iterator ((EList *)accounts);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *)e_iterator_get (iter);
+
+		if (account->templates_folder_uri) {
+			templates_uri = em_uri_to_camel (account->templates_folder_uri);
+			if (camel_store_folder_uri_equal (parent_store, templates_uri, uri)) {
+				g_free (templates_uri);
+				is = TRUE;
+				break;
+			}
+			g_free (templates_uri);
+		}
+
+		e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	return is;
+}
+
+/**
+ * em_utils_folder_is_drafts:
+ * @folder: folder
+ * @uri: uri for this folder, if known
+ *
+ * Decides if @folder is a Drafts folder.
+ *
+ * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
+ **/
+gboolean
+em_utils_folder_is_drafts(CamelFolder *folder, const gchar *uri)
+{
+	CamelFolder *local_drafts_folder;
+	CamelStore *parent_store;
+	EAccountList *accounts;
+	EAccount *account;
+	EIterator *iter;
+	gint is = FALSE;
+	gchar *drafts_uri;
+
+	local_drafts_folder =
+		e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS);
+
+	if (folder == local_drafts_folder)
+		return TRUE;
+
+	if (folder == NULL || uri == NULL)
+		return FALSE;
+
+	parent_store = camel_folder_get_parent_store (folder);
+
+	accounts = e_get_account_list ();
+	iter = e_list_get_iterator((EList *)accounts);
+	while (e_iterator_is_valid(iter)) {
+		account = (EAccount *)e_iterator_get(iter);
+
+		if (account->drafts_folder_uri) {
+			drafts_uri = em_uri_to_camel (account->drafts_folder_uri);
+			if (camel_store_folder_uri_equal (parent_store, drafts_uri, uri)) {
+				g_free (drafts_uri);
+				is = TRUE;
+				break;
+			}
+			g_free (drafts_uri);
+		}
+
+		e_iterator_next(iter);
+	}
+
+	g_object_unref(iter);
+
+	return is;
+}
+
+/**
+ * em_utils_folder_is_sent:
+ * @folder: folder
+ * @uri: uri for this folder, if known
+ *
+ * Decides if @folder is a Sent folder
+ *
+ * Returns %TRUE if this is a Sent folder or %FALSE otherwise.
+ **/
+gboolean
+em_utils_folder_is_sent(CamelFolder *folder, const gchar *uri)
+{
+	CamelFolder *local_sent_folder;
+	CamelStore *parent_store;
+	EAccountList *accounts;
+	EAccount *account;
+	EIterator *iter;
+	gint is = FALSE;
+	gchar *sent_uri;
+
+	local_sent_folder = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
+
+	if (folder == local_sent_folder)
+		return TRUE;
+
+	if (folder == NULL || uri == NULL)
+		return FALSE;
+
+	parent_store = camel_folder_get_parent_store (folder);
+
+	accounts = e_get_account_list ();
+	iter = e_list_get_iterator((EList *)accounts);
+	while (e_iterator_is_valid(iter)) {
+		account = (EAccount *)e_iterator_get(iter);
+
+		if (account->sent_folder_uri) {
+			sent_uri = em_uri_to_camel (account->sent_folder_uri);
+			if (camel_store_folder_uri_equal (parent_store, sent_uri, uri)) {
+				g_free (sent_uri);
+				is = TRUE;
+				break;
+			}
+			g_free (sent_uri);
+		}
+
+		e_iterator_next(iter);
+	}
+
+	g_object_unref(iter);
+
+	return is;
+}
+
+/**
+ * em_utils_folder_is_outbox:
+ * @folder: folder
+ * @uri: uri for this folder, if known
+ *
+ * Decides if @folder is an Outbox folder
+ *
+ * Returns %TRUE if this is an Outbox folder or %FALSE otherwise.
+ **/
+gboolean
+em_utils_folder_is_outbox(CamelFolder *folder, const gchar *uri)
+{
+	CamelFolder *local_outbox_folder;
+	const gchar *local_outbox_folder_uri;
+
+	local_outbox_folder =
+		e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
+	local_outbox_folder_uri =
+		e_mail_local_get_folder_uri (E_MAIL_FOLDER_OUTBOX);
+
+	if (folder == local_outbox_folder)
+		return TRUE;
+
+	if (uri == NULL)
+		return FALSE;
+
+	return camel_store_folder_uri_equal (
+		camel_folder_get_parent_store (local_outbox_folder),
+		local_outbox_folder_uri, uri);
+}
+
+static EAccount *
+guess_account_from_folder (CamelFolder *folder)
+{
+	CamelService *service;
+	CamelStore *parent_store;
+	EAccount *account;
+	gchar *source_url;
+
+	parent_store = camel_folder_get_parent_store (folder);
+	service = CAMEL_SERVICE (parent_store);
+
+	source_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL);
+	account = mail_config_get_account_by_source_url (source_url);
+	g_free (source_url);
+
+	return account;
+}
+
+static EAccount *
+guess_account_from_message (CamelMimeMessage *message)
+{
+	const gchar *source_url;
+
+	source_url = camel_mime_message_get_source (message);
+	if (source_url == NULL)
+		return NULL;
+
+	return mail_config_get_account_by_source_url (source_url);
+}
+
+GHashTable *
+em_utils_generate_account_hash (void)
+{
+	GHashTable *account_hash;
+	EAccount *account, *def;
+	EAccountList *accounts;
+	EIterator *iter;
+
+	accounts = e_get_account_list ();
+	account_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
+
+	def = e_get_default_account ();
+
+	iter = e_list_get_iterator ((EList *) accounts);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->id->address) {
+			EAccount *acnt;
+
+			/* Accounts with identical email addresses that are enabled
+			 * take precedence over the accounts that aren't. If all
+			 * accounts with matching email addresses are disabled, then
+			 * the first one in the list takes precedence. The default
+			 * account always takes precedence no matter what.
+			 */
+			acnt = g_hash_table_lookup (account_hash, account->id->address);
+			if (acnt && acnt != def && !acnt->enabled && account->enabled) {
+				g_hash_table_remove (account_hash, acnt->id->address);
+				acnt = NULL;
+			}
+
+			if (!acnt)
+				g_hash_table_insert (account_hash, (gchar *) account->id->address, (gpointer) account);
+		}
+
+		e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	/* The default account has to be there if none of the enabled accounts are present */
+	if (g_hash_table_size (account_hash) == 0 && def && def->id->address)
+		g_hash_table_insert (account_hash, (gchar *) def->id->address, (gpointer) def);
+
+	return account_hash;
+}
+
+EAccount *
+em_utils_guess_account (CamelMimeMessage *message,
+                        CamelFolder *folder)
+{
+	EAccount *account = NULL;
+
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+	if (folder != NULL)
+		g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+	/* check for newsgroup header */
+	if (folder != NULL
+	    && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups"))
+		account = guess_account_from_folder (folder);
+
+	/* check for source folder */
+	if (account == NULL && folder != NULL)
+		account = guess_account_from_folder (folder);
+
+	/* then message source */
+	if (account == NULL)
+		account = guess_account_from_message (message);
+
+	return account;
+}
+
+EAccount *
+em_utils_guess_account_with_recipients (CamelMimeMessage *message,
+                                        CamelFolder *folder)
+{
+	EAccount *account = NULL;
+	EAccountList *account_list;
+	GHashTable *recipients;
+	EIterator *iter;
+	CamelInternetAddress *addr;
+	const gchar *type;
+	const gchar *key;
+
+	/* This policy is subject to debate and tweaking,
+	 * but please also document the rational here. */
+
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+	/* Build a set of email addresses in which to test for membership.
+	 * Only the keys matter here; the values just need to be non-NULL. */
+	recipients = g_hash_table_new (g_str_hash, g_str_equal);
+
+	type = CAMEL_RECIPIENT_TYPE_TO;
+	addr = camel_mime_message_get_recipients (message, type);
+	if (addr != NULL) {
+		gint index = 0;
+
+		while (camel_internet_address_get (addr, index++, NULL, &key))
+			g_hash_table_insert (
+				recipients, (gpointer) key,
+				GINT_TO_POINTER (1));
+	}
+
+	type = CAMEL_RECIPIENT_TYPE_CC;
+	addr = camel_mime_message_get_recipients (message, type);
+	if (addr != NULL) {
+		gint index = 0;
+
+		while (camel_internet_address_get (addr, index++, NULL, &key))
+			g_hash_table_insert (
+				recipients, (gpointer) key,
+				GINT_TO_POINTER (1));
+	}
+
+	/* First Preference: We were given a folder that maps to an
+	 * enabled account, and that account's email address appears
+	 * in the list of To: or Cc: recipients. */
+
+	if (folder != NULL)
+		account = guess_account_from_folder (folder);
+
+	if (account == NULL || !account->enabled)
+		goto second_preference;
+
+	if ((key = account->id->address) == NULL)
+		goto second_preference;
+
+	if (g_hash_table_lookup (recipients, key) != NULL)
+		goto exit;
+
+second_preference:
+
+	/* Second Preference: Choose any enabled account whose email
+	 * address appears in the list to To: or Cc: recipients. */
+
+	account_list = e_get_account_list ();
+	iter = e_list_get_iterator (E_LIST (account_list));
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+		e_iterator_next (iter);
+
+		if (account == NULL || !account->enabled)
+			continue;
+
+		if ((key = account->id->address) == NULL)
+			continue;
+
+		if (g_hash_table_lookup (recipients, key) != NULL) {
+			g_object_unref (iter);
+			goto exit;
+		}
+	}
+	g_object_unref (iter);
+
+	/* Last Preference: Defer to em_utils_guess_account(). */
+	account = em_utils_guess_account (message, folder);
+
+exit:
+	g_hash_table_destroy (recipients);
+
+	return account;
+}
+
+
diff --git a/mail/daemon/mail-tools.h b/mail/daemon/mail-tools.h
new file mode 100644
index 0000000..5d4dc87
--- /dev/null
+++ b/mail/daemon/mail-tools.h
@@ -0,0 +1,77 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Peter Williams <peterw ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef MAIL_TOOLS_H
+#define MAIL_TOOLS_H
+
+#include <glib.h>
+#include <camel/camel.h>
+
+
+/* Misc stuff */
+#define E_FILTER_SOURCE_INCOMING "incoming" /* performed on incoming email */
+#define E_FILTER_SOURCE_DEMAND   "demand"   /* performed on the selected folder
+					     * when the user asks for it */
+#define E_FILTER_SOURCE_OUTGOING  "outgoing"/* performed on outgoing mail */
+#define E_FILTER_SOURCE_JUNKTEST  "junktest"/* check incoming mail for junk */
+
+
+/* Get the "inbox" for a url (uses global session) */
+CamelFolder *mail_tool_get_inbox (const gchar *url, GError **error);
+
+/* Get the "trash" for a url (uses global session) */
+CamelFolder *mail_tool_get_trash (const gchar *url, gint connect, GError **error);
+
+/* Does a camel_movemail into the local movemail folder
+ * and returns the path to the new movemail folder that was created. which shoudl be freed later */
+gchar *mail_tool_do_movemail (const gchar *source_url, GError **error);
+
+struct _camel_header_raw *mail_tool_remove_xevolution_headers (CamelMimeMessage *message);
+void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *);
+
+/* Generates the subject for a message forwarding @msg */
+gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg);
+
+/* Make a message into an attachment */
+CamelMimePart *mail_tool_make_message_attachment (CamelMimeMessage *message);
+
+/* Parse the ui into a real CamelFolder any way we know how. */
+CamelFolder *mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error);
+
+GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message);
+
+CamelFolder *mail_tools_x_evolution_message_parse (gchar *in, guint inlen, GPtrArray **uids);
+
+gchar *mail_tools_folder_to_url (CamelFolder *folder);
+
+gchar *em_uri_to_camel(const gchar *euri);
+void em_utils_uids_free (GPtrArray *uids);
+gboolean em_utils_folder_is_outbox(CamelFolder *folder, const gchar *uri);
+gboolean em_utils_folder_is_sent(CamelFolder *folder, const gchar *uri);
+gboolean em_utils_folder_is_drafts(CamelFolder *folder, const gchar *uri);
+gboolean em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri);
+GHashTable * em_utils_generate_account_hash (void);
+EAccount * em_utils_guess_account (CamelMimeMessage *message, CamelFolder *folder);
+EAccount * em_utils_guess_account_with_recipients (CamelMimeMessage *message, CamelFolder *folder);
+
+
+#endif
diff --git a/mail/daemon/main.c b/mail/daemon/main.c
new file mode 100644
index 0000000..12a72c0
--- /dev/null
+++ b/mail/daemon/main.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2011, Intel Corporation 2011.
+ *
+ * Author: Srinivasa Ragavan
+ * 
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ * 
+ * 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 General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserverui/e-passwords.h>
+#include "mail-session.h"
+#include "e-mail-store.h"
+#include "mail-folder-cache.h"
+#include "mail-mt.h"
+#include "mail-config.h"
+#include "mail-ops.h"
+#include "e-dbus-manager.h"
+#include "mail-send-recv.h"
+
+#include "utils.h"
+
+/* Yeah, the daemon shouldn't be a gtk+ app. But this code shuffling ends this up as a Gtk daemon. But once we solve password and alert issues, this should be a simple mainloop */
+
+extern CamelSession *session;
+static gint mail_sync_in_progress = 0;
+
+static void
+mail_sync_store_done_cb (CamelStore *store,
+                         gpointer user_data,
+			 GError *error)
+{
+	mail_sync_in_progress--;
+}
+
+static void
+mail_sync_store_cb (CamelStore *store,
+                    const gchar *display_name,
+                    gpointer not_used)
+{
+	mail_sync_in_progress++;
+
+	mail_sync_store (
+		store, FALSE,
+		mail_sync_store_done_cb,
+		NULL);
+}
+
+static gboolean
+mail_auto_sync ()
+{
+	/* If a sync is still in progress, skip this round. */
+	if (mail_sync_in_progress)
+		goto exit;
+
+	e_mail_store_foreach (
+		(GHFunc) mail_sync_store_cb,
+		NULL);
+
+exit:
+	return TRUE;
+}
+
+static gboolean
+start_mail_engine ()
+{
+	char *data_dir;
+
+	mail_debug_int ();
+	mail_session_start ();
+	mail_folder_cache_get_default ();
+	mail_config_init ();
+	mail_msg_init ();
+
+	data_dir = g_build_filename (e_get_user_data_dir(), "mail", NULL);
+	if (!g_file_test (data_dir, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR)) {
+		g_mkdir_with_parents (data_dir, 0700);
+	}
+	
+	e_mail_store_init (data_dir);
+
+	g_free(data_dir);
+
+	mail_autoreceive_init (session);
+
+	/* In regular intervals, sync to server. We donno how & when the daemon will die */
+	g_timeout_add_seconds (
+			mail_config_get_sync_timeout (),
+			(GSourceFunc) mail_auto_sync,
+			NULL);
+	e_dbus_manager_new ();
+
+	return FALSE;
+}
+
+int 
+main(int argc, char* argv[])
+{
+	gtk_init_with_args (
+		&argc, &argv,
+		_("- The Evolution Mail Data Server"),
+		NULL, (gchar *) GETTEXT_PACKAGE, NULL);
+
+	g_type_init ();
+	g_set_prgname ("e-mail-factory");
+	if (!g_thread_supported ()) g_thread_init (NULL);
+
+	e_passwords_init ();
+
+	g_idle_add ((GSourceFunc) start_mail_engine, NULL);
+	gtk_main ();
+
+   	return 0;
+}
diff --git a/mail/daemon/test-email-client.c b/mail/daemon/test-email-client.c
new file mode 100644
index 0000000..93a7dad
--- /dev/null
+++ b/mail/daemon/test-email-client.c
@@ -0,0 +1,1050 @@
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib/gi18n.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include <camel/camel.h>
+#include "e-account-utils.h"
+#include "e-gdbus-emailsession.h"
+#include "e-gdbus-emailstore.h"
+#include "e-gdbus-emailfolder.c"
+
+#define E_MAIL_DATA_FACTORY_SERVICE_NAME \
+	"org.gnome.evolution.dataserver.Mail"
+
+EGdbusSessionCS *session_proxy;
+
+static void
+message_info_dump (CamelMessageInfoBase *mi)
+{
+	CamelFlag *flag;
+	CamelTag *tag;
+	
+	if (mi == NULL) {
+		printf("No message?\n");
+		return;
+	}
+
+	printf("Subject: %s\n", camel_message_info_subject(mi));
+	printf("To: %s\n", camel_message_info_to(mi));
+	printf("Cc: %s\n", camel_message_info_cc(mi));
+	printf("mailing list: %s\n", camel_message_info_mlist(mi));
+	printf("From: %s\n", camel_message_info_from(mi));
+	printf("UID: %s\n", camel_message_info_uid(mi));
+	printf("Flags: %04x\n", camel_message_info_flags(mi));
+
+	printf("User flags: \t");
+	flag = mi->user_flags;
+	while (flag) {
+		printf ("%s\t", flag->name);
+		flag = flag->next;
+	}
+	printf("\n");
+
+	printf("User tags: \t");
+	tag = mi->user_tags;
+	while (tag) {
+		printf ("%s:%s\t", tag->name, tag->value);
+		tag = tag->next;
+	}
+	printf("\n");
+
+}
+
+static void
+test_folder_basic (EGdbusFolderCF *folder_proxy, char *folder_path)
+{
+	char *data = NULL;
+
+	egdbus_folder_cf_call_get_name_sync (folder_proxy, &data, NULL, NULL);
+	printf("\n Folder Name: %s\n", data);
+
+	egdbus_folder_cf_call_get_full_name_sync (folder_proxy, &data, NULL, NULL);
+	printf("\n Full Name: %s\n", data);
+
+	egdbus_folder_cf_call_get_description_sync (folder_proxy, &data, NULL, NULL);
+	printf("\n Description %s\n", data);
+}
+
+
+static CamelMessageInfoBase *
+info_from_variant (CamelFolder *folder, GVariant *vinfo) 
+{
+	CamelMessageInfoBase *info;
+	GVariantIter iter, aiter;
+	GVariant *item, *aitem;
+	int count, i;
+
+	info = (CamelMessageInfoBase *) camel_message_info_new (folder ? folder->summary : NULL);
+
+         /* Structure of CamelMessageInfoBase
+         ssssss - uid, sub, from, to, cc, mlist
+	 uu - flags, size
+	 tt - date_sent, date_received
+	 t  - message_id
+	 iat - references
+	 as - userflags
+	 a(ss) - usertags
+	 a(ss) - header 
+         NOTE: We aren't now sending content_info*/
+
+	g_variant_iter_init (&iter, vinfo);
+
+	/* Uid, Subject, From, To, CC, mlist */
+	item = g_variant_iter_next_value (&iter);
+	info->uid = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->subject = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->from = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->to = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->cc = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	item = g_variant_iter_next_value (&iter);
+	info->mlist = camel_pstring_strdup (g_variant_get_string(item, NULL));
+
+	/* Flags & size */
+	item = g_variant_iter_next_value (&iter);
+	info->flags = g_variant_get_uint32 (item);
+
+	item = g_variant_iter_next_value (&iter);
+	info->size = g_variant_get_uint32 (item);
+
+	/* Date: Sent/Received */
+	item = g_variant_iter_next_value (&iter);
+	info->date_sent = g_variant_get_uint64 (item);
+
+	item = g_variant_iter_next_value (&iter);
+	info->date_received = g_variant_get_uint64 (item);
+
+	/* Message Id */
+	item = g_variant_iter_next_value (&iter);	
+	info->message_id.id.id = g_variant_get_uint64 (item);
+
+	/* References */
+	item = g_variant_iter_next_value (&iter);	
+	count = g_variant_get_int32 (item);
+	if (count) {
+		item = g_variant_iter_next_value (&iter);	
+      		g_variant_iter_init (&aiter, item);
+	
+		info->references = g_malloc(sizeof(*info->references) + ((count-1) * sizeof(info->references->references[0])));
+		i=0;
+      		while ((aitem = g_variant_iter_next_value (&aiter))) {
+			info->references->references[i].id.id = g_variant_get_uint64 (aitem);
+			i++;
+        	}
+		info->references->size = count;
+	} else {
+		item = g_variant_iter_next_value (&iter);	
+	}
+
+	/* UserFlags */
+	item = g_variant_iter_next_value (&iter);	
+      	g_variant_iter_init (&aiter, item);
+	
+      	while ((aitem = g_variant_iter_next_value (&aiter))) {
+		char *str = g_variant_get_string (aitem, NULL);
+		if (str && *str)	
+			camel_flag_set (&info->user_flags, str, TRUE);
+		else
+			printf("Empty User Flags\n");
+        }
+	
+	/* User Tags */
+	item = g_variant_iter_next_value (&iter);	
+      	g_variant_iter_init (&aiter, item);
+	
+      	while ((aitem = g_variant_iter_next_value (&aiter))) {
+		GVariantIter siter;
+		GVariant *sitem;
+		char *tagname, *tagvalue;
+		
+		g_variant_iter_init (&siter, aitem);
+		sitem = g_variant_iter_next_value (&siter);
+		tagname = g_strdup (g_variant_get_string (sitem, NULL));
+		sitem = g_variant_iter_next_value (&siter);
+		tagvalue = g_strdup (g_variant_get_string (sitem, NULL));
+		if (tagname && *tagname && tagvalue && *tagvalue)
+			camel_tag_set (&info->user_tags, tagname, tagvalue);
+		g_free (tagname);
+		g_free (tagvalue);
+        }
+
+	return info;
+}
+
+#define VALUE_OR_NULL(x) x?x:""
+static GVariant *
+variant_from_info (CamelMessageInfoBase *info)
+{
+	GVariant *v, *v1;
+	GVariantBuilder *builder, *b1, *b2;
+	int i;
+	CamelFlag *flags;
+	CamelTag *tags;
+
+	builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+	
+	g_variant_builder_add (builder, "s", info->uid);
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->subject));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->from));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->to));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->cc));
+	g_variant_builder_add (builder, "s", VALUE_OR_NULL(info->mlist));
+
+
+	g_variant_builder_add (builder, "u", info->flags);
+	g_variant_builder_add (builder, "u", info->size);
+
+	g_variant_builder_add (builder, "t", info->date_sent);
+	g_variant_builder_add (builder, "t", info->date_received);
+
+	g_variant_builder_add (builder, "t", info->message_id.id.id);
+
+
+	
+	/* references */
+
+	if (info->references) {
+		g_variant_builder_add (builder, "i", info->references->size);
+
+		b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+		for (i=0; i<info->references->size; i++) {
+			g_variant_builder_add (b1, "t", info->references->references[i].id.id);
+		}
+		v1 = g_variant_builder_end (b1);
+		g_variant_builder_unref (b1);
+	
+		g_variant_builder_add_value (builder, v1);
+		g_variant_unref (v1);
+	} else {
+		g_variant_builder_add (builder, "i", 0);
+		b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+		g_variant_builder_add (b1, "t", 0);
+		v1 = g_variant_builder_end (b1);
+		g_variant_builder_unref (b1);
+	
+		g_variant_builder_add_value (builder, v1);
+		
+
+	}
+
+	/* User Flags */
+	b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+	flags = info->user_flags;
+	while (flags) {
+		g_variant_builder_add (b1, "s", flags->name);
+		flags = flags->next;
+	}
+	g_variant_builder_add (b1, "s", "");
+	v1 = g_variant_builder_end (b1);
+	g_variant_builder_unref (b1);
+	
+	g_variant_builder_add_value (builder, v1);
+
+	/* User Tags */
+	b1 = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+	tags = info->user_tags;
+	while (tags) {
+		b2 = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+		g_variant_builder_add (b2, "s", tags->name);
+		g_variant_builder_add (b2, "s", tags->value);
+		
+		v1 = g_variant_builder_end (b2);
+		g_variant_builder_unref (b2);
+
+		/* FIXME: Should we handle empty tags? Can it be empty? If it potential crasher ahead*/
+		g_variant_builder_add_value (b1, v1);
+
+		tags = tags->next;
+	}
+
+	b2 = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
+	g_variant_builder_add (b2, "s", "");
+	g_variant_builder_add (b2, "s", "");	
+	v1 = g_variant_builder_end (b2);
+	g_variant_builder_unref (b2);
+	g_variant_builder_add_value (b1, v1);
+
+	v1 = g_variant_builder_end (b1);
+	g_variant_builder_unref (b1);
+	
+	g_variant_builder_add_value (builder, v1);
+
+	v = g_variant_builder_end (builder);
+	g_variant_builder_unref (builder);
+
+	return v;
+}
+
+
+static void
+test_message_basics (char *folder_path, EGdbusFolderCF *folder_proxy)
+{
+	char *data = NULL;
+	char **uids;
+	GError *error = NULL;
+	GVariant *variant=NULL;
+
+	egdbus_folder_cf_call_get_uids_sync (folder_proxy, &uids, NULL, &error);
+
+	if (error) {
+		printf("Error while getting uids: %s\n", error->message);
+		g_error_free (error);
+		error = NULL;
+	} else {
+		gboolean ret, fg;
+		int i=0;
+		guint32 flags=0;
+		char *msg = NULL;
+		char *name, *val=NULL;
+		CamelMessageInfoBase *info;
+
+		printf("UIDS received: \t");
+		while (uids[i]) {
+			printf("%s\t", uids[i]);
+			i++;
+		}
+		printf("\n");
+
+		ret = egdbus_folder_cf_call_get_message_info_sync (folder_proxy, uids[0], &variant, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting messageinfo: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("Message info at beginning\n\n");	
+			info = info_from_variant (NULL, variant);
+			message_info_dump (info);
+			camel_message_info_free (info);
+			printf("\n\n");
+		}
+
+		/* Message flags */
+		ret = egdbus_folder_cf_call_get_message_flags_sync(folder_proxy, uids[0], &flags, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message flags: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nFlags of the message : %u\n", flags);
+		}
+
+		ret = egdbus_folder_cf_call_set_message_flags_sync(folder_proxy, uids[0], CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while setting message flags: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("Set the flags of the message : %u : success:%d\n", CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED, fg);
+		}
+
+
+		/* User flags */
+		ret = egdbus_folder_cf_call_get_message_user_flag_sync(folder_proxy, uids[0], "bold", &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message user flag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nUser Flags of the message for 'bold': %d\n", fg);
+		}
+	
+		ret = egdbus_folder_cf_call_set_message_user_flag_sync(folder_proxy, uids[0], "bold", TRUE, NULL, &error);
+		if (!ret || error) {
+			printf("Error while setting message user flag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nSet UserFlags of the message to 'bold': success\n");
+		}
+
+		ret = egdbus_folder_cf_call_get_message_user_flag_sync(folder_proxy, uids[0], "bold", &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message user flag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nUser Flags of the message for 'bold' : %d\n", fg);
+		}
+		
+		/* User Tag */
+		ret = egdbus_folder_cf_call_get_message_user_tag_sync(folder_proxy, uids[0], "", &val, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message user tag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("User Tag of the message : %s\n", val ? val : "<empty>");
+		}
+	
+		ret = egdbus_folder_cf_call_set_message_user_tag_sync(folder_proxy, uids[0], "bold", "strong", NULL, &error);
+		if (!ret || error) {
+			printf("Error while setting message user tag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nSet UserTag of the message 'bold' to 'strong': success\n");
+		}
+
+		ret = egdbus_folder_cf_call_get_message_user_tag_sync(folder_proxy, uids[0], "bold", &val, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message user tag: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n User Tag of the message for 'bold' : %s\n", val ? val : "<empty>");
+		}
+
+
+		printf("\n\nMessage Info at the end\n");
+
+		ret = egdbus_folder_cf_call_get_message_info_sync (folder_proxy, uids[0], &variant, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting messageinfo: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			
+			info = info_from_variant (NULL, variant);
+			message_info_dump (info);
+			/* camel_message_info_free (info); */
+		}
+
+		/* Get Message */
+		ret = egdbus_folder_cf_call_get_message_sync (folder_proxy, uids[0], &msg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting message: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n\n%s\n\n", msg);
+			/* g_free(msg); */
+		}
+
+		/* Folder sync */
+		ret = egdbus_folder_cf_call_sync_sync (folder_proxy, FALSE, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while syncing folder: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nSyncing folder success: %d\n", fg);
+		}
+
+		/* getPermanentFlags */
+		ret = egdbus_folder_cf_call_get_permanent_flags_sync (folder_proxy, &flags, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting folder permanent flags : %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Permanent Flags: %u\n", flags);
+		}
+
+		/* hasSummaryCapability */
+		ret = egdbus_folder_cf_call_has_summary_capability_sync (folder_proxy, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while checking has summary capability: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Has summary capability : %d\n", fg);
+		}
+
+		/* hasSearchCapability */
+		ret = egdbus_folder_cf_call_has_search_capability_sync (folder_proxy, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while checking has search capability: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Has search capability : %d\n", fg);
+		}
+
+		/* Total count */
+		ret = egdbus_folder_cf_call_total_message_count_sync (folder_proxy, &i, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting total msg count: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Total message count : %d\n", i);
+		}
+
+		/* Unread count */
+		ret = egdbus_folder_cf_call_unread_message_count_sync (folder_proxy, &i, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting unread msg count: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Unread message count : %d\n", i);
+		}
+
+		/* Deleted count*/
+		ret = egdbus_folder_cf_call_deleted_message_count_sync (folder_proxy, &i, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting deleted msg count: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Deleted message count : %d\n", i);
+		}
+
+		/* Expunge */
+		ret = egdbus_folder_cf_call_expunge_sync (folder_proxy, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while expunging folder: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nExpunging folder success: %d\n", fg);
+		}
+
+		/* Refresh */
+		ret = egdbus_folder_cf_call_refresh_info_sync (folder_proxy, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while refreshing folder: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Refreshing folder success: %d\n", fg);
+		}
+
+		/* Get UIDS */
+		egdbus_folder_cf_call_get_uids_sync (folder_proxy, &uids, NULL, &error);
+		if (error) {
+			printf("Error while getting uids: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			int i=0;
+			guint32 flags=0;
+			char *name, *val=NULL;
+
+			printf("UIDS at END received: \t");
+			while (uids[i]) {
+				printf("%s\t", uids[i]);
+				i++;
+			}
+			printf("\n");
+		}
+
+		/* get parent store */
+		ret = egdbus_folder_cf_call_get_parent_store_sync (folder_proxy, &name, NULL, &error);
+		if (error) {
+			printf("Error while getting parent store: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Parent Store OBJ: %s\n", name);
+			g_free (name);
+		}
+
+		/* Local Store*/
+		EGdbusFolderCF *local_folder_proxy;
+		char *local_folder_proxy_path;
+		EGdbusStoreMS *local_store_proxy;
+		char *local_store;
+
+		ret = egdbus_session_cs_call_get_local_store_sync (session_proxy, &local_store, NULL, &error);
+		if (error) {
+			printf("Error while getting local store: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Local store path: %s\n", local_store);
+			local_store_proxy = egdbus_store_ms_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (session_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							local_store,
+							NULL, &error);
+			if (error)
+				printf("Failed to create Local store proxy %s\n", error->message);
+			else 
+				printf("Created Local Store proxy\n");
+		}
+		/* Local Folder */
+		ret = egdbus_session_cs_call_get_local_folder_sync (session_proxy, "drafts", &local_folder_proxy_path, NULL, &error);
+		if (error) {
+			printf("Error while getting local folder: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\n Got Local Folder Drafts %s\n", local_folder_proxy_path);
+		
+			local_folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (session_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							local_folder_proxy_path,
+							NULL, &error);
+			if (error)
+				printf("failed to get local folder drafts: %s\n", error->message);
+			else
+				printf("Got Local Folder Drafts\n");
+		}
+		
+		/* append message */
+		char *retuid;
+		GVariant *gv = variant_from_info (info);
+		ret = egdbus_folder_cf_call_append_message_sync (local_folder_proxy, gv, msg, &retuid, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while getting appending msg: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("Successfully appended msg: %s\n", retuid);
+		}
+
+		/* Sync */
+		ret = egdbus_folder_cf_call_sync_sync (local_folder_proxy , FALSE, &fg, NULL, &error);
+		if (!ret || error) {
+			printf("Error while syncing folder: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			printf("\nSyncing folder success: %d\n", fg);
+		}
+		
+		/* Search by expression */
+		/* serach by uids */
+		
+	}
+}
+
+static void
+folder_changed_cb (EGdbusFolderCF *folder_proxy, 
+		   const gchar *const *added,
+		   const gchar *const *removed,
+		   const gchar *const *changed,
+		   const gchar *const *recent)
+{
+	int i=0;
+
+	printf("Received FOLDER CHANGED event\n");
+
+	printf("Folder: Added uids:\t");
+	while (added[i]) {
+		printf("%s\t", added[i]);
+		i++;
+	}
+	printf("\n");
+
+	i=0;
+	printf("Folder: Removed uids:\t");
+	while (removed[i]) {
+		printf("%s\t", removed[i]);
+		i++;
+	}
+	printf("\n");
+
+	printf("Folder: changed uids:\t");
+	while (changed[i]) {
+		printf("%s\t", changed[i]);
+		i++;
+	}
+	printf("\n");
+
+	printf("Folder: recent uids:\t");
+	while (recent[i]) {
+		printf("%s\t", recent[i]);
+		i++;
+	}
+	printf("\n");
+	
+
+}
+
+static GList *
+parse_infos (EGdbusStoreMS *store_proxy, GVariant *var_changes)
+{
+	GList *l = NULL;
+	GVariantIter iter;
+	guint32 u1;
+	gint32 i1, i2;
+	gchar *str1, *str2, *str3;
+	EGdbusFolderCF *inbox_proxy;
+	char *inbox_path;
+	EGdbusFolderCF *folder_proxy;
+	char *folder_proxy_path;
+	GError *error = NULL;
+	GVariant *cf_info;
+	gboolean success = FALSE;
+	char *new_folder_uri;
+
+	if (var_changes == NULL)
+		return NULL;
+
+	g_variant_iter_init (&iter, var_changes);
+	while (g_variant_iter_next (&iter, "(sssuii)", &str1, &str2, &str3, &u1, &i1, &i2)) {
+		printf("uri: %s Folder Name:%s Full Name:%s Flags:%u, UnreadCount%d TotalCount%d\n", str1, str2, str3, u1, i1, i2);
+	}
+
+	/* Get Inbox folder */
+	if (!egdbus_store_ms_call_get_folder_sync (
+		store_proxy, 
+		"INBOX", /* Pass the full name */
+		&folder_proxy_path,
+		NULL, 
+		&error))
+		printf("Error while getting folder INBOX: %s\n", error->message);
+	
+	printf("Folder path for %s\n", folder_proxy_path);
+		
+	folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (store_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							folder_proxy_path,
+							NULL, &error);
+	g_signal_connect (folder_proxy , "folder-changed", G_CALLBACK (folder_changed_cb), NULL);
+
+	printf("Success in getting FolderProxy? %p %s\n", folder_proxy, error ? error->message : "Yahoo");
+	inbox_proxy = folder_proxy;
+	inbox_path = g_strdup (folder_proxy_path);
+	
+#if 1
+	/* Get Inbox API */
+	/* Most providers don't implement Get Inbox */
+	if (!egdbus_store_ms_call_get_inbox_sync (
+		store_proxy, 
+		&folder_proxy_path,
+		NULL, 
+		&error))
+		printf("Error while getting GET INBOX: %s\n", error->message);
+	
+	printf("INBOX path for %s\n", folder_proxy_path);
+	if (!error)
+	folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (store_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							folder_proxy_path,
+							NULL, &error);
+	else
+		g_error_free (error);
+
+	error = NULL;
+	printf("Success in getting FolderProxy for INBOX ? %p %s\n", folder_proxy, error ? error->message : "Yahoo");
+#endif
+#if 1	
+	/* Get Trash */
+	if (!egdbus_store_ms_call_get_trash_sync (
+		store_proxy, 
+		&folder_proxy_path,
+		NULL, 
+		&error))
+		printf("Error while getting GET Trash: %s\n", error->message);
+	
+	printf("Trash path for %s\n", folder_proxy_path);
+		
+	if (!error)
+	folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (store_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							folder_proxy_path,
+							NULL, &error);
+	else
+		g_error_free (error);
+	error = NULL;
+	printf("Success in getting FolderProxy for TRASH ? %p %s\n", folder_proxy, error ? error->message : "Yahoo");
+	
+	/* Get Junk*/
+	if (!egdbus_store_ms_call_get_junk_sync (
+		store_proxy, 
+		&folder_proxy_path,
+		NULL, 
+		&error))
+		printf("Error while getting GET Junk: %s\n", error->message);
+	
+	printf("Junk path for %s\n", folder_proxy_path);
+	
+	if (!error)
+	folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (store_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							folder_proxy_path,
+							NULL, &error);
+	else
+		g_error_free (error);
+	error = NULL;
+	printf("Success in getting FolderProxy for JUNK ? %p %s\n", folder_proxy, error ? error->message : "Yahoo");
+
+#endif	
+
+	/* Create Folder */
+	if (!egdbus_store_ms_call_create_folder_sync (store_proxy, "", "ATestEmailServer", &cf_info, NULL, &error))
+		printf("Failed to create folder: %s \n", error->message);
+
+	if (error && error->message) 
+		g_error_free (error);
+	else {
+		g_variant_iter_init (&iter, cf_info);
+		while (g_variant_iter_next (&iter, "(sssuii)", &str1, &str2, &str3, &u1, &i1, &i2)) {
+			new_folder_uri = str1;
+			printf("NEW FOLDER: uri: %s Folder Name:%s Full Name:%s Flags:%u, UnreadCount%d TotalCount%d\n", str1, str2, str3, u1, i1, i2);
+			/* */
+			/* Get the folder */
+			if (!egdbus_store_ms_call_get_folder_sync (
+				store_proxy, 
+				str3, /* Pass the full name */
+				&folder_proxy_path,
+				NULL, 
+				&error))
+				printf("Error while getting folder : %s\n", error->message);
+	
+			printf("Folder path for %s\n", folder_proxy_path);
+		
+			folder_proxy = egdbus_folder_cf_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (store_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							folder_proxy_path,
+							NULL, &error);
+
+			printf("Success in getting FolderProxy? %p %s\n", folder_proxy, error ? error->message : "Yahoo");
+			test_folder_basic (folder_proxy, folder_proxy_path);
+			break;
+
+		}
+		
+	}
+	error = NULL;
+
+	/* supports subscription ?*/ 
+	if (!egdbus_store_ms_call_supports_subscriptions_sync(store_proxy, &success, NULL, &error)) {
+		printf("Unable to check sub: %s\n", error->message);
+		g_error_free (error);
+		error = NULL;
+	} else {
+		printf("Store supports subscription: %d\n", success);
+		/* Subscribe Folder */
+		if (!egdbus_store_ms_call_subscribe_folder_sync (store_proxy, "ATestEmailServer", &success, NULL, &error)) {
+			printf("Unable to subscribe: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+		} else {
+			/* Can Refresh Folder */
+			if (!egdbus_store_ms_call_can_refresh_folder_sync (store_proxy, cf_info, &success, NULL, &error)) {
+				printf("Unable to check if can refresh: %s\n", error->message);
+				g_error_free (error);
+				error = NULL;
+
+			} else {
+				printf("Can Refresh Folder\n");
+			}
+
+			/* Transfer one msg */
+			char *uids[2], **retuids;
+			uids[0] = "13989";
+			uids[1] = "13942";
+			uids[2] = NULL;
+
+			if (!egdbus_folder_cf_call_transfer_messages_to_sync (inbox_proxy,  &uids, folder_proxy_path,  FALSE, &retuids, NULL, NULL))
+				printf("\n Unable to copy \n");
+			else 
+				printf("\n COPIED %s\n", retuids[0] ? retuids[0] : "nil");
+			
+			test_message_basics (folder_proxy_path, folder_proxy);
+
+#if 0
+			/* Unsubscribe Folder */
+			printf("Folder successfully subscribed: %d\n", success);
+			if (!egdbus_store_ms_call_unsubscribe_folder_sync (store_proxy, "ATestEmailServer", &success, NULL, &error)) {
+			printf("Unable to unsubscribe: %s\n", error->message);
+			g_error_free (error);
+			error = NULL;
+			} else {
+				printf("Folder successfully unsubscribed: %d\n", success);
+			}
+#endif
+		}
+	}
+	
+
+
+
+	/* Rename Folder */
+	if (!egdbus_store_ms_call_rename_folder_sync (store_proxy, "ATestEmailServer", "ANOTHERTestEmailServer", &success, NULL, &error))
+		printf("Failed to rename folder: %s \n", error->message);
+
+	if (error && error->message) 
+		g_error_free (error);
+	else {
+		printf("SUCCESS, renamed folder to ANOTHERTestEmailServer\n");
+	}
+	error = NULL;
+
+
+#if 1
+	/* Delete folder */
+	if (!egdbus_store_ms_call_delete_folder_sync (store_proxy, "ANOTHERTestEmailServer", &success, NULL, &error))
+		printf("Failed to delete folder: %s \n", error->message);
+
+	if (error && error->message) 
+		g_error_free (error);
+	else {
+		printf("SUCCESS, delete folder to ANOTHERTestEmailServer\n");
+	}
+	error = NULL;
+#endif
+
+	/* Sync */
+	if (!egdbus_store_ms_call_sync_sync (store_proxy, FALSE, &success, NULL, &error)) {
+		printf("Unable to sync: %s\n", error->message);
+		g_error_free (error);
+		error = NULL;
+	} else {
+		printf("Sync store success\n");
+	}
+
+	/* Noop */
+	if (!egdbus_store_ms_call_noop_sync (store_proxy, &success, NULL, &error)) {
+		printf("Unable to noop : %s\n", error->message);
+		g_error_free (error);
+		error = NULL;
+	} else {
+		printf("Noop store success\n");
+	}
+
+
+	return g_list_reverse (l);
+}
+
+static void
+print_info (GVariant *v, const char *operation)
+{
+	GVariantIter iter;
+	char *str1, *str2, *str3;
+	int i1, i2;
+	guint32 u1;
+
+	g_variant_iter_init (&iter, v);
+	while (g_variant_iter_next (&iter, "(sssuii)", &str1, &str2, &str3, &u1, &i1, &i2)) {
+		if (!str1 || !*str1|| !str2 || !*str2|| !str3 || !*str3) {
+			break;
+		}
+		printf("\n\nSIGNAL: \n%s:::::::  uri: %s Folder Name:%s Full Name:%s Flags:%u, UnreadCount%d TotalCount%d\n\n\n", operation, str1, str2, str3, u1, i1, i2);
+	}
+
+}
+
+static void
+folder_opened_cb (EGdbusStoreMS *object, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder Opened");
+}
+static void
+folder_created_cb (EGdbusStoreMS *object, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder Created");	
+}
+static void
+folder_deleted_cb (EGdbusStoreMS *object, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder Deleted");
+	
+}
+static void
+folder_renamed_cb (EGdbusStoreMS *object, const char *oldname, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder Renamed");
+	printf("Old folder name: %s\n\n\n", oldname);
+	
+}
+static void
+folder_subscribed_cb (EGdbusStoreMS *object, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder Subscribed");
+}
+static void
+folder_unsubscribed_cb (EGdbusStoreMS *object, GVariant *v, gpointer data)
+{
+	print_info (v, "Folder UnSubscribed");	
+}
+
+static gboolean
+start_test_client (gpointer foo)
+{
+	EAccount *account = e_get_default_account ();
+	const char *uri = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
+	GError *error = NULL;
+	EGdbusStoreMS *store_proxy;
+	char *path;
+	GVariant *infos = NULL;
+
+	/* Get Session */
+	session_proxy = egdbus_session_cs_proxy_new_for_bus_sync (
+		G_BUS_TYPE_SESSION,
+		G_DBUS_PROXY_FLAGS_NONE,
+		E_MAIL_DATA_FACTORY_SERVICE_NAME,
+		"/org/gnome/evolution/dataserver/Mail/Session",
+		NULL,
+		&error);
+	if (error) 
+		printf("ERROR %s\n", error->message);
+	else 
+		printf("Success\n");
+
+	/* Get Store */
+	if (!egdbus_session_cs_call_get_store_sync (session_proxy, uri, &path, NULL, &error)) {
+		printf("Get store %s\n", error->message);
+	}
+
+	printf("PATH %s\n", path);
+
+	store_proxy = egdbus_store_ms_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (session_proxy)),
+							G_DBUS_PROXY_FLAGS_NONE,
+							E_MAIL_DATA_FACTORY_SERVICE_NAME,
+							path,
+							NULL, &error);
+	if (error)
+		printf("Failed to create store proxy %s\n", error->message);
+
+	/* Get Folder Info */
+	if (!egdbus_store_ms_call_get_folder_info_sync(store_proxy, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &infos, NULL, &error))
+		printf("Error %s\n", error->message);
+	
+	printf("Registering signalhandlers\n\n");
+	g_signal_connect (store_proxy, "folder-opened", G_CALLBACK (folder_opened_cb), NULL);
+	g_signal_connect (store_proxy, "folder-created", G_CALLBACK (folder_created_cb), NULL);
+	g_signal_connect (store_proxy, "folder-deleted", G_CALLBACK (folder_deleted_cb), NULL);
+	g_signal_connect (store_proxy, "folder-renamed", G_CALLBACK (folder_renamed_cb), NULL);
+	g_signal_connect (store_proxy, "folder-subscribed", G_CALLBACK (folder_subscribed_cb), NULL);
+	g_signal_connect (store_proxy, "folder-unsubscribed", G_CALLBACK (folder_unsubscribed_cb), NULL);
+
+	parse_infos (store_proxy, infos);
+	
+
+
+	return FALSE;
+}
+
+int 
+main(int argc, char* argv[])
+{
+	gtk_init_with_args (
+		&argc, &argv,
+		_("- The Evolution Mail Data Server"),
+		NULL, (gchar *) GETTEXT_PACKAGE, NULL);
+
+	g_type_init ();
+	g_set_prgname ("e-mail-test-client");
+	if (!g_thread_supported ()) g_thread_init (NULL);
+
+
+	g_idle_add ((GSourceFunc) start_test_client, NULL);
+	gtk_main ();
+
+   	return 0;
+}
diff --git a/mail/daemon/utils.c b/mail/daemon/utils.c
new file mode 100644
index 0000000..8820b7d
--- /dev/null
+++ b/mail/daemon/utils.c
@@ -0,0 +1,47 @@
+
+#include <string.h>
+#include <glib.h>
+#include "utils.h"
+
+/* 
+ * EDS_MAIL_DEBUG should be a CSV
+ * export EDS_MAIL_DEBUG=folder,store,session,micro,ipc
+ * */
+
+static int mail_debug_flag = 0;
+
+void
+mail_debug_int ()
+{
+	const char *log = g_getenv ("EDS_MAIL_DEBUG");
+	char **tokens;
+
+	if (log && *log) {
+		int i=0;
+		tokens = g_strsplit (log, ",", 0);
+		
+		while (tokens[i]) {
+			if (strcmp (tokens[i], "folder") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_FOLDER;
+			else if (strcmp (tokens[i], "store") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_STORE;
+			else if (strcmp (tokens[i], "session") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_SESSION;
+			else if (strcmp (tokens[i], "micro") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_MICRO;		
+			else if (strcmp (tokens[i], "ipc") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_IPC;						
+			else if (strcmp(tokens[i], "all") == 0)
+				mail_debug_flag |= EMAIL_DEBUG_SESSION|EMAIL_DEBUG_STORE|EMAIL_DEBUG_STORE|EMAIL_DEBUG_MICRO|EMAIL_DEBUG_IPC;
+			i++;
+		}
+
+		g_strfreev (tokens);
+	}
+}
+
+gboolean
+mail_debug_log (EMailDebugFlag flag)
+{
+	return (mail_debug_flag & flag) != 0;
+}
diff --git a/mail/daemon/utils.h b/mail/daemon/utils.h
new file mode 100644
index 0000000..6636281
--- /dev/null
+++ b/mail/daemon/utils.h
@@ -0,0 +1,22 @@
+
+
+#ifndef UTILS_H
+#define UTILS_H
+
+G_BEGIN_DECLS
+
+typedef enum {
+	EMAIL_DEBUG_FOLDER=1,
+	EMAIL_DEBUG_STORE=2,
+	EMAIL_DEBUG_SESSION=3,
+	EMAIL_DEBUG_IPC=4,
+	EMAIL_DEBUG_MICRO=5
+} EMailDebugFlag;
+
+void mail_debug_init ();
+gboolean mail_debug_log (EMailDebugFlag flag);
+
+G_END_DECLS
+
+#endif /* UTILS_H */
+
diff --git a/mail/libegdbus/Makefile.am b/mail/libegdbus/Makefile.am
new file mode 100644
index 0000000..7ee20e4
--- /dev/null
+++ b/mail/libegdbus/Makefile.am
@@ -0,0 +1,40 @@
+GDBUS_XML_FILES =					\
+	../daemon/e-mail-data-session.xml	\
+	../deamon/e-mail-data-store.xml		\
+	../daemon/e-mail-data-folder.xml
+
+gdbus-files: $(GDBUS_XML_FILES)
+	~/opt/master/bin/gdbus-codegen --namespace=EGdbus --strip-prefix=org.gnome.evolution.dataserver.mail --generate-c-code=$^ $^.xml
+
+#~/opt/master/bin/gdbus-codegen --namespace=EGdbusSession --strip-prefix=org.gnome.evolution.dataserver.mail. --generate-c-code=e-gdbus-emailsession ../src/e-mail-data-session.xml
+#~/opt/master/bin/gdbus-codegen --namespace=EGdbusFolder --strip-prefix=org.gnome.evolution.dataserver.mail. --generate-c-code=e-gdbus-emailfolder ../src/e-mail-data-folder.xml 
+#~/opt/master/bin/gdbus-codegen --namespace=EGdbusStore --strip-prefix=org.gnome.evolution.dataserver.mail. --generate-c-code=e-gdbus-emailstore ../src/e-mail-data-store.xml
+
+# The library
+noinst_LTLIBRARIES = libegdbus-mail.la
+
+libegdbus_mail_la_CPPFLAGS =			\
+	$(AM_CPPFLAGS)				\
+	$(CAMEL_CFLAGS)				\
+	-DG_LOG_DOMAIN=\"libegdbus-mail\"	\
+	$(E_MAIL_GDBUS_UTILS_CFLAGS)
+
+libegdbus_mail_la_SOURCES =			\
+	e-gdbus-emailfolder.h			\
+	e-gdbus-emailfolder.c			\
+	e-gdbus-emailstore.h		\
+	e-gdbus-emailstore.c		\
+	e-gdbus-emailsession.h		\
+	e-gdbus-emailsession.c		
+
+libegdbus_mail_la_LIBADD =			\
+	$(E_MAIL_GDBUS_UTILS_LIBS)		\
+	$(top_builddir)/camel/libcamel-1.2.la			\
+	$(top_builddir)/camel/libcamel-provider-1.2.la			\
+	$(top_builddir)/libedataserver/libedataserver-1.2.la
+	
+
+libegdbus_mail_la_LDFLAGS = $(NO_UNDEFINED)
+
+
+-include $(top_srcdir)/git.mk
diff --git a/mail/libegdbus/e-gdbus-emailfolder.c b/mail/libegdbus/e-gdbus-emailfolder.c
new file mode 100644
index 0000000..9951232
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailfolder.c
@@ -0,0 +1,4930 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "e-gdbus-emailfolder.h"
+
+typedef struct
+{
+  GDBusArgInfo parent_struct;
+  gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+  GDBusMethodInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+  GDBusSignalInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+  GDBusPropertyInfo parent_struct;
+  const gchar *hyphen_name;
+  gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GParamSpec *pspec;
+  GValue value;
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+  g_value_unset (&data->value);
+  g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+  gboolean ret = FALSE;
+  guint n;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  if (g_strv_length (a) != g_strv_length (b))
+    goto out;
+  for (n = 0; a[n] != NULL; n++)
+    if (g_strcmp0 (a[n], b[n]) != 0)
+      goto out;
+  ret = TRUE;
+out:
+  return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+  gboolean ret = FALSE;
+  if (a == NULL && b == NULL)
+    goto out;
+  if (a == NULL || b == NULL)
+    goto out;
+  ret = g_variant_equal (a, b);
+out:
+  return ret;
+}
+
+static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+  gboolean ret = FALSE;
+  g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+  switch (G_VALUE_TYPE (a))
+    {
+      case G_TYPE_BOOLEAN:
+        ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+        break;
+      case G_TYPE_UCHAR:
+        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+        break;
+      case G_TYPE_INT:
+        ret = (g_value_get_int (a) == g_value_get_int (b));
+        break;
+      case G_TYPE_UINT:
+        ret = (g_value_get_uint (a) == g_value_get_uint (b));
+        break;
+      case G_TYPE_INT64:
+        ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+        break;
+      case G_TYPE_UINT64:
+        ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+        break;
+      case G_TYPE_DOUBLE:
+        ret = (g_value_get_double (a) == g_value_get_double (b));
+        break;
+      case G_TYPE_STRING:
+        ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+        break;
+      case G_TYPE_VARIANT:
+        ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+        break;
+      default:
+        if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+          ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+        else
+          g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+        break;
+    }
+  return ret;
+}
+
+#include <ffi.h>
+static ffi_type *
+value_to_ffi_type (const GValue *gvalue, gpointer *value)
+{
+  ffi_type *rettype = NULL;
+  GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
+  g_assert (type != G_TYPE_INVALID);
+
+  switch (type)
+    {
+    case G_TYPE_BOOLEAN:
+    case G_TYPE_CHAR:
+    case G_TYPE_INT:
+      rettype = &ffi_type_sint;
+      *value = (gpointer)&(gvalue->data[0].v_int);
+      break;
+    case G_TYPE_UCHAR:
+    case G_TYPE_UINT:
+      rettype = &ffi_type_uint;
+      *value = (gpointer)&(gvalue->data[0].v_uint);
+      break;
+    case G_TYPE_STRING:
+    case G_TYPE_OBJECT:
+    case G_TYPE_BOXED:
+    case G_TYPE_POINTER:
+    case G_TYPE_INTERFACE:
+    case G_TYPE_VARIANT:
+      rettype = &ffi_type_pointer;
+      *value = (gpointer)&(gvalue->data[0].v_pointer);
+      break;
+    case G_TYPE_FLOAT:
+      rettype = &ffi_type_float;
+      *value = (gpointer)&(gvalue->data[0].v_float);
+      break;
+    case G_TYPE_DOUBLE:
+      rettype = &ffi_type_double;
+      *value = (gpointer)&(gvalue->data[0].v_double);
+      break;
+    case G_TYPE_LONG:
+      rettype = &ffi_type_slong;
+      *value = (gpointer)&(gvalue->data[0].v_long);
+      break;
+    case G_TYPE_ULONG:
+      rettype = &ffi_type_ulong;
+      *value = (gpointer)&(gvalue->data[0].v_ulong);
+      break;
+    case G_TYPE_INT64:
+      rettype = &ffi_type_sint64;
+      *value = (gpointer)&(gvalue->data[0].v_int64);
+      break;
+    case G_TYPE_UINT64:
+      rettype = &ffi_type_uint64;
+      *value = (gpointer)&(gvalue->data[0].v_uint64);
+      break;
+    default:
+      rettype = &ffi_type_pointer;
+      *value = NULL;
+      g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
+      break;
+    }
+  return rettype;
+}
+
+static void
+value_from_ffi_type (GValue *gvalue, gpointer *value)
+{
+  switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
+    {
+    case G_TYPE_INT:
+      g_value_set_int (gvalue, *(gint*)value);
+      break;
+    case G_TYPE_FLOAT:
+      g_value_set_float (gvalue, *(gfloat*)value);
+      break;
+    case G_TYPE_DOUBLE:
+      g_value_set_double (gvalue, *(gdouble*)value);
+      break;
+    case G_TYPE_BOOLEAN:
+      g_value_set_boolean (gvalue, *(gboolean*)value);
+      break;
+    case G_TYPE_STRING:
+      g_value_set_string (gvalue, *(gchar**)value);
+      break;
+    case G_TYPE_CHAR:
+      g_value_set_char (gvalue, *(gchar*)value);
+      break;
+    case G_TYPE_UCHAR:
+      g_value_set_uchar (gvalue, *(guchar*)value);
+      break;
+    case G_TYPE_UINT:
+      g_value_set_uint (gvalue, *(guint*)value);
+      break;
+    case G_TYPE_POINTER:
+      g_value_set_pointer (gvalue, *(gpointer*)value);
+      break;
+    case G_TYPE_LONG:
+      g_value_set_long (gvalue, *(glong*)value);
+      break;
+    case G_TYPE_ULONG:
+      g_value_set_ulong (gvalue, *(gulong*)value);
+      break;
+    case G_TYPE_INT64:
+      g_value_set_int64 (gvalue, *(gint64*)value);
+      break;
+    case G_TYPE_UINT64:
+      g_value_set_uint64 (gvalue, *(guint64*)value);
+      break;
+    case G_TYPE_BOXED:
+      g_value_set_boxed (gvalue, *(gpointer*)value);
+      break;
+    default:
+      g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
+                g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
+    }
+}
+
+static void
+_cclosure_marshal_generic (GClosure *closure,
+                             GValue *return_gvalue,
+                             guint n_param_values,
+                             const GValue *param_values,
+                             gpointer invocation_hint,
+                             gpointer marshal_data)
+{
+  ffi_type *rtype;
+  void *rvalue;
+  int n_args;
+  ffi_type **atypes;
+  void **args;
+  int i;
+  ffi_cif cif;
+  GCClosure *cc = (GCClosure*) closure;
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue)) 
+    {
+      rtype = value_to_ffi_type (return_gvalue, &rvalue);
+    }
+  else 
+    {
+      rtype = &ffi_type_void;
+    }
+
+  rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
+  
+  n_args = n_param_values + 1;
+  atypes = g_alloca (sizeof (ffi_type *) * n_args);
+  args =  g_alloca (sizeof (gpointer) * n_args);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      atypes[n_args-1] = value_to_ffi_type (param_values + 0,  
+                                            &args[n_args-1]);
+      atypes[0] = &ffi_type_pointer;
+      args[0] = &closure->data;
+    }
+  else
+    {
+      atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
+      atypes[n_args-1] = &ffi_type_pointer;
+      args[n_args-1] = &closure->data;
+    }
+
+  for (i = 1; i < n_args - 1; i++)
+    atypes[i] = value_to_ffi_type (param_values + i, &args[i]);
+
+  if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
+    return;
+
+  ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue))
+    value_from_ffi_type (return_gvalue, rvalue);
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.gnome.evolution.dataserver.mail.Folder
+ * ------------------------------------------------------------------------
+ */
+
+/* ---- Introspection data for org.gnome.evolution.dataserver.mail.Folder ---- */
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_refresh_info_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_refresh_info_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_refresh_info_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_refresh_info =
+{
+  {
+    -1,
+    "refreshInfo",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_refresh_info_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-refresh-info"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_sync_IN_ARG_expunge =
+{
+  {
+    -1,
+    "expunge",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_sync_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_sync_IN_ARG_expunge,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_sync_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_sync_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_sync_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_sync =
+{
+  {
+    -1,
+    "sync",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_sync_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_sync_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-sync"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_expunge_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_expunge_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_expunge_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_expunge =
+{
+  {
+    -1,
+    "expunge",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_expunge_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-expunge"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_name_OUT_ARG_name =
+{
+  {
+    -1,
+    "name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_name_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_name_OUT_ARG_name,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_name =
+{
+  {
+    -1,
+    "getName",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_name_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-name"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_name_IN_ARG_name =
+{
+  {
+    -1,
+    "name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_name_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_name_IN_ARG_name,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_name =
+{
+  {
+    -1,
+    "setName",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_name_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-name"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_full_name_OUT_ARG_name =
+{
+  {
+    -1,
+    "name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_full_name_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_full_name_OUT_ARG_name,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_full_name =
+{
+  {
+    -1,
+    "getFullName",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_full_name_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-full-name"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_full_name_IN_ARG_name =
+{
+  {
+    -1,
+    "name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_full_name_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_full_name_IN_ARG_name,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_full_name =
+{
+  {
+    -1,
+    "setFullName",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_full_name_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-full-name"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_description_OUT_ARG_desc =
+{
+  {
+    -1,
+    "desc",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_description_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_description_OUT_ARG_desc,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_description =
+{
+  {
+    -1,
+    "getDescription",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_description_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-description"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_description_IN_ARG_desc =
+{
+  {
+    -1,
+    "desc",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_description_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_description_IN_ARG_desc,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_description =
+{
+  {
+    -1,
+    "setDescription",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_description_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-description"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_permanent_flags_OUT_ARG_flags =
+{
+  {
+    -1,
+    "flags",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_permanent_flags_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_permanent_flags_OUT_ARG_flags,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_permanent_flags =
+{
+  {
+    -1,
+    "getPermanentFlags",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_permanent_flags_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-permanent-flags"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_has_summary_capability_OUT_ARG_summary =
+{
+  {
+    -1,
+    "summary",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_has_summary_capability_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_has_summary_capability_OUT_ARG_summary,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_has_summary_capability =
+{
+  {
+    -1,
+    "hasSummaryCapability",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_has_summary_capability_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-has-summary-capability"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_has_search_capability_OUT_ARG_search =
+{
+  {
+    -1,
+    "search",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_has_search_capability_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_has_search_capability_OUT_ARG_search,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_has_search_capability =
+{
+  {
+    -1,
+    "hasSearchCapability",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_has_search_capability_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-has-search-capability"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_total_message_count_OUT_ARG_count =
+{
+  {
+    -1,
+    "count",
+    "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_total_message_count_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_total_message_count_OUT_ARG_count,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_total_message_count =
+{
+  {
+    -1,
+    "totalMessageCount",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_total_message_count_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-total-message-count"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_unread_message_count_OUT_ARG_count =
+{
+  {
+    -1,
+    "count",
+    "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_unread_message_count_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_unread_message_count_OUT_ARG_count,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_unread_message_count =
+{
+  {
+    -1,
+    "unreadMessageCount",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_unread_message_count_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-unread-message-count"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_deleted_message_count_OUT_ARG_count =
+{
+  {
+    -1,
+    "count",
+    "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_deleted_message_count_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_deleted_message_count_OUT_ARG_count,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_deleted_message_count =
+{
+  {
+    -1,
+    "deletedMessageCount",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_deleted_message_count_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-deleted-message-count"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_flags_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_flags_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_flags_IN_ARG_uid,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_flags_OUT_ARG_flags =
+{
+  {
+    -1,
+    "flags",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_flags_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_flags_OUT_ARG_flags,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_message_flags =
+{
+  {
+    -1,
+    "getMessageFlags",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_flags_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_flags_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-message-flags"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_flags_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_flags_IN_ARG_flags =
+{
+  {
+    -1,
+    "flags",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_flags_IN_ARG_set =
+{
+  {
+    -1,
+    "set",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_message_flags_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_message_flags_IN_ARG_uid,
+  &_egdbus_folder_cf_method_info_set_message_flags_IN_ARG_flags,
+  &_egdbus_folder_cf_method_info_set_message_flags_IN_ARG_set,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_flags_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_message_flags_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_message_flags_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_message_flags =
+{
+  {
+    -1,
+    "setMessageFlags",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_message_flags_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_message_flags_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-set-message-flags"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_flagname =
+{
+  {
+    -1,
+    "flagname",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_uid,
+  &_egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_flagname,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_flag_OUT_ARG_flag =
+{
+  {
+    -1,
+    "flag",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_user_flag_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_user_flag_OUT_ARG_flag,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_message_user_flag =
+{
+  {
+    -1,
+    "getMessageUserFlag",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_user_flag_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_user_flag_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-message-user-flag"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_flagname =
+{
+  {
+    -1,
+    "flagname",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_set =
+{
+  {
+    -1,
+    "set",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_uid,
+  &_egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_flagname,
+  &_egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_set,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_message_user_flag =
+{
+  {
+    -1,
+    "setMessageUserFlag",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_message_user_flag_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-message-user-flag"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_param =
+{
+  {
+    -1,
+    "param",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_uid,
+  &_egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_param,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_user_tag_OUT_ARG_value =
+{
+  {
+    -1,
+    "value",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_user_tag_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_user_tag_OUT_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_message_user_tag =
+{
+  {
+    -1,
+    "getMessageUserTag",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_user_tag_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_user_tag_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-message-user-tag"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_param =
+{
+  {
+    -1,
+    "param",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_value =
+{
+  {
+    -1,
+    "value",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_uid,
+  &_egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_param,
+  &_egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_set_message_user_tag =
+{
+  {
+    -1,
+    "setMessageUserTag",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_set_message_user_tag_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-message-user-tag"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_parent_store_OUT_ARG_store =
+{
+  {
+    -1,
+    "store",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_parent_store_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_parent_store_OUT_ARG_store,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_parent_store =
+{
+  {
+    -1,
+    "getParentStore",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_parent_store_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-parent-store"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_append_message_IN_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "(ssssssuutttiatasa(ss))",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_append_message_IN_ARG_message =
+{
+  {
+    -1,
+    "message",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_append_message_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_append_message_IN_ARG_info,
+  &_egdbus_folder_cf_method_info_append_message_IN_ARG_message,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_append_message_OUT_ARG_appendeduid =
+{
+  {
+    -1,
+    "appendeduid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_append_message_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_append_message_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_append_message_OUT_ARG_appendeduid,
+  &_egdbus_folder_cf_method_info_append_message_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_append_message =
+{
+  {
+    -1,
+    "AppendMessage",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_append_message_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_append_message_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-append-message"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_uids_OUT_ARG_uids =
+{
+  {
+    -1,
+    "uids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_uids_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_uids_OUT_ARG_uids,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_uids =
+{
+  {
+    -1,
+    "getUids",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_uids_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-uids"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_IN_ARG_uid,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_OUT_ARG_message =
+{
+  {
+    -1,
+    "message",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_OUT_ARG_message,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_message =
+{
+  {
+    -1,
+    "getMessage",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-message"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_search_by_expression_IN_ARG_expression =
+{
+  {
+    -1,
+    "expression",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_search_by_expression_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_search_by_expression_IN_ARG_expression,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_search_by_expression_OUT_ARG_uids =
+{
+  {
+    -1,
+    "uids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_search_by_expression_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_search_by_expression_OUT_ARG_uids,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_search_by_expression =
+{
+  {
+    -1,
+    "searchByExpression",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_search_by_expression_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_search_by_expression_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-search-by-expression"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_search_by_uids_IN_ARG_expression =
+{
+  {
+    -1,
+    "expression",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_search_by_uids_IN_ARG_searchuids =
+{
+  {
+    -1,
+    "searchuids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_search_by_uids_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_search_by_uids_IN_ARG_expression,
+  &_egdbus_folder_cf_method_info_search_by_uids_IN_ARG_searchuids,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_search_by_uids_OUT_ARG_resultuids =
+{
+  {
+    -1,
+    "resultuids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_search_by_uids_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_search_by_uids_OUT_ARG_resultuids,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_search_by_uids =
+{
+  {
+    -1,
+    "searchByUids",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_search_by_uids_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_search_by_uids_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-search-by-uids"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_info_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_info_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_info_IN_ARG_uid,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_get_message_info_OUT_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "(ssssssuutttiatasa(ss))",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_get_message_info_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_get_message_info_OUT_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_get_message_info =
+{
+  {
+    -1,
+    "getMessageInfo",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_info_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_get_message_info_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-message-info"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_uids =
+{
+  {
+    -1,
+    "uids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_destfolder =
+{
+  {
+    -1,
+    "destfolder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_deleteoriginals =
+{
+  {
+    -1,
+    "deleteoriginals",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_uids,
+  &_egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_destfolder,
+  &_egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_deleteoriginals,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_method_info_transfer_messages_to_OUT_ARG_returnuids =
+{
+  {
+    -1,
+    "returnuids",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_method_info_transfer_messages_to_OUT_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_transfer_messages_to_OUT_ARG_returnuids,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_transfer_messages_to =
+{
+  {
+    -1,
+    "transferMessagesTo",
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_transfer_messages_to_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_folder_cf_method_info_transfer_messages_to_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-transfer-messages-to"
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_folder_cf_method_info_prepare_summary =
+{
+  {
+    -1,
+    "prepareSummary",
+    NULL,
+    NULL,
+    NULL
+  },
+  "handle-prepare-summary"
+};
+
+static const _ExtendedGDBusMethodInfo * const _egdbus_folder_cf_method_info_pointers[] =
+{
+  &_egdbus_folder_cf_method_info_refresh_info,
+  &_egdbus_folder_cf_method_info_sync,
+  &_egdbus_folder_cf_method_info_expunge,
+  &_egdbus_folder_cf_method_info_get_name,
+  &_egdbus_folder_cf_method_info_set_name,
+  &_egdbus_folder_cf_method_info_get_full_name,
+  &_egdbus_folder_cf_method_info_set_full_name,
+  &_egdbus_folder_cf_method_info_get_description,
+  &_egdbus_folder_cf_method_info_set_description,
+  &_egdbus_folder_cf_method_info_get_permanent_flags,
+  &_egdbus_folder_cf_method_info_has_summary_capability,
+  &_egdbus_folder_cf_method_info_has_search_capability,
+  &_egdbus_folder_cf_method_info_total_message_count,
+  &_egdbus_folder_cf_method_info_unread_message_count,
+  &_egdbus_folder_cf_method_info_deleted_message_count,
+  &_egdbus_folder_cf_method_info_get_message_flags,
+  &_egdbus_folder_cf_method_info_set_message_flags,
+  &_egdbus_folder_cf_method_info_get_message_user_flag,
+  &_egdbus_folder_cf_method_info_set_message_user_flag,
+  &_egdbus_folder_cf_method_info_get_message_user_tag,
+  &_egdbus_folder_cf_method_info_set_message_user_tag,
+  &_egdbus_folder_cf_method_info_get_parent_store,
+  &_egdbus_folder_cf_method_info_append_message,
+  &_egdbus_folder_cf_method_info_get_uids,
+  &_egdbus_folder_cf_method_info_get_message,
+  &_egdbus_folder_cf_method_info_search_by_expression,
+  &_egdbus_folder_cf_method_info_search_by_uids,
+  &_egdbus_folder_cf_method_info_get_message_info,
+  &_egdbus_folder_cf_method_info_transfer_messages_to,
+  &_egdbus_folder_cf_method_info_prepare_summary,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_signal_info_folder_changed_ARG_uids_added =
+{
+  {
+    -1,
+    "uids_added",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_signal_info_folder_changed_ARG_uids_removed =
+{
+  {
+    -1,
+    "uids_removed",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_signal_info_folder_changed_ARG_uids_changed =
+{
+  {
+    -1,
+    "uids_changed",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_folder_cf_signal_info_folder_changed_ARG_uids_recent =
+{
+  {
+    -1,
+    "uids_recent",
+    "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_folder_cf_signal_info_folder_changed_ARG_pointers[] =
+{
+  &_egdbus_folder_cf_signal_info_folder_changed_ARG_uids_added,
+  &_egdbus_folder_cf_signal_info_folder_changed_ARG_uids_removed,
+  &_egdbus_folder_cf_signal_info_folder_changed_ARG_uids_changed,
+  &_egdbus_folder_cf_signal_info_folder_changed_ARG_uids_recent,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_folder_cf_signal_info_folder_changed =
+{
+  {
+    -1,
+    "FolderChanged",
+    (GDBusArgInfo **) &_egdbus_folder_cf_signal_info_folder_changed_ARG_pointers,
+    NULL
+  },
+  "folder-changed"
+};
+
+static const _ExtendedGDBusSignalInfo * const _egdbus_folder_cf_signal_info_pointers[] =
+{
+  &_egdbus_folder_cf_signal_info_folder_changed,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_folder_cf_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "EMailDataFolder",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_folder_cf_annotation_info_pointers[] =
+{
+  &_egdbus_folder_cf_annotation_info_0,
+  NULL
+};
+
+static const GDBusInterfaceInfo _egdbus_folder_cf_interface_info =
+{
+  -1,
+  "org.gnome.evolution.dataserver.mail.Folder",
+  (GDBusMethodInfo **) &_egdbus_folder_cf_method_info_pointers,
+  (GDBusSignalInfo **) &_egdbus_folder_cf_signal_info_pointers,
+  NULL,
+  (GDBusAnnotationInfo **) &_egdbus_folder_cf_annotation_info_pointers
+};
+
+
+GDBusInterfaceInfo *
+egdbus_folder_cf_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info;
+}
+
+
+
+static void
+egdbus_folder_cf_default_init (EGdbusFolderCFIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  g_signal_new ("handle-refresh-info",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_refresh_info),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-sync",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_sync),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_BOOLEAN);
+
+  g_signal_new ("handle-expunge",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_expunge),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-name",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_name),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-set-name",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_name),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-full-name",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_full_name),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-set-full-name",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_full_name),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-description",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_description),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-set-description",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_description),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-permanent-flags",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_permanent_flags),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-has-summary-capability",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_has_summary_capability),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-has-search-capability",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_has_search_capability),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-total-message-count",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_total_message_count),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-unread-message-count",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_unread_message_count),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-deleted-message-count",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_deleted_message_count),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-message-flags",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_message_flags),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-set-message-flags",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_message_flags),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    4,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT);
+
+  g_signal_new ("handle-get-message-user-flag",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_message_user_flag),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING);
+
+  g_signal_new ("handle-set-message-user-flag",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_message_user_flag),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    4,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
+
+  g_signal_new ("handle-get-message-user-tag",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_message_user_tag),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING);
+
+  g_signal_new ("handle-set-message-user-tag",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_set_message_user_tag),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    4,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-parent-store",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_parent_store),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-append-message",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_append_message),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-uids",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_uids),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-message",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_message),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-search-by-expression",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_search_by_expression),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-search-by-uids",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_search_by_uids),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRV);
+
+  g_signal_new ("handle-get-message-info",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_get_message_info),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-transfer-messages-to",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_transfer_messages_to),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    4,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRV, G_TYPE_STRING, G_TYPE_BOOLEAN);
+
+  g_signal_new ("handle-prepare-summary",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, handle_prepare_summary),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /* GObject signals for received D-Bus signals: */
+  g_signal_new ("folder-changed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusFolderCFIface, folder_changed),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    4, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_STRV);
+
+}
+
+typedef EGdbusFolderCFIface EGdbusFolderCFInterface;
+#define egdbus_folder_cf_get_type egdbus_folder_cf_get_gtype
+G_DEFINE_INTERFACE (EGdbusFolderCF, egdbus_folder_cf, G_TYPE_OBJECT);
+#undef egdbus_folder_cf_get_type
+
+void
+egdbus_folder_cf_emit_folder_changed (
+    EGdbusFolderCF *object,
+    const gchar *const *uids_added,
+    const gchar *const *uids_removed,
+    const gchar *const *uids_changed,
+    const gchar *const *uids_recent)
+{
+  g_signal_emit_by_name (object, "folder-changed", uids_added, uids_removed, uids_changed, uids_recent);
+}
+
+void
+egdbus_folder_cf_call_refresh_info (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "refreshInfo",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_refresh_info_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_refresh_info_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "refreshInfo",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_sync (
+    EGdbusFolderCF *proxy,
+    gboolean expunge,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "sync",
+    g_variant_new ("(b)",
+                   expunge),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_sync_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_sync_sync (
+    EGdbusFolderCF *proxy,
+    gboolean expunge,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "sync",
+    g_variant_new ("(b)",
+                   expunge),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_expunge (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "expunge",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_expunge_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_expunge_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "expunge",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_name (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getName",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_name_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_name);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_name_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getName",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_name);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_name (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setName",
+    g_variant_new ("(s)",
+                   name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_name_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_name_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setName",
+    g_variant_new ("(s)",
+                   name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_full_name (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getFullName",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_full_name_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_name);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_full_name_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getFullName",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_name);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_full_name (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setFullName",
+    g_variant_new ("(s)",
+                   name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_full_name_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_full_name_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setFullName",
+    g_variant_new ("(s)",
+                   name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_description (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getDescription",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_description_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_desc,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_desc);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_description_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_desc,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getDescription",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_desc);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_description (
+    EGdbusFolderCF *proxy,
+    const gchar *desc,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setDescription",
+    g_variant_new ("(s)",
+                   desc),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_description_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_description_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *desc,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setDescription",
+    g_variant_new ("(s)",
+                   desc),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_permanent_flags (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getPermanentFlags",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_permanent_flags_finish (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(u)",
+                 out_flags);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_permanent_flags_sync (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getPermanentFlags",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(u)",
+                 out_flags);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_has_summary_capability (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "hasSummaryCapability",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_has_summary_capability_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_summary,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_summary);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_has_summary_capability_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_summary,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "hasSummaryCapability",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_summary);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_has_search_capability (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "hasSearchCapability",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_has_search_capability_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_search,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_search);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_has_search_capability_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_search,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "hasSearchCapability",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_search);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_total_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "totalMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_total_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_total_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "totalMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_unread_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "unreadMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_unread_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_unread_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "unreadMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_deleted_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "deletedMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_deleted_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_deleted_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "deletedMessageCount",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_count);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_message_flags (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getMessageFlags",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_flags_finish (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(u)",
+                 out_flags);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_flags_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint *out_flags,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getMessageFlags",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(u)",
+                 out_flags);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_message_flags (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint flags,
+    guint set,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setMessageFlags",
+    g_variant_new ("(suu)",
+                   uid,
+                   flags,
+                   set),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_flags_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_flags_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint flags,
+    guint set,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setMessageFlags",
+    g_variant_new ("(suu)",
+                   uid,
+                   flags,
+                   set),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_message_user_flag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getMessageUserFlag",
+    g_variant_new ("(ss)",
+                   uid,
+                   flagname),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_user_flag_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_flag,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_flag);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_user_flag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    gboolean *out_flag,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getMessageUserFlag",
+    g_variant_new ("(ss)",
+                   uid,
+                   flagname),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_flag);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_message_user_flag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    guint set,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setMessageUserFlag",
+    g_variant_new ("(ssu)",
+                   uid,
+                   flagname,
+                   set),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_user_flag_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_user_flag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    guint set,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setMessageUserFlag",
+    g_variant_new ("(ssu)",
+                   uid,
+                   flagname,
+                   set),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_message_user_tag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getMessageUserTag",
+    g_variant_new ("(ss)",
+                   uid,
+                   param),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_user_tag_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_value,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_user_tag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    gchar **out_value,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getMessageUserTag",
+    g_variant_new ("(ss)",
+                   uid,
+                   param),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_set_message_user_tag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    const gchar *value,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setMessageUserTag",
+    g_variant_new ("(sss)",
+                   uid,
+                   param,
+                   value),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_user_tag_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_set_message_user_tag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    const gchar *value,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setMessageUserTag",
+    g_variant_new ("(sss)",
+                   uid,
+                   param,
+                   value),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_parent_store (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getParentStore",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_parent_store_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_parent_store_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getParentStore",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_append_message (
+    EGdbusFolderCF *proxy,
+    GVariant *info,
+    const gchar *message,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "AppendMessage",
+    g_variant_new ("(@(ssssssuutttiatasa(ss))s)",
+                   info,
+                   message),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_append_message_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_appendeduid,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(sb)",
+                 out_appendeduid,
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_append_message_sync (
+    EGdbusFolderCF *proxy,
+    GVariant *info,
+    const gchar *message,
+    gchar **out_appendeduid,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "AppendMessage",
+    g_variant_new ("(@(ssssssuutttiatasa(ss))s)",
+                   info,
+                   message),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(sb)",
+                 out_appendeduid,
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_uids (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getUids",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_uids_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_uids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_uids_sync (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getUids",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_uids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_message (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getMessage",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_message,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_message);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    gchar **out_message,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getMessage",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_message);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_search_by_expression (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "searchByExpression",
+    g_variant_new ("(s)",
+                   expression),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_search_by_expression_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_uids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_search_by_expression_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    gchar ***out_uids,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "searchByExpression",
+    g_variant_new ("(s)",
+                   expression),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_uids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_search_by_uids (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    const gchar *const *searchuids,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "searchByUids",
+    g_variant_new ("(s^as)",
+                   expression,
+                   searchuids),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_search_by_uids_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_resultuids,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_resultuids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_search_by_uids_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    const gchar *const *searchuids,
+    gchar ***out_resultuids,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "searchByUids",
+    g_variant_new ("(s^as)",
+                   expression,
+                   searchuids),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_resultuids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_get_message_info (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getMessageInfo",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_info_finish (
+    EGdbusFolderCF *proxy,
+    GVariant **out_info,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@(ssssssuutttiatasa(ss)))",
+                 out_info);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_get_message_info_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GVariant **out_info,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getMessageInfo",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@(ssssssuutttiatasa(ss)))",
+                 out_info);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_transfer_messages_to (
+    EGdbusFolderCF *proxy,
+    const gchar *const *uids,
+    const gchar *destfolder,
+    gboolean deleteoriginals,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "transferMessagesTo",
+    g_variant_new ("(^asob)",
+                   uids,
+                   destfolder,
+                   deleteoriginals),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_transfer_messages_to_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_returnuids,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_returnuids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_transfer_messages_to_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *const *uids,
+    const gchar *destfolder,
+    gboolean deleteoriginals,
+    gchar ***out_returnuids,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "transferMessagesTo",
+    g_variant_new ("(^asob)",
+                   uids,
+                   destfolder,
+                   deleteoriginals),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(^as)",
+                 out_returnuids);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_call_prepare_summary (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "prepareSummary",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_folder_cf_call_prepare_summary_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_folder_cf_call_prepare_summary_sync (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "prepareSummary",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_folder_cf_complete_refresh_info (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_folder_cf_complete_sync (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_folder_cf_complete_expunge (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_folder_cf_complete_get_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   name));
+}
+
+void
+egdbus_folder_cf_complete_set_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
+egdbus_folder_cf_complete_get_full_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   name));
+}
+
+void
+egdbus_folder_cf_complete_set_full_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
+egdbus_folder_cf_complete_get_description (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *desc)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   desc));
+}
+
+void
+egdbus_folder_cf_complete_set_description (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
+egdbus_folder_cf_complete_get_permanent_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    guint flags)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(u)",
+                   flags));
+}
+
+void
+egdbus_folder_cf_complete_has_summary_capability (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean summary)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   summary));
+}
+
+void
+egdbus_folder_cf_complete_has_search_capability (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean search)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   search));
+}
+
+void
+egdbus_folder_cf_complete_total_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   count));
+}
+
+void
+egdbus_folder_cf_complete_unread_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   count));
+}
+
+void
+egdbus_folder_cf_complete_deleted_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   count));
+}
+
+void
+egdbus_folder_cf_complete_get_message_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    guint flags)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(u)",
+                   flags));
+}
+
+void
+egdbus_folder_cf_complete_set_message_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_folder_cf_complete_get_message_user_flag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean flag)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   flag));
+}
+
+void
+egdbus_folder_cf_complete_set_message_user_flag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
+egdbus_folder_cf_complete_get_message_user_tag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *value)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   value));
+}
+
+void
+egdbus_folder_cf_complete_set_message_user_tag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
+egdbus_folder_cf_complete_get_parent_store (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   store));
+}
+
+void
+egdbus_folder_cf_complete_append_message (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *appendeduid,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(sb)",
+                   appendeduid,
+                   success));
+}
+
+void
+egdbus_folder_cf_complete_get_uids (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *uids)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(^as)",
+                   uids));
+}
+
+void
+egdbus_folder_cf_complete_get_message (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *message)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   message));
+}
+
+void
+egdbus_folder_cf_complete_search_by_expression (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *uids)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(^as)",
+                   uids));
+}
+
+void
+egdbus_folder_cf_complete_search_by_uids (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *resultuids)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(^as)",
+                   resultuids));
+}
+
+void
+egdbus_folder_cf_complete_get_message_info (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(@(ssssssuutttiatasa(ss)))",
+                   info));
+}
+
+void
+egdbus_folder_cf_complete_transfer_messages_to (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *returnuids)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(^as)",
+                   returnuids));
+}
+
+void
+egdbus_folder_cf_complete_prepare_summary (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void
+egdbus_folder_cf_proxy_iface_init (EGdbusFolderCFIface *iface)
+{
+}
+
+#define egdbus_folder_cf_proxy_get_type egdbus_folder_cf_proxy_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusFolderCFProxy, egdbus_folder_cf_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_FOLDER_TYPE_CF, egdbus_folder_cf_proxy_iface_init));
+#undef egdbus_folder_cf_proxy_get_type
+
+static void
+egdbus_folder_cf_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_folder_cf_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_folder_cf_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], EGDBUS_FOLDER_TYPE_CF);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_FOLDER_TYPE_CF);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+egdbus_folder_cf_proxy_g_properties_changed (GDBusProxy *proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static void
+egdbus_folder_cf_proxy_init (EGdbusFolderCFProxy *proxy)
+{
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), egdbus_folder_cf_interface_info ());
+}
+
+static void
+egdbus_folder_cf_proxy_class_init (EGdbusFolderCFProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->get_property = egdbus_folder_cf_proxy_get_property;
+  gobject_class->set_property = egdbus_folder_cf_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = egdbus_folder_cf_proxy_g_signal;
+  proxy_class->g_properties_changed = egdbus_folder_cf_proxy_g_properties_changed;
+
+}
+void
+egdbus_folder_cf_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_FOLDER_TYPE_CF_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Folder", NULL);
+}
+
+EGdbusFolderCF *
+egdbus_folder_cf_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_FOLDER_CF (ret);
+  else
+    return NULL;
+}
+
+EGdbusFolderCF *
+egdbus_folder_cf_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_FOLDER_TYPE_CF_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Folder", NULL);
+  if (ret != NULL)
+    return EGDBUS_FOLDER_CF (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_folder_cf_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_FOLDER_TYPE_CF_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Folder", NULL);
+}
+
+EGdbusFolderCF *
+egdbus_folder_cf_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_FOLDER_CF (ret);
+  else
+    return NULL;
+}
+
+EGdbusFolderCF *
+egdbus_folder_cf_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_FOLDER_TYPE_CF_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Folder", NULL);
+  if (ret != NULL)
+    return EGDBUS_FOLDER_CF (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+struct _EGdbusFolderCFStubPrivate
+{
+  GValueArray *properties;
+  GDBusObject *object;
+  GDBusInterfaceFlags flags;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GDBusConnection *connection;
+  gchar *object_path;
+  GMainContext *context;
+};
+
+static void
+_egdbus_folder_cf_stub_handle_method_call (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  GValue return_value = {0};
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_interface_info_lookup_method ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, method_name);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 2);
+  g_value_init (&paramv[0], EGDBUS_FOLDER_TYPE_CF);
+  g_value_set_object (&paramv[0], stub);
+  g_value_init (&paramv[1], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[1], invocation);
+  g_variant_iter_init (&iter, parameters);
+  n = 2;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - 2];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_FOLDER_TYPE_CF);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + 2; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_egdbus_folder_cf_stub_handle_get_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (stub), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_egdbus_folder_cf_stub_handle_set_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_folder_cf_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (stub), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _egdbus_folder_cf_stub_vtable =
+{
+  _egdbus_folder_cf_stub_handle_method_call,
+  _egdbus_folder_cf_stub_handle_get_property,
+  _egdbus_folder_cf_stub_handle_set_property
+};
+
+static GDBusInterfaceInfo *
+egdbus_folder_cf_stub_dbus_interface_get_info (GDBusInterface *interface)
+{
+  return egdbus_folder_cf_interface_info ();
+}
+
+static GVariant *
+egdbus_folder_cf_stub_dbus_interface_get_properties (GDBusInterface *interface)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_egdbus_folder_cf_interface_info.properties == NULL)
+    goto out;
+  for (n = 0; _egdbus_folder_cf_interface_info.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _egdbus_folder_cf_interface_info.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _egdbus_folder_cf_stub_handle_get_property (stub->priv->connection, NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Folder", info->name, NULL, stub);
+          if (value != NULL)
+            {
+              if (g_variant_is_floating (value))
+                g_variant_ref_sink (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static void
+egdbus_folder_cf_stub_dbus_interface_flush (GDBusInterface *interface)
+{
+}
+
+static void
+_egdbus_folder_cf_on_object_unregistered (EGdbusFolderCFStub *stub)
+{
+  stub->priv->connection = NULL;
+  g_free (stub->priv->object_path);
+  stub->priv->object_path = NULL;
+}
+
+static guint
+egdbus_folder_cf_stub_dbus_interface_register_object (GDBusInterface *interface,  GDBusConnection *connection,
+  const gchar *object_path,
+  GError **error)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+  stub->priv->connection = connection;
+  stub->priv->object_path = g_strdup (object_path);
+  stub->priv->context = g_main_context_get_thread_default ();
+  if (stub->priv->context != NULL)
+    g_main_context_ref (stub->priv->context);
+  return g_dbus_connection_register_object (connection, object_path, egdbus_folder_cf_interface_info (), &_egdbus_folder_cf_stub_vtable, stub, (GDestroyNotify) _egdbus_folder_cf_on_object_unregistered, error);
+}
+
+static GDBusObject *
+egdbus_folder_cf_stub_dbus_interface_get_object (GDBusInterface *interface)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+  return stub->priv->object != NULL ? g_object_ref (stub->priv->object) : NULL;
+}
+
+static void
+egdbus_folder_cf_stub_dbus_interface_set_object (GDBusInterface *interface,  GDBusObject *object)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+  stub->priv->object = object;
+}
+
+static GDBusInterfaceFlags
+egdbus_folder_cf_stub_dbus_interface_get_flags (GDBusInterface *interface)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+  return stub->priv->flags;
+}
+
+static void
+egdbus_folder_cf_stub_dbus_interface_set_flags (GDBusInterface *interface,  GDBusInterfaceFlags flags)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (interface);
+  stub->priv->flags = flags;
+}
+
+static void
+_egdbus_folder_cf_on_signal_folder_changed (
+    EGdbusFolderCF *object,
+    const gchar *const *uids_added,
+    const gchar *const *uids_removed,
+    const gchar *const *uids_changed,
+    const gchar *const *uids_recent)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Folder", "FolderChanged",
+    g_variant_new ("(^as^as^as^as)",
+                   uids_added,
+                   uids_removed,
+                   uids_changed,
+                   uids_recent), NULL);
+}
+
+static void
+egdbus_folder_cf_stub_iface_init (EGdbusFolderCFIface *iface)
+{
+  iface->folder_changed = _egdbus_folder_cf_on_signal_folder_changed;
+}
+
+static void
+egdbus_folder_cf_stub_dbus_iface_init (GDBusInterfaceIface *iface)
+{
+  iface->get_info = egdbus_folder_cf_stub_dbus_interface_get_info;
+  iface->get_properties = egdbus_folder_cf_stub_dbus_interface_get_properties;
+  iface->flush = egdbus_folder_cf_stub_dbus_interface_flush;
+  iface->register_object = egdbus_folder_cf_stub_dbus_interface_register_object;
+  iface->get_object = egdbus_folder_cf_stub_dbus_interface_get_object;
+  iface->set_object = egdbus_folder_cf_stub_dbus_interface_set_object;
+  iface->get_flags = egdbus_folder_cf_stub_dbus_interface_get_flags;
+  iface->set_flags = egdbus_folder_cf_stub_dbus_interface_set_flags;
+}
+
+#define egdbus_folder_cf_stub_get_type egdbus_folder_cf_stub_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusFolderCFStub, egdbus_folder_cf_stub, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_FOLDER_TYPE_CF, egdbus_folder_cf_stub_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_INTERFACE, egdbus_folder_cf_stub_dbus_iface_init));
+#undef egdbus_folder_cf_stub_get_type
+
+static void
+egdbus_folder_cf_stub_finalize (GObject *object)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (object);
+  g_list_foreach (stub->priv->changed_properties, (GFunc) _changed_property_free, NULL);
+  g_list_free (stub->priv->changed_properties);
+  if (stub->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (stub->priv->changed_properties_idle_source);
+  if (stub->priv->context != NULL)
+    g_main_context_unref (stub->priv->context);
+  G_OBJECT_CLASS (egdbus_folder_cf_stub_parent_class)->finalize (object);
+}
+
+static void
+egdbus_folder_cf_stub_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  EGdbusFolderCFStub *stub = EGDBUS_FOLDER_CF_STUB (object);
+  g_assert (prop_id - 1 >= 0 && prop_id - 1 < 0);
+  g_value_copy (&stub->priv->properties->values[prop_id - 1], value);
+}
+
+static void
+egdbus_folder_cf_stub_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_folder_cf_stub_init (EGdbusFolderCFStub *stub)
+{
+  stub->priv = G_TYPE_INSTANCE_GET_PRIVATE (stub, EGDBUS_FOLDER_TYPE_CF_STUB, EGdbusFolderCFStubPrivate);
+}
+
+static void
+egdbus_folder_cf_stub_class_init (EGdbusFolderCFStubClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  g_type_class_add_private (klass, sizeof (EGdbusFolderCFStubPrivate));
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = egdbus_folder_cf_stub_finalize;
+  gobject_class->get_property = egdbus_folder_cf_stub_get_property;
+  gobject_class->set_property = egdbus_folder_cf_stub_set_property;
+
+}
+
+EGdbusFolderCF *
+egdbus_folder_cf_stub_new (void)
+{
+  return EGDBUS_FOLDER_CF (g_object_new (EGDBUS_FOLDER_TYPE_CF_STUB, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for proxy manager
+ * ------------------------------------------------------------------------
+ */
+
+/* ------------------------------------------------------------------------ */
+
+#define egdbus_folder_proxy_manager_get_type egdbus_folder_proxy_manager_get_gtype
+G_DEFINE_TYPE (EGdbusFolderProxyManager, egdbus_folder_proxy_manager, G_TYPE_DBUS_PROXY_MANAGER);
+#undef egdbus_folder_proxy_manager_get_type
+
+static void
+egdbus_folder_proxy_manager_init (EGdbusFolderProxyManager *manager)
+{
+}
+
+static void
+egdbus_folder_proxy_manager_class_init (EGdbusFolderProxyManagerClass *klass)
+{
+}
+
+static GType
+_egdbus_folder_proxy_manager_get_proxy_type_func (GDBusProxyManager *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data)
+{
+  GType ret;
+  ret = G_TYPE_DBUS_PROXY;
+  if (FALSE)
+    ;
+  else if (g_strcmp0 (interface_name, "org.gnome.evolution.dataserver.mail.Folder") == 0)
+    ret = EGDBUS_FOLDER_TYPE_CF_PROXY;
+  return ret;
+}
+
+GDBusProxyTypeFunc
+egdbus_folder_proxy_manager_get_proxy_type_func (void)
+{
+  return _egdbus_folder_proxy_manager_get_proxy_type_func;
+}
+
+void
+egdbus_folder_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_FOLDER_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_folder_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_folder_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_folder_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_FOLDER_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_folder_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_folder_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_FOLDER_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_folder_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_folder_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_folder_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_FOLDER_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_folder_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
diff --git a/mail/libegdbus/e-gdbus-emailfolder.h b/mail/libegdbus/e-gdbus-emailfolder.h
new file mode 100644
index 0000000..a573654
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailfolder.h
@@ -0,0 +1,1113 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifndef __E_GDBUS_EMAILFOLDER_H__
+#define __E_GDBUS_EMAILFOLDER_H__
+
+#include <gio/gio.h>
+#include <gdbusinterface.h>
+#include <gdbusobjectproxy.h>
+#include <gdbusproxymanager.h>
+#include <gdbusobject.h>
+#include <gdbusobjectmanager.h>
+#include <gdbuscodegen-enumtypes.h>
+
+G_BEGIN_DECLS
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.gnome.evolution.dataserver.mail.Folder */
+
+#define EGDBUS_FOLDER_TYPE_CF (egdbus_folder_cf_get_gtype ())
+#define EGDBUS_FOLDER_CF(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_FOLDER_TYPE_CF, EGdbusFolderCF))
+#define EGDBUS_FOLDER_IS_CF(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_FOLDER_TYPE_CF))
+#define EGDBUS_FOLDER_CF_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EGDBUS_FOLDER_TYPE_CF, EGdbusFolderCF))
+
+struct _EGdbusFolderCF;
+typedef struct _EGdbusFolderCF EGdbusFolderCF;
+typedef struct _EGdbusFolderCFIface EGdbusFolderCFIface;
+
+struct _EGdbusFolderCFIface
+{
+  GTypeInterface parent_iface;
+
+  /* GObject signal class handlers for incoming D-Bus method calls: */
+  gboolean (*handle_refresh_info) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_sync) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean expunge);
+
+  gboolean (*handle_expunge) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_name) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set_name) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name);
+
+  gboolean (*handle_get_full_name) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set_full_name) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name);
+
+  gboolean (*handle_get_description) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set_description) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *desc);
+
+  gboolean (*handle_get_permanent_flags) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_has_summary_capability) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_has_search_capability) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_total_message_count) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_unread_message_count) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_deleted_message_count) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_message_flags) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid);
+
+  gboolean (*handle_set_message_flags) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid,
+    guint flags,
+    guint set);
+
+  gboolean (*handle_get_message_user_flag) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid,
+    const gchar *flagname);
+
+  gboolean (*handle_set_message_user_flag) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid,
+    const gchar *flagname,
+    guint set);
+
+  gboolean (*handle_get_message_user_tag) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid,
+    const gchar *param);
+
+  gboolean (*handle_set_message_user_tag) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid,
+    const gchar *param,
+    const gchar *value);
+
+  gboolean (*handle_get_parent_store) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_append_message) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info,
+    const gchar *message);
+
+  gboolean (*handle_get_uids) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_message) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid);
+
+  gboolean (*handle_search_by_expression) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *expression);
+
+  gboolean (*handle_search_by_uids) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *expression,
+    const gchar *const *searchuids);
+
+  gboolean (*handle_get_message_info) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid);
+
+  gboolean (*handle_transfer_messages_to) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *uids,
+    const gchar *destfolder,
+    gboolean deleteoriginals);
+
+  gboolean (*handle_prepare_summary) (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+
+  /* GObject signal class handlers for received D-Bus signals: */
+  void (*folder_changed) (
+    EGdbusFolderCF *object,
+    const gchar *const *uids_added,
+    const gchar *const *uids_removed,
+    const gchar *const *uids_changed,
+    const gchar *const *uids_recent);
+
+};
+
+GType egdbus_folder_cf_get_gtype (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *egdbus_folder_cf_interface_info (void);
+
+
+/* D-Bus method call completion functions: */
+void egdbus_folder_cf_complete_refresh_info (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_folder_cf_complete_sync (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_folder_cf_complete_expunge (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_folder_cf_complete_get_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name);
+
+void egdbus_folder_cf_complete_set_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+void egdbus_folder_cf_complete_get_full_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *name);
+
+void egdbus_folder_cf_complete_set_full_name (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+void egdbus_folder_cf_complete_get_description (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *desc);
+
+void egdbus_folder_cf_complete_set_description (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+void egdbus_folder_cf_complete_get_permanent_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    guint flags);
+
+void egdbus_folder_cf_complete_has_summary_capability (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean summary);
+
+void egdbus_folder_cf_complete_has_search_capability (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean search);
+
+void egdbus_folder_cf_complete_total_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count);
+
+void egdbus_folder_cf_complete_unread_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count);
+
+void egdbus_folder_cf_complete_deleted_message_count (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gint count);
+
+void egdbus_folder_cf_complete_get_message_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    guint flags);
+
+void egdbus_folder_cf_complete_set_message_flags (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_folder_cf_complete_get_message_user_flag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    gboolean flag);
+
+void egdbus_folder_cf_complete_set_message_user_flag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+void egdbus_folder_cf_complete_get_message_user_tag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *value);
+
+void egdbus_folder_cf_complete_set_message_user_tag (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+void egdbus_folder_cf_complete_get_parent_store (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store);
+
+void egdbus_folder_cf_complete_append_message (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *appendeduid,
+    gboolean success);
+
+void egdbus_folder_cf_complete_get_uids (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *uids);
+
+void egdbus_folder_cf_complete_get_message (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *message);
+
+void egdbus_folder_cf_complete_search_by_expression (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *uids);
+
+void egdbus_folder_cf_complete_search_by_uids (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *resultuids);
+
+void egdbus_folder_cf_complete_get_message_info (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info);
+
+void egdbus_folder_cf_complete_transfer_messages_to (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *returnuids);
+
+void egdbus_folder_cf_complete_prepare_summary (
+    EGdbusFolderCF *object,
+    GDBusMethodInvocation *invocation);
+
+
+
+/* D-Bus signal emissions functions: */
+void egdbus_folder_cf_emit_folder_changed (
+    EGdbusFolderCF *object,
+    const gchar *const *uids_added,
+    const gchar *const *uids_removed,
+    const gchar *const *uids_changed,
+    const gchar *const *uids_recent);
+
+
+
+/* D-Bus method calls: */
+void egdbus_folder_cf_call_refresh_info (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_refresh_info_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_refresh_info_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_sync (
+    EGdbusFolderCF *proxy,
+    gboolean expunge,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_sync_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_sync_sync (
+    EGdbusFolderCF *proxy,
+    gboolean expunge,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_expunge (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_expunge_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_expunge_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_name (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_name_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_name_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_name (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_name_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_name_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_full_name (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_full_name_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_full_name_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_name,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_full_name (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_full_name_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_full_name_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *name,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_description (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_description_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_desc,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_description_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_desc,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_description (
+    EGdbusFolderCF *proxy,
+    const gchar *desc,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_description_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_description_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *desc,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_permanent_flags (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_permanent_flags_finish (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_permanent_flags_sync (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_has_summary_capability (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_has_summary_capability_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_summary,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_has_summary_capability_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_summary,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_has_search_capability (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_has_search_capability_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_search,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_has_search_capability_sync (
+    EGdbusFolderCF *proxy,
+    gboolean *out_search,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_total_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_total_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_total_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_unread_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_unread_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_unread_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_deleted_message_count (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_deleted_message_count_finish (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_deleted_message_count_sync (
+    EGdbusFolderCF *proxy,
+    gint *out_count,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_message_flags (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_message_flags_finish (
+    EGdbusFolderCF *proxy,
+    guint *out_flags,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_message_flags_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint *out_flags,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_message_flags (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint flags,
+    guint set,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_message_flags_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_message_flags_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    guint flags,
+    guint set,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_message_user_flag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_message_user_flag_finish (
+    EGdbusFolderCF *proxy,
+    gboolean *out_flag,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_message_user_flag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    gboolean *out_flag,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_message_user_flag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    guint set,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_message_user_flag_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_message_user_flag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *flagname,
+    guint set,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_message_user_tag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_message_user_tag_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_value,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_message_user_tag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    gchar **out_value,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_set_message_user_tag (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    const gchar *value,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_set_message_user_tag_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_set_message_user_tag_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    const gchar *param,
+    const gchar *value,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_parent_store (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_parent_store_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_parent_store_sync (
+    EGdbusFolderCF *proxy,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_append_message (
+    EGdbusFolderCF *proxy,
+    GVariant *info,
+    const gchar *message,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_append_message_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_appendeduid,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_append_message_sync (
+    EGdbusFolderCF *proxy,
+    GVariant *info,
+    const gchar *message,
+    gchar **out_appendeduid,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_uids (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_uids_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_uids_sync (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_message (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_message_finish (
+    EGdbusFolderCF *proxy,
+    gchar **out_message,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_message_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    gchar **out_message,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_search_by_expression (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_search_by_expression_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_uids,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_search_by_expression_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    gchar ***out_uids,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_search_by_uids (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    const gchar *const *searchuids,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_search_by_uids_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_resultuids,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_search_by_uids_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *expression,
+    const gchar *const *searchuids,
+    gchar ***out_resultuids,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_get_message_info (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_get_message_info_finish (
+    EGdbusFolderCF *proxy,
+    GVariant **out_info,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_get_message_info_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *uid,
+    GVariant **out_info,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_transfer_messages_to (
+    EGdbusFolderCF *proxy,
+    const gchar *const *uids,
+    const gchar *destfolder,
+    gboolean deleteoriginals,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_transfer_messages_to_finish (
+    EGdbusFolderCF *proxy,
+    gchar ***out_returnuids,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_transfer_messages_to_sync (
+    EGdbusFolderCF *proxy,
+    const gchar *const *uids,
+    const gchar *destfolder,
+    gboolean deleteoriginals,
+    gchar ***out_returnuids,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_folder_cf_call_prepare_summary (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_folder_cf_call_prepare_summary_finish (
+    EGdbusFolderCF *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_folder_cf_call_prepare_summary_sync (
+    EGdbusFolderCF *proxy,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* ---- */
+
+#define EGDBUS_FOLDER_TYPE_CF_PROXY (egdbus_folder_cf_proxy_get_gtype ())
+#define EGDBUS_FOLDER_CF_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_FOLDER_TYPE_CF_PROXY, EGdbusFolderCFProxy))
+#define EGDBUS_FOLDER_CF_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_FOLDER_TYPE_CF_PROXY, EGdbusFolderCFProxyClass))
+#define EGDBUS_FOLDER_CF_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_FOLDER_TYPE_CF_PROXY, EGdbusFolderCFProxyClass))
+#define EGDBUS_FOLDER_IS_CF_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_FOLDER_TYPE_CF_PROXY))
+#define EGDBUS_FOLDER_IS_CF_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_FOLDER_TYPE_CF_PROXY))
+
+typedef struct _EGdbusFolderCFProxy EGdbusFolderCFProxy;
+typedef struct _EGdbusFolderCFProxyClass EGdbusFolderCFProxyClass;
+typedef struct _EGdbusFolderCFProxyPrivate EGdbusFolderCFProxyPrivate;
+
+struct _EGdbusFolderCFProxy
+{
+  GDBusProxy parent_instance;
+  EGdbusFolderCFProxyPrivate *priv;
+};
+
+struct _EGdbusFolderCFProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType egdbus_folder_cf_proxy_get_gtype (void) G_GNUC_CONST;
+
+void egdbus_folder_cf_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusFolderCF *egdbus_folder_cf_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusFolderCF *egdbus_folder_cf_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_folder_cf_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusFolderCF *egdbus_folder_cf_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusFolderCF *egdbus_folder_cf_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+#define EGDBUS_FOLDER_GET_CF(object_proxy) (g_dbus_object_proxy_lookup_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Folder", EGDBUS_FOLDER_TYPE_CF))
+#define EGDBUS_FOLDER_PEEK_CF(object_proxy) (g_dbus_object_proxy_peek_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Folder", EGDBUS_FOLDER_TYPE_CF))
+
+
+/* ---- */
+
+#define EGDBUS_FOLDER_TYPE_CF_STUB (egdbus_folder_cf_stub_get_gtype ())
+#define EGDBUS_FOLDER_CF_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_FOLDER_TYPE_CF_STUB, EGdbusFolderCFStub))
+#define EGDBUS_FOLDER_CF_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_FOLDER_TYPE_CF_STUB, EGdbusFolderCFStubClass))
+#define EGDBUS_FOLDER_CF_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_FOLDER_TYPE_CF_STUB, EGdbusFolderCFStubClass))
+#define EGDBUS_FOLDER_IS_CF_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_FOLDER_TYPE_CF_STUB))
+#define EGDBUS_FOLDER_IS_CF_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_FOLDER_TYPE_CF_STUB))
+
+typedef struct _EGdbusFolderCFStub EGdbusFolderCFStub;
+typedef struct _EGdbusFolderCFStubClass EGdbusFolderCFStubClass;
+typedef struct _EGdbusFolderCFStubPrivate EGdbusFolderCFStubPrivate;
+
+struct _EGdbusFolderCFStub
+{
+  GObject parent_instance;
+  EGdbusFolderCFStubPrivate *priv;
+};
+
+struct _EGdbusFolderCFStubClass
+{
+  GObjectClass parent_class;
+};
+
+GType egdbus_folder_cf_stub_get_gtype (void) G_GNUC_CONST;
+
+EGdbusFolderCF *egdbus_folder_cf_stub_new (void);
+
+
+/* ---- */
+
+#define EGDBUS_FOLDER_TYPE_PROXY_MANAGER (egdbus_folder_proxy_manager_get_gtype ())
+#define EGDBUS_FOLDER_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_FOLDER_TYPE_PROXY_MANAGER, EGdbusFolderProxyManager))
+#define EGDBUS_FOLDER_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_FOLDER_TYPE_PROXY_MANAGER, EGdbusFolderProxyManagerClass))
+#define EGDBUS_FOLDER_PROXY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_FOLDER_TYPE_PROXY_MANAGER, EGdbusFolderProxyManagerClass))
+#define EGDBUS_FOLDER_IS_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_FOLDER_TYPE_PROXY_MANAGER))
+#define EGDBUS_FOLDER_IS_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_FOLDER_TYPE_PROXY_MANAGER))
+
+typedef struct _EGdbusFolderProxyManager EGdbusFolderProxyManager;
+typedef struct _EGdbusFolderProxyManagerClass EGdbusFolderProxyManagerClass;
+typedef struct _EGdbusFolderProxyManagerPrivate EGdbusFolderProxyManagerPrivate;
+
+struct _EGdbusFolderProxyManager
+{
+  GDBusProxyManager parent_instance;
+  EGdbusFolderProxyManagerPrivate *priv;
+};
+
+struct _EGdbusFolderProxyManagerClass
+{
+  GDBusProxyManagerClass parent_class;
+};
+
+GType egdbus_folder_proxy_manager_get_gtype (void) G_GNUC_CONST;
+
+GDBusProxyTypeFunc egdbus_folder_proxy_manager_get_proxy_type_func (void);
+
+void egdbus_folder_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_folder_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_folder_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_folder_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_folder_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_folder_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+G_END_DECLS
+
+#endif /* __E_GDBUS_EMAILFOLDER_H__ */
diff --git a/mail/libegdbus/e-gdbus-emailsession.c b/mail/libegdbus/e-gdbus-emailsession.c
new file mode 100644
index 0000000..3d57139
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailsession.c
@@ -0,0 +1,1423 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "e-gdbus-emailsession.h"
+
+typedef struct
+{
+  GDBusArgInfo parent_struct;
+  gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+  GDBusMethodInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+  GDBusSignalInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+  GDBusPropertyInfo parent_struct;
+  const gchar *hyphen_name;
+  gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GParamSpec *pspec;
+  GValue value;
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+  g_value_unset (&data->value);
+  g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+  gboolean ret = FALSE;
+  guint n;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  if (g_strv_length (a) != g_strv_length (b))
+    goto out;
+  for (n = 0; a[n] != NULL; n++)
+    if (g_strcmp0 (a[n], b[n]) != 0)
+      goto out;
+  ret = TRUE;
+out:
+  return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+  gboolean ret = FALSE;
+  if (a == NULL && b == NULL)
+    goto out;
+  if (a == NULL || b == NULL)
+    goto out;
+  ret = g_variant_equal (a, b);
+out:
+  return ret;
+}
+
+static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+  gboolean ret = FALSE;
+  g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+  switch (G_VALUE_TYPE (a))
+    {
+      case G_TYPE_BOOLEAN:
+        ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+        break;
+      case G_TYPE_UCHAR:
+        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+        break;
+      case G_TYPE_INT:
+        ret = (g_value_get_int (a) == g_value_get_int (b));
+        break;
+      case G_TYPE_UINT:
+        ret = (g_value_get_uint (a) == g_value_get_uint (b));
+        break;
+      case G_TYPE_INT64:
+        ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+        break;
+      case G_TYPE_UINT64:
+        ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+        break;
+      case G_TYPE_DOUBLE:
+        ret = (g_value_get_double (a) == g_value_get_double (b));
+        break;
+      case G_TYPE_STRING:
+        ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+        break;
+      case G_TYPE_VARIANT:
+        ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+        break;
+      default:
+        if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+          ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+        else
+          g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+        break;
+    }
+  return ret;
+}
+
+#include <ffi.h>
+static ffi_type *
+value_to_ffi_type (const GValue *gvalue, gpointer *value)
+{
+  ffi_type *rettype = NULL;
+  GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
+  g_assert (type != G_TYPE_INVALID);
+
+  switch (type)
+    {
+    case G_TYPE_BOOLEAN:
+    case G_TYPE_CHAR:
+    case G_TYPE_INT:
+      rettype = &ffi_type_sint;
+      *value = (gpointer)&(gvalue->data[0].v_int);
+      break;
+    case G_TYPE_UCHAR:
+    case G_TYPE_UINT:
+      rettype = &ffi_type_uint;
+      *value = (gpointer)&(gvalue->data[0].v_uint);
+      break;
+    case G_TYPE_STRING:
+    case G_TYPE_OBJECT:
+    case G_TYPE_BOXED:
+    case G_TYPE_POINTER:
+    case G_TYPE_INTERFACE:
+    case G_TYPE_VARIANT:
+      rettype = &ffi_type_pointer;
+      *value = (gpointer)&(gvalue->data[0].v_pointer);
+      break;
+    case G_TYPE_FLOAT:
+      rettype = &ffi_type_float;
+      *value = (gpointer)&(gvalue->data[0].v_float);
+      break;
+    case G_TYPE_DOUBLE:
+      rettype = &ffi_type_double;
+      *value = (gpointer)&(gvalue->data[0].v_double);
+      break;
+    case G_TYPE_LONG:
+      rettype = &ffi_type_slong;
+      *value = (gpointer)&(gvalue->data[0].v_long);
+      break;
+    case G_TYPE_ULONG:
+      rettype = &ffi_type_ulong;
+      *value = (gpointer)&(gvalue->data[0].v_ulong);
+      break;
+    case G_TYPE_INT64:
+      rettype = &ffi_type_sint64;
+      *value = (gpointer)&(gvalue->data[0].v_int64);
+      break;
+    case G_TYPE_UINT64:
+      rettype = &ffi_type_uint64;
+      *value = (gpointer)&(gvalue->data[0].v_uint64);
+      break;
+    default:
+      rettype = &ffi_type_pointer;
+      *value = NULL;
+      g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
+      break;
+    }
+  return rettype;
+}
+
+static void
+value_from_ffi_type (GValue *gvalue, gpointer *value)
+{
+  switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
+    {
+    case G_TYPE_INT:
+      g_value_set_int (gvalue, *(gint*)value);
+      break;
+    case G_TYPE_FLOAT:
+      g_value_set_float (gvalue, *(gfloat*)value);
+      break;
+    case G_TYPE_DOUBLE:
+      g_value_set_double (gvalue, *(gdouble*)value);
+      break;
+    case G_TYPE_BOOLEAN:
+      g_value_set_boolean (gvalue, *(gboolean*)value);
+      break;
+    case G_TYPE_STRING:
+      g_value_set_string (gvalue, *(gchar**)value);
+      break;
+    case G_TYPE_CHAR:
+      g_value_set_char (gvalue, *(gchar*)value);
+      break;
+    case G_TYPE_UCHAR:
+      g_value_set_uchar (gvalue, *(guchar*)value);
+      break;
+    case G_TYPE_UINT:
+      g_value_set_uint (gvalue, *(guint*)value);
+      break;
+    case G_TYPE_POINTER:
+      g_value_set_pointer (gvalue, *(gpointer*)value);
+      break;
+    case G_TYPE_LONG:
+      g_value_set_long (gvalue, *(glong*)value);
+      break;
+    case G_TYPE_ULONG:
+      g_value_set_ulong (gvalue, *(gulong*)value);
+      break;
+    case G_TYPE_INT64:
+      g_value_set_int64 (gvalue, *(gint64*)value);
+      break;
+    case G_TYPE_UINT64:
+      g_value_set_uint64 (gvalue, *(guint64*)value);
+      break;
+    case G_TYPE_BOXED:
+      g_value_set_boxed (gvalue, *(gpointer*)value);
+      break;
+    default:
+      g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
+                g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
+    }
+}
+
+static void
+_cclosure_marshal_generic (GClosure *closure,
+                             GValue *return_gvalue,
+                             guint n_param_values,
+                             const GValue *param_values,
+                             gpointer invocation_hint,
+                             gpointer marshal_data)
+{
+  ffi_type *rtype;
+  void *rvalue;
+  int n_args;
+  ffi_type **atypes;
+  void **args;
+  int i;
+  ffi_cif cif;
+  GCClosure *cc = (GCClosure*) closure;
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue)) 
+    {
+      rtype = value_to_ffi_type (return_gvalue, &rvalue);
+    }
+  else 
+    {
+      rtype = &ffi_type_void;
+    }
+
+  rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
+  
+  n_args = n_param_values + 1;
+  atypes = g_alloca (sizeof (ffi_type *) * n_args);
+  args =  g_alloca (sizeof (gpointer) * n_args);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      atypes[n_args-1] = value_to_ffi_type (param_values + 0,  
+                                            &args[n_args-1]);
+      atypes[0] = &ffi_type_pointer;
+      args[0] = &closure->data;
+    }
+  else
+    {
+      atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
+      atypes[n_args-1] = &ffi_type_pointer;
+      args[n_args-1] = &closure->data;
+    }
+
+  for (i = 1; i < n_args - 1; i++)
+    atypes[i] = value_to_ffi_type (param_values + i, &args[i]);
+
+  if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
+    return;
+
+  ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue))
+    value_from_ffi_type (return_gvalue, rvalue);
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.gnome.evolution.dataserver.mail.Session
+ * ------------------------------------------------------------------------
+ */
+
+/* ---- Introspection data for org.gnome.evolution.dataserver.mail.Session ---- */
+
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_store_IN_ARG_uri =
+{
+  {
+    -1,
+    "uri",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_store_IN_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_store_IN_ARG_uri,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_store_OUT_ARG_store =
+{
+  {
+    -1,
+    "store",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_store_OUT_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_store_OUT_ARG_store,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_session_cs_method_get_store_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "impl_Mail_Session_getStore",
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_session_cs_method_get_store_annotation_info_1 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.Async",
+  "",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_session_cs_method_get_store_annotation_info_pointers[] =
+{
+  &_egdbus_session_cs_method_get_store_annotation_info_0,
+  &_egdbus_session_cs_method_get_store_annotation_info_1,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_get_store =
+{
+  {
+    -1,
+    "getStore",
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_get_store_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_get_store_OUT_ARG_pointers,
+    (GDBusAnnotationInfo **) &_egdbus_session_cs_method_get_store_annotation_info_pointers
+  },
+  "handle-get-store"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_local_store_OUT_ARG_store =
+{
+  {
+    -1,
+    "store",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_local_store_OUT_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_local_store_OUT_ARG_store,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_get_local_store =
+{
+  {
+    -1,
+    "getLocalStore",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_get_local_store_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-local-store"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_local_folder_IN_ARG_type =
+{
+  {
+    -1,
+    "type",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_local_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_local_folder_IN_ARG_type,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_get_local_folder_OUT_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_get_local_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_local_folder_OUT_ARG_folder,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_get_local_folder =
+{
+  {
+    -1,
+    "getLocalFolder",
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_get_local_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_get_local_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-local-folder"
+};
+
+static const _ExtendedGDBusMethodInfo * const _egdbus_session_cs_method_info_pointers[] =
+{
+  &_egdbus_session_cs_method_info_get_store,
+  &_egdbus_session_cs_method_info_get_local_store,
+  &_egdbus_session_cs_method_info_get_local_folder,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_session_cs_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "EMailDataSession",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_session_cs_annotation_info_pointers[] =
+{
+  &_egdbus_session_cs_annotation_info_0,
+  NULL
+};
+
+static const GDBusInterfaceInfo _egdbus_session_cs_interface_info =
+{
+  -1,
+  "org.gnome.evolution.dataserver.mail.Session",
+  (GDBusMethodInfo **) &_egdbus_session_cs_method_info_pointers,
+  NULL,
+  NULL,
+  (GDBusAnnotationInfo **) &_egdbus_session_cs_annotation_info_pointers
+};
+
+
+GDBusInterfaceInfo *
+egdbus_session_cs_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info;
+}
+
+
+
+static void
+egdbus_session_cs_default_init (EGdbusSessionCSIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  g_signal_new ("handle-get-store",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_get_store),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-local-store",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_get_local_store),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-local-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_get_local_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+}
+
+typedef EGdbusSessionCSIface EGdbusSessionCSInterface;
+#define egdbus_session_cs_get_type egdbus_session_cs_get_gtype
+G_DEFINE_INTERFACE (EGdbusSessionCS, egdbus_session_cs, G_TYPE_OBJECT);
+#undef egdbus_session_cs_get_type
+
+void
+egdbus_session_cs_call_get_store (
+    EGdbusSessionCS *proxy,
+    const gchar *uri,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getStore",
+    g_variant_new ("(s)",
+                   uri),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_session_cs_call_get_store_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_session_cs_call_get_store_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *uri,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getStore",
+    g_variant_new ("(s)",
+                   uri),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_session_cs_call_get_local_store (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getLocalStore",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_session_cs_call_get_local_store_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_session_cs_call_get_local_store_sync (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getLocalStore",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_store);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_session_cs_call_get_local_folder (
+    EGdbusSessionCS *proxy,
+    const gchar *type,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getLocalFolder",
+    g_variant_new ("(s)",
+                   type),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_session_cs_call_get_local_folder_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_session_cs_call_get_local_folder_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *type,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getLocalFolder",
+    g_variant_new ("(s)",
+                   type),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_session_cs_complete_get_store (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   store));
+}
+
+void
+egdbus_session_cs_complete_get_local_store (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   store));
+}
+
+void
+egdbus_session_cs_complete_get_local_folder (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   folder));
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void
+egdbus_session_cs_proxy_iface_init (EGdbusSessionCSIface *iface)
+{
+}
+
+#define egdbus_session_cs_proxy_get_type egdbus_session_cs_proxy_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusSessionCSProxy, egdbus_session_cs_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_SESSION_TYPE_CS, egdbus_session_cs_proxy_iface_init));
+#undef egdbus_session_cs_proxy_get_type
+
+static void
+egdbus_session_cs_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_session_cs_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_session_cs_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], EGDBUS_SESSION_TYPE_CS);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_SESSION_TYPE_CS);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+egdbus_session_cs_proxy_g_properties_changed (GDBusProxy *proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static void
+egdbus_session_cs_proxy_init (EGdbusSessionCSProxy *proxy)
+{
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), egdbus_session_cs_interface_info ());
+}
+
+static void
+egdbus_session_cs_proxy_class_init (EGdbusSessionCSProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->get_property = egdbus_session_cs_proxy_get_property;
+  gobject_class->set_property = egdbus_session_cs_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = egdbus_session_cs_proxy_g_signal;
+  proxy_class->g_properties_changed = egdbus_session_cs_proxy_g_properties_changed;
+
+}
+void
+egdbus_session_cs_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_SESSION_TYPE_CS_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Session", NULL);
+}
+
+EGdbusSessionCS *
+egdbus_session_cs_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_SESSION_CS (ret);
+  else
+    return NULL;
+}
+
+EGdbusSessionCS *
+egdbus_session_cs_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_SESSION_TYPE_CS_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Session", NULL);
+  if (ret != NULL)
+    return EGDBUS_SESSION_CS (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_session_cs_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_SESSION_TYPE_CS_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Session", NULL);
+}
+
+EGdbusSessionCS *
+egdbus_session_cs_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_SESSION_CS (ret);
+  else
+    return NULL;
+}
+
+EGdbusSessionCS *
+egdbus_session_cs_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_SESSION_TYPE_CS_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Session", NULL);
+  if (ret != NULL)
+    return EGDBUS_SESSION_CS (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+struct _EGdbusSessionCSStubPrivate
+{
+  GValueArray *properties;
+  GDBusObject *object;
+  GDBusInterfaceFlags flags;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GDBusConnection *connection;
+  gchar *object_path;
+  GMainContext *context;
+};
+
+static void
+_egdbus_session_cs_stub_handle_method_call (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  GValue return_value = {0};
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_interface_info_lookup_method ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, method_name);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 2);
+  g_value_init (&paramv[0], EGDBUS_SESSION_TYPE_CS);
+  g_value_set_object (&paramv[0], stub);
+  g_value_init (&paramv[1], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[1], invocation);
+  g_variant_iter_init (&iter, parameters);
+  n = 2;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - 2];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_SESSION_TYPE_CS);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + 2; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_egdbus_session_cs_stub_handle_get_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (stub), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_egdbus_session_cs_stub_handle_set_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_session_cs_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (stub), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _egdbus_session_cs_stub_vtable =
+{
+  _egdbus_session_cs_stub_handle_method_call,
+  _egdbus_session_cs_stub_handle_get_property,
+  _egdbus_session_cs_stub_handle_set_property
+};
+
+static GDBusInterfaceInfo *
+egdbus_session_cs_stub_dbus_interface_get_info (GDBusInterface *interface)
+{
+  return egdbus_session_cs_interface_info ();
+}
+
+static GVariant *
+egdbus_session_cs_stub_dbus_interface_get_properties (GDBusInterface *interface)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_egdbus_session_cs_interface_info.properties == NULL)
+    goto out;
+  for (n = 0; _egdbus_session_cs_interface_info.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _egdbus_session_cs_interface_info.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _egdbus_session_cs_stub_handle_get_property (stub->priv->connection, NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Session", info->name, NULL, stub);
+          if (value != NULL)
+            {
+              if (g_variant_is_floating (value))
+                g_variant_ref_sink (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static void
+egdbus_session_cs_stub_dbus_interface_flush (GDBusInterface *interface)
+{
+}
+
+static void
+_egdbus_session_cs_on_object_unregistered (EGdbusSessionCSStub *stub)
+{
+  stub->priv->connection = NULL;
+  g_free (stub->priv->object_path);
+  stub->priv->object_path = NULL;
+}
+
+static guint
+egdbus_session_cs_stub_dbus_interface_register_object (GDBusInterface *interface,  GDBusConnection *connection,
+  const gchar *object_path,
+  GError **error)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+  stub->priv->connection = connection;
+  stub->priv->object_path = g_strdup (object_path);
+  stub->priv->context = g_main_context_get_thread_default ();
+  if (stub->priv->context != NULL)
+    g_main_context_ref (stub->priv->context);
+  return g_dbus_connection_register_object (connection, object_path, egdbus_session_cs_interface_info (), &_egdbus_session_cs_stub_vtable, stub, (GDestroyNotify) _egdbus_session_cs_on_object_unregistered, error);
+}
+
+static GDBusObject *
+egdbus_session_cs_stub_dbus_interface_get_object (GDBusInterface *interface)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+  return stub->priv->object != NULL ? g_object_ref (stub->priv->object) : NULL;
+}
+
+static void
+egdbus_session_cs_stub_dbus_interface_set_object (GDBusInterface *interface,  GDBusObject *object)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+  stub->priv->object = object;
+}
+
+static GDBusInterfaceFlags
+egdbus_session_cs_stub_dbus_interface_get_flags (GDBusInterface *interface)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+  return stub->priv->flags;
+}
+
+static void
+egdbus_session_cs_stub_dbus_interface_set_flags (GDBusInterface *interface,  GDBusInterfaceFlags flags)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (interface);
+  stub->priv->flags = flags;
+}
+
+static void
+egdbus_session_cs_stub_iface_init (EGdbusSessionCSIface *iface)
+{
+}
+
+static void
+egdbus_session_cs_stub_dbus_iface_init (GDBusInterfaceIface *iface)
+{
+  iface->get_info = egdbus_session_cs_stub_dbus_interface_get_info;
+  iface->get_properties = egdbus_session_cs_stub_dbus_interface_get_properties;
+  iface->flush = egdbus_session_cs_stub_dbus_interface_flush;
+  iface->register_object = egdbus_session_cs_stub_dbus_interface_register_object;
+  iface->get_object = egdbus_session_cs_stub_dbus_interface_get_object;
+  iface->set_object = egdbus_session_cs_stub_dbus_interface_set_object;
+  iface->get_flags = egdbus_session_cs_stub_dbus_interface_get_flags;
+  iface->set_flags = egdbus_session_cs_stub_dbus_interface_set_flags;
+}
+
+#define egdbus_session_cs_stub_get_type egdbus_session_cs_stub_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusSessionCSStub, egdbus_session_cs_stub, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_SESSION_TYPE_CS, egdbus_session_cs_stub_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_INTERFACE, egdbus_session_cs_stub_dbus_iface_init));
+#undef egdbus_session_cs_stub_get_type
+
+static void
+egdbus_session_cs_stub_finalize (GObject *object)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (object);
+  g_list_foreach (stub->priv->changed_properties, (GFunc) _changed_property_free, NULL);
+  g_list_free (stub->priv->changed_properties);
+  if (stub->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (stub->priv->changed_properties_idle_source);
+  if (stub->priv->context != NULL)
+    g_main_context_unref (stub->priv->context);
+  G_OBJECT_CLASS (egdbus_session_cs_stub_parent_class)->finalize (object);
+}
+
+static void
+egdbus_session_cs_stub_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  EGdbusSessionCSStub *stub = EGDBUS_SESSION_CS_STUB (object);
+  g_assert (prop_id - 1 >= 0 && prop_id - 1 < 0);
+  g_value_copy (&stub->priv->properties->values[prop_id - 1], value);
+}
+
+static void
+egdbus_session_cs_stub_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_session_cs_stub_init (EGdbusSessionCSStub *stub)
+{
+  stub->priv = G_TYPE_INSTANCE_GET_PRIVATE (stub, EGDBUS_SESSION_TYPE_CS_STUB, EGdbusSessionCSStubPrivate);
+}
+
+static void
+egdbus_session_cs_stub_class_init (EGdbusSessionCSStubClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  g_type_class_add_private (klass, sizeof (EGdbusSessionCSStubPrivate));
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = egdbus_session_cs_stub_finalize;
+  gobject_class->get_property = egdbus_session_cs_stub_get_property;
+  gobject_class->set_property = egdbus_session_cs_stub_set_property;
+
+}
+
+EGdbusSessionCS *
+egdbus_session_cs_stub_new (void)
+{
+  return EGDBUS_SESSION_CS (g_object_new (EGDBUS_SESSION_TYPE_CS_STUB, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for proxy manager
+ * ------------------------------------------------------------------------
+ */
+
+/* ------------------------------------------------------------------------ */
+
+#define egdbus_session_proxy_manager_get_type egdbus_session_proxy_manager_get_gtype
+G_DEFINE_TYPE (EGdbusSessionProxyManager, egdbus_session_proxy_manager, G_TYPE_DBUS_PROXY_MANAGER);
+#undef egdbus_session_proxy_manager_get_type
+
+static void
+egdbus_session_proxy_manager_init (EGdbusSessionProxyManager *manager)
+{
+}
+
+static void
+egdbus_session_proxy_manager_class_init (EGdbusSessionProxyManagerClass *klass)
+{
+}
+
+static GType
+_egdbus_session_proxy_manager_get_proxy_type_func (GDBusProxyManager *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data)
+{
+  GType ret;
+  ret = G_TYPE_DBUS_PROXY;
+  if (FALSE)
+    ;
+  else if (g_strcmp0 (interface_name, "org.gnome.evolution.dataserver.mail.Session") == 0)
+    ret = EGDBUS_SESSION_TYPE_CS_PROXY;
+  return ret;
+}
+
+GDBusProxyTypeFunc
+egdbus_session_proxy_manager_get_proxy_type_func (void)
+{
+  return _egdbus_session_proxy_manager_get_proxy_type_func;
+}
+
+void
+egdbus_session_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_SESSION_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_session_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_session_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_session_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_SESSION_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_session_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_session_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_SESSION_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_session_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_session_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_session_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_SESSION_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_session_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
diff --git a/mail/libegdbus/e-gdbus-emailsession.h b/mail/libegdbus/e-gdbus-emailsession.h
new file mode 100644
index 0000000..c6425f9
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailsession.h
@@ -0,0 +1,302 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifndef __E_GDBUS_EMAILSESSION_H__
+#define __E_GDBUS_EMAILSESSION_H__
+
+#include <gio/gio.h>
+#include <gdbusinterface.h>
+#include <gdbusobjectproxy.h>
+#include <gdbusproxymanager.h>
+#include <gdbusobject.h>
+#include <gdbusobjectmanager.h>
+#include <gdbuscodegen-enumtypes.h>
+
+G_BEGIN_DECLS
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.gnome.evolution.dataserver.mail.Session */
+
+#define EGDBUS_SESSION_TYPE_CS (egdbus_session_cs_get_gtype ())
+#define EGDBUS_SESSION_CS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_SESSION_TYPE_CS, EGdbusSessionCS))
+#define EGDBUS_SESSION_IS_CS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_SESSION_TYPE_CS))
+#define EGDBUS_SESSION_CS_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EGDBUS_SESSION_TYPE_CS, EGdbusSessionCS))
+
+struct _EGdbusSessionCS;
+typedef struct _EGdbusSessionCS EGdbusSessionCS;
+typedef struct _EGdbusSessionCSIface EGdbusSessionCSIface;
+
+struct _EGdbusSessionCSIface
+{
+  GTypeInterface parent_iface;
+
+  /* GObject signal class handlers for incoming D-Bus method calls: */
+  gboolean (*handle_get_store) (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uri);
+
+  gboolean (*handle_get_local_store) (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_local_folder) (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *type);
+
+};
+
+GType egdbus_session_cs_get_gtype (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *egdbus_session_cs_interface_info (void);
+
+
+/* D-Bus method call completion functions: */
+void egdbus_session_cs_complete_get_store (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store);
+
+void egdbus_session_cs_complete_get_local_store (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *store);
+
+void egdbus_session_cs_complete_get_local_folder (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder);
+
+
+
+/* D-Bus method calls: */
+void egdbus_session_cs_call_get_store (
+    EGdbusSessionCS *proxy,
+    const gchar *uri,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_session_cs_call_get_store_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_session_cs_call_get_store_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *uri,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_session_cs_call_get_local_store (
+    EGdbusSessionCS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_session_cs_call_get_local_store_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_session_cs_call_get_local_store_sync (
+    EGdbusSessionCS *proxy,
+    gchar **out_store,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_session_cs_call_get_local_folder (
+    EGdbusSessionCS *proxy,
+    const gchar *type,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_session_cs_call_get_local_folder_finish (
+    EGdbusSessionCS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_session_cs_call_get_local_folder_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *type,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* ---- */
+
+#define EGDBUS_SESSION_TYPE_CS_PROXY (egdbus_session_cs_proxy_get_gtype ())
+#define EGDBUS_SESSION_CS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_SESSION_TYPE_CS_PROXY, EGdbusSessionCSProxy))
+#define EGDBUS_SESSION_CS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_SESSION_TYPE_CS_PROXY, EGdbusSessionCSProxyClass))
+#define EGDBUS_SESSION_CS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_SESSION_TYPE_CS_PROXY, EGdbusSessionCSProxyClass))
+#define EGDBUS_SESSION_IS_CS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_SESSION_TYPE_CS_PROXY))
+#define EGDBUS_SESSION_IS_CS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_SESSION_TYPE_CS_PROXY))
+
+typedef struct _EGdbusSessionCSProxy EGdbusSessionCSProxy;
+typedef struct _EGdbusSessionCSProxyClass EGdbusSessionCSProxyClass;
+typedef struct _EGdbusSessionCSProxyPrivate EGdbusSessionCSProxyPrivate;
+
+struct _EGdbusSessionCSProxy
+{
+  GDBusProxy parent_instance;
+  EGdbusSessionCSProxyPrivate *priv;
+};
+
+struct _EGdbusSessionCSProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType egdbus_session_cs_proxy_get_gtype (void) G_GNUC_CONST;
+
+void egdbus_session_cs_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusSessionCS *egdbus_session_cs_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusSessionCS *egdbus_session_cs_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_session_cs_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusSessionCS *egdbus_session_cs_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusSessionCS *egdbus_session_cs_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+#define EGDBUS_SESSION_GET_CS(object_proxy) (g_dbus_object_proxy_lookup_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Session", EGDBUS_SESSION_TYPE_CS))
+#define EGDBUS_SESSION_PEEK_CS(object_proxy) (g_dbus_object_proxy_peek_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Session", EGDBUS_SESSION_TYPE_CS))
+
+
+/* ---- */
+
+#define EGDBUS_SESSION_TYPE_CS_STUB (egdbus_session_cs_stub_get_gtype ())
+#define EGDBUS_SESSION_CS_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_SESSION_TYPE_CS_STUB, EGdbusSessionCSStub))
+#define EGDBUS_SESSION_CS_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_SESSION_TYPE_CS_STUB, EGdbusSessionCSStubClass))
+#define EGDBUS_SESSION_CS_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_SESSION_TYPE_CS_STUB, EGdbusSessionCSStubClass))
+#define EGDBUS_SESSION_IS_CS_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_SESSION_TYPE_CS_STUB))
+#define EGDBUS_SESSION_IS_CS_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_SESSION_TYPE_CS_STUB))
+
+typedef struct _EGdbusSessionCSStub EGdbusSessionCSStub;
+typedef struct _EGdbusSessionCSStubClass EGdbusSessionCSStubClass;
+typedef struct _EGdbusSessionCSStubPrivate EGdbusSessionCSStubPrivate;
+
+struct _EGdbusSessionCSStub
+{
+  GObject parent_instance;
+  EGdbusSessionCSStubPrivate *priv;
+};
+
+struct _EGdbusSessionCSStubClass
+{
+  GObjectClass parent_class;
+};
+
+GType egdbus_session_cs_stub_get_gtype (void) G_GNUC_CONST;
+
+EGdbusSessionCS *egdbus_session_cs_stub_new (void);
+
+
+/* ---- */
+
+#define EGDBUS_SESSION_TYPE_PROXY_MANAGER (egdbus_session_proxy_manager_get_gtype ())
+#define EGDBUS_SESSION_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_SESSION_TYPE_PROXY_MANAGER, EGdbusSessionProxyManager))
+#define EGDBUS_SESSION_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_SESSION_TYPE_PROXY_MANAGER, EGdbusSessionProxyManagerClass))
+#define EGDBUS_SESSION_PROXY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_SESSION_TYPE_PROXY_MANAGER, EGdbusSessionProxyManagerClass))
+#define EGDBUS_SESSION_IS_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_SESSION_TYPE_PROXY_MANAGER))
+#define EGDBUS_SESSION_IS_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_SESSION_TYPE_PROXY_MANAGER))
+
+typedef struct _EGdbusSessionProxyManager EGdbusSessionProxyManager;
+typedef struct _EGdbusSessionProxyManagerClass EGdbusSessionProxyManagerClass;
+typedef struct _EGdbusSessionProxyManagerPrivate EGdbusSessionProxyManagerPrivate;
+
+struct _EGdbusSessionProxyManager
+{
+  GDBusProxyManager parent_instance;
+  EGdbusSessionProxyManagerPrivate *priv;
+};
+
+struct _EGdbusSessionProxyManagerClass
+{
+  GDBusProxyManagerClass parent_class;
+};
+
+GType egdbus_session_proxy_manager_get_gtype (void) G_GNUC_CONST;
+
+GDBusProxyTypeFunc egdbus_session_proxy_manager_get_proxy_type_func (void);
+
+void egdbus_session_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_session_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_session_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_session_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_session_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_session_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+G_END_DECLS
+
+#endif /* __E_GDBUS_EMAILSESSION_H__ */
diff --git a/mail/libegdbus/e-gdbus-emailstore.c b/mail/libegdbus/e-gdbus-emailstore.c
new file mode 100644
index 0000000..61780d9
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailstore.c
@@ -0,0 +1,3411 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "e-gdbus-emailstore.h"
+
+typedef struct
+{
+  GDBusArgInfo parent_struct;
+  gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+  GDBusMethodInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+  GDBusSignalInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+  GDBusPropertyInfo parent_struct;
+  const gchar *hyphen_name;
+  gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GParamSpec *pspec;
+  GValue value;
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+  g_value_unset (&data->value);
+  g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+  gboolean ret = FALSE;
+  guint n;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  if (g_strv_length (a) != g_strv_length (b))
+    goto out;
+  for (n = 0; a[n] != NULL; n++)
+    if (g_strcmp0 (a[n], b[n]) != 0)
+      goto out;
+  ret = TRUE;
+out:
+  return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+  gboolean ret = FALSE;
+  if (a == NULL && b == NULL)
+    goto out;
+  if (a == NULL || b == NULL)
+    goto out;
+  ret = g_variant_equal (a, b);
+out:
+  return ret;
+}
+
+static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+  gboolean ret = FALSE;
+  g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+  switch (G_VALUE_TYPE (a))
+    {
+      case G_TYPE_BOOLEAN:
+        ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+        break;
+      case G_TYPE_UCHAR:
+        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+        break;
+      case G_TYPE_INT:
+        ret = (g_value_get_int (a) == g_value_get_int (b));
+        break;
+      case G_TYPE_UINT:
+        ret = (g_value_get_uint (a) == g_value_get_uint (b));
+        break;
+      case G_TYPE_INT64:
+        ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+        break;
+      case G_TYPE_UINT64:
+        ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+        break;
+      case G_TYPE_DOUBLE:
+        ret = (g_value_get_double (a) == g_value_get_double (b));
+        break;
+      case G_TYPE_STRING:
+        ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+        break;
+      case G_TYPE_VARIANT:
+        ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+        break;
+      default:
+        if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+          ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+        else
+          g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+        break;
+    }
+  return ret;
+}
+
+#include <ffi.h>
+static ffi_type *
+value_to_ffi_type (const GValue *gvalue, gpointer *value)
+{
+  ffi_type *rettype = NULL;
+  GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
+  g_assert (type != G_TYPE_INVALID);
+
+  switch (type)
+    {
+    case G_TYPE_BOOLEAN:
+    case G_TYPE_CHAR:
+    case G_TYPE_INT:
+      rettype = &ffi_type_sint;
+      *value = (gpointer)&(gvalue->data[0].v_int);
+      break;
+    case G_TYPE_UCHAR:
+    case G_TYPE_UINT:
+      rettype = &ffi_type_uint;
+      *value = (gpointer)&(gvalue->data[0].v_uint);
+      break;
+    case G_TYPE_STRING:
+    case G_TYPE_OBJECT:
+    case G_TYPE_BOXED:
+    case G_TYPE_POINTER:
+    case G_TYPE_INTERFACE:
+    case G_TYPE_VARIANT:
+      rettype = &ffi_type_pointer;
+      *value = (gpointer)&(gvalue->data[0].v_pointer);
+      break;
+    case G_TYPE_FLOAT:
+      rettype = &ffi_type_float;
+      *value = (gpointer)&(gvalue->data[0].v_float);
+      break;
+    case G_TYPE_DOUBLE:
+      rettype = &ffi_type_double;
+      *value = (gpointer)&(gvalue->data[0].v_double);
+      break;
+    case G_TYPE_LONG:
+      rettype = &ffi_type_slong;
+      *value = (gpointer)&(gvalue->data[0].v_long);
+      break;
+    case G_TYPE_ULONG:
+      rettype = &ffi_type_ulong;
+      *value = (gpointer)&(gvalue->data[0].v_ulong);
+      break;
+    case G_TYPE_INT64:
+      rettype = &ffi_type_sint64;
+      *value = (gpointer)&(gvalue->data[0].v_int64);
+      break;
+    case G_TYPE_UINT64:
+      rettype = &ffi_type_uint64;
+      *value = (gpointer)&(gvalue->data[0].v_uint64);
+      break;
+    default:
+      rettype = &ffi_type_pointer;
+      *value = NULL;
+      g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
+      break;
+    }
+  return rettype;
+}
+
+static void
+value_from_ffi_type (GValue *gvalue, gpointer *value)
+{
+  switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
+    {
+    case G_TYPE_INT:
+      g_value_set_int (gvalue, *(gint*)value);
+      break;
+    case G_TYPE_FLOAT:
+      g_value_set_float (gvalue, *(gfloat*)value);
+      break;
+    case G_TYPE_DOUBLE:
+      g_value_set_double (gvalue, *(gdouble*)value);
+      break;
+    case G_TYPE_BOOLEAN:
+      g_value_set_boolean (gvalue, *(gboolean*)value);
+      break;
+    case G_TYPE_STRING:
+      g_value_set_string (gvalue, *(gchar**)value);
+      break;
+    case G_TYPE_CHAR:
+      g_value_set_char (gvalue, *(gchar*)value);
+      break;
+    case G_TYPE_UCHAR:
+      g_value_set_uchar (gvalue, *(guchar*)value);
+      break;
+    case G_TYPE_UINT:
+      g_value_set_uint (gvalue, *(guint*)value);
+      break;
+    case G_TYPE_POINTER:
+      g_value_set_pointer (gvalue, *(gpointer*)value);
+      break;
+    case G_TYPE_LONG:
+      g_value_set_long (gvalue, *(glong*)value);
+      break;
+    case G_TYPE_ULONG:
+      g_value_set_ulong (gvalue, *(gulong*)value);
+      break;
+    case G_TYPE_INT64:
+      g_value_set_int64 (gvalue, *(gint64*)value);
+      break;
+    case G_TYPE_UINT64:
+      g_value_set_uint64 (gvalue, *(guint64*)value);
+      break;
+    case G_TYPE_BOXED:
+      g_value_set_boxed (gvalue, *(gpointer*)value);
+      break;
+    default:
+      g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
+                g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
+    }
+}
+
+static void
+_cclosure_marshal_generic (GClosure *closure,
+                             GValue *return_gvalue,
+                             guint n_param_values,
+                             const GValue *param_values,
+                             gpointer invocation_hint,
+                             gpointer marshal_data)
+{
+  ffi_type *rtype;
+  void *rvalue;
+  int n_args;
+  ffi_type **atypes;
+  void **args;
+  int i;
+  ffi_cif cif;
+  GCClosure *cc = (GCClosure*) closure;
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue)) 
+    {
+      rtype = value_to_ffi_type (return_gvalue, &rvalue);
+    }
+  else 
+    {
+      rtype = &ffi_type_void;
+    }
+
+  rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
+  
+  n_args = n_param_values + 1;
+  atypes = g_alloca (sizeof (ffi_type *) * n_args);
+  args =  g_alloca (sizeof (gpointer) * n_args);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      atypes[n_args-1] = value_to_ffi_type (param_values + 0,  
+                                            &args[n_args-1]);
+      atypes[0] = &ffi_type_pointer;
+      args[0] = &closure->data;
+    }
+  else
+    {
+      atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
+      atypes[n_args-1] = &ffi_type_pointer;
+      args[n_args-1] = &closure->data;
+    }
+
+  for (i = 1; i < n_args - 1; i++)
+    atypes[i] = value_to_ffi_type (param_values + i, &args[i]);
+
+  if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
+    return;
+
+  ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
+
+  if (return_gvalue && G_VALUE_TYPE (return_gvalue))
+    value_from_ffi_type (return_gvalue, rvalue);
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.gnome.evolution.dataserver.mail.Store
+ * ------------------------------------------------------------------------
+ */
+
+/* ---- Introspection data for org.gnome.evolution.dataserver.mail.Store ---- */
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_folder_IN_ARG_full_name =
+{
+  {
+    -1,
+    "full_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_folder_IN_ARG_full_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_folder_OUT_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_folder_OUT_ARG_folder,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_store_ms_method_get_folder_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "impl_Mail_Store_getFolder",
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_store_ms_method_get_folder_annotation_info_1 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.Async",
+  "",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_store_ms_method_get_folder_annotation_info_pointers[] =
+{
+  &_egdbus_store_ms_method_get_folder_annotation_info_0,
+  &_egdbus_store_ms_method_get_folder_annotation_info_1,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_get_folder =
+{
+  {
+    -1,
+    "getFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_folder_OUT_ARG_pointers,
+    (GDBusAnnotationInfo **) &_egdbus_store_ms_method_get_folder_annotation_info_pointers
+  },
+  "handle-get-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_folder_info_IN_ARG_full_name =
+{
+  {
+    -1,
+    "full_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_folder_info_IN_ARG_flags =
+{
+  {
+    -1,
+    "flags",
+    "u",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_folder_info_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_folder_info_IN_ARG_full_name,
+  &_egdbus_store_ms_method_info_get_folder_info_IN_ARG_flags,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_folder_info_OUT_ARG_infos =
+{
+  {
+    -1,
+    "infos",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_folder_info_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_folder_info_OUT_ARG_infos,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_store_ms_method_get_folder_info_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "impl_Mail_Store_getFolderInfo",
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_store_ms_method_get_folder_info_annotation_info_1 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.Async",
+  "",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_store_ms_method_get_folder_info_annotation_info_pointers[] =
+{
+  &_egdbus_store_ms_method_get_folder_info_annotation_info_0,
+  &_egdbus_store_ms_method_get_folder_info_annotation_info_1,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_get_folder_info =
+{
+  {
+    -1,
+    "getFolderInfo",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_folder_info_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_folder_info_OUT_ARG_pointers,
+    (GDBusAnnotationInfo **) &_egdbus_store_ms_method_get_folder_info_annotation_info_pointers
+  },
+  "handle-get-folder-info"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_inbox_OUT_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_inbox_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_inbox_OUT_ARG_folder,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_get_inbox =
+{
+  {
+    -1,
+    "getInbox",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_inbox_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-inbox"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_junk_OUT_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_junk_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_junk_OUT_ARG_folder,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_get_junk =
+{
+  {
+    -1,
+    "getJunk",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_junk_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-junk"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_get_trash_OUT_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_get_trash_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_trash_OUT_ARG_folder,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_get_trash =
+{
+  {
+    -1,
+    "getTrash",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_get_trash_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-trash"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_create_folder_IN_ARG_parent_name =
+{
+  {
+    -1,
+    "parent_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_create_folder_IN_ARG_folder_name =
+{
+  {
+    -1,
+    "folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_create_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_create_folder_IN_ARG_parent_name,
+  &_egdbus_store_ms_method_info_create_folder_IN_ARG_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_create_folder_OUT_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_create_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_create_folder_OUT_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_create_folder =
+{
+  {
+    -1,
+    "createFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_create_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_create_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-create-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_delete_folder_IN_ARG_folder_name =
+{
+  {
+    -1,
+    "folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_delete_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_delete_folder_IN_ARG_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_delete_folder_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_delete_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_delete_folder_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_delete_folder =
+{
+  {
+    -1,
+    "deleteFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_delete_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_delete_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-delete-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_rename_folder_IN_ARG_old_folder_name =
+{
+  {
+    -1,
+    "old_folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_rename_folder_IN_ARG_new_folder_name =
+{
+  {
+    -1,
+    "new_folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_rename_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_rename_folder_IN_ARG_old_folder_name,
+  &_egdbus_store_ms_method_info_rename_folder_IN_ARG_new_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_rename_folder_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_rename_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_rename_folder_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_rename_folder =
+{
+  {
+    -1,
+    "renameFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_rename_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_rename_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-rename-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_supports_subscriptions_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_supports_subscriptions_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_supports_subscriptions_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_supports_subscriptions =
+{
+  {
+    -1,
+    "supportsSubscriptions",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_supports_subscriptions_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-supports-subscriptions"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_is_folder_subscribed_IN_ARG_folder_name =
+{
+  {
+    -1,
+    "folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_is_folder_subscribed_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_is_folder_subscribed_IN_ARG_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_is_folder_subscribed_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_is_folder_subscribed_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_is_folder_subscribed_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_is_folder_subscribed =
+{
+  {
+    -1,
+    "isFolderSubscribed",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_is_folder_subscribed_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_is_folder_subscribed_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-is-folder-subscribed"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_subscribe_folder_IN_ARG_folder_name =
+{
+  {
+    -1,
+    "folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_subscribe_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_subscribe_folder_IN_ARG_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_subscribe_folder_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_subscribe_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_subscribe_folder_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_subscribe_folder =
+{
+  {
+    -1,
+    "subscribeFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_subscribe_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_subscribe_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-subscribe-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_unsubscribe_folder_IN_ARG_folder_name =
+{
+  {
+    -1,
+    "folder_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_unsubscribe_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_unsubscribe_folder_IN_ARG_folder_name,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_unsubscribe_folder_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_unsubscribe_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_unsubscribe_folder_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_unsubscribe_folder =
+{
+  {
+    -1,
+    "unsubscribeFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_unsubscribe_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_unsubscribe_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-unsubscribe-folder"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_sync_IN_ARG_expunge =
+{
+  {
+    -1,
+    "expunge",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_sync_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_sync_IN_ARG_expunge,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_sync_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_sync_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_sync_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_sync =
+{
+  {
+    -1,
+    "sync",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_sync_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_sync_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-sync"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_noop_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_noop_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_noop_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_noop =
+{
+  {
+    -1,
+    "noop",
+    NULL,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_noop_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-noop"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_can_refresh_folder_IN_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_can_refresh_folder_IN_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_can_refresh_folder_IN_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_method_info_can_refresh_folder_OUT_ARG_success =
+{
+  {
+    -1,
+    "success",
+    "b",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_method_info_can_refresh_folder_OUT_ARG_pointers[] =
+{
+  &_egdbus_store_ms_method_info_can_refresh_folder_OUT_ARG_success,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_store_ms_method_info_can_refresh_folder =
+{
+  {
+    -1,
+    "canRefreshFolder",
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_can_refresh_folder_IN_ARG_pointers,
+    (GDBusArgInfo **) &_egdbus_store_ms_method_info_can_refresh_folder_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-can-refresh-folder"
+};
+
+static const _ExtendedGDBusMethodInfo * const _egdbus_store_ms_method_info_pointers[] =
+{
+  &_egdbus_store_ms_method_info_get_folder,
+  &_egdbus_store_ms_method_info_get_folder_info,
+  &_egdbus_store_ms_method_info_get_inbox,
+  &_egdbus_store_ms_method_info_get_junk,
+  &_egdbus_store_ms_method_info_get_trash,
+  &_egdbus_store_ms_method_info_create_folder,
+  &_egdbus_store_ms_method_info_delete_folder,
+  &_egdbus_store_ms_method_info_rename_folder,
+  &_egdbus_store_ms_method_info_supports_subscriptions,
+  &_egdbus_store_ms_method_info_is_folder_subscribed,
+  &_egdbus_store_ms_method_info_subscribe_folder,
+  &_egdbus_store_ms_method_info_unsubscribe_folder,
+  &_egdbus_store_ms_method_info_sync,
+  &_egdbus_store_ms_method_info_noop,
+  &_egdbus_store_ms_method_info_can_refresh_folder,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_opened_ARG_folder =
+{
+  {
+    -1,
+    "folder",
+    "o",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_opened_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_opened_ARG_folder,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_opened =
+{
+  {
+    -1,
+    "FolderOpened",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_opened_ARG_pointers,
+    NULL
+  },
+  "folder-opened"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_created_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_created_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_created_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_created =
+{
+  {
+    -1,
+    "FolderCreated",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_created_ARG_pointers,
+    NULL
+  },
+  "folder-created"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_deleted_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_deleted_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_deleted_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_deleted =
+{
+  {
+    -1,
+    "FolderDeleted",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_deleted_ARG_pointers,
+    NULL
+  },
+  "folder-deleted"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_renamed_ARG_old_name =
+{
+  {
+    -1,
+    "old_name",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_renamed_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_renamed_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_renamed_ARG_old_name,
+  &_egdbus_store_ms_signal_info_folder_renamed_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_renamed =
+{
+  {
+    -1,
+    "FolderRenamed",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_renamed_ARG_pointers,
+    NULL
+  },
+  "folder-renamed"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_subscribed_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_subscribed_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_subscribed_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_subscribed =
+{
+  {
+    -1,
+    "FolderSubscribed",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_subscribed_ARG_pointers,
+    NULL
+  },
+  "folder-subscribed"
+};
+
+static const _ExtendedGDBusArgInfo _egdbus_store_ms_signal_info_folder_unsubscribed_ARG_info =
+{
+  {
+    -1,
+    "info",
+    "a(sssuii)",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_store_ms_signal_info_folder_unsubscribed_ARG_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_unsubscribed_ARG_info,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _egdbus_store_ms_signal_info_folder_unsubscribed =
+{
+  {
+    -1,
+    "FolderUnsubscribed",
+    (GDBusArgInfo **) &_egdbus_store_ms_signal_info_folder_unsubscribed_ARG_pointers,
+    NULL
+  },
+  "folder-unsubscribed"
+};
+
+static const _ExtendedGDBusSignalInfo * const _egdbus_store_ms_signal_info_pointers[] =
+{
+  &_egdbus_store_ms_signal_info_folder_opened,
+  &_egdbus_store_ms_signal_info_folder_created,
+  &_egdbus_store_ms_signal_info_folder_deleted,
+  &_egdbus_store_ms_signal_info_folder_renamed,
+  &_egdbus_store_ms_signal_info_folder_subscribed,
+  &_egdbus_store_ms_signal_info_folder_unsubscribed,
+  NULL
+};
+
+static const GDBusAnnotationInfo _egdbus_store_ms_annotation_info_0 =
+{
+  -1,
+  "org.freedesktop.DBus.GLib.CSymbol",
+  "EMailDataStore",
+  NULL
+};
+
+static const GDBusAnnotationInfo * const _egdbus_store_ms_annotation_info_pointers[] =
+{
+  &_egdbus_store_ms_annotation_info_0,
+  NULL
+};
+
+static const GDBusInterfaceInfo _egdbus_store_ms_interface_info =
+{
+  -1,
+  "org.gnome.evolution.dataserver.mail.Store",
+  (GDBusMethodInfo **) &_egdbus_store_ms_method_info_pointers,
+  (GDBusSignalInfo **) &_egdbus_store_ms_signal_info_pointers,
+  NULL,
+  (GDBusAnnotationInfo **) &_egdbus_store_ms_annotation_info_pointers
+};
+
+
+GDBusInterfaceInfo *
+egdbus_store_ms_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info;
+}
+
+
+
+static void
+egdbus_store_ms_default_init (EGdbusStoreMSIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  g_signal_new ("handle-get-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_get_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-get-folder-info",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_get_folder_info),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_UINT);
+
+  g_signal_new ("handle-get-inbox",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_get_inbox),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-junk",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_get_junk),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-get-trash",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_get_trash),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-create-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_create_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING);
+
+  g_signal_new ("handle-delete-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_delete_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-rename-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_rename_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    3,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING, G_TYPE_STRING);
+
+  g_signal_new ("handle-supports-subscriptions",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_supports_subscriptions),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-is-folder-subscribed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_is_folder_subscribed),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-subscribe-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_subscribe_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-unsubscribe-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_unsubscribe_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+  g_signal_new ("handle-sync",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_sync),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_BOOLEAN);
+
+  g_signal_new ("handle-noop",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_noop),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  g_signal_new ("handle-can-refresh-folder",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, handle_can_refresh_folder),
+    g_signal_accumulator_true_handled,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_VARIANT);
+
+  /* GObject signals for received D-Bus signals: */
+  g_signal_new ("folder-opened",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_opened),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_STRING);
+
+  g_signal_new ("folder-created",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_created),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_VARIANT);
+
+  g_signal_new ("folder-deleted",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_deleted),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_VARIANT);
+
+  g_signal_new ("folder-renamed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_renamed),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    2, G_TYPE_STRING, G_TYPE_VARIANT);
+
+  g_signal_new ("folder-subscribed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_subscribed),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_VARIANT);
+
+  g_signal_new ("folder-unsubscribed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusStoreMSIface, folder_unsubscribed),
+    NULL,
+    NULL,
+    _cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_VARIANT);
+
+}
+
+typedef EGdbusStoreMSIface EGdbusStoreMSInterface;
+#define egdbus_store_ms_get_type egdbus_store_ms_get_gtype
+G_DEFINE_INTERFACE (EGdbusStoreMS, egdbus_store_ms, G_TYPE_OBJECT);
+#undef egdbus_store_ms_get_type
+
+void
+egdbus_store_ms_emit_folder_opened (
+    EGdbusStoreMS *object,
+    const gchar *folder)
+{
+  g_signal_emit_by_name (object, "folder-opened", folder);
+}
+
+void
+egdbus_store_ms_emit_folder_created (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  g_signal_emit_by_name (object, "folder-created", info);
+}
+
+void
+egdbus_store_ms_emit_folder_deleted (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  g_signal_emit_by_name (object, "folder-deleted", info);
+}
+
+void
+egdbus_store_ms_emit_folder_renamed (
+    EGdbusStoreMS *object,
+    const gchar *old_name,
+    GVariant *info)
+{
+  g_signal_emit_by_name (object, "folder-renamed", old_name, info);
+}
+
+void
+egdbus_store_ms_emit_folder_subscribed (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  g_signal_emit_by_name (object, "folder-subscribed", info);
+}
+
+void
+egdbus_store_ms_emit_folder_unsubscribed (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  g_signal_emit_by_name (object, "folder-unsubscribed", info);
+}
+
+void
+egdbus_store_ms_call_get_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getFolder",
+    g_variant_new ("(s)",
+                   full_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_get_folder_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_get_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getFolder",
+    g_variant_new ("(s)",
+                   full_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_get_folder_info (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    guint flags,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getFolderInfo",
+    g_variant_new ("(su)",
+                   full_name,
+                   flags),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_get_folder_info_finish (
+    EGdbusStoreMS *proxy,
+    GVariant **out_infos,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@a(sssuii))",
+                 out_infos);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_get_folder_info_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    guint flags,
+    GVariant **out_infos,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getFolderInfo",
+    g_variant_new ("(su)",
+                   full_name,
+                   flags),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@a(sssuii))",
+                 out_infos);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_get_inbox (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getInbox",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_get_inbox_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_get_inbox_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getInbox",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_get_junk (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getJunk",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_get_junk_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_get_junk_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getJunk",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_get_trash (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getTrash",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_get_trash_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_get_trash_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getTrash",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(o)",
+                 out_folder);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_create_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *parent_name,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "createFolder",
+    g_variant_new ("(ss)",
+                   parent_name,
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_create_folder_finish (
+    EGdbusStoreMS *proxy,
+    GVariant **out_info,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@a(sssuii))",
+                 out_info);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_create_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *parent_name,
+    const gchar *folder_name,
+    GVariant **out_info,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "createFolder",
+    g_variant_new ("(ss)",
+                   parent_name,
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(@a(sssuii))",
+                 out_info);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_delete_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "deleteFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_delete_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_delete_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "deleteFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_rename_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *old_folder_name,
+    const gchar *new_folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "renameFolder",
+    g_variant_new ("(ss)",
+                   old_folder_name,
+                   new_folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_rename_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_rename_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *old_folder_name,
+    const gchar *new_folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "renameFolder",
+    g_variant_new ("(ss)",
+                   old_folder_name,
+                   new_folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_supports_subscriptions (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "supportsSubscriptions",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_supports_subscriptions_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_supports_subscriptions_sync (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "supportsSubscriptions",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_is_folder_subscribed (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "isFolderSubscribed",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_is_folder_subscribed_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_is_folder_subscribed_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "isFolderSubscribed",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_subscribe_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "subscribeFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_subscribe_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_subscribe_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "subscribeFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_unsubscribe_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "unsubscribeFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_unsubscribe_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_unsubscribe_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "unsubscribeFolder",
+    g_variant_new ("(s)",
+                   folder_name),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_sync (
+    EGdbusStoreMS *proxy,
+    gboolean expunge,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "sync",
+    g_variant_new ("(b)",
+                   expunge),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_sync_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_sync_sync (
+    EGdbusStoreMS *proxy,
+    gboolean expunge,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "sync",
+    g_variant_new ("(b)",
+                   expunge),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_noop (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "noop",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_noop_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_noop_sync (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "noop",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_call_can_refresh_folder (
+    EGdbusStoreMS *proxy,
+    GVariant *info,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "canRefreshFolder",
+    g_variant_new ("(@a(sssuii))",
+                   info),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_store_ms_call_can_refresh_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+gboolean
+egdbus_store_ms_call_can_refresh_folder_sync (
+    EGdbusStoreMS *proxy,
+    GVariant *info,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "canRefreshFolder",
+    g_variant_new ("(@a(sssuii))",
+                   info),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(b)",
+                 out_success);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+void
+egdbus_store_ms_complete_get_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   folder));
+}
+
+void
+egdbus_store_ms_complete_get_folder_info (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *infos)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(@a(sssuii))",
+                   infos));
+}
+
+void
+egdbus_store_ms_complete_get_inbox (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   folder));
+}
+
+void
+egdbus_store_ms_complete_get_junk (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   folder));
+}
+
+void
+egdbus_store_ms_complete_get_trash (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(o)",
+                   folder));
+}
+
+void
+egdbus_store_ms_complete_create_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(@a(sssuii))",
+                   info));
+}
+
+void
+egdbus_store_ms_complete_delete_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_rename_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_supports_subscriptions (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_is_folder_subscribed (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_subscribe_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_unsubscribe_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_sync (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_noop (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+void
+egdbus_store_ms_complete_can_refresh_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(b)",
+                   success));
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void
+egdbus_store_ms_proxy_iface_init (EGdbusStoreMSIface *iface)
+{
+}
+
+#define egdbus_store_ms_proxy_get_type egdbus_store_ms_proxy_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusStoreMSProxy, egdbus_store_ms_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_STORE_TYPE_MS, egdbus_store_ms_proxy_iface_init));
+#undef egdbus_store_ms_proxy_get_type
+
+static void
+egdbus_store_ms_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_store_ms_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_store_ms_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], EGDBUS_STORE_TYPE_MS);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_STORE_TYPE_MS);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+egdbus_store_ms_proxy_g_properties_changed (GDBusProxy *proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static void
+egdbus_store_ms_proxy_init (EGdbusStoreMSProxy *proxy)
+{
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), egdbus_store_ms_interface_info ());
+}
+
+static void
+egdbus_store_ms_proxy_class_init (EGdbusStoreMSProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->get_property = egdbus_store_ms_proxy_get_property;
+  gobject_class->set_property = egdbus_store_ms_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = egdbus_store_ms_proxy_g_signal;
+  proxy_class->g_properties_changed = egdbus_store_ms_proxy_g_properties_changed;
+
+}
+void
+egdbus_store_ms_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_STORE_TYPE_MS_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Store", NULL);
+}
+
+EGdbusStoreMS *
+egdbus_store_ms_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_STORE_MS (ret);
+  else
+    return NULL;
+}
+
+EGdbusStoreMS *
+egdbus_store_ms_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_STORE_TYPE_MS_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Store", NULL);
+  if (ret != NULL)
+    return EGDBUS_STORE_MS (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_store_ms_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_STORE_TYPE_MS_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Store", NULL);
+}
+
+EGdbusStoreMS *
+egdbus_store_ms_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return EGDBUS_STORE_MS (ret);
+  else
+    return NULL;
+}
+
+EGdbusStoreMS *
+egdbus_store_ms_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_STORE_TYPE_MS_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gnome.evolution.dataserver.mail.Store", NULL);
+  if (ret != NULL)
+    return EGDBUS_STORE_MS (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+struct _EGdbusStoreMSStubPrivate
+{
+  GValueArray *properties;
+  GDBusObject *object;
+  GDBusInterfaceFlags flags;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GDBusConnection *connection;
+  gchar *object_path;
+  GMainContext *context;
+};
+
+static void
+_egdbus_store_ms_stub_handle_method_call (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  GValue return_value = {0};
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_interface_info_lookup_method ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, method_name);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 2);
+  g_value_init (&paramv[0], EGDBUS_STORE_TYPE_MS);
+  g_value_set_object (&paramv[0], stub);
+  g_value_init (&paramv[1], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[1], invocation);
+  g_variant_iter_init (&iter, parameters);
+  n = 2;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - 2];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, EGDBUS_STORE_TYPE_MS);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + 2; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_egdbus_store_ms_stub_handle_get_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (stub), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_egdbus_store_ms_stub_handle_set_property (
+  GDBusConnection *connection,
+  const gchar *sender,
+  const gchar *object_path,
+  const gchar *interface_name,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (user_data);
+  GValue value = {0};
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_egdbus_store_ms_interface_info, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (stub), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _egdbus_store_ms_stub_vtable =
+{
+  _egdbus_store_ms_stub_handle_method_call,
+  _egdbus_store_ms_stub_handle_get_property,
+  _egdbus_store_ms_stub_handle_set_property
+};
+
+static GDBusInterfaceInfo *
+egdbus_store_ms_stub_dbus_interface_get_info (GDBusInterface *interface)
+{
+  return egdbus_store_ms_interface_info ();
+}
+
+static GVariant *
+egdbus_store_ms_stub_dbus_interface_get_properties (GDBusInterface *interface)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_egdbus_store_ms_interface_info.properties == NULL)
+    goto out;
+  for (n = 0; _egdbus_store_ms_interface_info.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _egdbus_store_ms_interface_info.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _egdbus_store_ms_stub_handle_get_property (stub->priv->connection, NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", info->name, NULL, stub);
+          if (value != NULL)
+            {
+              if (g_variant_is_floating (value))
+                g_variant_ref_sink (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static void
+egdbus_store_ms_stub_dbus_interface_flush (GDBusInterface *interface)
+{
+}
+
+static void
+_egdbus_store_ms_on_object_unregistered (EGdbusStoreMSStub *stub)
+{
+  stub->priv->connection = NULL;
+  g_free (stub->priv->object_path);
+  stub->priv->object_path = NULL;
+}
+
+static guint
+egdbus_store_ms_stub_dbus_interface_register_object (GDBusInterface *interface,  GDBusConnection *connection,
+  const gchar *object_path,
+  GError **error)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+  stub->priv->connection = connection;
+  stub->priv->object_path = g_strdup (object_path);
+  stub->priv->context = g_main_context_get_thread_default ();
+  if (stub->priv->context != NULL)
+    g_main_context_ref (stub->priv->context);
+  return g_dbus_connection_register_object (connection, object_path, egdbus_store_ms_interface_info (), &_egdbus_store_ms_stub_vtable, stub, (GDestroyNotify) _egdbus_store_ms_on_object_unregistered, error);
+}
+
+static GDBusObject *
+egdbus_store_ms_stub_dbus_interface_get_object (GDBusInterface *interface)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+  return stub->priv->object != NULL ? g_object_ref (stub->priv->object) : NULL;
+}
+
+static void
+egdbus_store_ms_stub_dbus_interface_set_object (GDBusInterface *interface,  GDBusObject *object)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+  stub->priv->object = object;
+}
+
+static GDBusInterfaceFlags
+egdbus_store_ms_stub_dbus_interface_get_flags (GDBusInterface *interface)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+  return stub->priv->flags;
+}
+
+static void
+egdbus_store_ms_stub_dbus_interface_set_flags (GDBusInterface *interface,  GDBusInterfaceFlags flags)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (interface);
+  stub->priv->flags = flags;
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_opened (
+    EGdbusStoreMS *object,
+    const gchar *folder)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderOpened",
+    g_variant_new ("(o)",
+                   folder), NULL);
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_created (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderCreated",
+    g_variant_new ("(@a(sssuii))",
+                   info), NULL);
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_deleted (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderDeleted",
+    g_variant_new ("(@a(sssuii))",
+                   info), NULL);
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_renamed (
+    EGdbusStoreMS *object,
+    const gchar *old_name,
+    GVariant *info)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderRenamed",
+    g_variant_new ("(s a(sssuii))",
+                   old_name,
+                   info), NULL);
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_subscribed (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderSubscribed",
+    g_variant_new ("(@a(sssuii))",
+                   info), NULL);
+}
+
+static void
+_egdbus_store_ms_on_signal_folder_unsubscribed (
+    EGdbusStoreMS *object,
+    GVariant *info)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  if (stub->priv->connection == NULL)
+    return;
+  g_dbus_connection_emit_signal (stub->priv->connection,
+    NULL, stub->priv->object_path, "org.gnome.evolution.dataserver.mail.Store", "FolderUnsubscribed",
+    g_variant_new ("(@a(sssuii))",
+                   info), NULL);
+}
+
+static void
+egdbus_store_ms_stub_iface_init (EGdbusStoreMSIface *iface)
+{
+  iface->folder_opened = _egdbus_store_ms_on_signal_folder_opened;
+  iface->folder_created = _egdbus_store_ms_on_signal_folder_created;
+  iface->folder_deleted = _egdbus_store_ms_on_signal_folder_deleted;
+  iface->folder_renamed = _egdbus_store_ms_on_signal_folder_renamed;
+  iface->folder_subscribed = _egdbus_store_ms_on_signal_folder_subscribed;
+  iface->folder_unsubscribed = _egdbus_store_ms_on_signal_folder_unsubscribed;
+}
+
+static void
+egdbus_store_ms_stub_dbus_iface_init (GDBusInterfaceIface *iface)
+{
+  iface->get_info = egdbus_store_ms_stub_dbus_interface_get_info;
+  iface->get_properties = egdbus_store_ms_stub_dbus_interface_get_properties;
+  iface->flush = egdbus_store_ms_stub_dbus_interface_flush;
+  iface->register_object = egdbus_store_ms_stub_dbus_interface_register_object;
+  iface->get_object = egdbus_store_ms_stub_dbus_interface_get_object;
+  iface->set_object = egdbus_store_ms_stub_dbus_interface_set_object;
+  iface->get_flags = egdbus_store_ms_stub_dbus_interface_get_flags;
+  iface->set_flags = egdbus_store_ms_stub_dbus_interface_set_flags;
+}
+
+#define egdbus_store_ms_stub_get_type egdbus_store_ms_stub_get_gtype
+G_DEFINE_TYPE_WITH_CODE (EGdbusStoreMSStub, egdbus_store_ms_stub, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EGDBUS_STORE_TYPE_MS, egdbus_store_ms_stub_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_INTERFACE, egdbus_store_ms_stub_dbus_iface_init));
+#undef egdbus_store_ms_stub_get_type
+
+static void
+egdbus_store_ms_stub_finalize (GObject *object)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  g_list_foreach (stub->priv->changed_properties, (GFunc) _changed_property_free, NULL);
+  g_list_free (stub->priv->changed_properties);
+  if (stub->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (stub->priv->changed_properties_idle_source);
+  if (stub->priv->context != NULL)
+    g_main_context_unref (stub->priv->context);
+  G_OBJECT_CLASS (egdbus_store_ms_stub_parent_class)->finalize (object);
+}
+
+static void
+egdbus_store_ms_stub_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  EGdbusStoreMSStub *stub = EGDBUS_STORE_MS_STUB (object);
+  g_assert (prop_id - 1 >= 0 && prop_id - 1 < 0);
+  g_value_copy (&stub->priv->properties->values[prop_id - 1], value);
+}
+
+static void
+egdbus_store_ms_stub_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+}
+
+static void
+egdbus_store_ms_stub_init (EGdbusStoreMSStub *stub)
+{
+  stub->priv = G_TYPE_INSTANCE_GET_PRIVATE (stub, EGDBUS_STORE_TYPE_MS_STUB, EGdbusStoreMSStubPrivate);
+}
+
+static void
+egdbus_store_ms_stub_class_init (EGdbusStoreMSStubClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  g_type_class_add_private (klass, sizeof (EGdbusStoreMSStubPrivate));
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = egdbus_store_ms_stub_finalize;
+  gobject_class->get_property = egdbus_store_ms_stub_get_property;
+  gobject_class->set_property = egdbus_store_ms_stub_set_property;
+
+}
+
+EGdbusStoreMS *
+egdbus_store_ms_stub_new (void)
+{
+  return EGDBUS_STORE_MS (g_object_new (EGDBUS_STORE_TYPE_MS_STUB, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for proxy manager
+ * ------------------------------------------------------------------------
+ */
+
+/* ------------------------------------------------------------------------ */
+
+#define egdbus_store_proxy_manager_get_type egdbus_store_proxy_manager_get_gtype
+G_DEFINE_TYPE (EGdbusStoreProxyManager, egdbus_store_proxy_manager, G_TYPE_DBUS_PROXY_MANAGER);
+#undef egdbus_store_proxy_manager_get_type
+
+static void
+egdbus_store_proxy_manager_init (EGdbusStoreProxyManager *manager)
+{
+}
+
+static void
+egdbus_store_proxy_manager_class_init (EGdbusStoreProxyManagerClass *klass)
+{
+}
+
+static GType
+_egdbus_store_proxy_manager_get_proxy_type_func (GDBusProxyManager *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data)
+{
+  GType ret;
+  ret = G_TYPE_DBUS_PROXY;
+  if (FALSE)
+    ;
+  else if (g_strcmp0 (interface_name, "org.gnome.evolution.dataserver.mail.Store") == 0)
+    ret = EGDBUS_STORE_TYPE_MS_PROXY;
+  return ret;
+}
+
+GDBusProxyTypeFunc
+egdbus_store_proxy_manager_get_proxy_type_func (void)
+{
+  return _egdbus_store_proxy_manager_get_proxy_type_func;
+}
+
+void
+egdbus_store_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_STORE_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_store_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_store_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_store_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_STORE_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", _egdbus_store_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
+void
+egdbus_store_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (EGDBUS_STORE_TYPE_PROXY_MANAGER, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_store_proxy_manager_get_proxy_type_func, NULL);
+}
+
+GDBusProxyManager *
+egdbus_store_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+GDBusProxyManager *
+egdbus_store_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (EGDBUS_STORE_TYPE_PROXY_MANAGER, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", _egdbus_store_proxy_manager_get_proxy_type_func, NULL);
+  if (ret != NULL)
+    return G_DBUS_PROXY_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
diff --git a/mail/libegdbus/e-gdbus-emailstore.h b/mail/libegdbus/e-gdbus-emailstore.h
new file mode 100644
index 0000000..f864ccd
--- /dev/null
+++ b/mail/libegdbus/e-gdbus-emailstore.h
@@ -0,0 +1,714 @@
+/*
+ * Generated by gdbus-codegen.py 0.1. DO NOT EDIT.
+ */
+
+#ifndef __E_GDBUS_EMAILSTORE_H__
+#define __E_GDBUS_EMAILSTORE_H__
+
+#include <gio/gio.h>
+#include <gdbusinterface.h>
+#include <gdbusobjectproxy.h>
+#include <gdbusproxymanager.h>
+#include <gdbusobject.h>
+#include <gdbusobjectmanager.h>
+#include <gdbuscodegen-enumtypes.h>
+
+G_BEGIN_DECLS
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.gnome.evolution.dataserver.mail.Store */
+
+#define EGDBUS_STORE_TYPE_MS (egdbus_store_ms_get_gtype ())
+#define EGDBUS_STORE_MS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_STORE_TYPE_MS, EGdbusStoreMS))
+#define EGDBUS_STORE_IS_MS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_STORE_TYPE_MS))
+#define EGDBUS_STORE_MS_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EGDBUS_STORE_TYPE_MS, EGdbusStoreMS))
+
+struct _EGdbusStoreMS;
+typedef struct _EGdbusStoreMS EGdbusStoreMS;
+typedef struct _EGdbusStoreMSIface EGdbusStoreMSIface;
+
+struct _EGdbusStoreMSIface
+{
+  GTypeInterface parent_iface;
+
+  /* GObject signal class handlers for incoming D-Bus method calls: */
+  gboolean (*handle_get_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *full_name);
+
+  gboolean (*handle_get_folder_info) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *full_name,
+    guint flags);
+
+  gboolean (*handle_get_inbox) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_junk) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_trash) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_create_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *parent_name,
+    const gchar *folder_name);
+
+  gboolean (*handle_delete_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder_name);
+
+  gboolean (*handle_rename_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *old_folder_name,
+    const gchar *new_folder_name);
+
+  gboolean (*handle_supports_subscriptions) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_is_folder_subscribed) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder_name);
+
+  gboolean (*handle_subscribe_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder_name);
+
+  gboolean (*handle_unsubscribe_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder_name);
+
+  gboolean (*handle_sync) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean expunge);
+
+  gboolean (*handle_noop) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_can_refresh_folder) (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info);
+
+
+  /* GObject signal class handlers for received D-Bus signals: */
+  void (*folder_opened) (
+    EGdbusStoreMS *object,
+    const gchar *folder);
+
+  void (*folder_created) (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+  void (*folder_deleted) (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+  void (*folder_renamed) (
+    EGdbusStoreMS *object,
+    const gchar *old_name,
+    GVariant *info);
+
+  void (*folder_subscribed) (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+  void (*folder_unsubscribed) (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+};
+
+GType egdbus_store_ms_get_gtype (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *egdbus_store_ms_interface_info (void);
+
+
+/* D-Bus method call completion functions: */
+void egdbus_store_ms_complete_get_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder);
+
+void egdbus_store_ms_complete_get_folder_info (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *infos);
+
+void egdbus_store_ms_complete_get_inbox (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder);
+
+void egdbus_store_ms_complete_get_junk (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder);
+
+void egdbus_store_ms_complete_get_trash (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *folder);
+
+void egdbus_store_ms_complete_create_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    GVariant *info);
+
+void egdbus_store_ms_complete_delete_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_rename_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_supports_subscriptions (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_is_folder_subscribed (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_subscribe_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_unsubscribe_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_sync (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_noop (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+void egdbus_store_ms_complete_can_refresh_folder (
+    EGdbusStoreMS *object,
+    GDBusMethodInvocation *invocation,
+    gboolean success);
+
+
+
+/* D-Bus signal emissions functions: */
+void egdbus_store_ms_emit_folder_opened (
+    EGdbusStoreMS *object,
+    const gchar *folder);
+
+void egdbus_store_ms_emit_folder_created (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+void egdbus_store_ms_emit_folder_deleted (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+void egdbus_store_ms_emit_folder_renamed (
+    EGdbusStoreMS *object,
+    const gchar *old_name,
+    GVariant *info);
+
+void egdbus_store_ms_emit_folder_subscribed (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+void egdbus_store_ms_emit_folder_unsubscribed (
+    EGdbusStoreMS *object,
+    GVariant *info);
+
+
+
+/* D-Bus method calls: */
+void egdbus_store_ms_call_get_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_get_folder_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_get_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_get_folder_info (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    guint flags,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_get_folder_info_finish (
+    EGdbusStoreMS *proxy,
+    GVariant **out_infos,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_get_folder_info_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *full_name,
+    guint flags,
+    GVariant **out_infos,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_get_inbox (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_get_inbox_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_get_inbox_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_get_junk (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_get_junk_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_get_junk_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_get_trash (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_get_trash_finish (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_get_trash_sync (
+    EGdbusStoreMS *proxy,
+    gchar **out_folder,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_create_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *parent_name,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_create_folder_finish (
+    EGdbusStoreMS *proxy,
+    GVariant **out_info,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_create_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *parent_name,
+    const gchar *folder_name,
+    GVariant **out_info,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_delete_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_delete_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_delete_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_rename_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *old_folder_name,
+    const gchar *new_folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_rename_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_rename_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *old_folder_name,
+    const gchar *new_folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_supports_subscriptions (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_supports_subscriptions_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_supports_subscriptions_sync (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_is_folder_subscribed (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_is_folder_subscribed_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_is_folder_subscribed_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_subscribe_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_subscribe_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_subscribe_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_unsubscribe_folder (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_unsubscribe_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_unsubscribe_folder_sync (
+    EGdbusStoreMS *proxy,
+    const gchar *folder_name,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_sync (
+    EGdbusStoreMS *proxy,
+    gboolean expunge,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_sync_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_sync_sync (
+    EGdbusStoreMS *proxy,
+    gboolean expunge,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_noop (
+    EGdbusStoreMS *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_noop_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_noop_sync (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+void egdbus_store_ms_call_can_refresh_folder (
+    EGdbusStoreMS *proxy,
+    GVariant *info,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_store_ms_call_can_refresh_folder_finish (
+    EGdbusStoreMS *proxy,
+    gboolean *out_success,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_store_ms_call_can_refresh_folder_sync (
+    EGdbusStoreMS *proxy,
+    GVariant *info,
+    gboolean *out_success,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* ---- */
+
+#define EGDBUS_STORE_TYPE_MS_PROXY (egdbus_store_ms_proxy_get_gtype ())
+#define EGDBUS_STORE_MS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_STORE_TYPE_MS_PROXY, EGdbusStoreMSProxy))
+#define EGDBUS_STORE_MS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_STORE_TYPE_MS_PROXY, EGdbusStoreMSProxyClass))
+#define EGDBUS_STORE_MS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_STORE_TYPE_MS_PROXY, EGdbusStoreMSProxyClass))
+#define EGDBUS_STORE_IS_MS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_STORE_TYPE_MS_PROXY))
+#define EGDBUS_STORE_IS_MS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_STORE_TYPE_MS_PROXY))
+
+typedef struct _EGdbusStoreMSProxy EGdbusStoreMSProxy;
+typedef struct _EGdbusStoreMSProxyClass EGdbusStoreMSProxyClass;
+typedef struct _EGdbusStoreMSProxyPrivate EGdbusStoreMSProxyPrivate;
+
+struct _EGdbusStoreMSProxy
+{
+  GDBusProxy parent_instance;
+  EGdbusStoreMSProxyPrivate *priv;
+};
+
+struct _EGdbusStoreMSProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType egdbus_store_ms_proxy_get_gtype (void) G_GNUC_CONST;
+
+void egdbus_store_ms_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusStoreMS *egdbus_store_ms_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusStoreMS *egdbus_store_ms_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_store_ms_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+EGdbusStoreMS *egdbus_store_ms_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+EGdbusStoreMS *egdbus_store_ms_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+#define EGDBUS_STORE_GET_MS(object_proxy) (g_dbus_object_proxy_lookup_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Store", EGDBUS_STORE_TYPE_MS))
+#define EGDBUS_STORE_PEEK_MS(object_proxy) (g_dbus_object_proxy_peek_with_typecheck (object_proxy, "org.gnome.evolution.dataserver.mail.Store", EGDBUS_STORE_TYPE_MS))
+
+
+/* ---- */
+
+#define EGDBUS_STORE_TYPE_MS_STUB (egdbus_store_ms_stub_get_gtype ())
+#define EGDBUS_STORE_MS_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_STORE_TYPE_MS_STUB, EGdbusStoreMSStub))
+#define EGDBUS_STORE_MS_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_STORE_TYPE_MS_STUB, EGdbusStoreMSStubClass))
+#define EGDBUS_STORE_MS_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_STORE_TYPE_MS_STUB, EGdbusStoreMSStubClass))
+#define EGDBUS_STORE_IS_MS_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_STORE_TYPE_MS_STUB))
+#define EGDBUS_STORE_IS_MS_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_STORE_TYPE_MS_STUB))
+
+typedef struct _EGdbusStoreMSStub EGdbusStoreMSStub;
+typedef struct _EGdbusStoreMSStubClass EGdbusStoreMSStubClass;
+typedef struct _EGdbusStoreMSStubPrivate EGdbusStoreMSStubPrivate;
+
+struct _EGdbusStoreMSStub
+{
+  GObject parent_instance;
+  EGdbusStoreMSStubPrivate *priv;
+};
+
+struct _EGdbusStoreMSStubClass
+{
+  GObjectClass parent_class;
+};
+
+GType egdbus_store_ms_stub_get_gtype (void) G_GNUC_CONST;
+
+EGdbusStoreMS *egdbus_store_ms_stub_new (void);
+
+
+/* ---- */
+
+#define EGDBUS_STORE_TYPE_PROXY_MANAGER (egdbus_store_proxy_manager_get_gtype ())
+#define EGDBUS_STORE_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGDBUS_STORE_TYPE_PROXY_MANAGER, EGdbusStoreProxyManager))
+#define EGDBUS_STORE_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EGDBUS_STORE_TYPE_PROXY_MANAGER, EGdbusStoreProxyManagerClass))
+#define EGDBUS_STORE_PROXY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGDBUS_STORE_TYPE_PROXY_MANAGER, EGdbusStoreProxyManagerClass))
+#define EGDBUS_STORE_IS_PROXY_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGDBUS_STORE_TYPE_PROXY_MANAGER))
+#define EGDBUS_STORE_IS_PROXY_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGDBUS_STORE_TYPE_PROXY_MANAGER))
+
+typedef struct _EGdbusStoreProxyManager EGdbusStoreProxyManager;
+typedef struct _EGdbusStoreProxyManagerClass EGdbusStoreProxyManagerClass;
+typedef struct _EGdbusStoreProxyManagerPrivate EGdbusStoreProxyManagerPrivate;
+
+struct _EGdbusStoreProxyManager
+{
+  GDBusProxyManager parent_instance;
+  EGdbusStoreProxyManagerPrivate *priv;
+};
+
+struct _EGdbusStoreProxyManagerClass
+{
+  GDBusProxyManagerClass parent_class;
+};
+
+GType egdbus_store_proxy_manager_get_gtype (void) G_GNUC_CONST;
+
+GDBusProxyTypeFunc egdbus_store_proxy_manager_get_proxy_type_func (void);
+
+void egdbus_store_proxy_manager_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_store_proxy_manager_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_store_proxy_manager_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void egdbus_store_proxy_manager_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+GDBusProxyManager *egdbus_store_proxy_manager_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusProxyManager *egdbus_store_proxy_manager_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+G_END_DECLS
+
+#endif /* __E_GDBUS_EMAILSTORE_H__ */
diff --git a/mail/libemailutils/Makefile.am b/mail/libemailutils/Makefile.am
new file mode 100644
index 0000000..b329971
--- /dev/null
+++ b/mail/libemailutils/Makefile.am
@@ -0,0 +1,49 @@
+
+lib_LTLIBRARIES = libemail-utils.la
+
+AM_CFLAGS = @E_MAIL_FACTORY_CFLAGS@ -Wall -Werror -g3 -O0 -ggdb -DPKGDATADIR="\"$(pkgdatadir)\""
+AM_LDFLAGS = @E_MAIL_FACTORY_LIBS@ 
+
+
+MARSHAL_GENERATED = e-marshal.c e-marshal.h
+ EVO_MARSHAL_RULE@
+
+libemail_utils_la_CPPFLAGS = \
+	$(AM_CPPFLAGS)	\
+	$(E_MAIL_UTILS_CFLAGS)	\
+	$(CAMEL_CFLAGS)		\
+	$(GNOME_PLATFORM_CFLAGS)
+
+libemail_utils_la_LIBADD = 	\
+		$(E_MAIL_UTILS_LIBS)	\
+		$(CAMEL_LIBS)		\
+		$(GNOME_PLATFORM_LIBS)	\
+		$(top_builddir)/camel/libcamel-1.2.la			\
+		$(top_builddir)/camel/libcamel-provider-1.2.la			\
+		$(top_builddir)/libedataserver/libedataserver-1.2.la
+
+libemail_utils_la_LDFLAGS = 
+
+libemail_utils_la_SOURCES = 	\
+		mail-mt.c	\
+		e-marshal.c	\
+		e-account-utils.c
+
+libmailutilsincludedir = $(includedir)/libemail-utils
+libmailutilsinclude_HEADERS = 	\
+		mail-mt.h	\
+		e-marshal.h	\
+		e-account-utils.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libemail-utils.pc
+
+BUILT_SOURCES = $(MARSHAL_GENERATED) 
+
+EXTRA_DIST = e-marshal.list
+CLEANFILES    = $(BUILT_SOURCES)
+DISTCLEANFILES = $(pkgconfig_DATA)
+
+dist-hook:
+	cd $(distdir); rm -f $(BUILT_SOURCES)
+
diff --git a/mail/libemailutils/e-account-utils.c b/mail/libemailutils/e-account-utils.c
new file mode 100644
index 0000000..6624240
--- /dev/null
+++ b/mail/libemailutils/e-account-utils.c
@@ -0,0 +1,181 @@
+/*
+ * 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/>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ */
+
+/**
+ * SECTION: e-account-utils
+ * @include: e-util/e-account-utils.h
+ **/
+
+#include "e-account-utils.h"
+
+#include <gconf/gconf-client.h>
+
+static EAccountList *global_account_list;
+
+/**
+ * e_get_account_list:
+ *
+ * Returns the global #EAccountList.
+ *
+ * Returns: the global #EAccountList
+ **/
+EAccountList *
+e_get_account_list (void)
+{
+	if (G_UNLIKELY (global_account_list == NULL)) {
+		GConfClient *client;
+
+		client = gconf_client_get_default ();
+		global_account_list = e_account_list_new (client);
+		g_object_unref (client);
+	}
+
+	g_return_val_if_fail (global_account_list != NULL, NULL);
+
+	return global_account_list;
+}
+
+/**
+ * e_get_default_account:
+ *
+ * Returns the #EAccount marked as the default mail account.
+ *
+ * Returns: the default #EAccount
+ **/
+EAccount *
+e_get_default_account (void)
+{
+	EAccountList *account_list;
+	const EAccount *account;
+
+	account_list = e_get_account_list ();
+	account = e_account_list_get_default (account_list);
+
+	/* XXX EAccountList misuses const. */
+	return (EAccount *) account;
+}
+
+/**
+ * e_set_default_account:
+ * @account: an #EAccount
+ *
+ * Marks @account as the default mail account.
+ **/
+void
+e_set_default_account (EAccount *account)
+{
+	EAccountList *account_list;
+
+	g_return_if_fail (E_IS_ACCOUNT (account));
+
+	account_list = e_get_account_list ();
+	e_account_list_set_default (account_list, account);
+}
+
+/**
+ * e_get_account_by_name:
+ * @name: a mail account name
+ *
+ * Returns the #EAccount with the given name, or %NULL if no such
+ * account exists.
+ *
+ * Returns: an #EAccount having the given account name, or %NULL
+ **/
+EAccount *
+e_get_account_by_name (const gchar *name)
+{
+	EAccountList *account_list;
+	const EAccount *account;
+	e_account_find_t find;
+
+	g_return_val_if_fail (name != NULL, NULL);
+
+	find = E_ACCOUNT_FIND_NAME;
+	account_list = e_get_account_list ();
+	account = e_account_list_find (account_list, find, name);
+
+	/* XXX EAccountList misuses const. */
+	return (EAccount *) account;
+}
+
+/**
+ * e_get_account_by_uid:
+ * @uid: a mail account UID
+ *
+ * Returns the #EAccount with the given unique ID, or %NULL if no such
+ * account exists.
+ *
+ * Returns: an #EAccount having the given unique ID, or %NULL
+ **/
+EAccount *
+e_get_account_by_uid (const gchar *uid)
+{
+	EAccountList *account_list;
+	const EAccount *account;
+	e_account_find_t find;
+
+	g_return_val_if_fail (uid != NULL, NULL);
+
+	find = E_ACCOUNT_FIND_UID;
+	account_list = e_get_account_list ();
+	account = e_account_list_find (account_list, find, uid);
+
+	/* XXX EAccountList misuses const. */
+	return (EAccount *) account;
+}
+
+/**
+ * e_get_any_enabled_account:
+ *
+ * Returns the default mail account if it's enabled, otherwise the first
+ * enabled mail account in the global #EAccountList, or finally %NULL if
+ * all mail accounts are disabled or none exist.
+ *
+ * Returns: an enabled #EAccount, or %NULL if there are none
+ **/
+EAccount *
+e_get_any_enabled_account (void)
+{
+	EAccount *account;
+	EAccountList *account_list;
+	EIterator *iter;
+
+	account = e_get_default_account ();
+	if (account != NULL && account->enabled)
+		return account;
+
+	account = NULL;
+
+	account_list = e_get_account_list ();
+	iter = e_list_get_iterator (E_LIST (account_list));
+
+	while (e_iterator_is_valid (iter) && account == NULL) {
+		EAccount *candidate;
+
+		/* XXX EIterator misuses const. */
+		candidate = (EAccount *) e_iterator_get (iter);
+
+		if (candidate->enabled)
+			account = candidate;
+		else
+			e_iterator_next (iter);
+	}
+
+	g_object_unref (iter);
+
+	return account;
+}
diff --git a/mail/libemailutils/e-account-utils.h b/mail/libemailutils/e-account-utils.h
new file mode 100644
index 0000000..f8c5c96
--- /dev/null
+++ b/mail/libemailutils/e-account-utils.h
@@ -0,0 +1,36 @@
+/*
+ * 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/>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ */
+
+#ifndef E_ACCOUNT_UTILS_H
+#define E_ACCOUNT_UTILS_H
+
+#include <glib.h>
+#include <libedataserver/e-account.h>
+#include <libedataserver/e-account-list.h>
+
+G_BEGIN_DECLS
+
+EAccountList *	e_get_account_list		(void);
+EAccount *	e_get_default_account		(void);
+void		e_set_default_account		(EAccount *account);
+EAccount *	e_get_account_by_name		(const gchar *name);
+EAccount *	e_get_account_by_uid		(const gchar *uid);
+EAccount *	e_get_any_enabled_account	(void);
+
+G_END_DECLS
+
+#endif /* E_ACCOUNT_UTILS_H */
diff --git a/mail/libemailutils/e-marshal.list b/mail/libemailutils/e-marshal.list
new file mode 100644
index 0000000..9cc975f
--- /dev/null
+++ b/mail/libemailutils/e-marshal.list
@@ -0,0 +1,57 @@
+BOOLEAN:BOXED
+BOOLEAN:BOXED,STRING
+BOOLEAN:BOXED,POINTER,POINTER
+BOOLEAN:INT,INT,BOXED
+BOOLEAN:INT,INT,OBJECT,INT,INT,UINT
+BOOLEAN:INT,POINTER,INT,BOXED
+BOOLEAN:INT,POINTER,INT,OBJECT,INT,INT,UINT
+BOOLEAN:NONE
+BOOLEAN:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+BOOLEAN:POINTER
+BOOLEAN:POINTER,BOOLEAN,POINTER
+BOOLEAN:POINTER,POINTER
+BOOLEAN:POINTER,POINTER,POINTER,POINTER
+BOOLEAN:STRING
+BOOLEAN:STRING,INT
+DOUBLE:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+INT:BOXED
+INT:INT
+INT:INT,INT,BOXED
+INT:INT,POINTER,INT,BOXED
+INT:OBJECT,BOXED
+INT:POINTER
+NONE:INT,INT
+NONE:INT,INT,BOXED
+NONE:INT,INT,OBJECT
+NONE:INT,INT,OBJECT,BOXED,UINT,UINT
+NONE:INT,INT,OBJECT,INT,INT,BOXED,UINT,UINT
+NONE:INT,INT,OBJECT,UINT
+NONE:INT,OBJECT
+NONE:INT,POINTER
+NONE:INT,POINTER,INT,BOXED
+NONE:INT,POINTER,INT,OBJECT
+NONE:INT,POINTER,INT,OBJECT,BOXED,UINT,UINT
+NONE:INT,POINTER,INT,OBJECT,INT,INT,BOXED,UINT,UINT
+NONE:INT,POINTER,INT,OBJECT,UINT
+NONE:INT,STRING,INT
+NONE:LONG,LONG
+NONE:OBJECT,BOOLEAN
+NONE:OBJECT,DOUBLE,DOUBLE,BOOLEAN
+NONE:OBJECT,OBJECT
+NONE:OBJECT,STRING
+NONE:OBJECT,STRING,INT
+NONE:OBJECT,STRING,STRING
+NONE:OBJECT,STRING,STRING,INT,STRING,STRING,STRING
+NONE:POINTER,INT
+NONE:POINTER,INT,INT,INT,INT
+NONE:POINTER,INT,OBJECT
+NONE:POINTER,OBJECT
+NONE:POINTER,POINTER
+NONE:POINTER,POINTER,INT
+NONE:STRING,DOUBLE
+NONE:STRING,INT,INT
+NONE:STRING,POINTER,POINTER
+NONE:STRING,STRING
+NONE:STRING,STRING,UINT
+NONE:UINT,STRING
+STRING:NONE
diff --git a/mail/libemailutils/libemail-utils.pc.in b/mail/libemailutils/libemail-utils.pc.in
new file mode 100644
index 0000000..384147b
--- /dev/null
+++ b/mail/libemailutils/libemail-utils.pc.in
@@ -0,0 +1,15 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+datarootdir= datarootdir@
+datadir= datadir@
+
+privincludedir= privincludedir@
+
+Name: libemail-utils
+Description: Client library for evolution mail
+Version: @VERSION@
+Requires: camel-1.2 libedataserver-1.2 gio-2.0
+Libs: -L${libdir} -lemail-utils
+Cflags: -I${privincludedir}
diff --git a/mail/libemailutils/mail-mt.c b/mail/libemailutils/mail-mt.c
new file mode 100644
index 0000000..1fda93c
--- /dev/null
+++ b/mail/libemailutils/mail-mt.c
@@ -0,0 +1,889 @@
+/*
+ * 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/>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <libedataserver/e-flag.h>
+
+#include "mail-mt.h"
+
+/*#define MALLOC_CHECK*/
+#define d(x)
+
+static void mail_operation_status		(CamelOperation *op,
+						 const gchar *what,
+						 gint pc,
+						 gpointer data);
+
+/* background operation status stuff */
+struct _MailMsgPrivate {
+	gint activity_state;
+	gboolean cancelable;
+};
+
+static guint mail_msg_seq; /* sequence number of each message */
+
+/* Table of active messages.  Must hold mail_msg_lock to access. */
+static GHashTable *mail_msg_active_table;
+static GMutex *mail_msg_lock;
+static GCond *mail_msg_cond;
+
+MailAsyncEvent *mail_async_event;
+
+gpointer
+mail_msg_new (MailMsgInfo *info)
+{
+	MailMsg *msg;
+
+	g_mutex_lock (mail_msg_lock);
+
+	msg = g_slice_alloc0 (info->size);
+	msg->info = info;
+	msg->ref_count = 1;
+	msg->seq = mail_msg_seq++;
+	msg->cancel = camel_operation_new(mail_operation_status, GINT_TO_POINTER(msg->seq));
+	msg->priv = g_slice_new0 (MailMsgPrivate);
+	msg->priv->cancelable = TRUE;
+
+	g_hash_table_insert(mail_msg_active_table, GINT_TO_POINTER(msg->seq), msg);
+
+	d(printf("New message %p\n", msg));
+
+	g_mutex_unlock (mail_msg_lock);
+
+	return msg;
+}
+
+static void
+end_event_callback (CamelObject *o, gpointer data, char *error)
+{
+	if (error != NULL) {
+		g_warning("Event with %p ended with %s\n", o, error);
+		g_free (error);
+	}
+}
+
+#ifdef MALLOC_CHECK
+#include <mcheck.h>
+
+static void
+checkmem(gpointer p)
+{
+	if (p) {
+		gint status = mprobe(p);
+
+		switch (status) {
+		case MCHECK_HEAD:
+			printf("Memory underrun at %p\n", p);
+			abort();
+		case MCHECK_TAIL:
+			printf("Memory overrun at %p\n", p);
+			abort();
+		case MCHECK_FREE:
+			printf("Double free %p\n", p);
+			abort();
+		}
+	}
+}
+#endif
+
+static void
+mail_msg_free (MailMsg *mail_msg)
+{
+	if (mail_msg->cancel != NULL) {
+		camel_operation_mute (mail_msg->cancel);
+		camel_operation_unref (mail_msg->cancel);
+	}
+
+	if (mail_msg->error != NULL)
+		g_error_free (mail_msg->error);
+
+	g_slice_free (MailMsgPrivate, mail_msg->priv);
+	g_slice_free1 (mail_msg->info->size, mail_msg);
+}
+
+gpointer
+mail_msg_ref (gpointer msg)
+{
+	MailMsg *mail_msg = msg;
+
+	g_return_val_if_fail (mail_msg != NULL, msg);
+	g_return_val_if_fail (mail_msg->ref_count > 0, msg);
+
+	g_atomic_int_add (&mail_msg->ref_count, 1);
+	return msg;
+}
+
+void
+mail_msg_unref (gpointer msg)
+{
+	MailMsg *mail_msg = msg;
+	char *error = NULL;
+	g_return_if_fail (mail_msg != NULL);
+	g_return_if_fail (mail_msg->ref_count > 0);
+
+	if (g_atomic_int_exchange_and_add (&mail_msg->ref_count, -1) > 1)
+		return;
+
+#ifdef MALLOC_CHECK
+	checkmem(mail_msg);
+	checkmem(mail_msg->cancel);
+	checkmem(mail_msg->priv);
+#endif
+	d(printf("Free message %p\n", msg));
+
+	if (mail_msg->info->free)
+		mail_msg->info->free(mail_msg);
+
+	g_mutex_lock (mail_msg_lock);
+
+	g_hash_table_remove (
+		mail_msg_active_table, GINT_TO_POINTER (mail_msg->seq));
+	g_cond_broadcast (mail_msg_cond);
+
+	/* We need to make sure we dont lose a reference here YUCK YUCK */
+	/* This is tightly integrated with the code in do_op_status,
+	   as it closely relates to the CamelOperation setup in msg_new() above */
+	if (mail_msg->priv->activity_state == 1) {
+		/* tell the other to free it itself */
+		mail_msg->priv->activity_state = 3;
+		g_mutex_unlock (mail_msg_lock);
+		return;
+	} else {
+	    if (mail_msg->error != NULL
+	    && !g_error_matches (mail_msg->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)
+	    && !g_error_matches (mail_msg->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID)) {
+		
+		error = g_strdup(mail_msg->error->message);
+	    }
+	}
+
+	g_mutex_unlock (mail_msg_lock);
+
+	mail_msg_free (mail_msg);
+
+	if (error && *error) {
+		mail_async_event_emit (
+			mail_async_event, MAIL_ASYNC_GUI,
+			(MailAsyncFunc) end_event_callback,
+			NULL, NULL/* activity */, error);
+	}
+}
+
+void
+mail_msg_check_error (gpointer msg)
+{
+	MailMsg *m = msg;
+
+#ifdef MALLOC_CHECK
+	checkmem(m);
+	checkmem(m->cancel);
+	checkmem(m->priv);
+#endif
+
+	if (m->error == NULL
+	    || g_error_matches (m->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)
+	    || g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID)
+	    || (m->cancel && camel_operation_cancel_check (m->cancel)))
+		return;
+
+	/*FIXME: Have a error propogation logic */
+}
+
+void mail_msg_cancel(guint msgid)
+{
+	MailMsg *m;
+
+	g_mutex_lock (mail_msg_lock);
+
+	m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
+
+	if (m && m->cancel)
+		camel_operation_cancel(m->cancel);
+
+	g_mutex_unlock (mail_msg_lock);
+}
+
+/* waits for a message to be finished processing (freed)
+   the messageid is from MailMsg->seq */
+void mail_msg_wait(guint msgid)
+{
+	MailMsg *m;
+
+	if (mail_in_main_thread ()) {
+		g_mutex_lock (mail_msg_lock);
+		m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
+		while (m) {
+			g_mutex_unlock (mail_msg_lock);
+			gtk_main_iteration();
+			g_mutex_lock (mail_msg_lock);
+			m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
+		}
+		g_mutex_unlock (mail_msg_lock);
+	} else {
+		g_mutex_lock (mail_msg_lock);
+		m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
+		while (m) {
+			g_cond_wait (mail_msg_cond, mail_msg_lock);
+			m = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid));
+		}
+		g_mutex_unlock (mail_msg_lock);
+	}
+}
+
+gint mail_msg_active(guint msgid)
+{
+	gint active;
+
+	g_mutex_lock (mail_msg_lock);
+	if (msgid == (guint)-1)
+		active = g_hash_table_size(mail_msg_active_table) > 0;
+	else
+		active = g_hash_table_lookup(mail_msg_active_table, GINT_TO_POINTER(msgid)) != NULL;
+	g_mutex_unlock (mail_msg_lock);
+
+	return active;
+}
+
+void mail_msg_wait_all(void)
+{
+	if (mail_in_main_thread ()) {
+		g_mutex_lock (mail_msg_lock);
+		while (g_hash_table_size(mail_msg_active_table) > 0) {
+			g_mutex_unlock (mail_msg_lock);
+			gtk_main_iteration();
+			g_mutex_lock (mail_msg_lock);
+		}
+		g_mutex_unlock (mail_msg_lock);
+	} else {
+		g_mutex_lock (mail_msg_lock);
+		while (g_hash_table_size(mail_msg_active_table) > 0) {
+			g_cond_wait (mail_msg_cond, mail_msg_lock);
+		}
+		g_mutex_unlock (mail_msg_lock);
+	}
+}
+
+/* **************************************** */
+
+static GHookList cancel_hook_list;
+
+GHook *
+mail_cancel_hook_add (GHookFunc func, gpointer data)
+{
+	GHook *hook;
+
+	g_mutex_lock (mail_msg_lock);
+
+	if (!cancel_hook_list.is_setup)
+		g_hook_list_init (&cancel_hook_list, sizeof (GHook));
+
+	hook = g_hook_alloc (&cancel_hook_list);
+	hook->func = func;
+	hook->data = data;
+
+	g_hook_append (&cancel_hook_list, hook);
+
+	g_mutex_unlock (mail_msg_lock);
+
+	return hook;
+}
+
+void
+mail_cancel_hook_remove (GHook *hook)
+{
+	g_mutex_lock (mail_msg_lock);
+
+	g_return_if_fail (cancel_hook_list.is_setup);
+	g_hook_destroy_link (&cancel_hook_list, hook);
+
+	g_mutex_unlock (mail_msg_lock);
+}
+
+void
+mail_cancel_all (void)
+{
+	camel_operation_cancel (NULL);
+
+	g_mutex_lock (mail_msg_lock);
+
+	if (cancel_hook_list.is_setup)
+		g_hook_list_invoke (&cancel_hook_list, FALSE);
+
+	g_mutex_unlock (mail_msg_lock);
+}
+
+void
+mail_msg_set_cancelable (gpointer msg, gboolean status)
+{
+	MailMsg *mail_msg = msg;
+
+	mail_msg->priv->cancelable = status;
+}
+
+static guint idle_source_id = 0;
+G_LOCK_DEFINE_STATIC (idle_source_id);
+static GAsyncQueue *main_loop_queue = NULL;
+static GAsyncQueue *msg_reply_queue = NULL;
+static GThread *main_thread = NULL;
+
+static gboolean
+mail_msg_idle_cb (void)
+{
+	MailMsg *msg;
+
+	g_return_val_if_fail (main_loop_queue != NULL, FALSE);
+	g_return_val_if_fail (msg_reply_queue != NULL, FALSE);
+
+	G_LOCK (idle_source_id);
+	idle_source_id = 0;
+	G_UNLOCK (idle_source_id);
+	/* check the main loop queue */
+	while ((msg = g_async_queue_try_pop (main_loop_queue)) != NULL) {
+		if (msg->info->exec != NULL)
+			msg->info->exec (msg);
+		if (msg->info->done != NULL)
+			msg->info->done (msg);
+		mail_msg_unref (msg);
+	}
+
+	/* check the reply queue */
+	while ((msg = g_async_queue_try_pop (msg_reply_queue)) != NULL) {
+		if (msg->info->done != NULL)
+			msg->info->done (msg);
+		mail_msg_check_error (msg);
+		mail_msg_unref (msg);
+	}
+	return FALSE;
+}
+
+static void
+mail_msg_proxy (MailMsg *msg)
+{
+	if (msg->info->desc != NULL && msg->cancel) {
+		gchar *text = msg->info->desc (msg);
+		camel_operation_register (msg->cancel);
+		camel_operation_start (msg->cancel, "%s", text);
+		g_free (text);
+	}
+
+	if (msg->info->exec != NULL)
+		msg->info->exec (msg);
+
+	if (msg->info->desc != NULL && msg->cancel) {
+		camel_operation_end (msg->cancel);
+		camel_operation_unregister (msg->cancel);
+	}
+
+	g_async_queue_push (msg_reply_queue, msg);
+
+	G_LOCK (idle_source_id);
+	if (idle_source_id == 0)
+		idle_source_id = g_idle_add (
+			(GSourceFunc) mail_msg_idle_cb, NULL);
+	G_UNLOCK (idle_source_id);
+}
+
+void
+mail_msg_cleanup (void)
+{
+	mail_msg_wait_all();
+
+	G_LOCK (idle_source_id);
+	if (idle_source_id != 0) {
+		GSource *source;
+
+		/* Cancel the idle source. */
+		source = g_main_context_find_source_by_id (
+			g_main_context_default (), idle_source_id);
+		g_source_destroy (source);
+		idle_source_id = 0;
+	}
+	G_UNLOCK (idle_source_id);
+
+	g_async_queue_unref (main_loop_queue);
+	main_loop_queue = NULL;
+
+	g_async_queue_unref (msg_reply_queue);
+	msg_reply_queue = NULL;
+}
+
+void
+mail_msg_init (void)
+{
+	mail_msg_lock = g_mutex_new ();
+	mail_msg_cond = g_cond_new ();
+
+	main_loop_queue = g_async_queue_new ();
+	msg_reply_queue = g_async_queue_new ();
+
+	mail_msg_active_table = g_hash_table_new (NULL, NULL);
+	main_thread = g_thread_self ();
+
+	mail_async_event = mail_async_event_new ();
+}
+
+static gint
+mail_msg_compare (const MailMsg *msg1, const MailMsg *msg2)
+{
+	gint priority1 = msg1->priority;
+	gint priority2 = msg2->priority;
+
+	if (priority1 == priority2)
+		return 0;
+
+	return (priority1 < priority2) ? 1 : -1;
+}
+
+static gpointer
+create_thread_pool (gpointer data)
+{
+	GThreadPool *thread_pool;
+	gint max_threads = GPOINTER_TO_INT (data);
+
+	/* once created, run forever */
+	thread_pool = g_thread_pool_new (
+		(GFunc) mail_msg_proxy, NULL, max_threads, FALSE, NULL);
+	g_thread_pool_set_sort_function (
+		thread_pool, (GCompareDataFunc) mail_msg_compare, NULL);
+
+	return thread_pool;
+}
+
+void
+mail_msg_main_loop_push (gpointer msg)
+{
+	g_async_queue_push_sorted (main_loop_queue, msg,
+		(GCompareDataFunc) mail_msg_compare, NULL);
+
+	G_LOCK (idle_source_id);
+	if (idle_source_id == 0)
+		idle_source_id = g_idle_add (
+			(GSourceFunc) mail_msg_idle_cb, NULL);
+	G_UNLOCK (idle_source_id);
+}
+
+void
+mail_msg_unordered_push (gpointer msg)
+{
+	static GOnce once = G_ONCE_INIT;
+
+	g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (10));
+
+	g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
+}
+
+void
+mail_msg_fast_ordered_push (gpointer msg)
+{
+	static GOnce once = G_ONCE_INIT;
+
+	g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (1));
+
+	g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
+}
+
+void
+mail_msg_slow_ordered_push (gpointer msg)
+{
+	static GOnce once = G_ONCE_INIT;
+
+	g_once (&once, (GThreadFunc) create_thread_pool, GINT_TO_POINTER (1));
+
+	g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
+}
+
+gboolean
+mail_in_main_thread (void)
+{
+	return (g_thread_self () == main_thread);
+}
+
+/* ********************************************************************** */
+
+struct _proxy_msg {
+	MailMsg base;
+
+	MailAsyncEvent *ea;
+	mail_async_event_t type;
+
+	GThread *thread;
+	guint idle_id;
+
+	MailAsyncFunc func;
+	gpointer o;
+	gpointer event_data;
+	gpointer data;
+};
+
+static void
+do_async_event(struct _proxy_msg *m)
+{
+	m->thread = g_thread_self ();
+	m->func(m->o, m->event_data, m->data);
+	m->thread = NULL;
+
+	g_mutex_lock(m->ea->lock);
+	m->ea->tasks = g_slist_remove(m->ea->tasks, m);
+	g_mutex_unlock(m->ea->lock);
+}
+
+static gint
+idle_async_event (struct _proxy_msg *m)
+{
+	m->idle_id = 0;
+	do_async_event (m);
+	mail_msg_unref (m);
+
+	return FALSE;
+}
+
+static MailMsgInfo async_event_info = {
+	sizeof (struct _proxy_msg),
+	(MailMsgDescFunc) NULL,
+	(MailMsgExecFunc) do_async_event,
+	(MailMsgDoneFunc) NULL,
+	(MailMsgFreeFunc) NULL
+};
+
+MailAsyncEvent *
+mail_async_event_new (void)
+{
+	MailAsyncEvent *ea;
+
+	ea = g_malloc0(sizeof(*ea));
+	ea->lock = g_mutex_new();
+
+	return ea;
+}
+
+guint
+mail_async_event_emit (MailAsyncEvent *ea,
+                       mail_async_event_t type,
+                       MailAsyncFunc func,
+                       gpointer o,
+                       gpointer event_data,
+                       gpointer data)
+{
+	struct _proxy_msg *m;
+	guint id;
+
+	/* We dont have a reply port for this, we dont
+	 * care when/if it gets executed, just queue it. */
+	m = mail_msg_new(&async_event_info);
+	m->func = func;
+	m->o = o;
+	m->event_data = event_data;
+	m->data = data;
+	m->ea = ea;
+	m->type = type;
+	m->thread = NULL;
+
+	id = m->base.seq;
+	g_mutex_lock(ea->lock);
+	ea->tasks = g_slist_prepend(ea->tasks, m);
+	g_mutex_unlock(ea->lock);
+
+	/* We use an idle function instead of our own message port only
+	 * because the gui message ports's notification buffer might
+	 * overflow and deadlock us. */
+	if (type == MAIL_ASYNC_GUI) {
+		if (mail_in_main_thread ())
+			m->idle_id = g_idle_add (
+				(GSourceFunc) idle_async_event, m);
+		else
+			mail_msg_main_loop_push(m);
+	} else
+		mail_msg_fast_ordered_push (m);
+
+	return id;
+}
+
+gint
+mail_async_event_destroy (MailAsyncEvent *ea)
+{
+	gint id;
+	struct _proxy_msg *m;
+
+	g_mutex_lock(ea->lock);
+	while (ea->tasks) {
+		m = ea->tasks->data;
+		id = m->base.seq;
+		if (m->thread == g_thread_self ()) {
+			g_warning("Destroying async event from inside an event, returning EDEADLK");
+			g_mutex_unlock(ea->lock);
+			errno = EDEADLK;
+			return -1;
+		}
+		if (m->idle_id > 0) {
+			g_source_remove (m->idle_id);
+			m->idle_id = 0;
+		}
+		g_mutex_unlock(ea->lock);
+		mail_msg_wait(id);
+		g_mutex_lock(ea->lock);
+	}
+	g_mutex_unlock(ea->lock);
+
+	g_mutex_free(ea->lock);
+	g_free(ea);
+
+	return 0;
+}
+
+/* ********************************************************************** */
+
+struct _call_msg {
+	MailMsg base;
+
+	mail_call_t type;
+	MailMainFunc func;
+	gpointer ret;
+	va_list ap;
+	EFlag *done;
+};
+
+static void
+do_call(struct _call_msg *m)
+{
+	gpointer p1, *p2, *p3, *p4, *p5;
+	gint i1;
+	va_list ap;
+
+	G_VA_COPY(ap, m->ap);
+
+	switch (m->type) {
+	case MAIL_CALL_p_p:
+		p1 = va_arg(ap, gpointer );
+		m->ret = m->func(p1);
+		break;
+	case MAIL_CALL_p_pp:
+		p1 = va_arg(ap, gpointer );
+		p2 = va_arg(ap, gpointer );
+		m->ret = m->func(p1, p2);
+		break;
+	case MAIL_CALL_p_ppp:
+		p1 = va_arg(ap, gpointer );
+		p2 = va_arg(ap, gpointer );
+		p3 = va_arg(ap, gpointer );
+		m->ret = m->func(p1, p2, p3);
+		break;
+	case MAIL_CALL_p_pppp:
+		p1 = va_arg(ap, gpointer );
+		p2 = va_arg(ap, gpointer );
+		p3 = va_arg(ap, gpointer );
+		p4 = va_arg(ap, gpointer );
+		m->ret = m->func(p1, p2, p3, p4);
+		break;
+	case MAIL_CALL_p_ppppp:
+		p1 = va_arg(ap, gpointer );
+		p2 = va_arg(ap, gpointer );
+		p3 = va_arg(ap, gpointer );
+		p4 = va_arg(ap, gpointer );
+		p5 = va_arg(ap, gpointer );
+		m->ret = m->func(p1, p2, p3, p4, p5);
+		break;
+	case MAIL_CALL_p_ppippp:
+		p1 = va_arg(ap, gpointer );
+		p2 = va_arg(ap, gpointer );
+		i1 = va_arg(ap, gint);
+		p3 = va_arg(ap, gpointer );
+		p4 = va_arg(ap, gpointer );
+		p5 = va_arg(ap, gpointer );
+		m->ret = m->func(p1, p2, i1, p3, p4, p5);
+		break;
+	}
+
+	if (m->done != NULL)
+		e_flag_set (m->done);
+}
+
+static MailMsgInfo mail_call_info = {
+	sizeof (struct _call_msg),
+	(MailMsgDescFunc) NULL,
+	(MailMsgExecFunc) do_call,
+	(MailMsgDoneFunc) NULL,
+	(MailMsgFreeFunc) NULL
+};
+
+gpointer
+mail_call_main (mail_call_t type, MailMainFunc func, ...)
+{
+	struct _call_msg *m;
+	gpointer ret;
+	va_list ap;
+
+	va_start(ap, func);
+
+	m = mail_msg_new (&mail_call_info);
+	m->type = type;
+	m->func = func;
+	G_VA_COPY(m->ap, ap);
+
+	if (mail_in_main_thread ())
+		do_call (m);
+	else {
+		mail_msg_ref (m);
+		m->done = e_flag_new ();
+		mail_msg_main_loop_push (m);
+		e_flag_wait (m->done);
+		e_flag_free (m->done);
+	}
+
+	va_end(ap);
+
+	ret = m->ret;
+	mail_msg_unref (m);
+
+	return ret;
+}
+
+/* ******************************************************************************** */
+
+struct _op_status_msg {
+	MailMsg base;
+
+	CamelOperation *op;
+	gchar *what;
+	gint pc;
+	gpointer data;
+};
+
+static void
+op_status_exec (struct _op_status_msg *m)
+{
+	MailMsg *msg;
+	MailMsgPrivate *data;
+	gchar *out, *p, *o, c;
+	gint pc;
+
+	g_return_if_fail (mail_in_main_thread ());
+
+	g_mutex_lock (mail_msg_lock);
+
+	msg = g_hash_table_lookup (mail_msg_active_table, m->data);
+
+	if (msg == NULL) {
+		g_mutex_unlock (mail_msg_lock);
+		return;
+	}
+
+	data = msg->priv;
+
+	out = g_alloca (strlen (m->what) * 2 + 1);
+	o = out;
+	p = m->what;
+	while ((c = *p++)) {
+		if (c == '%')
+			*o++ = '%';
+		*o++ = c;
+	}
+	*o = 0;
+
+	pc = m->pc;
+
+	if (1 /* activity handler */) {
+		gchar *what;
+
+		/* its being created/removed?  well leave it be */
+		if (data->activity_state == 1 || data->activity_state == 3) {
+			g_mutex_unlock (mail_msg_lock);
+			return;
+		} else {
+			data->activity_state = 1;
+
+			g_mutex_unlock (mail_msg_lock);
+			if (msg->info->desc)
+				what = msg->info->desc (msg);
+			else if (m->what)
+				what = g_strdup (m->what);
+			/* uncommenting because message is not very useful for a user, see bug 271734*/
+			else {
+				what = g_strdup("");
+			}
+
+			/* 'what' described the activity */
+			g_free (what);
+			g_mutex_lock (mail_msg_lock);
+			if (data->activity_state == 3) {
+
+				g_mutex_unlock (mail_msg_lock);
+				mail_msg_free (msg);
+
+				mail_async_event_emit (
+					mail_async_event, MAIL_ASYNC_GUI, (MailAsyncFunc) end_event_callback,
+							NULL, NULL, NULL);
+			} else {
+				data->activity_state = 2;
+				g_mutex_unlock (mail_msg_lock);
+			}
+			return;
+		}
+	} else {
+		g_mutex_unlock (mail_msg_lock);
+	}
+}
+
+static void
+op_status_free (struct _op_status_msg *m)
+{
+	g_free (m->what);
+}
+
+static MailMsgInfo op_status_info = {
+	sizeof (struct _op_status_msg),
+	(MailMsgDescFunc) NULL,
+	(MailMsgExecFunc) op_status_exec,
+	(MailMsgDoneFunc) NULL,
+	(MailMsgFreeFunc) op_status_free
+};
+
+static void
+mail_operation_status (CamelOperation *op,
+                       const gchar *what,
+                       gint pc,
+                       gpointer data)
+{
+	struct _op_status_msg *m;
+
+	d(printf("got operation statys: %s %d%%\n", what, pc));
+
+	m = mail_msg_new(&op_status_info);
+	m->op = op;
+	m->what = g_strdup(what);
+	switch (pc) {
+	case CAMEL_OPERATION_START:
+		pc = 0;
+		break;
+	case CAMEL_OPERATION_END:
+		pc = 100;
+		break;
+	}
+	m->pc = pc;
+	m->data = data;
+	mail_msg_main_loop_push(m);
+}
+
+
diff --git a/mail/libemailutils/mail-mt.h b/mail/libemailutils/mail-mt.h
new file mode 100644
index 0000000..d8b4fc7
--- /dev/null
+++ b/mail/libemailutils/mail-mt.h
@@ -0,0 +1,128 @@
+/*
+ * 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/>
+ *
+ *
+ * Authors:
+ *		Michael Zucchi <notzed ximian com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef _MAIL_MT
+#define _MAIL_MT
+
+#include <camel/camel.h>
+
+typedef struct _MailMsg MailMsg;
+typedef struct _MailMsgInfo MailMsgInfo;
+typedef struct _MailMsgPrivate MailMsgPrivate;
+
+typedef gchar *	(*MailMsgDescFunc)	(MailMsg *msg);
+typedef void	(*MailMsgExecFunc)	(MailMsg *msg);
+typedef void	(*MailMsgDoneFunc)	(MailMsg *msg);
+typedef void	(*MailMsgFreeFunc)	(MailMsg *msg);
+typedef void	(*MailMsgDispatchFunc)	(gpointer msg);
+
+struct _MailMsg {
+	MailMsgInfo *info;
+	volatile gint ref_count;
+	guint seq;	/* seq number for synchronisation */
+	gint priority;		/* priority (default = 0) */
+	CamelOperation *cancel;	/* a cancellation/status handle */
+	GError *error;		/* up to the caller to use this */
+	MailMsgPrivate *priv;
+};
+
+struct _MailMsgInfo {
+	gsize size;
+	MailMsgDescFunc desc;
+	MailMsgExecFunc exec;
+	MailMsgDoneFunc done;
+	MailMsgFreeFunc free;
+};
+
+/* setup ports */
+void mail_msg_init(void);
+void mail_msg_cleanup (void);
+
+gboolean mail_in_main_thread (void);
+
+/* allocate a new message */
+gpointer mail_msg_new (MailMsgInfo *info);
+gpointer mail_msg_ref (gpointer msg);
+void mail_msg_unref (gpointer msg);
+void mail_msg_check_error (gpointer msg);
+void mail_msg_cancel(guint msgid);
+void mail_msg_wait(guint msgid);
+void mail_msg_wait_all(void);
+gint mail_msg_active(guint msgid);
+
+/* dispatch a message */
+void mail_msg_main_loop_push (gpointer msg);
+void mail_msg_unordered_push (gpointer msg);
+void mail_msg_fast_ordered_push (gpointer msg);
+void mail_msg_slow_ordered_push (gpointer msg);
+
+/* To implement the stop button */
+GHook * mail_cancel_hook_add (GHookFunc func, gpointer data);
+void mail_cancel_hook_remove (GHook *hook);
+void mail_cancel_all (void);
+void mail_msg_set_cancelable (gpointer msg, gboolean status);
+
+/* request a string/password */
+gchar *mail_get_password (CamelService *service, const gchar *prompt,
+			 gboolean secret, gboolean *cache);
+
+/* asynchronous event proxies */
+typedef struct _MailAsyncEvent {
+	GMutex *lock;
+	GSList *tasks;
+} MailAsyncEvent;
+
+typedef enum _mail_async_event_t {
+	MAIL_ASYNC_GUI,
+	MAIL_ASYNC_THREAD
+} mail_async_event_t;
+
+typedef void (*MailAsyncFunc)(gpointer , gpointer , gpointer );
+
+/* create a new async event handler */
+MailAsyncEvent *mail_async_event_new(void);
+/* forward a camel event (or other call) to the gui thread */
+guint mail_async_event_emit(MailAsyncEvent *ea, mail_async_event_t type, MailAsyncFunc func, gpointer , gpointer , gpointer );
+/* wait for all outstanding async events to complete */
+gint mail_async_event_destroy(MailAsyncEvent *ea);
+
+void mail_mt_set_backend (gchar *backend);
+
+/* Call a function in the gui thread, wait for it to return, type is the marshaller to use */
+typedef enum {
+	MAIL_CALL_p_p,
+	MAIL_CALL_p_pp,
+	MAIL_CALL_p_ppp,
+	MAIL_CALL_p_pppp,
+	MAIL_CALL_p_ppppp,
+	MAIL_CALL_p_ppippp
+} mail_call_t;
+
+typedef gpointer (*MailMainFunc)();
+
+gpointer mail_call_main(mail_call_t type, MailMainFunc func, ...);
+
+/* A generic proxy event for anything that can be proxied during the life of the mailer (almost nothing) */
+/* Note that almost all objects care about the lifecycle of their events, so this cannot be used */
+extern MailAsyncEvent *mail_async_event;
+
+#endif /* _MAIL_MT */



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