// Copyright (c) 2010 Martin Knafve / hMailServer.com. // http://www.hmailserver.com #pragma once #include "IMAPCommand.h" #include "IMAPSearchParser.h" namespace HM { class IMAPSearchParser; class IMAPConnection; class MessageData; class MimeHeader; class IMAPCommandSEARCH : public IMAPCommand { public: IMAPCommandSEARCH(bool bIsSort); virtual ~IMAPCommandSEARCH(); void SetIsUID() { is_uid_ = true; } IMAPResult ExecuteCommand(std::shared_ptr pConnection, std::shared_ptr pArgument); private: bool MatchesHeaderCriteria_(const String &fileName,std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesUIDCriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSequenceSetCriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria, int index); bool MatchesTEXTCriteria_(const String &fileName, std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesBODYCriteria_(const String &fileName, std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesONCriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSENTONCriteria_(const String &fileName, std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSENTBEFORECriteria_(const String &fileName, std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSENTSINCECriteria_(const String &fileName, std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSINCECriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesBEFORECriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesLARGERCriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); bool MatchesSMALLERCriteria_(std::shared_ptr pMessage, std::shared_ptr pCriteria); String GetHeaderValue_(const String &fileName, std::shared_ptr pMessage, const String &sHeaderField); bool DoesMessageMatch_(std::shared_ptr pConnection, std::shared_ptr pParentCriteria, const String &fileName, std::shared_ptr pMessage, int index); bool IsMessageRecent_(std::shared_ptr pConnection, __int64 message_uid); std::shared_ptr message_data_; std::shared_ptr mime_header_; bool is_sort_; bool is_uid_; }; }