[geary] Make MailboxSpecifier.from_folder_path delim parameter required.



commit e30ab0a6b78d212cc85cbadf8fb7599962a97c9a
Author: Michael James Gratton <mike vee net>
Date:   Tue Oct 27 15:14:14 2015 +1100

    Make MailboxSpecifier.from_folder_path delim parameter required.
    
    Since we can't get the delim from the FolderPath's root any more, we need
    to ensure it is always passed in.
    
    * src/engine/imap/message/imap-mailbox-specifier.vala (from_folder_path):
      Made delim param non-nullable. Updated call sites.
    
    * src/engine/imap/api/imap-folder.vala: Use existing MailboxInformation
      property to get the delim since we don't have access to the account.
    
    * src/engine/imap/api/imap-account.vala: Use the account's existing
      knowedge of the INBOX's delim as the delim.
    
    * src/engine/imap-db/imap-db-folder.vala: Hardcode ">" as the delim since
      it's a local folder and we don't care, but on the bright side it also
      makes it obvious when to_string()'ed what we are looking at.
    
    * src/engine/api/geary-folder-path.vala (get_fullpath): Make return value
      non-nullable, since it is now.

 src/engine/api/geary-folder-path.vala              |    2 +-
 src/engine/imap-db/imap-db-folder.vala             |    2 +-
 src/engine/imap/api/imap-account.vala              |    4 ++--
 src/engine/imap/api/imap-folder.vala               |    4 ++--
 .../imap/message/imap-mailbox-specifier.vala       |   14 ++------------
 5 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/src/engine/api/geary-folder-path.vala b/src/engine/api/geary-folder-path.vala
index c7bbf3b..f831f78 100644
--- a/src/engine/api/geary-folder-path.vala
+++ b/src/engine/api/geary-folder-path.vala
@@ -172,7 +172,7 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
      *
      * The separator is not appended to the fullpath.
      */
-    public string? get_fullpath(string separator) {
+    public string get_fullpath(string separator) {
         // use cached copy if the stars align
         if (fullpath != null && fullpath_separator == separator)
             return fullpath;
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index a916900..5682c53 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -190,7 +190,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
                 : null;
             
             // Note that recent is not stored
-            status_data = new Imap.StatusData(new Imap.MailboxSpecifier.from_folder_path(path, null),
+            status_data = new Imap.StatusData(new Imap.MailboxSpecifier.from_folder_path(path, ">"),
                 messages, 0, uid_next, uid_validity, result.int_for("unread_count"));
             
             return Db.TransactionOutcome.DONE;
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index 6dae38b..f49909c 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -225,7 +225,7 @@ private class Geary.Imap.Account : BaseObject {
         check_open();
         
         StatusResponse response = yield send_command_async(new CreateCommand(
-            new MailboxSpecifier.from_folder_path(path, null)), null, null, cancellable);
+            new MailboxSpecifier.from_folder_path(path, hierarchy_delimiter)), null, null, cancellable);
         
         if (response.status != Status.OK) {
             throw new ImapError.SERVER_ERROR("Server reports error creating path %s: %s", path.to_string(),
@@ -346,7 +346,7 @@ private class Geary.Imap.Account : BaseObject {
         
         Gee.List<StatusData> status_results = new Gee.ArrayList<StatusData>();
         StatusResponse response = yield send_command_async(
-            new StatusCommand(new MailboxSpecifier.from_folder_path(path, null), status_types),
+            new StatusCommand(new MailboxSpecifier.from_folder_path(path, hierarchy_delimiter), 
status_types),
             null, status_results, cancellable);
         
         throw_fetch_error(response, path, status_results.size);
diff --git a/src/engine/imap/api/imap-folder.vala b/src/engine/imap/api/imap-folder.vala
index 70957a4..e802c8c 100644
--- a/src/engine/imap/api/imap-folder.vala
+++ b/src/engine/imap/api/imap-folder.vala
@@ -680,7 +680,7 @@ private class Geary.Imap.Folder : BaseObject {
         check_open();
         
         CopyCommand cmd = new CopyCommand(msg_set,
-            new MailboxSpecifier.from_folder_path(destination, null));
+            new MailboxSpecifier.from_folder_path(destination, info.delim));
         
         Gee.Map<Command, StatusResponse>? responses = yield exec_commands_async(
             Geary.iterate<Command>(cmd).to_array_list(), null, null, cancellable);
@@ -1037,7 +1037,7 @@ private class Geary.Imap.Folder : BaseObject {
         if (date_received != null)
             internaldate = new InternalDate.from_date_time(date_received);
         
-        AppendCommand cmd = new AppendCommand(new MailboxSpecifier.from_folder_path(path, null),
+        AppendCommand cmd = new AppendCommand(new MailboxSpecifier.from_folder_path(path, info.delim),
             msg_flags, internaldate, message.get_network_buffer(false));
         
         Gee.Map<Command, StatusResponse> responses = yield exec_commands_async(
diff --git a/src/engine/imap/message/imap-mailbox-specifier.vala 
b/src/engine/imap/message/imap-mailbox-specifier.vala
index 1408eeb..b9fdbbf 100644
--- a/src/engine/imap/message/imap-mailbox-specifier.vala
+++ b/src/engine/imap/message/imap-mailbox-specifier.vala
@@ -90,19 +90,9 @@ public class Geary.Imap.MailboxSpecifier : BaseObject, Gee.Hashable<MailboxSpeci
     
     /**
      * Converts a generic { link FolderPath} into an IMAP mailbox specifier.
-     *
-     * If the delimiter was supplied from a { link ListCommand} response, it can be supplied here.
-     * Otherwise, the path's { link FolderRoot.default_separator} will be used.  If neither have a
-     * separator, { link ImapError.INVALID} is thrown.
      */
-    public MailboxSpecifier.from_folder_path(FolderPath path, string? delim) throws ImapError {
-        string? fullpath = path.get_fullpath(delim);
-        if (fullpath == null) {
-            throw new ImapError.INVALID("Unable to convert FolderPath to MailboxSpecifier: no delimiter for 
%s",
-                path.to_string());
-        }
-        
-        init(fullpath);
+    public MailboxSpecifier.from_folder_path(FolderPath path, string delim) throws ImapError {
+        init(path.get_fullpath(delim));
     }
     
     private void init(string decoded) {


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