123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /*
- * @file IMAPClient.h
- * @brief libcurl wrapper for IMAP operations
- *
- * @author Mohamed Amine Mzoughi <mohamed-amine.mzoughi@laposte.net>
- * @date 2017-01-02
- *
- * Updated by acetone in 2023
- */
- #ifndef INCLUDE_IMAPCLIENT_H_
- #define INCLUDE_IMAPCLIENT_H_
- #include "MAILClient.h"
- class CIMAPClient : public CMailClient
- {
- public:
- enum class MailProperty
- {
- Deleted,
- Seen,
- Answered,
- Flagged,
- Draft,
- Recent
- };
- enum class SearchOption
- {
- ANSWERED,
- DELETED,
- DRAFT,
- FLAGGED,
- NEW,
- RECENT,
- SEEN,
- UNSEEN
- };
- explicit CIMAPClient(LogFnCallback oLogger);
- // copy constructor and assignment operator are disabled
- CIMAPClient(const CIMAPClient& Copy) = delete;
- CIMAPClient& operator=(const CIMAPClient& Copy) = delete;
- bool CleanupSession() override;
- /* list the folders within a mailbox and save it in strList */
- bool List(std::string& strList, const std::string& strFolderName = "");
- /* list the subscribed folders and save it in strList */
- bool ListSubFolders(std::string& strList);
- /* send a string as an e-mail */
- bool SendString(const std::string& strMail);
- /* send a text file as an e-mail */
- bool SendFile(const std::string& strPath);
- /* retrieve e-mail and save its content in strOutput */
- bool GetString(const std::string& strMsgNumber, std::string& strOutput);
- /* retrieve e-mail and save its content in a file */
- bool GetFile(const std::string& strMsgNumber, const std::string& strFilePath);
- /* delete an existing folder */
- bool DeleteFolder(const std::string& strMsgNumber);
- /* perform a noop */
- bool Noop();
- /* copy an e-mail from one folder to another */
- bool CopyMail(const std::string& strMsgNumber, const std::string& strFolder);
- /* create a new folder */
- bool CreateFolder(const std::string& strFolderName);
- /* modify the properties of an e-mail according to MailProperty */
- bool SetMailProperty(const std::string& strMsgNumber, MailProperty eNewProperty);
-
- /* search for e-mails according to SearchOption */
- bool Search(std::string& strRes, SearchOption eSearchOption = SearchOption::NEW);
-
- /* obtain information about a folder */
- bool InfoFolder(std::string& strFolderName, std::string& strInfo);
- protected:
- enum MailOperation
- {
- IMAP_NOOP,
- IMAP_LIST,
- IMAP_SEND_STRING,
- IMAP_SEND_FILE,
- IMAP_RETR_FILE,
- IMAP_RETR_STRING,
- IMAP_DELETE_FOLDER,
- IMAP_INFO_FOLDER,
- IMAP_LSUB,
- IMAP_COPY,
- IMAP_CREATE,
- IMAP_SEARCH,
- IMAP_STORE
- };
- bool PrePerform() override;
- bool PostPerform(CURLcode ePerformCode) override;
- inline void ParseURL(std::string& strURL) override final;
- MailOperation m_eOperationType;
- MailProperty m_eMailProperty;
- SearchOption m_eSearchOption;
- std::string m_strFrom;
- std::string m_strTo;
- std::string m_strCc;
- std::string m_strMail;
- std::string m_strMsgNumber;
- std::string m_strFolderName;
- std::string* m_pstrText;
- };
- #endif
|