diff options
Diffstat (limited to 'src/net/imap')
-rw-r--r-- | src/net/imap/IMAPFolder.cpp | 11 | ||||
-rw-r--r-- | src/net/imap/IMAPMessage.cpp | 9 | ||||
-rw-r--r-- | src/net/imap/IMAPUtils.cpp | 22 |
3 files changed, 24 insertions, 18 deletions
diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp index 94d7ab13..3a3615e6 100644 --- a/src/net/imap/IMAPFolder.cpp +++ b/src/net/imap/IMAPFolder.cpp @@ -751,7 +751,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive) } -void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const int options, +void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options, utility::progressListener* progress) { ref <IMAPStore> store = m_store.acquire(); @@ -845,7 +845,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const int opti } -void IMAPFolder::fetchMessage(ref <message> msg, const int options) +void IMAPFolder::fetchMessage(ref <message> msg, const fetchAttributes& options) { std::vector <ref <message> > msgs; msgs.push_back(msg); @@ -856,9 +856,10 @@ void IMAPFolder::fetchMessage(ref <message> msg, const int options) int IMAPFolder::getFetchCapabilities() const { - return (FETCH_ENVELOPE | FETCH_CONTENT_INFO | FETCH_STRUCTURE | - FETCH_FLAGS | FETCH_SIZE | FETCH_FULL_HEADER | FETCH_UID | - FETCH_IMPORTANCE); + return fetchAttributes::ENVELOPE | fetchAttributes::CONTENT_INFO | + fetchAttributes::STRUCTURE | fetchAttributes::FLAGS | + fetchAttributes::SIZE | fetchAttributes::FULL_HEADER | + fetchAttributes::UID | fetchAttributes::IMPORTANCE; } diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp index 33599689..d512e752 100644 --- a/src/net/imap/IMAPMessage.cpp +++ b/src/net/imap/IMAPMessage.cpp @@ -366,7 +366,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream& int IMAPMessage::processFetchResponse - (const int options, const IMAPParser::message_data* msgData) + (const fetchAttributes& options, const IMAPParser::message_data* msgData) { ref <IMAPFolder> folder = m_folder.acquire(); @@ -403,7 +403,7 @@ int IMAPMessage::processFetchResponse } case IMAPParser::msg_att_item::ENVELOPE: { - if (!(options & folder::FETCH_FULL_HEADER)) + if (!options.has(fetchAttributes::FULL_HEADER)) { const IMAPParser::envelope* env = (*it)->envelope(); ref <vmime::header> hdr = getOrCreateHeader(); @@ -478,7 +478,7 @@ int IMAPMessage::processFetchResponse } case IMAPParser::msg_att_item::BODY_SECTION: { - if (!(options & folder::FETCH_FULL_HEADER)) + if (!options.has(fetchAttributes::FULL_HEADER)) { if ((*it)->section()->section_text1() && (*it)->section()->section_text1()->type() @@ -599,7 +599,8 @@ ref <vmime::message> IMAPMessage::getParsedMessage() std::vector <ref <message> > msgs; msgs.push_back(thisRef().dynamicCast <IMAPMessage>()); - m_folder.acquire()->fetchMessages(msgs, IMAPFolder::FETCH_STRUCTURE, /* progress */ NULL); + m_folder.acquire()->fetchMessages + (msgs, fetchAttributes(fetchAttributes::STRUCTURE), /* progress */ NULL); structure = getStructure(); } diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp index 13373012..caaf6575 100644 --- a/src/net/imap/IMAPUtils.cpp +++ b/src/net/imap/IMAPUtils.cpp @@ -544,7 +544,7 @@ const string IMAPUtils::dateTime(const vmime::datetime& date) // static const string IMAPUtils::buildFetchRequest - (ref <IMAPConnection> cnt, const messageSet& msgs, const int options) + (ref <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options) { // Example: // C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) @@ -555,16 +555,16 @@ const string IMAPUtils::buildFetchRequest std::vector <string> items; - if (options & folder::FETCH_SIZE) + if (options.has(fetchAttributes::SIZE)) items.push_back("RFC822.SIZE"); - if (options & folder::FETCH_FLAGS) + if (options.has(fetchAttributes::FLAGS)) items.push_back("FLAGS"); - if (options & folder::FETCH_STRUCTURE) + if (options.has(fetchAttributes::STRUCTURE)) items.push_back("BODYSTRUCTURE"); - if (options & folder::FETCH_UID) + if (options.has(fetchAttributes::UID)) { items.push_back("UID"); @@ -573,24 +573,28 @@ const string IMAPUtils::buildFetchRequest items.push_back("MODSEQ"); } - if (options & folder::FETCH_FULL_HEADER) + if (options.has(fetchAttributes::FULL_HEADER)) items.push_back("RFC822.HEADER"); else { - if (options & folder::FETCH_ENVELOPE) + if (options.has(fetchAttributes::ENVELOPE)) items.push_back("ENVELOPE"); std::vector <string> headerFields; - if (options & folder::FETCH_CONTENT_INFO) + if (options.has(fetchAttributes::CONTENT_INFO)) headerFields.push_back("CONTENT_TYPE"); - if (options & folder::FETCH_IMPORTANCE) + if (options.has(fetchAttributes::IMPORTANCE)) { headerFields.push_back("IMPORTANCE"); headerFields.push_back("X-PRIORITY"); } + // Also add custom header fields to fetch, if any + const std::vector <string> customHeaderFields = options.getHeaderFields(); + std::copy(customHeaderFields.begin(), customHeaderFields.end(), std::back_inserter(headerFields)); + if (!headerFields.empty()) { string list; |