From a0d02afc6961a6ac7631666abf497d2d67a4ecb1 Mon Sep 17 00:00:00 2001 From: Jacek Piszczek Date: Wed, 24 Mar 2021 12:27:47 -0400 Subject: [PATCH] IMAP PEEK support --- src/vmime/net/fetchAttributes.hpp | 1 + src/vmime/net/imap/IMAPFolder.cpp | 3 ++- src/vmime/net/imap/IMAPUtils.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vmime/net/fetchAttributes.hpp b/src/vmime/net/fetchAttributes.hpp index 19d92627..1a32116b 100644 --- a/src/vmime/net/fetchAttributes.hpp +++ b/src/vmime/net/fetchAttributes.hpp @@ -57,6 +57,7 @@ public: FULL_HEADER = (1 << 5), /**< Full RFC-[2]822 header. */ UID = (1 << 6), /**< Unique identifier (protocol specific). */ IMPORTANCE = (1 << 7), /**< Header fields suitable for use with misc::importanceHelper. */ + PEEK = (1 << 8), /**< Use IMAP PEEK method when accessing HEADER fields. */ CUSTOM = (1 << 16) /**< Reserved for future use. */ }; diff --git a/src/vmime/net/imap/IMAPFolder.cpp b/src/vmime/net/imap/IMAPFolder.cpp index 98bc05d8..3a33469a 100644 --- a/src/vmime/net/imap/IMAPFolder.cpp +++ b/src/vmime/net/imap/IMAPFolder.cpp @@ -964,7 +964,8 @@ int IMAPFolder::getFetchCapabilities() const { return fetchAttributes::ENVELOPE | fetchAttributes::CONTENT_INFO | fetchAttributes::STRUCTURE | fetchAttributes::FLAGS | fetchAttributes::SIZE | fetchAttributes::FULL_HEADER | - fetchAttributes::UID | fetchAttributes::IMPORTANCE; + fetchAttributes::UID | fetchAttributes::IMPORTANCE | + fetchAttributes::PEEK; } diff --git a/src/vmime/net/imap/IMAPUtils.cpp b/src/vmime/net/imap/IMAPUtils.cpp index 59b1e181..8c055356 100644 --- a/src/vmime/net/imap/IMAPUtils.cpp +++ b/src/vmime/net/imap/IMAPUtils.cpp @@ -691,7 +691,11 @@ shared_ptr IMAPUtils::buildFetchCommand( list += *it; } - items.push_back("BODY[HEADER.FIELDS (" + list + ")]"); + if (options.has(fetchAttributes::PEEK)) { + items.push_back("BODY.PEEK[HEADER.FIELDS (" + list + ")]"); + } else { + items.push_back("BODY[HEADER.FIELDS (" + list + ")]"); + } } }