[evolution-data-server] Bug 729848 - [IMAPx] Hard to get to cached messages in offline
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 729848 - [IMAPx] Hard to get to cached messages in offline
- Date: Wed, 11 Jun 2014 17:37:53 +0000 (UTC)
commit 95564f186dd4a9dfc858c2016daa60eaf4f6029a
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 11 19:37:17 2014 +0200
Bug 729848 - [IMAPx] Hard to get to cached messages in offline
camel/camel-folder.c | 26 ++++++--------------------
camel/providers/imapx/camel-imapx-folder.c | 8 ++++++++
camel/providers/imapx/camel-imapx-store.c | 27 ++++++++++++++++++++-------
3 files changed, 34 insertions(+), 27 deletions(-)
---
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 39270be..919f7c9 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -2667,7 +2667,6 @@ camel_folder_append_message_sync (CamelFolder *folder,
GError **error)
{
CamelFolderClass *class;
- CamelStore *parent_store;
gboolean success;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
@@ -2677,9 +2676,7 @@ camel_folder_append_message_sync (CamelFolder *folder,
g_return_val_if_fail (class->append_message_sync != NULL, FALSE);
/* Need to connect the service before we can append. */
- parent_store = camel_folder_get_parent_store (folder);
- success = camel_service_connect_sync (
- CAMEL_SERVICE (parent_store), cancellable, error);
+ success = folder_maybe_connect_sync (folder, cancellable, error);
if (!success)
return FALSE;
@@ -2838,7 +2835,6 @@ camel_folder_expunge_sync (CamelFolder *folder,
GError **error)
{
CamelFolderClass *class;
- CamelStore *parent_store;
const gchar *display_name;
const gchar *message;
gboolean success;
@@ -2849,9 +2845,7 @@ camel_folder_expunge_sync (CamelFolder *folder,
g_return_val_if_fail (class->expunge_sync != NULL, FALSE);
/* Need to connect the service before we can expunge. */
- parent_store = camel_folder_get_parent_store (folder);
- success = camel_service_connect_sync (
- CAMEL_SERVICE (parent_store), cancellable, error);
+ success = folder_maybe_connect_sync (folder, cancellable, error);
if (!success)
return FALSE;
@@ -3457,7 +3451,6 @@ camel_folder_refresh_info_sync (CamelFolder *folder,
GError **error)
{
CamelFolderClass *class;
- CamelStore *parent_store;
const gchar *display_name;
const gchar *message;
gboolean success;
@@ -3468,9 +3461,7 @@ camel_folder_refresh_info_sync (CamelFolder *folder,
g_return_val_if_fail (class->refresh_info_sync != NULL, FALSE);
/* Need to connect the service before we can refresh. */
- parent_store = camel_folder_get_parent_store (folder);
- success = camel_service_connect_sync (
- CAMEL_SERVICE (parent_store), cancellable, error);
+ success = folder_maybe_connect_sync (folder, cancellable, error);
if (!success)
return FALSE;
@@ -3600,7 +3591,6 @@ camel_folder_synchronize_sync (CamelFolder *folder,
GError **error)
{
CamelFolderClass *class;
- CamelStore *parent_store;
gboolean success;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
@@ -3609,9 +3599,7 @@ camel_folder_synchronize_sync (CamelFolder *folder,
g_return_val_if_fail (class->synchronize_sync != NULL, FALSE);
/* Need to connect the service before we can synchronize. */
- parent_store = camel_folder_get_parent_store (folder);
- success = camel_service_connect_sync (
- CAMEL_SERVICE (parent_store), cancellable, error);
+ success = folder_maybe_connect_sync (folder, cancellable, error);
if (!success)
return FALSE;
@@ -3940,11 +3928,9 @@ camel_folder_transfer_messages_to_sync (CamelFolder *source,
destination_store = camel_folder_get_parent_store (destination);
/* Need to connect both services before we can transfer. */
- success = camel_service_connect_sync (
- CAMEL_SERVICE (destination_store), cancellable, error);
+ success = folder_maybe_connect_sync (destination, cancellable, error);
if (success && source_store != destination_store)
- success = camel_service_connect_sync (
- CAMEL_SERVICE (source_store), cancellable, error);
+ success = folder_maybe_connect_sync (source, cancellable, error);
if (!success)
return FALSE;
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 296226a..e9f3910 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -827,6 +827,10 @@ imapx_refresh_info_sync (CamelFolder *folder,
store = camel_folder_get_parent_store (folder);
folder_name = camel_folder_get_full_name (folder);
+ /* Not connected, thus skip the operation */
+ if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)))
+ return TRUE;
+
imapx_store = CAMEL_IMAPX_STORE (store);
imapx_server = camel_imapx_store_ref_server (imapx_store, folder_name, TRUE, cancellable, error);
@@ -1078,6 +1082,10 @@ imapx_synchronize_sync (CamelFolder *folder,
store = camel_folder_get_parent_store (folder);
folder_name = camel_folder_get_full_name (folder);
+ /* Not connected, thus skip the operation */
+ if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)))
+ return TRUE;
+
imapx_store = CAMEL_IMAPX_STORE (store);
/* while it can be expensive job, do not treat it as such, to avoid a blockage
by really expensive jobs */
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 60eb592..47a889d 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -2665,20 +2665,33 @@ camel_imapx_store_ref_server (CamelIMAPXStore *store,
GError **error)
{
CamelIMAPXServer *server = NULL;
+ GError *local_error = NULL;
g_return_val_if_fail (CAMEL_IS_IMAPX_STORE (store), NULL);
server = camel_imapx_conn_manager_get_connection (
- store->priv->con_man, folder_name, for_expensive_job, cancellable, error);
+ store->priv->con_man, folder_name, for_expensive_job, cancellable, &local_error);
+
+ if (!server && (!local_error || local_error->domain == G_RESOLVER_ERROR)) {
+ if (!local_error) {
+ g_set_error (
+ &local_error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation"));
+ } else {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_UNAVAILABLE,
+ _("You must be working online to complete this operation (%s)"),
+ local_error->message);
- if (!server && error && !*error) {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_UNAVAILABLE,
- _("You must be working online "
- "to complete this operation"));
+ g_clear_error (&local_error);
+ }
}
+ if (local_error)
+ g_propagate_error (error, local_error);
+
return server;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]