[geary/wip/795595-fix-special-folder-creation] Add support for creating/deleting folders to the console app



commit 6df979dadec7276ed056753aecb2aab6a410a582
Author: Michael Gratton <mike vee net>
Date:   Wed Sep 26 23:54:47 2018 +1000

    Add support for creating/deleting folders to the console app

 src/console/main.vala                            | 32 ++++++++++++++++++++++++
 src/engine/imap/command/imap-delete-command.vala | 26 +++++++++++++++++++
 src/engine/meson.build                           |  1 +
 3 files changed, 59 insertions(+)
---
diff --git a/src/console/main.vala b/src/console/main.vala
index b1a04542..0b0e78de 100644
--- a/src/console/main.vala
+++ b/src/console/main.vala
@@ -93,6 +93,8 @@ class ImapConsole : Gtk.Window {
         "list",
         "xlist",
         "examine",
+        "create",
+        "delete",
         "fetch",
         "uid-fetch",
         "fetch-fields",
@@ -184,6 +186,14 @@ class ImapConsole : Gtk.Window {
                         examine(cmd, args);
                     break;
 
+                    case "create":
+                        create(cmd, args);
+                    break;
+
+                    case "delete":
+                        @delete(cmd, args);
+                    break;
+
                     case "fetch":
                     case "uid-fetch":
                         fetch(cmd, args);
@@ -421,6 +431,28 @@ class ImapConsole : Gtk.Window {
         this.cx.send_command(new Geary.Imap.ExamineCommand(new Geary.Imap.MailboxSpecifier(args[0])));
     }
 
+    private void create(string cmd, string[] args) throws Error {
+        check_connected(cmd, args, 1, "<mailbox>");
+
+        status("Creating %s".printf(args[0]));
+        this.cx.send_command(
+            new Geary.Imap.CreateCommand(
+                new Geary.Imap.MailboxSpecifier(args[0])
+            )
+        );
+    }
+
+    private void @delete(string cmd, string[] args) throws Error {
+        check_connected(cmd, args, 1, "<mailbox>");
+
+        status("Deleting %s".printf(args[0]));
+        this.cx.send_command(
+            new Geary.Imap.DeleteCommand(
+                new Geary.Imap.MailboxSpecifier(args[0])
+            )
+        );
+    }
+
     private void fetch(string cmd, string[] args) throws Error {
         check_min_connected(cmd, args, 2, "<message-span> <data-item...>");
 
diff --git a/src/engine/imap/command/imap-delete-command.vala 
b/src/engine/imap/command/imap-delete-command.vala
new file mode 100644
index 00000000..e183f510
--- /dev/null
+++ b/src/engine/imap/command/imap-delete-command.vala
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/**
+ * The RFC 3501 DELETE command.
+ *
+ * Deletes the given mailbox. Per the RFC, this must not be used to
+ * delete mailboxes with child (inferior) mailboxes and that also are
+ * marked \Noselect.
+ *
+ * See [[http://tools.ietf.org/html/rfc3501#section-6.3.4]]
+ */
+public class Geary.Imap.DeleteCommand : Command {
+
+    public const string NAME = "DELETE";
+
+    public DeleteCommand(MailboxSpecifier mailbox) {
+        base(NAME);
+        this.args.add(mailbox.to_parameter());
+    }
+
+}
diff --git a/src/engine/meson.build b/src/engine/meson.build
index 3d99bcb8..222a0edc 100644
--- a/src/engine/meson.build
+++ b/src/engine/meson.build
@@ -99,6 +99,7 @@ geary_engine_vala_sources = files(
   'imap/command/imap-compress-command.vala',
   'imap/command/imap-copy-command.vala',
   'imap/command/imap-create-command.vala',
+  'imap/command/imap-delete-command.vala',
   'imap/command/imap-examine-command.vala',
   'imap/command/imap-expunge-command.vala',
   'imap/command/imap-fetch-command.vala',


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