[geary] Remove Geary.FolderRoot.default_separator.



commit 24403065163efe95f29525a329c1a47ce6796a69
Author: Michael James Gratton <mike vee net>
Date:   Tue Oct 27 12:34:39 2015 +1100

    Remove Geary.FolderRoot.default_separator.
    
    * src/engine/api/geary-folder-path.vala (FolderRoot): Remove
      default_separator property and param from the ctor. Updated subclasses,
      uses of the property.
      (Geary.FolderPath.has_default_separator): Removed, since it never has a
      default_separator any more. Updated call sites.
    
    * src/engine/imap-db/imap-db-folder.vala (set_path): Removed, no longer
      useful since folder paths do not need to have their delim updated.
    
    * src/engine/imap/api/imap-account.vala: Use the account's
      hierarchy_delimiter instead of the root folder's.

 src/engine/api/geary-account-information.vala      |    2 +-
 src/engine/api/geary-folder-path.vala              |   51 +++-----------------
 src/engine/imap-db/imap-db-account.vala            |    9 +---
 src/engine/imap-db/imap-db-folder.vala             |    6 --
 .../imap-db/outbox/smtp-outbox-folder-root.vala    |    2 +-
 .../imap-db/search/imap-db-search-folder-root.vala |    2 +-
 .../imap-engine/imap-engine-generic-account.vala   |    6 +-
 .../yahoo/imap-engine-yahoo-account.vala           |    8 ++--
 src/engine/imap/api/imap-account.vala              |    9 ++--
 src/engine/imap/api/imap-folder-root.vala          |    4 +-
 .../imap/message/imap-mailbox-specifier.vala       |    4 +-
 11 files changed, 27 insertions(+), 76 deletions(-)
---
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index 04bb659..7870785 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -715,7 +715,7 @@ public class Geary.AccountInformation : BaseObject {
         if (parts == null || parts.size == 0)
             return null;
         
-        Geary.FolderPath path = new Imap.FolderRoot(parts[0], null);
+        Geary.FolderPath path = new Imap.FolderRoot(parts[0]);
         for (int i = 1; i < parts.size; i++)
             path = path.get_child(parts.get(i));
         return path;
diff --git a/src/engine/api/geary-folder-path.vala b/src/engine/api/geary-folder-path.vala
index 4350c55..c7bbf3b 100644
--- a/src/engine/api/geary-folder-path.vala
+++ b/src/engine/api/geary-folder-path.vala
@@ -10,8 +10,6 @@
  * A FolderPath may have one parent and one child.  A FolderPath without a parent is called a
  * root folder can be be created with { link FolderRoot}, which is a FolderPath.
  *
- * A FolderPath has a delimiter.  This delimiter is specified in the FolderRoot.
- *
  * @see FolderRoot
  */
 
@@ -150,20 +148,10 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
     }
     
     /**
-     * Returns true if this { link FolderPath} has a default separator.
-     *
-     * It determines this by returning true if its { link FolderRoot.default_separator} is
-     * non-null and non-empty.
-     */
-    public bool has_default_separator() {
-        return get_root().default_separator != null;
-    }
-    
-    /**
      * Returns true if the other { link FolderPath} has the same parent as this one.
      *
-     * Like { link equal_to} and { link compare_to}, this comparison does not account for the
-     * { link FolderRoot.default_separator}.  The comparison is lexiographic, not by reference.
+     * Like { link equal_to} and { link compare_to}, this comparison the comparison is
+     * lexiographic, not by reference.
      */
     public bool has_same_parent(FolderPath other) {
         FolderPath? parent = get_parent();
@@ -182,19 +170,9 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
      * Returns the { link FolderPath} as a single string with the supplied separator used as a
      * delimiter.
      *
-     * If null is passed in, { link FolderRoot.default_separator} is used.  If the default
-     * separator is null, no fullpath can be produced and this method will return null.
-     *
      * The separator is not appended to the fullpath.
-     *
-     * @see has_default_separator
      */
-    public string? get_fullpath(string? use_separator) {
-        string? separator = use_separator ?? get_root().default_separator;
-        
-        if (separator == null && !is_root())
-            return null;
-        
+    public string? get_fullpath(string separator) {
         // use cached copy if the stars align
         if (fullpath != null && fullpath_separator == separator)
             return fullpath;
@@ -273,8 +251,7 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
      * are less-than longer paths, assuming the path elements are equal up to the shorter path's
      * length.
      *
-     * Note that the { link FolderRoot.default_separator} has no bearing on comparisons, although
-     * { link FolderPath.case_sensitive} does.
+     * Note that { link FolderRoot.case_sensitive} affects comparisons.
      *
      * Returns -1 if this path is lexiographically before the other, 1 if its after, and 0 if they
      * are equal.
@@ -286,8 +263,7 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
     /**
      * { inheritDoc}
      *
-     * As with { link compare_to}, the { link FolderRoot.default_separator} has no bearing on the
-     * hash, although { link FolderPath.case_sensitive} does.
+     * Note that { link FolderRoot.case_sensitive} affects comparisons.
      */
     public uint hash() {
         if (stored_hash != uint.MAX)
@@ -334,8 +310,7 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
      * Use only for debugging and logging.
      */
     public string to_string() {
-        // use slash if no default separator available
-        return get_fullpath(has_default_separator() ? null : "/");
+        return get_fullpath("?");
     }
 }
 
@@ -351,16 +326,6 @@ public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
  */
 public abstract class Geary.FolderRoot : Geary.FolderPath {
     /**
-     * The default separator (delimiter) for this path.
-     *
-     * If null, the separator can be supplied later to { link FolderPath.get_fullpath}.
-     *
-     * This value will never be empty (i.e. zero-length).  A zero-length separator passed to the
-     * constructor will result in this property being null.
-     */
-    public string? default_separator { get; private set; }
-    
-    /**
      * The default case sensitivity of each element in the { link FolderPath}.
      *
      * @see FolderRoot.case_sensitive
@@ -368,11 +333,9 @@ public abstract class Geary.FolderRoot : Geary.FolderPath {
      */
     public bool default_case_sensitivity { get; private set; }
     
-    protected FolderRoot(string basename, string? default_separator, bool case_sensitive,
-        bool default_case_sensitivity) {
+    protected FolderRoot(string basename, bool case_sensitive, bool default_case_sensitivity) {
         base (basename, case_sensitive);
         
-        this.default_separator = !String.is_empty(default_separator) ? default_separator : null;
         this.default_case_sensitivity = default_case_sensitivity;
     }
 }
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 9e29cfa..cc8cf73 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -477,7 +477,7 @@ private class Geary.ImapDB.Account : BaseObject {
                 
                 Geary.FolderPath path = (parent != null)
                     ? parent.get_child(basename)
-                    : new Imap.FolderRoot(basename, "/");
+                    : new Imap.FolderRoot(basename);
                 
                 Geary.Imap.FolderProperties properties = new Geary.Imap.FolderProperties(
                     result.int_for("last_seen_total"), result.int_for("unread_count"), 0,
@@ -598,11 +598,6 @@ private class Geary.ImapDB.Account : BaseObject {
         if (folder == null)
             return null;
         
-        // use supplied FolderPath rather than one here; if it came from the server, it has
-        // a usable separator
-        if (path.get_root().default_separator != null)
-            folder.set_path(path);
-        
         return folder;
     }
     
@@ -1663,7 +1658,7 @@ private class Geary.ImapDB.Account : BaseObject {
         }
         
         if (parent_id <= 0)
-            return new Imap.FolderRoot(name, null);
+            return new Imap.FolderRoot(name);
         
         Geary.FolderPath? parent_path = do_find_folder_path(cx, parent_id, cancellable);
         return (parent_path == null ? null : parent_path.get_child(name));
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 90d8cbf..a916900 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -109,12 +109,6 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
         return path;
     }
     
-    // Use with caution; ImapDB.Account uses this to "improve" the path with one from the server,
-    // which has a usable path delimiter.
-    internal void set_path(FolderPath path) {
-        this.path = path;
-    }
-    
     public Geary.Imap.FolderProperties get_properties() {
         return properties;
     }
diff --git a/src/engine/imap-db/outbox/smtp-outbox-folder-root.vala 
b/src/engine/imap-db/outbox/smtp-outbox-folder-root.vala
index 5837ce1..701cfcd 100644
--- a/src/engine/imap-db/outbox/smtp-outbox-folder-root.vala
+++ b/src/engine/imap-db/outbox/smtp-outbox-folder-root.vala
@@ -8,7 +8,7 @@ private class Geary.SmtpOutboxFolderRoot : Geary.FolderRoot {
     public const string MAGIC_BASENAME = "$GearyOutbox$";
     
     public SmtpOutboxFolderRoot() {
-        base(MAGIC_BASENAME, null, false, false);
+        base(MAGIC_BASENAME, false, false);
     }
 }
 
diff --git a/src/engine/imap-db/search/imap-db-search-folder-root.vala 
b/src/engine/imap-db/search/imap-db-search-folder-root.vala
index 8b8109f..f1094fa 100644
--- a/src/engine/imap-db/search/imap-db-search-folder-root.vala
+++ b/src/engine/imap-db/search/imap-db-search-folder-root.vala
@@ -8,7 +8,7 @@ private class Geary.ImapDB.SearchFolderRoot : Geary.FolderRoot {
     public const string MAGIC_BASENAME = "$GearySearchFolder$";
     
     public SearchFolderRoot() {
-        base(MAGIC_BASENAME, null, false, false);
+        base(MAGIC_BASENAME, false, false);
     }
 }
 
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index bef229d..65ef91c 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -621,7 +621,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             
             Gee.ArrayList<string> search_names = get_mailbox_search_names().get(special);
             foreach (string search_name in search_names) {
-                Geary.FolderPath search_path = new Imap.FolderRoot(search_name, null);
+                Geary.FolderPath search_path = new Imap.FolderRoot(search_name);
                 foreach (Geary.FolderPath test_path in folder_map.keys) {
                     if (test_path.compare_normalized_ci(search_path) == 0) {
                         path = search_path;
@@ -634,7 +634,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             if (path == null) {
                 foreach (string search_name in search_names) {
                     Geary.FolderPath search_path = new Imap.FolderRoot(
-                        Imap.MailboxSpecifier.CANONICAL_INBOX_NAME, null).get_child(search_name);
+                        Imap.MailboxSpecifier.CANONICAL_INBOX_NAME).get_child(search_name);
                     foreach (Geary.FolderPath test_path in folder_map.keys) {
                         if (test_path.compare_normalized_ci(search_path) == 0) {
                             path = search_path;
@@ -647,7 +647,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             }
             
             if (path == null)
-                path = new Imap.FolderRoot(search_names[0], null);
+                path = new Imap.FolderRoot(search_names[0]);
             
             information.set_special_folder_path(special, path);
             yield information.store_async(cancellable);
diff --git a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala 
b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
index de2ed92..2e5dfae 100644
--- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
+++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
@@ -31,10 +31,10 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
             special_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>();
             
             special_map.set(Imap.MailboxSpecifier.inbox.to_folder_path(null, null), 
Geary.SpecialFolderType.INBOX);
-            special_map.set(new Imap.FolderRoot("Sent", null), Geary.SpecialFolderType.SENT);
-            special_map.set(new Imap.FolderRoot("Draft", null), Geary.SpecialFolderType.DRAFTS);
-            special_map.set(new Imap.FolderRoot("Bulk Mail", null), Geary.SpecialFolderType.SPAM);
-            special_map.set(new Imap.FolderRoot("Trash", null), Geary.SpecialFolderType.TRASH);
+            special_map.set(new Imap.FolderRoot("Sent"), Geary.SpecialFolderType.SENT);
+            special_map.set(new Imap.FolderRoot("Draft"), Geary.SpecialFolderType.DRAFTS);
+            special_map.set(new Imap.FolderRoot("Bulk Mail"), Geary.SpecialFolderType.SPAM);
+            special_map.set(new Imap.FolderRoot("Trash"), Geary.SpecialFolderType.TRASH);
         }
     }
     
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index bfdcb4a..6dae38b 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -477,14 +477,13 @@ private class Geary.Imap.Account : BaseObject {
         if (parent == null) {
             cmd = new ListCommand.wildcarded("", new MailboxSpecifier("%"), can_xlist, return_param);
         } else {
-            string? specifier = parent.get_fullpath(null);
-            string? delim = parent.get_root().default_separator;
-            if (specifier == null || delim == null) {
+            if (hierarchy_delimiter == null) {
                 throw new ImapError.INVALID("Unable to list children of %s: no delimiter specified",
                     parent.to_string());
             }
             
-            specifier += specifier.has_suffix(delim) ? "%" : (delim + "%");
+            string? specifier = parent.get_fullpath(hierarchy_delimiter);
+            specifier += specifier.has_suffix(hierarchy_delimiter) ? "%" : (hierarchy_delimiter + "%");
             
             cmd = new ListCommand(new MailboxSpecifier(specifier), can_xlist, return_param);
         }
@@ -502,7 +501,7 @@ private class Geary.Imap.Account : BaseObject {
         if (parent != null) {
             Gee.Iterator<MailboxInformation> iter = list_results.iterator();
             while (iter.next()) {
-                FolderPath list_path = iter.get().mailbox.to_folder_path(parent.get_root().default_separator,
+                FolderPath list_path = iter.get().mailbox.to_folder_path(hierarchy_delimiter,
                     inbox_specifier);
                 if (list_path.equal_to(parent)) {
                     debug("Removing parent from LIST results: %s", list_path.to_string());
diff --git a/src/engine/imap/api/imap-folder-root.vala b/src/engine/imap/api/imap-folder-root.vala
index ead111e..2d397f9 100644
--- a/src/engine/imap/api/imap-folder-root.vala
+++ b/src/engine/imap/api/imap-folder-root.vala
@@ -15,11 +15,11 @@
 private class Geary.Imap.FolderRoot : Geary.FolderRoot {
     public bool is_inbox { get; private set; }
     
-    public FolderRoot(string basename, string? default_separator) {
+    public FolderRoot(string basename) {
         bool init_is_inbox;
         string normalized_basename = init(basename, out init_is_inbox);
         
-        base (normalized_basename, default_separator, !init_is_inbox, true);
+        base (normalized_basename, !init_is_inbox, true);
         
         is_inbox = init_is_inbox;
     }
diff --git a/src/engine/imap/message/imap-mailbox-specifier.vala 
b/src/engine/imap/message/imap-mailbox-specifier.vala
index 38deb43..1408eeb 100644
--- a/src/engine/imap/message/imap-mailbox-specifier.vala
+++ b/src/engine/imap/message/imap-mailbox-specifier.vala
@@ -148,9 +148,9 @@ public class Geary.Imap.MailboxSpecifier : BaseObject, Gee.Hashable<MailboxSpeci
         // keep
         FolderPath path;
         if (inbox_specifier != null && list[0] == inbox_specifier.name)
-            path = new Imap.FolderRoot(CANONICAL_INBOX_NAME, delim);
+            path = new Imap.FolderRoot(CANONICAL_INBOX_NAME);
         else
-            path = new Imap.FolderRoot(list[0], delim);
+            path = new Imap.FolderRoot(list[0]);
         
         // walk down rest of elements adding as we go
         for (int ctr = 1; ctr < list.size; ctr++)


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