From 1791e5114a30006bb4f728a51ca1cd705ed851ea Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 31 Dec 2013 11:49:28 +0100 Subject: [PATCH] Do not expose internal constants. --- src/vmime/net/folder.hpp | 27 ++++++++++++++----------- src/vmime/net/imap/IMAPFolder.cpp | 2 +- src/vmime/net/imap/IMAPFolder.hpp | 4 ++-- src/vmime/net/maildir/maildirFolder.cpp | 10 ++++----- src/vmime/net/maildir/maildirFolder.hpp | 4 ++-- src/vmime/net/message.hpp | 11 ++++++---- src/vmime/net/pop3/POP3Folder.hpp | 4 ++-- 7 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/vmime/net/folder.hpp b/src/vmime/net/folder.hpp index 3a0781f5..2db89f4b 100644 --- a/src/vmime/net/folder.hpp +++ b/src/vmime/net/folder.hpp @@ -65,6 +65,15 @@ protected: folder(const folder&) : object() { } folder() { } + + enum PrivateConstants + { + TYPE_UNDEFINED = 9999, /**< Used internally to indicate type has not + been initialized yet. */ + FLAG_UNDEFINED = 9999 /**< Used internally to indicate flags have not + been initialized yet. */ + }; + public: virtual ~folder() { } @@ -87,10 +96,7 @@ public: enum Types { TYPE_CONTAINS_FOLDERS = (1 << 0), /**< Folder can contain folders. */ - TYPE_CONTAINS_MESSAGES = (1 << 1), /**< Folder can contain messages. */ - - TYPE_UNDEFINED = 9999 /**< Used internally (this should not be returned - by the type() function). */ + TYPE_CONTAINS_MESSAGES = (1 << 1) /**< Folder can contain messages. */ }; /** Folder flags. @@ -98,10 +104,7 @@ public: enum Flags { FLAG_HAS_CHILDREN = (1 << 0), /**< Folder contains subfolders. */ - FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */ - - FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned - by the type() function). */ + FLAG_NO_OPEN = (1 << 1) /**< Folder cannot be open. */ }; /** Return the type of this folder. @@ -266,7 +269,7 @@ public: /** Add a message to this folder. * * @param msg message to add (data: header + body) - * @param flags flags for the new message + * @param flags flags for the new message (if -1, default flags are used) * @param date date/time for the new message (if NULL, the current time is used) * @param progress progress listener, or NULL if not used * @return a message set containing the number or UID of the new message, or @@ -276,7 +279,7 @@ public: */ virtual messageSet addMessage (shared_ptr msg, - const int flags = message::FLAG_UNDEFINED, + const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; @@ -284,7 +287,7 @@ public: * * @param is message to add (data: header + body) * @param size size of the message to add (in bytes) - * @param flags flags for the new message + * @param flags flags for the new message (if -1, default flags are used) * @param date date/time for the new message (if NULL, the current time is used) * @param progress progress listener, or NULL if not used * @return a message set containing the number or UID of the new message, or @@ -295,7 +298,7 @@ public: virtual messageSet addMessage (utility::inputStream& is, const size_t size, - const int flags = message::FLAG_UNDEFINED, + const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0; diff --git a/src/vmime/net/imap/IMAPFolder.cpp b/src/vmime/net/imap/IMAPFolder.cpp index 83d3e924..97a4c2e2 100644 --- a/src/vmime/net/imap/IMAPFolder.cpp +++ b/src/vmime/net/imap/IMAPFolder.cpp @@ -1028,7 +1028,7 @@ messageSet IMAPFolder::addMessage const string flagList = IMAPUtils::messageFlagList(flags); - if (flags != message::FLAG_UNDEFINED && !flagList.empty()) + if (flags != -1 && !flagList.empty()) { command << flagList; command << ' '; diff --git a/src/vmime/net/imap/IMAPFolder.hpp b/src/vmime/net/imap/IMAPFolder.hpp index 8b31f10f..8d6f6278 100644 --- a/src/vmime/net/imap/IMAPFolder.hpp +++ b/src/vmime/net/imap/IMAPFolder.hpp @@ -107,14 +107,14 @@ public: messageSet addMessage (shared_ptr msg, - const int flags = message::FLAG_UNDEFINED, + const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); messageSet addMessage (utility::inputStream& is, const size_t size, - const int flags = message::FLAG_UNDEFINED, + const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); diff --git a/src/vmime/net/maildir/maildirFolder.cpp b/src/vmime/net/maildir/maildirFolder.cpp index 7bcbc04f..5d57f3e7 100644 --- a/src/vmime/net/maildir/maildirFolder.cpp +++ b/src/vmime/net/maildir/maildirFolder.cpp @@ -647,7 +647,7 @@ void maildirFolder::setMessageFlags m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && - (*it)->m_flags != message::FLAG_UNDEFINED) + (*it)->m_flags != maildirMessage::FLAG_UNDEFINED) { (*it)->m_flags |= flags; } @@ -661,7 +661,7 @@ void maildirFolder::setMessageFlags m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && - (*it)->m_flags != message::FLAG_UNDEFINED) + (*it)->m_flags != maildirMessage::FLAG_UNDEFINED) { (*it)->m_flags &= ~flags; } @@ -676,7 +676,7 @@ void maildirFolder::setMessageFlags m_messages.begin() ; it != m_messages.end() ; ++it) { if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && - (*it)->m_flags != message::FLAG_UNDEFINED) + (*it)->m_flags != maildirMessage::FLAG_UNDEFINED) { (*it)->m_flags = flags; } @@ -745,7 +745,7 @@ messageSet maildirFolder::addMessage const utility::file::path::component filename = maildirUtils::buildFilename(maildirUtils::generateId(), - ((flags == message::FLAG_UNDEFINED) ? 0 : flags)); + ((flags == -1) ? 0 : flags)); try { @@ -778,7 +778,7 @@ messageSet maildirFolder::addMessage m_messageInfos.push_back(msgInfos); m_messageCount++; - if ((flags == message::FLAG_UNDEFINED) || !(flags & message::FLAG_SEEN)) + if ((flags == -1) || !(flags & message::FLAG_SEEN)) m_unreadMessageCount++; // Notification diff --git a/src/vmime/net/maildir/maildirFolder.hpp b/src/vmime/net/maildir/maildirFolder.hpp index 8b2548ed..6563b86a 100644 --- a/src/vmime/net/maildir/maildirFolder.hpp +++ b/src/vmime/net/maildir/maildirFolder.hpp @@ -102,8 +102,8 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); - messageSet addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); - messageSet addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + messageSet addMessage(shared_ptr msg, const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + messageSet addMessage(utility::inputStream& is, const size_t size, const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); messageSet copyMessages(const folder::path& dest, const messageSet& msgs); diff --git a/src/vmime/net/message.hpp b/src/vmime/net/message.hpp index 5bb62c53..2a8eb30d 100644 --- a/src/vmime/net/message.hpp +++ b/src/vmime/net/message.hpp @@ -171,6 +171,12 @@ protected: message() { } message(const message&) : object() { } + enum PrivateConstants + { + FLAG_UNDEFINED = 9999 /**< Used internally to indicate flags have not + been initialized yet. */ + }; + public: virtual ~message() { } @@ -257,10 +263,7 @@ public: FLAG_REPLIED = (1 << 3), /**< User replied to this message. */ FLAG_MARKED = (1 << 4), /**< Used-defined flag. */ FLAG_PASSED = (1 << 5), /**< Message has been resent/forwarded/bounced. */ - FLAG_DRAFT = (1 << 6), /**< Message is marked as a 'draft'. */ - - FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned - by the flags() function). */ + FLAG_DRAFT = (1 << 6) /**< Message is marked as a 'draft'. */ }; /** Methods for setting the flags. diff --git a/src/vmime/net/pop3/POP3Folder.hpp b/src/vmime/net/pop3/POP3Folder.hpp index 7349e966..a4b30c18 100644 --- a/src/vmime/net/pop3/POP3Folder.hpp +++ b/src/vmime/net/pop3/POP3Folder.hpp @@ -99,8 +99,8 @@ public: void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); - messageSet addMessage(shared_ptr msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); - messageSet addMessage(utility::inputStream& is, const size_t size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + messageSet addMessage(shared_ptr msg, const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); + messageSet addMessage(utility::inputStream& is, const size_t size, const int flags = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); messageSet copyMessages(const folder::path& dest, const messageSet& msgs);