[geary/mjog/email-templates: 4/6] Plugin.Account: Support creating folders in the personal name space



commit 13e339f009cf4797a99d56315b7cd943e2f8c023
Author: Michael Gratton <mike vee net>
Date:   Wed Apr 22 19:08:27 2020 +1000

    Plugin.Account: Support creating folders in the personal name space
    
    Add `create_personal_folder` method and implement it in
    Application.FolderStoreImpl.

 .../application-folder-store-factory.vala           | 21 +++++++++++++++++++++
 src/client/plugin/plugin-folder-store.vala          |  9 +++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/client/application/application-folder-store-factory.vala 
b/src/client/application/application-folder-store-factory.vala
index 8ca3d0e2..84fdf1a8 100644
--- a/src/client/application/application-folder-store-factory.vala
+++ b/src/client/application/application-folder-store-factory.vala
@@ -58,6 +58,27 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
             return folders;
         }
 
+        public async Plugin.Folder create_personal_folder(
+            Plugin.Account target,
+            string name,
+            GLib.Cancellable? cancellable
+        ) throws GLib.Error {
+            var account = target as PluginManager.AccountImpl;
+            if (account == null) {
+                throw new Plugin.Error.NOT_SUPPORTED("Invalid account object");
+            }
+            Geary.Folder engine = yield account.backing.account.create_personal_folder(
+                name, NONE, cancellable
+            );
+            var folder = this.factory.get_plugin_folder(engine);
+            if (folder == null) {
+                throw new Geary.EngineError.NOT_FOUND(
+                    "No plugin folder found for the created folder"
+                );
+            }
+            return folder;
+        }
+
         public Plugin.Folder? get_folder_from_variant(GLib.Variant variant) {
             var folder = this.factory.get_folder_from_variant(variant);
             return this.factory.folders.get(folder);
diff --git a/src/client/plugin/plugin-folder-store.vala b/src/client/plugin/plugin-folder-store.vala
index f552d3fd..5cd1127f 100644
--- a/src/client/plugin/plugin-folder-store.vala
+++ b/src/client/plugin/plugin-folder-store.vala
@@ -46,6 +46,15 @@ public interface Plugin.FolderStore : Geary.BaseObject {
         GLib.Cancellable? cancellable
     ) throws GLib.Error;
 
+    /**
+     * Creates a folder in the root of an account's personal name space.
+     */
+    public abstract async Folder create_personal_folder(
+        Account target,
+        string name,
+        GLib.Cancellable? cancellable
+    ) throws GLib.Error;
+
     /**
      * Returns the folder specified by the given variant, if any.
      *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]