aboutsummaryrefslogtreecommitdiffstats
path: root/src/messaging/maildirUtils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/messaging/maildirUtils.hpp')
-rw-r--r--src/messaging/maildirUtils.hpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/messaging/maildirUtils.hpp b/src/messaging/maildirUtils.hpp
index 44d36ad3..dddc735d 100644
--- a/src/messaging/maildirUtils.hpp
+++ b/src/messaging/maildirUtils.hpp
@@ -32,18 +32,37 @@ namespace messaging {
class maildirStore;
+/** Miscellaneous helpers functions for maildir messaging system.
+ */
+
class maildirUtils
{
public:
+ /** Comparator for message filenames, based only on the
+ * unique identifier part of the filename.
+ */
+ class messageIdComparator
+ {
+ public:
+
+ messageIdComparator(const utility::file::path::component& comp);
+
+ const bool operator()(const utility::file::path::component& other) const;
+
+ private:
+
+ const utility::file::path::component m_comp;
+ };
+
/** Mode for return value of getFolderFSPath(). */
enum FolderFSPathMode
{
- FOLDER_PATH_ROOT, /**< Root folder (eg. ~/Mail/MyFolder) */
- FOLDER_PATH_NEW, /**< Folder containing unread messages (eg. ~/Mail/MyFolder/new) */
- FOLDER_PATH_CUR, /**< Folder containing messages that have been seen (eg. ~/Mail/MyFolder/cur) */
- FOLDER_PATH_TMP, /**< Temporary folder used for reliable delivery (eg. ~/Mail/MyFolder/tmp) */
- FOLDER_PATH_CONTAINER /**< Container for sub-folders (eg. ~/Mail/.MyFolder.directory) */
+ FOLDER_PATH_ROOT, /**< Root folder. Eg: ~/Mail/MyFolder */
+ FOLDER_PATH_NEW, /**< Folder containing unread messages. Eg: ~/Mail/MyFolder/new */
+ FOLDER_PATH_CUR, /**< Folder containing messages that have been seen. Eg: ~/Mail/MyFolder/cur */
+ FOLDER_PATH_TMP, /**< Temporary folder used for reliable delivery. Eg: ~/Mail/MyFolder/tmp */
+ FOLDER_PATH_CONTAINER /**< Container for sub-folders. Eg: ~/Mail/.MyFolder.directory */
};
/** Return the path on the filesystem for the folder in specified store.
@@ -55,8 +74,32 @@ public:
*/
static const utility::file::path getFolderFSPath(maildirStore* store, const utility::path& folderPath, const FolderFSPathMode mode);
+ /** Test whether the specified file-system directory corresponds to
+ * a maildir sub-folder. The name of the directory should not start
+ * with '.' to be listed as a sub-folder.
+ *
+ * @return true if the specified directory is a maildir sub-folder,
+ * false otherwise
+ */
static const bool isSubfolderDirectory(const utility::file& file);
+ /** Extract the unique identifier part of the message filename.
+ * Eg: for the filename "1071577232.28549.m03s:2,RS", it will
+ * return "1071577232.28549.m03s".
+ *
+ * @return part of the filename that corresponds to the unique
+ * identifier of the message
+ */
+ static const utility::file::path::component extractId(const utility::file::path::component& filename);
+
+ /** Extract message flags from the specified message filename.
+ * Eg: for the filename "1071577232.28549.m03s:2,RS", it will
+ * return (message::FLAG_SEEN | message::FLAG_REPLIED).
+ *
+ * @return message flags extracted from the specified filename
+ */
+ static const int extractFlags(const utility::file::path::component& comp);
+
private:
static const vmime::word TMP_DIR;