[geary/wip/create-folders-713492: 1/4] Add create command



commit 5e166886a5fbf67905aa57420b755183996626c7
Author: Charles Lindsay <chaz yorba org>
Date:   Thu Jan 30 15:14:19 2014 -0800

    Add create command

 po/POTFILES.in                                   |    1 +
 src/CMakeLists.txt                               |    1 +
 src/engine/imap/api/imap-account.vala            |   12 ++++++++++
 src/engine/imap/command/imap-create-command.vala |   25 ++++++++++++++++++++++
 4 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0044498..563fe59 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -154,6 +154,7 @@ src/engine/imap/command/imap-close-command.vala
 src/engine/imap/command/imap-command.vala
 src/engine/imap/command/imap-compress-command.vala
 src/engine/imap/command/imap-copy-command.vala
+src/engine/imap/command/imap-create-command.vala
 src/engine/imap/command/imap-examine-command.vala
 src/engine/imap/command/imap-expunge-command.vala
 src/engine/imap/command/imap-fetch-command.vala
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f48b548..26390b2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -94,6 +94,7 @@ engine/imap/command/imap-close-command.vala
 engine/imap/command/imap-command.vala
 engine/imap/command/imap-compress-command.vala
 engine/imap/command/imap-copy-command.vala
+engine/imap/command/imap-create-command.vala
 engine/imap/command/imap-examine-command.vala
 engine/imap/command/imap-expunge-command.vala
 engine/imap/command/imap-fetch-command.vala
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index 82aa491..980726d 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -152,6 +152,18 @@ private class Geary.Imap.Account : BaseObject {
         return path_to_mailbox.has_key(path);
     }
     
+    public async void create_folder_async(FolderPath path, Cancellable? cancellable) throws Error {
+        check_open();
+        
+        StatusResponse response = yield send_command_async(new CreateCommand(
+            new MailboxSpecifier.from_folder_path(path, null)), null, null, cancellable);
+        
+        if (response.status != Status.OK) {
+            throw new ImapError.SERVER_ERROR("Server reports error creating path %s: %s", path.to_string(),
+                response.to_string());
+        }
+    }
+    
     public async Imap.Folder fetch_folder_async(FolderPath path, Cancellable? cancellable)
         throws Error {
         check_open();
diff --git a/src/engine/imap/command/imap-create-command.vala 
b/src/engine/imap/command/imap-create-command.vala
new file mode 100644
index 0000000..1ecf727
--- /dev/null
+++ b/src/engine/imap/command/imap-create-command.vala
@@ -0,0 +1,25 @@
+/* Copyright 2011-2013 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+/**
+ * See [[http://tools.ietf.org/html/rfc3501#section-6.3.3]]
+ *
+ * @see ExamineCommand
+ */
+
+public class Geary.Imap.CreateCommand : Command {
+    public const string NAME = "create";
+    
+    public MailboxSpecifier mailbox { get; private set; }
+    
+    public CreateCommand(MailboxSpecifier mailbox) {
+        base (NAME);
+        
+        this.mailbox = mailbox;
+        
+        add(mailbox.to_parameter());
+    }
+}


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