From 5915ca4e34d2192cb3ef06c8f47aaa4b16cf7f53 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 14 Nov 2013 23:17:40 +0100 Subject: Custom fetch attributes. --- src/net/imap/IMAPUtils.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/net/imap/IMAPUtils.cpp') 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 cnt, const messageSet& msgs, const int options) + (ref 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 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 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 customHeaderFields = options.getHeaderFields(); + std::copy(customHeaderFields.begin(), customHeaderFields.end(), std::back_inserter(headerFields)); + if (!headerFields.empty()) { string list; -- cgit