[geary/wip/trash-714212: 3/4] Don't support trash from local-only/trash itself
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/trash-714212: 3/4] Don't support trash from local-only/trash itself
- Date: Thu, 19 Dec 2013 01:41:12 +0000 (UTC)
commit aa0306ccfd1fbe190b89ed3df7823236c284a786
Author: Charles Lindsay <chaz yorba org>
Date: Wed Dec 18 15:58:18 2013 -0800
Don't support trash from local-only/trash itself
src/client/application/geary-controller.vala | 14 ++++++++------
src/engine/abstract/geary-abstract-account.vala | 2 ++
src/engine/api/geary-account.vala | 5 +++++
.../imap-engine/imap-engine-generic-account.vala | 5 +++++
4 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 2570bbd..6623031 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1866,12 +1866,14 @@ public class GearyController : Geary.BaseObject {
private Geary.FolderSupport.Move? current_folder_supports_trash(out Geary.FolderPath? trash_path) {
try {
- // TODO: current_folder is not a trash folder or a local-only folder
- Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
- Geary.Folder? trash_folder = current_account.get_special_folder(Geary.SpecialFolderType.TRASH);
- if (supports_move != null && trash_folder != null) {
- trash_path = trash_folder.path;
- return supports_move;
+ if (current_folder != null && current_folder.special_folder_type != Geary.SpecialFolderType.TRASH
+ && current_account != null && !current_account.folder_is_local_only(current_folder.path)) {
+ Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
+ Geary.Folder? trash_folder =
current_account.get_special_folder(Geary.SpecialFolderType.TRASH);
+ if (supports_move != null && trash_folder != null) {
+ trash_path = trash_folder.path;
+ return supports_move;
+ }
}
} catch (Error e) {
debug("Error finding trash folder: %s", e.message);
diff --git a/src/engine/abstract/geary-abstract-account.vala b/src/engine/abstract/geary-abstract-account.vala
index 4ee8115..11f7eaf 100644
--- a/src/engine/abstract/geary-abstract-account.vala
+++ b/src/engine/abstract/geary-abstract-account.vala
@@ -93,6 +93,8 @@ public abstract class Geary.AbstractAccount : BaseObject, Geary.Account {
public abstract async bool folder_exists_async(Geary.FolderPath path, Cancellable? cancellable = null)
throws Error;
+ public abstract bool folder_is_local_only(Geary.FolderPath path) throws Error;
+
public abstract async Geary.Folder fetch_folder_async(Geary.FolderPath path,
Cancellable? cancellable = null) throws Error;
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index f2dc933..06a1089 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -253,6 +253,11 @@ public interface Geary.Account : BaseObject {
throws Error;
/**
+ * Returns true if the given folder path exists locally but not on the server.
+ */
+ public abstract bool folder_is_local_only(Geary.FolderPath path) throws Error;
+
+ /**
* Fetches a Folder object corresponding to the supplied path. If the backing medium does
* not have a record of a folder at the path, EngineError.NOT_FOUND will be thrown.
*
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index d26aef2..e67f96e 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -381,6 +381,11 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
return local.contact_store;
}
+ public override bool folder_is_local_only(Geary.FolderPath path) throws Error {
+ check_open();
+ return (path in local_only.keys);
+ }
+
public override async bool folder_exists_async(Geary.FolderPath path,
Cancellable? cancellable = null) throws Error {
check_open();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]