aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-23 05:26:08 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-23 05:26:08 +0800
commit2636da7dac1683c7bac98b7a6d1ee084ea2efbca (patch)
tree6263ef3079c3fc885339f46a48cfdea9c35a04ef /mail/mail-ops.c
parenta910a31a06fa3eadb1a44698f0502436bc5db6ce (diff)
downloadgsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar.gz
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar.bz2
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar.lz
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar.xz
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.tar.zst
gsoc2013-evolution-2636da7dac1683c7bac98b7a6d1ee084ea2efbca.zip
Kill mail_store_set_offline().
Replace it with new async functions: e_mail_store_go_offline() e_mail_store_go_offline_finish() e_mail_store_go_online() e_mail_store_go_online_finish()
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c179
1 files changed, 1 insertions, 178 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index ce219ed372..d10473606b 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -2351,91 +2351,7 @@ mail_save_messages (CamelFolder *folder, GPtrArray *uids, const gchar *path,
return id;
}
-/* ** PREPARE OFFLINE ***************************************************** */
-
-struct _prep_offline_msg {
- MailMsg base;
-
- EMailSession *session;
- GCancellable *cancel;
- gchar *uri;
- void (*done)(const gchar *uri, gpointer data);
- gpointer data;
-};
-
-static void
-prep_offline_exec (struct _prep_offline_msg *m,
- GCancellable *cancellable,
- GError **error)
-{
- CamelFolder *folder;
-
- folder = e_mail_session_uri_to_folder_sync (
- m->session, m->uri, 0,
- cancellable, error);
- if (folder) {
- if (CAMEL_IS_DISCO_FOLDER (folder)) {
- camel_disco_folder_prepare_for_offline (
- CAMEL_DISCO_FOLDER (folder),
- "(match-all)", m->cancel, error);
- } else if (CAMEL_IS_OFFLINE_FOLDER (folder)) {
- camel_offline_folder_downsync_sync (
- CAMEL_OFFLINE_FOLDER (folder),
- "(match-all)", m->cancel, error);
- }
- /* prepare_for_offline should do this? */
- /* of course it should all be atomic, but ... */
- /* FIXME Not passing a GCancellable here. */
- camel_folder_synchronize_sync (folder, FALSE, NULL, NULL);
- g_object_unref (folder);
- }
-}
-
-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)
-{
- g_object_unref (m->session);
- if (m->cancel)
- g_object_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 (EMailSession *session,
- 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->session = g_object_ref (session);
- if (G_IS_CANCELLABLE (cancel))
- m->cancel = g_object_ref (cancel);
- m->uri = g_strdup (uri);
- m->data = data;
- m->done = done;
-
- mail_msg_slow_ordered_push (m);
-}
-
-/* ** GO OFFLINE ***************************************************** */
+/* ** Prepare OFFLINE ***************************************************** */
struct _set_offline_msg {
MailMsg base;
@@ -2447,99 +2363,6 @@ struct _set_offline_msg {
};
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,
- GCancellable *cancellable,
- GError **error)
-{
- if (CAMEL_IS_DISCO_STORE (m->store)) {
- if (!m->offline) {
- camel_disco_store_set_status (
- CAMEL_DISCO_STORE (m->store),
- CAMEL_DISCO_STORE_ONLINE,
- cancellable, 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,
- cancellable, error);
- return;
- }
- } else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
- camel_offline_store_set_online_sync (
- CAMEL_OFFLINE_STORE (m->store),
- !m->offline, cancellable, error);
- return;
- }
-
- if (m->offline)
- camel_service_disconnect_sync (
- CAMEL_SERVICE (m->store), TRUE, 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);