aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-05-10 06:01:42 +0800
committerDan Winship <danw@src.gnome.org>2001-05-10 06:01:42 +0800
commit72be879a2786d992936b8195b328dfca75b22919 (patch)
treedfe94a8ecaf416ebf13c3c109d9bbd3b4ad389be /mail/mail-ops.c
parent630241d74b1a6dede97380c8ed70c74641399e0f (diff)
downloadgsoc2013-evolution-72be879a2786d992936b8195b328dfca75b22919.tar.gz
gsoc2013-evolution-72be879a2786d992936b8195b328dfca75b22919.tar.zst
gsoc2013-evolution-72be879a2786d992936b8195b328dfca75b22919.zip
New file, started by Ettore, finished by me, to implement the
* mail-offline-handler.c: New file, started by Ettore, finished by me, to implement the GNOME_Evolution_Offline interface. * Makefile.am (evolution_mail_SOURCES): Add mail-offline-handler.[ch] * mail-ops.c (mail_store_set_offline): Set a store online or offline. * mail-send-recv.c (auto_timeout): Don't run auto-check-for-mail while the session is offline. * component-factory.c (component_fn): Set up offline handler. svn path=/trunk/; revision=9739
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 05ab7cbf4b..5b106636dc 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1917,3 +1917,98 @@ mail_save_part(CamelMimePart *part, const char *path,
return id;
}
+
+
+/* ** GO OFFLINE ***************************************************** */
+
+struct _set_offline_msg {
+ struct _mail_msg msg;
+
+ CamelStore *store;
+ gboolean offline;
+ void (*done)(CamelStore *store, void *data);
+ void *data;
+};
+
+static char *set_offline_desc(struct _mail_msg *mm, int done)
+{
+ struct _set_offline_msg *m = (struct _set_offline_msg *)mm;
+ char *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
+ char *msg;
+
+ msg = g_strdup_printf (_("Disconnecting from %s"), service_name);
+ g_free (service_name);
+ return msg;
+}
+
+static void set_offline_do(struct _mail_msg *mm)
+{
+ struct _set_offline_msg *m = (struct _set_offline_msg *)mm;
+
+ if (CAMEL_IS_DISCO_STORE (m->store) &&
+ camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (m->store))) {
+ if (m->offline) {
+ CamelFolder *inbox;
+
+ /* FIXME. Something more generic here... */
+ inbox = camel_store_get_inbox (m->store, NULL);
+ if (inbox) {
+ camel_disco_folder_prepare_for_offline (
+ CAMEL_DISCO_FOLDER (inbox),
+ "(match-all (not (system-flag \"Seen\")))",
+ &mm->ex);
+ camel_object_unref (CAMEL_OBJECT (inbox));
+ if (camel_exception_is_set (&mm->ex))
+ return;
+ }
+ }
+
+ camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store),
+ m->offline ? CAMEL_DISCO_STORE_OFFLINE :
+ CAMEL_DISCO_STORE_ONLINE, &mm->ex);
+ } else {
+ if (m->offline) {
+ camel_service_disconnect (CAMEL_SERVICE (m->store),
+ TRUE, &mm->ex);
+ }
+ }
+}
+
+static void set_offline_done(struct _mail_msg *mm)
+{
+ struct _set_offline_msg *m = (struct _set_offline_msg *)mm;
+
+ if (m->done)
+ m->done(m->store, m->data);
+}
+
+static void set_offline_free(struct _mail_msg *mm)
+{
+ struct _set_offline_msg *m = (struct _set_offline_msg *)mm;
+
+ camel_object_unref((CamelObject *)m->store);
+}
+
+static struct _mail_msg_op set_offline_op = {
+ set_offline_desc,
+ set_offline_do,
+ set_offline_done,
+ set_offline_free,
+};
+
+void
+mail_store_set_offline (CamelStore *store, gboolean offline,
+ void (*done)(CamelStore *, void *data),
+ void *data)
+{
+ struct _set_offline_msg *m;
+
+ m = mail_msg_new(&set_offline_op, NULL, sizeof(*m));
+ m->store = store;
+ camel_object_ref((CamelObject *)store);
+ m->offline = offline;
+ m->data = data;
+ m->done = done;
+
+ e_thread_put(mail_thread_queued, (EMsg *)m);
+}