aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2013-08-22 19:01:21 +0800
committerFabiano FidĂȘncio <fidencio@redhat.com>2013-08-27 07:52:02 +0800
commitaa255972359662e58c34db33320e0377060de1b0 (patch)
tree06d89e8aa506b25082ec752d1b102aeb7d19bbad
parente56159372131bc4036d2d6339149db4617fbac41 (diff)
downloadgsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar.gz
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar.bz2
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar.lz
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar.xz
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.tar.zst
gsoc2013-evolution-aa255972359662e58c34db33320e0377060de1b0.zip
Bug #659715 - Reject folder copy/move in offline
-rw-r--r--mail/em-folder-tree.c30
-rw-r--r--mail/em-folder-utils.c54
2 files changed, 66 insertions, 18 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 195a09fad7..e2aa6d5e37 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -1970,10 +1970,13 @@ ask_drop_folder (EMFolderTree *folder_tree,
EMailSession *session;
GSettings *settings;
gchar *set_value, *src_folder_name = NULL;
+ CamelProvider *src_provider, *des_provider;
+ CamelStore *src_store = NULL;
GError *error = NULL;
GtkWidget *widget;
GtkWindow *parent;
gint response;
+ gboolean src_store_is_local, des_store_is_local, session_is_online;
g_return_val_if_fail (folder_tree != NULL, FALSE);
g_return_val_if_fail (src_folder_uri != NULL, FALSE);
@@ -2000,7 +2003,7 @@ ask_drop_folder (EMFolderTree *folder_tree,
e_mail_folder_uri_parse (
CAMEL_SESSION (session),
- src_folder_uri, NULL, &src_folder_name, &error);
+ src_folder_uri, &src_store, &src_folder_name, &error);
if (error != NULL) {
g_warning (
@@ -2012,6 +2015,30 @@ ask_drop_folder (EMFolderTree *folder_tree,
return FALSE;
}
+ session_is_online = camel_session_get_online (CAMEL_SESSION (session));
+
+ src_provider = camel_service_get_provider (CAMEL_SERVICE (src_store));
+ src_store_is_local = (src_provider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
+
+ des_provider = camel_service_get_provider (CAMEL_SERVICE (des_store));
+ des_store_is_local = (des_provider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
+
+ if (!session_is_online && (!src_store_is_local || !des_store_is_local)) {
+ EAlertSink *alert_sink;
+
+ alert_sink = em_folder_tree_get_alert_sink (folder_tree);
+ e_alert_submit (
+ alert_sink,
+ "mail:online-operation",
+ src_store_is_local ? des_full_name : src_folder_name,
+ NULL);
+ g_free (src_folder_name);
+ g_object_unref (src_store);
+ g_object_unref (settings);
+
+ return FALSE;
+ }
+
parent = NULL;
widget = gtk_widget_get_toplevel (GTK_WIDGET (folder_tree));
if (widget && gtk_widget_is_toplevel (widget) && GTK_IS_WINDOW (widget))
@@ -2033,6 +2060,7 @@ ask_drop_folder (EMFolderTree *folder_tree,
g_settings_set_string (settings, key, "never");
g_free (src_folder_name);
+ g_object_unref (src_store);
g_object_unref (settings);
return response == GTK_RESPONSE_YES || response == GTK_RESPONSE_OK;
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 686750a8c7..8302cebef7 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -339,24 +339,31 @@ emfu_copy_folder_selected (EMailSession *session,
gpointer data)
{
struct _copy_folder_data *cfd = data;
+ CamelProvider *provider, *toprovider;
CamelStore *tostore = NULL;
- CamelService *service;
- gboolean store_is_local;
- const gchar *uid;
+ CamelService *service, *toservice;
+ gboolean store_is_local, tostore_is_local, session_is_online;
gchar *tobase = NULL;
GError *local_error = NULL;
if (uri == NULL)
goto fail;
+ session_is_online = camel_session_get_online (CAMEL_SESSION (session));
+
service = CAMEL_SERVICE (cfd->source_store);
- camel_service_connect_sync (service, NULL, &local_error);
+ provider = camel_service_get_provider (service);
+ store_is_local = (provider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
+
+ e_mail_folder_uri_parse (
+ CAMEL_SESSION (session), uri,
+ &tostore, &tobase, &local_error);
if (local_error != NULL) {
e_alert_submit (
alert_sink, cfd->delete ?
- "mail:no-move-folder-nostore" :
- "mail:no-copy-folder-nostore",
+ "mail:no-move-folder-to-nostore" :
+ "mail:no-copy-folder-to-nostore",
cfd->source_folder_name, uri,
local_error->message, NULL);
goto fail;
@@ -364,8 +371,29 @@ emfu_copy_folder_selected (EMailSession *session,
g_return_if_fail (CAMEL_IS_STORE (service));
- uid = camel_service_get_uid (CAMEL_SERVICE (cfd->source_store));
- store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
+ toservice = CAMEL_SERVICE (tostore);
+ toprovider = camel_service_get_provider (toservice);
+ tostore_is_local = (toprovider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
+
+ if (!session_is_online && (!store_is_local || !tostore_is_local)) {
+ e_alert_submit (
+ alert_sink,
+ "mail:online-operation",
+ store_is_local ? uri : cfd->source_folder_name,
+ NULL);
+ goto fail;
+ }
+
+ camel_service_connect_sync (service, NULL, &local_error);
+ if (local_error != NULL) {
+ e_alert_submit (
+ alert_sink, cfd->delete ?
+ "mail:no-move-folder-nostore" :
+ "mail:no-copy-folder-nostore",
+ cfd->source_folder_name, uri,
+ local_error->message, NULL);
+ goto fail;
+ }
if (cfd->delete && store_is_local &&
emfu_is_special_local_folder (cfd->source_folder_name)) {
@@ -376,15 +404,7 @@ emfu_copy_folder_selected (EMailSession *session,
goto fail;
}
- if (!e_mail_folder_uri_parse (
- CAMEL_SESSION (session), uri,
- &tostore, &tobase, &local_error))
- tostore = NULL;
-
- if (tostore != NULL)
- camel_service_connect_sync (
- CAMEL_SERVICE (tostore), NULL, &local_error);
-
+ camel_service_connect_sync (toservice, NULL, &local_error);
if (local_error != NULL) {
e_alert_submit (
alert_sink, cfd->delete ?