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() { }
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 <vmime::message> 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;

View File

@ -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 << ' ';

View File

@ -107,14 +107,14 @@ public:
messageSet addMessage
(shared_ptr <vmime::message> 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);

View File

@ -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

View File

@ -102,8 +102,8 @@ public:
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(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 <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 = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
messageSet copyMessages(const folder::path& dest, const messageSet& msgs);

View File

@ -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.

View File

@ -99,8 +99,8 @@ public:
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(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 <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 = -1, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
messageSet copyMessages(const folder::path& dest, const messageSet& msgs);