diff --git a/ChangeLog b/ChangeLog index ac44b350..eda6a8a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ VERSION 0.6.0-cvs * Finished 'maildir' implementation. This is EXPERIMENTAL! + * Added a getCapabilities() function on 'vmime::messaging::store' to + quickly check which features are available. + 2004-12-19 Vincent Richard * Added chaining in exception handling. vmime::exception::other() returns diff --git a/SConstruct b/SConstruct index 74eebaa7..977b6e75 100644 --- a/SConstruct +++ b/SConstruct @@ -360,7 +360,7 @@ opts.AddOptions( + 'This option has no effect if "with_messaging" is not activated.\n' + 'Separate protocols with spaces; string must be quoted with ".\n' + 'Available protocols: pop3, smtp, imap, maildir.', - '"pop3 smtp imap"' + '"pop3 smtp imap maildir"' ), ( 'with_platforms', diff --git a/src/messaging/IMAPStore.cpp b/src/messaging/IMAPStore.cpp index 5e208db4..0025e55d 100644 --- a/src/messaging/IMAPStore.cpp +++ b/src/messaging/IMAPStore.cpp @@ -125,7 +125,7 @@ folder* IMAPStore::getFolder(const folder::path& path) } -const bool IMAPStore::isValidFolderName(const folder::path::component& /* name */) +const bool IMAPStore::isValidFolderName(const folder::path::component& /* name */) const { return true; } @@ -219,6 +219,19 @@ void IMAPStore::unregisterFolder(IMAPFolder* folder) } +const int IMAPStore::getCapabilities() const +{ + return (CAPABILITY_CREATE_FOLDER | + CAPABILITY_RENAME_FOLDER | + CAPABILITY_ADD_MESSAGE | + CAPABILITY_COPY_MESSAGE | + CAPABILITY_DELETE_MESSAGE | + CAPABILITY_PARTIAL_FETCH | + CAPABILITY_MESSAGE_FLAGS | + CAPABILITY_EXTRACT_PART); +} + + // Service infos diff --git a/src/messaging/IMAPStore.hpp b/src/messaging/IMAPStore.hpp index b79967f9..8ad99991 100644 --- a/src/messaging/IMAPStore.hpp +++ b/src/messaging/IMAPStore.hpp @@ -57,7 +57,7 @@ public: folder* getRootFolder(); folder* getFolder(const folder::path& path); - const bool isValidFolderName(const folder::path::component& name); + const bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; @@ -68,6 +68,8 @@ public: void noop(); + const int getCapabilities() const; + private: // Connection diff --git a/src/messaging/POP3Store.cpp b/src/messaging/POP3Store.cpp index 0bc3b6a5..4bf40583 100644 --- a/src/messaging/POP3Store.cpp +++ b/src/messaging/POP3Store.cpp @@ -82,7 +82,7 @@ folder* POP3Store::getFolder(const folder::path& path) } -const bool POP3Store::isValidFolderName(const folder::path::component& /* name */) +const bool POP3Store::isValidFolderName(const folder::path::component& /* name */) const { return true; } @@ -565,6 +565,12 @@ void POP3Store::unregisterFolder(POP3Folder* folder) } +const int POP3Store::getCapabilities() const +{ + return (CAPABILITY_DELETE_MESSAGE); +} + + // Service infos diff --git a/src/messaging/POP3Store.hpp b/src/messaging/POP3Store.hpp index d91f0d69..b4c670d3 100644 --- a/src/messaging/POP3Store.hpp +++ b/src/messaging/POP3Store.hpp @@ -51,7 +51,7 @@ public: folder* getRootFolder(); folder* getFolder(const folder::path& path); - const bool isValidFolderName(const folder::path::component& name); + const bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; @@ -62,6 +62,8 @@ public: void noop(); + const int getCapabilities() const; + private: static const bool isSuccessResponse(const string& buffer); diff --git a/src/messaging/folder.hpp b/src/messaging/folder.hpp index e67d0689..e7c50451 100644 --- a/src/messaging/folder.hpp +++ b/src/messaging/folder.hpp @@ -308,7 +308,7 @@ public: */ virtual store* getStore() = 0; - /** Possible fetchable objects. + /** Fetchable objects. */ enum FetchOptions { diff --git a/src/messaging/maildirStore.cpp b/src/messaging/maildirStore.cpp index 3434321f..206c032b 100644 --- a/src/messaging/maildirStore.cpp +++ b/src/messaging/maildirStore.cpp @@ -75,7 +75,7 @@ folder* maildirStore::getFolder(const folder::path& path) } -const bool maildirStore::isValidFolderName(const folder::path::component& name) +const bool maildirStore::isValidFolderName(const folder::path::component& name) const { if (!platformDependant::getHandler()->getFileSystemFactory()->isValidPathComponent(name)) return false; @@ -154,6 +154,19 @@ const utility::path& maildirStore::getFileSystemPath() const } +const int maildirStore::getCapabilities() const +{ + return (CAPABILITY_CREATE_FOLDER | + CAPABILITY_RENAME_FOLDER | + CAPABILITY_ADD_MESSAGE | + CAPABILITY_COPY_MESSAGE | + CAPABILITY_DELETE_MESSAGE | + CAPABILITY_PARTIAL_FETCH | + CAPABILITY_MESSAGE_FLAGS | + CAPABILITY_EXTRACT_PART); +} + + // Service infos diff --git a/src/messaging/maildirStore.hpp b/src/messaging/maildirStore.hpp index 4c7db7dc..8a904dfa 100644 --- a/src/messaging/maildirStore.hpp +++ b/src/messaging/maildirStore.hpp @@ -56,7 +56,7 @@ public: folder* getRootFolder(); folder* getFolder(const folder::path& path); - const bool isValidFolderName(const folder::path::component& name); + const bool isValidFolderName(const folder::path::component& name) const; static const serviceInfos& getInfosInstance(); const serviceInfos& getInfos() const; @@ -69,6 +69,8 @@ public: const utility::path& getFileSystemPath() const; + const int getCapabilities() const; + private: void registerFolder(maildirFolder* folder); diff --git a/src/messaging/store.hpp b/src/messaging/store.hpp index c692ba19..dc2d3358 100644 --- a/src/messaging/store.hpp +++ b/src/messaging/store.hpp @@ -50,7 +50,7 @@ public: virtual folder* getDefaultFolder() = 0; /** Return the root folder. This is protocol dependant - * and usually is the user's mail drop root folder + * and usually is the user's mail drop root folder. * * @return root folder */ @@ -68,7 +68,27 @@ public: * * @return true if the specified folder name is valid, false otherwise */ - virtual const bool isValidFolderName(const folder::path::component& name) = 0; + virtual const bool isValidFolderName(const folder::path::component& name) const = 0; + + /** Store capabilities. */ + enum Capabilities + { + CAPABILITY_CREATE_FOLDER = (1 << 0), /**< Can create folders. */ + CAPABILITY_RENAME_FOLDER = (1 << 1), /**< Can rename folders. */ + CAPABILITY_ADD_MESSAGE = (1 << 2), /**< Can append message to folders. */ + CAPABILITY_COPY_MESSAGE = (1 << 3), /**< Can copy messages from a folder to another one. */ + CAPABILITY_DELETE_MESSAGE = (1 << 4), /**< Can delete messages. */ + CAPABILITY_PARTIAL_FETCH = (1 << 5), /**< Is partial fetch supported? */ + CAPABILITY_MESSAGE_FLAGS = (1 << 6), /**< Can set flags on messages. */ + CAPABILITY_EXTRACT_PART = (1 << 7) /**< Can extract a specific part of the message. */ + }; + + /** Return the features supported by this service. This is + * a combination of store::CAPABILITY_xxx flags. + * + * @return features supported by this service + */ + virtual const int getCapabilities() const = 0; const Type getType() const { return (TYPE_STORE); }