Do not expose internal constants.

This commit is contained in:
Vincent Richard 2013-12-31 11:49:28 +01:00
parent e13a9d19bc
commit 1791e5114a
7 changed files with 34 additions and 28 deletions

View File

@ -65,6 +65,15 @@ protected:
folder(const folder&) : object() { } folder(const folder&) : object() { }
folder() { } 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: public:
virtual ~folder() { } virtual ~folder() { }
@ -87,10 +96,7 @@ public:
enum Types enum Types
{ {
TYPE_CONTAINS_FOLDERS = (1 << 0), /**< Folder can contain folders. */ TYPE_CONTAINS_FOLDERS = (1 << 0), /**< Folder can contain folders. */
TYPE_CONTAINS_MESSAGES = (1 << 1), /**< Folder can contain messages. */ TYPE_CONTAINS_MESSAGES = (1 << 1) /**< Folder can contain messages. */
TYPE_UNDEFINED = 9999 /**< Used internally (this should not be returned
by the type() function). */
}; };
/** Folder flags. /** Folder flags.
@ -98,10 +104,7 @@ public:
enum Flags enum Flags
{ {
FLAG_HAS_CHILDREN = (1 << 0), /**< Folder contains subfolders. */ FLAG_HAS_CHILDREN = (1 << 0), /**< Folder contains subfolders. */
FLAG_NO_OPEN = (1 << 1), /**< Folder cannot be open. */ FLAG_NO_OPEN = (1 << 1) /**< Folder cannot be open. */
FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned
by the type() function). */
}; };
/** Return the type of this folder. /** Return the type of this folder.
@ -266,7 +269,7 @@ public:
/** Add a message to this folder. /** Add a message to this folder.
* *
* @param msg message to add (data: header + body) * @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 date date/time for the new message (if NULL, the current time is used)
* @param progress progress listener, or NULL if not used * @param progress progress listener, or NULL if not used
* @return a message set containing the number or UID of the new message, or * @return a message set containing the number or UID of the new message, or
@ -276,7 +279,7 @@ public:
*/ */
virtual messageSet addMessage virtual messageSet addMessage
(shared_ptr <vmime::message> msg, (shared_ptr <vmime::message> msg,
const int flags = message::FLAG_UNDEFINED, const int flags = -1,
vmime::datetime* date = NULL, vmime::datetime* date = NULL,
utility::progressListener* progress = NULL) = 0; utility::progressListener* progress = NULL) = 0;
@ -284,7 +287,7 @@ public:
* *
* @param is message to add (data: header + body) * @param is message to add (data: header + body)
* @param size size of the message to add (in bytes) * @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 date date/time for the new message (if NULL, the current time is used)
* @param progress progress listener, or NULL if not used * @param progress progress listener, or NULL if not used
* @return a message set containing the number or UID of the new message, or * @return a message set containing the number or UID of the new message, or
@ -295,7 +298,7 @@ public:
virtual messageSet addMessage virtual messageSet addMessage
(utility::inputStream& is, (utility::inputStream& is,
const size_t size, const size_t size,
const int flags = message::FLAG_UNDEFINED, const int flags = -1,
vmime::datetime* date = NULL, vmime::datetime* date = NULL,
utility::progressListener* progress = NULL) = 0; utility::progressListener* progress = NULL) = 0;

View File

@ -1028,7 +1028,7 @@ messageSet IMAPFolder::addMessage
const string flagList = IMAPUtils::messageFlagList(flags); const string flagList = IMAPUtils::messageFlagList(flags);
if (flags != message::FLAG_UNDEFINED && !flagList.empty()) if (flags != -1 && !flagList.empty())
{ {
command << flagList; command << flagList;
command << ' '; command << ' ';

View File

@ -107,14 +107,14 @@ public:
messageSet addMessage messageSet addMessage
(shared_ptr <vmime::message> msg, (shared_ptr <vmime::message> msg,
const int flags = message::FLAG_UNDEFINED, const int flags = -1,
vmime::datetime* date = NULL, vmime::datetime* date = NULL,
utility::progressListener* progress = NULL); utility::progressListener* progress = NULL);
messageSet addMessage messageSet addMessage
(utility::inputStream& is, (utility::inputStream& is,
const size_t size, const size_t size,
const int flags = message::FLAG_UNDEFINED, const int flags = -1,
vmime::datetime* date = NULL, vmime::datetime* date = NULL,
utility::progressListener* progress = NULL); utility::progressListener* progress = NULL);

View File

@ -647,7 +647,7 @@ void maildirFolder::setMessageFlags
m_messages.begin() ; it != m_messages.end() ; ++it) m_messages.begin() ; it != m_messages.end() ; ++it)
{ {
if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && 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; (*it)->m_flags |= flags;
} }
@ -661,7 +661,7 @@ void maildirFolder::setMessageFlags
m_messages.begin() ; it != m_messages.end() ; ++it) m_messages.begin() ; it != m_messages.end() ; ++it)
{ {
if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && 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; (*it)->m_flags &= ~flags;
} }
@ -676,7 +676,7 @@ void maildirFolder::setMessageFlags
m_messages.begin() ; it != m_messages.end() ; ++it) m_messages.begin() ; it != m_messages.end() ; ++it)
{ {
if (std::binary_search(nums.begin(), nums.end(), (*it)->getNumber()) && 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; (*it)->m_flags = flags;
} }
@ -745,7 +745,7 @@ messageSet maildirFolder::addMessage
const utility::file::path::component filename = const utility::file::path::component filename =
maildirUtils::buildFilename(maildirUtils::generateId(), maildirUtils::buildFilename(maildirUtils::generateId(),
((flags == message::FLAG_UNDEFINED) ? 0 : flags)); ((flags == -1) ? 0 : flags));
try try
{ {
@ -778,7 +778,7 @@ messageSet maildirFolder::addMessage
m_messageInfos.push_back(msgInfos); m_messageInfos.push_back(msgInfos);
m_messageCount++; m_messageCount++;
if ((flags == message::FLAG_UNDEFINED) || !(flags & message::FLAG_SEEN)) if ((flags == -1) || !(flags & message::FLAG_SEEN))
m_unreadMessageCount++; m_unreadMessageCount++;
// Notification // Notification

View File

@ -102,8 +102,8 @@ public:
void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
messageSet addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); messageSet addMessage(shared_ptr <vmime::message> 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 = message::FLAG_UNDEFINED, 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); messageSet copyMessages(const folder::path& dest, const messageSet& msgs);

View File

@ -171,6 +171,12 @@ protected:
message() { } message() { }
message(const message&) : object() { } message(const message&) : object() { }
enum PrivateConstants
{
FLAG_UNDEFINED = 9999 /**< Used internally to indicate flags have not
been initialized yet. */
};
public: public:
virtual ~message() { } virtual ~message() { }
@ -257,10 +263,7 @@ public:
FLAG_REPLIED = (1 << 3), /**< User replied to this message. */ FLAG_REPLIED = (1 << 3), /**< User replied to this message. */
FLAG_MARKED = (1 << 4), /**< Used-defined flag. */ FLAG_MARKED = (1 << 4), /**< Used-defined flag. */
FLAG_PASSED = (1 << 5), /**< Message has been resent/forwarded/bounced. */ FLAG_PASSED = (1 << 5), /**< Message has been resent/forwarded/bounced. */
FLAG_DRAFT = (1 << 6), /**< Message is marked as a 'draft'. */ FLAG_DRAFT = (1 << 6) /**< Message is marked as a 'draft'. */
FLAG_UNDEFINED = 9999 /**< Used internally (this should not be returned
by the flags() function). */
}; };
/** Methods for setting the flags. /** Methods for setting the flags.

View File

@ -99,8 +99,8 @@ public:
void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
messageSet addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL); messageSet addMessage(shared_ptr <vmime::message> 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 = message::FLAG_UNDEFINED, 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); messageSet copyMessages(const folder::path& dest, const messageSet& msgs);