aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-09-27 22:47:46 +0800
committerDan Winship <danw@src.gnome.org>2001-09-27 22:47:46 +0800
commitac54446b56cc61726a675b51cd07305956643fbc (patch)
tree357357cf620120955d674573a4977dc36a67acdd /mail
parent5120d7098b94b95a75993be8faa3377507a50b45 (diff)
downloadgsoc2013-evolution-ac54446b56cc61726a675b51cd07305956643fbc.tar.gz
gsoc2013-evolution-ac54446b56cc61726a675b51cd07305956643fbc.tar.zst
gsoc2013-evolution-ac54446b56cc61726a675b51cd07305956643fbc.zip
A service needs to be disconnected if it's remote, not already offline,
* mail-offline-handler.c (service_is_relevant): A service needs to be disconnected if it's remote, not already offline, and either connected OR connecting. (storage_go_offline): Don't put non-relevant stores offline. (Eg, don't force an IMAP store which you hadn't already connected to to connect and sync.) (storage_go_online): Likewise, don't "reconnect" stores that weren't connected before. * mail-ops.c (set_offline_desc): Fix the message to say "reconnecting" instead of "disconnecting" when appropriate. (mail_store_set_offline): If offline is TRUE, call camel_service_cancel_connect on the store. (We do this here because we don't want the cancel_connect request to get queued up behind a hanging connection attempt.) svn path=/trunk/; revision=13192
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog18
-rw-r--r--mail/mail-offline-handler.c26
-rw-r--r--mail/mail-ops.c56
3 files changed, 68 insertions, 32 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 3ff048a02c..2895bfac23 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,21 @@
+2001-09-27 Dan Winship <danw@ximian.com>
+
+ * mail-offline-handler.c (service_is_relevant): A service needs to
+ be disconnected if it's remote, not already offline, and either
+ connected OR connecting.
+ (storage_go_offline): Don't put non-relevant stores offline. (Eg,
+ don't force an IMAP store which you hadn't already connected to to
+ connect and sync.)
+ (storage_go_online): Likewise, don't "reconnect" stores that
+ weren't connected before.
+
+ * mail-ops.c (set_offline_desc): Fix the message to say
+ "reconnecting" instead of "disconnecting" when appropriate.
+ (mail_store_set_offline): If offline is TRUE, call
+ camel_service_cancel_connect on the store. (We do this here
+ because we don't want the cancel_connect request to get queued up
+ behind a hanging connection attempt.)
+
2001-09-26 Anna Marie Dirks <anna@ximian.com>
* mail-config.glade: Added a "Description:" label and moved
diff --git a/mail/mail-offline-handler.c b/mail/mail-offline-handler.c
index ba33ee7d2c..dfa3af7d53 100644
--- a/mail/mail-offline-handler.c
+++ b/mail/mail-offline-handler.c
@@ -42,18 +42,26 @@ struct _MailOfflineHandlerPrivate {
GNOME_Evolution_OfflineProgressListener listener_interface;
};
+static gboolean
+service_is_relevant (CamelService *service, gboolean going_offline)
+{
+ if (!(service->provider->flags & CAMEL_PROVIDER_IS_REMOTE))
+ return FALSE;
+
+ if (CAMEL_IS_DISCO_STORE (service) && going_offline &&
+ camel_disco_store_status (CAMEL_DISCO_STORE (service)) == CAMEL_DISCO_STORE_OFFLINE)
+ return FALSE;
+
+ return service->status != CAMEL_SERVICE_DISCONNECTED;
+}
+
static void
add_connection (gpointer key, gpointer data, gpointer user_data)
{
CamelService *service = key;
GNOME_Evolution_ConnectionList *list = user_data;
- if (!(service->provider->flags & CAMEL_PROVIDER_IS_REMOTE) ||
- !service->connected)
- return;
-
- if (CAMEL_IS_DISCO_STORE (service) &&
- camel_disco_store_status (CAMEL_DISCO_STORE (service)) == CAMEL_DISCO_STORE_OFFLINE)
+ if (!service_is_relevant (service, TRUE))
return;
list->_buffer[list->_length].hostName = CORBA_string_dup (service->url->host);
@@ -128,7 +136,8 @@ storage_go_offline (gpointer key, gpointer value, gpointer data)
CamelStore *store = key;
MailOfflineHandler *offline_handler = data;
- mail_store_set_offline (store, TRUE, went_offline, offline_handler);
+ if (service_is_relevant (CAMEL_SERVICE (store), TRUE))
+ mail_store_set_offline (store, TRUE, went_offline, offline_handler);
}
static void
@@ -157,7 +166,8 @@ storage_go_online (gpointer key, gpointer value, gpointer data)
{
CamelStore *store = key;
- mail_store_set_offline (store, FALSE, NULL, NULL);
+ if (service_is_relevant (CAMEL_SERVICE (store), FALSE))
+ mail_store_set_offline (store, FALSE, NULL, NULL);
}
static void
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 9d11277e8a..8867ecb140 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -2061,7 +2061,8 @@ static char *set_offline_desc(struct _mail_msg *mm, int done)
char *service_name = camel_service_get_name (CAMEL_SERVICE (m->store), TRUE);
char *msg;
- msg = g_strdup_printf (_("Disconnecting from %s"), service_name);
+ msg = g_strdup_printf (m->offline ? _("Disconnecting from %s") :
+ _("Reconnecting to %s"), service_name);
g_free (service_name);
return msg;
}
@@ -2070,34 +2071,35 @@ 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_folder_sync (inbox, FALSE, NULL);
- 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 (!CAMEL_IS_DISCO_STORE (m->store) ||
+ !camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (m->store))) {
if (m->offline) {
camel_service_disconnect (CAMEL_SERVICE (m->store),
TRUE, &mm->ex);
}
+ return;
}
+
+ if (m->offline && camel_disco_store_status (CAMEL_DISCO_STORE (m->store)) == CAMEL_DISCO_STORE_ONLINE) {
+ CamelFolder *inbox;
+
+ /* FIXME. Something more generic here... (bug 10755) */
+ 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_folder_sync (inbox, FALSE, NULL);
+ 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);
}
static void set_offline_done(struct _mail_msg *mm)
@@ -2129,6 +2131,12 @@ mail_store_set_offline (CamelStore *store, gboolean offline,
{
struct _set_offline_msg *m;
+ /* 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_op, NULL, sizeof(*m));
m->store = store;
camel_object_ref((CamelObject *)store);