From ac54446b56cc61726a675b51cd07305956643fbc Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 27 Sep 2001 14:47:46 +0000 Subject: 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 --- mail/mail-offline-handler.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'mail/mail-offline-handler.c') 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 -- cgit