Commit 2371f913 authored by Srinivasa Ragavan's avatar Srinivasa Ragavan

Add API for Fetching specific accounts.

parent 2b7314e4
......@@ -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 ();
......
......@@ -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">
......
......@@ -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;
......
......@@ -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
......
......@@ -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,
......@@ -1338,6 +1379,67 @@ _out:
return _ret != NULL;
}
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,
......@@ -1457,6 +1559,15 @@ egdbus_session_cs_complete_send_receive (
g_variant_new ("()"));
}
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,
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment