[evolution-data-server/email-factory] Add API for Fetching specific accounts.



commit 2371f9134e03df0869a5899eee902738e22f8111
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Thu Jun 2 01:01:11 2011 +0530

    Add API for Fetching specific accounts.

 mail/daemon/e-mail-data-session.c     |   24 +++++++
 mail/daemon/e-mail-data-session.xml   |    4 +
 mail/daemon/mail-send-recv.c          |   22 ++++---
 mail/daemon/mail-send-recv.h          |    2 +
 mail/libegdbus/e-gdbus-emailsession.c |  111 +++++++++++++++++++++++++++++++++
 mail/libegdbus/e-gdbus-emailsession.h |   27 ++++++++
 6 files changed, 182 insertions(+), 8 deletions(-)
---
diff --git a/mail/daemon/e-mail-data-session.c b/mail/daemon/e-mail-data-session.c
index d1fca27..8be36b6 100644
--- a/mail/daemon/e-mail-data-session.c
+++ b/mail/daemon/e-mail-data-session.c
@@ -8,6 +8,9 @@
 #include <gio/gio.h>
 #include "mail-ops.h"
 #include "utils.h"
+#include <libedataserver/e-account-list.h>
+#include <libedataserverui/e-passwords.h>
+#include <string.h>
 
 extern CamelSession *session;
 #define micro(x) if (mail_debug_log(EMAIL_DEBUG_SESSION|EMAIL_DEBUG_MICRO)) x;
@@ -357,6 +360,26 @@ impl_Mail_sendReceive (EGdbusSessionCS *object, GDBusMethodInvocation *invocatio
 	egdbus_session_cs_complete_send_receive (object, invocation);
 	return TRUE;
 }
+static gboolean
+impl_Mail_fetchAccount (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, char *uid, EMailDataSession *msession)
+{
+	EIterator *iter;
+	EAccountList *accounts;
+	EAccount *account;
+	
+	accounts = e_get_account_list ();
+	for (iter = e_list_get_iterator ((EList *)accounts);
+	     e_iterator_is_valid (iter);
+	     e_iterator_next (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+		if (account->uid && strcmp (account->uid, uid) == 0) {
+			mail_fetch_account (account);
+		}
+	}
+
+	egdbus_session_cs_complete_fetch_account (object, invocation);
+	return TRUE;
+}
 
 static gboolean
 impl_Mail_cancelOperations (EGdbusSessionCS *object, GDBusMethodInvocation *invocation, EMailDataSession *msession)
@@ -429,6 +452,7 @@ e_mail_data_session_init (EMailDataSession *self)
 	g_signal_connect (priv->gdbus_object, "handle-get-folder-from-uri", G_CALLBACK (impl_Mail_getFolderFromUri), self);
 	g_signal_connect (priv->gdbus_object, "handle-add-password", G_CALLBACK (impl_Mail_addPassword), self);
 	g_signal_connect (priv->gdbus_object, "handle-send-receive", G_CALLBACK (impl_Mail_sendReceive), self);
+	g_signal_connect (priv->gdbus_object, "handle-fetch-account", G_CALLBACK (impl_Mail_fetchAccount), self);
 	g_signal_connect (priv->gdbus_object, "handle-cancel-operations", G_CALLBACK (impl_Mail_cancelOperations), self);
 
 	priv->stores_lock = g_mutex_new ();
diff --git a/mail/daemon/e-mail-data-session.xml b/mail/daemon/e-mail-data-session.xml
index c578195..793a7f6 100644
--- a/mail/daemon/e-mail-data-session.xml
+++ b/mail/daemon/e-mail-data-session.xml
@@ -42,6 +42,10 @@
 
     <method name="sendReceive">
     </method>
+    <method name="fetchAccount">
+      <arg name="uid" type="s" direction="in"/>	    
+    </method>
+
     <method name="cancelOperations">
     </method>    
     <signal name="sendReceiveComplete">
diff --git a/mail/daemon/mail-send-recv.c b/mail/daemon/mail-send-recv.c
index fee6511..6b218f3 100644
--- a/mail/daemon/mail-send-recv.c
+++ b/mail/daemon/mail-send-recv.c
@@ -1052,20 +1052,26 @@ struct _auto_data {
 
 static GHashTable *auto_active;
 
+void
+mail_fetch_account (EAccount *account)
+{
+	const gchar *uri;
+	gboolean keep_on_server;
+
+	uri = e_account_get_string (
+		account, E_ACCOUNT_SOURCE_URL);
+	keep_on_server = e_account_get_bool (
+		account, E_ACCOUNT_SOURCE_KEEP_ON_SERVER);
+	mail_receive_uri (uri, keep_on_server);
+}
+
 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);
+		mail_fetch_account (info->account);
 	}
 
 	return TRUE;
diff --git a/mail/daemon/mail-send-recv.h b/mail/daemon/mail-send-recv.h
index 81c9cfb..c732cee 100644
--- a/mail/daemon/mail-send-recv.h
+++ b/mail/daemon/mail-send-recv.h
@@ -25,6 +25,7 @@
 
 #include <gtk/gtk.h>
 #include <camel/camel.h>
+#include <libedataserver/e-account.h>
 
 G_BEGIN_DECLS
 
@@ -39,6 +40,7 @@ void		mail_send			(void);
 
 /* setup auto receive stuff */
 void		mail_autoreceive_init		(CamelSession *session);
+void		mail_fetch_account 		(EAccount *account);
 
 G_END_DECLS
 
diff --git a/mail/libegdbus/e-gdbus-emailsession.c b/mail/libegdbus/e-gdbus-emailsession.c
index 98c9fb0..617e7dd 100644
--- a/mail/libegdbus/e-gdbus-emailsession.c
+++ b/mail/libegdbus/e-gdbus-emailsession.c
@@ -562,6 +562,35 @@ static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_send_receiv
   "handle-send-receive"
 };
 
+static const _ExtendedGDBusArgInfo _egdbus_session_cs_method_info_fetch_account_IN_ARG_uid =
+{
+  {
+    -1,
+    "uid",
+    "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _egdbus_session_cs_method_info_fetch_account_IN_ARG_pointers[] =
+{
+  &_egdbus_session_cs_method_info_fetch_account_IN_ARG_uid,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_fetch_account =
+{
+  {
+    -1,
+    "fetchAccount",
+    (GDBusArgInfo **) &_egdbus_session_cs_method_info_fetch_account_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-fetch-account"
+};
+
 static const _ExtendedGDBusMethodInfo _egdbus_session_cs_method_info_cancel_operations =
 {
   {
@@ -582,6 +611,7 @@ static const _ExtendedGDBusMethodInfo * const _egdbus_session_cs_method_info_poi
   &_egdbus_session_cs_method_info_get_local_folder,
   &_egdbus_session_cs_method_info_get_folder_from_uri,
   &_egdbus_session_cs_method_info_send_receive,
+  &_egdbus_session_cs_method_info_fetch_account,
   &_egdbus_session_cs_method_info_cancel_operations,
   NULL
 };
@@ -846,6 +876,17 @@ egdbus_session_cs_default_init (EGdbusSessionCSIface *iface)
     1,
     G_TYPE_DBUS_METHOD_INVOCATION);
 
+  g_signal_new ("handle-fetch-account",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (EGdbusSessionCSIface, handle_fetch_account),
+    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-cancel-operations",
     G_TYPE_FROM_INTERFACE (iface),
     G_SIGNAL_RUN_LAST,
@@ -1339,6 +1380,67 @@ _out:
 }
 
 void
+egdbus_session_cs_call_fetch_account (
+    EGdbusSessionCS *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "fetchAccount",
+    g_variant_new ("(s)",
+                   uid),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+gboolean
+egdbus_session_cs_call_fetch_account_finish (
+    EGdbusSessionCS *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_session_cs_call_fetch_account_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "fetchAccount",
+    g_variant_new ("(s)",
+                   uid),
+    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_session_cs_call_cancel_operations (
     EGdbusSessionCS *proxy,
     GCancellable *cancellable,
@@ -1458,6 +1560,15 @@ egdbus_session_cs_complete_send_receive (
 }
 
 void
+egdbus_session_cs_complete_fetch_account (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+void
 egdbus_session_cs_complete_cancel_operations (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation)
diff --git a/mail/libegdbus/e-gdbus-emailsession.h b/mail/libegdbus/e-gdbus-emailsession.h
index 9cd1d5e..5610fbf 100644
--- a/mail/libegdbus/e-gdbus-emailsession.h
+++ b/mail/libegdbus/e-gdbus-emailsession.h
@@ -63,6 +63,11 @@ struct _EGdbusSessionCSIface
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
 
+  gboolean (*handle_fetch_account) (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *uid);
+
   gboolean (*handle_cancel_operations) (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
@@ -126,6 +131,10 @@ void egdbus_session_cs_complete_send_receive (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
 
+void egdbus_session_cs_complete_fetch_account (
+    EGdbusSessionCS *object,
+    GDBusMethodInvocation *invocation);
+
 void egdbus_session_cs_complete_cancel_operations (
     EGdbusSessionCS *object,
     GDBusMethodInvocation *invocation);
@@ -273,6 +282,24 @@ gboolean egdbus_session_cs_call_send_receive_sync (
     GCancellable *cancellable,
     GError **error);
 
+void egdbus_session_cs_call_fetch_account (
+    EGdbusSessionCS *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean egdbus_session_cs_call_fetch_account_finish (
+    EGdbusSessionCS *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean egdbus_session_cs_call_fetch_account_sync (
+    EGdbusSessionCS *proxy,
+    const gchar *uid,
+    GCancellable *cancellable,
+    GError **error);
+
 void egdbus_session_cs_call_cancel_operations (
     EGdbusSessionCS *proxy,
     GCancellable *cancellable,



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