Instead of each top-level IMAP folder being a FolderRoot object, then children of that being FolderPath objects, this makes FolderRoot an "empty" FolderPath, so that both top-level and descendant folders are plain FolderPath objects. Aside from being more technically correct, this means that empty namespace roots can now be used interchangably with non-empty namespace roots (addressing issue #181), and custom folder implementations no longer need to provide their own trivial, custom FolderRoot. To support this, a notion of an IMAP root and a local root have been added from which all remote and local folder paths are now derived, existing places that assume top-level == root have been fixed, and unit tests have been added.
55 lines
1.7 KiB
Vala
55 lines
1.7 KiB
Vala
/*
|
|
* Copyright 2016 Software Freedom Conservancy Inc.
|
|
*
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
*/
|
|
|
|
/**
|
|
* The root of all IMAP mailbox paths.
|
|
*
|
|
* Because IMAP has peculiar requirements about its mailbox paths (in
|
|
* particular, Inbox is guaranteed at the root and is named
|
|
* case-insensitive, and that delimiters are particular to each path),
|
|
* this class ensure certain requirements are held throughout the
|
|
* library.
|
|
*/
|
|
public class Geary.Imap.FolderRoot : Geary.FolderRoot {
|
|
|
|
|
|
/**
|
|
* The canonical path for the IMAP inbox.
|
|
*
|
|
* This specific path object will always be returned when a child
|
|
* with some case-insensitive version of the IMAP inbox mailbox is
|
|
* obtained via {@link get_child} from this root folder. However
|
|
* since multiple folder roots may be constructed, in general
|
|
* {@link FolderPath.equal_to} or {@link FolderPath.compare_to}
|
|
* should still be used for testing equality with this path.
|
|
*/
|
|
public FolderPath inbox { get; private set; }
|
|
|
|
|
|
public FolderRoot() {
|
|
base(false);
|
|
this.inbox = base.get_child(
|
|
MailboxSpecifier.CANONICAL_INBOX_NAME,
|
|
Trillian.FALSE
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Creates a path that is a child of this folder.
|
|
*
|
|
* If the given basename is that of the IMAP inbox, then {@link
|
|
* inbox} will be returned.
|
|
*/
|
|
public override
|
|
FolderPath get_child(string basename,
|
|
Trillian is_case_sensitive = Trillian.UNKNOWN) {
|
|
return (MailboxSpecifier.is_inbox_name(basename))
|
|
? this.inbox
|
|
: base.get_child(basename, is_case_sensitive);
|
|
}
|
|
|
|
}
|