1 /* 2 * Copyright 2013, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef IMAP_PROTOCOL_H 6 #define IMAP_PROTOCOL_H 7 8 9 #include <map> 10 11 #include <MailProtocol.h> 12 #include <ObjectList.h> 13 14 #include "Settings.h" 15 16 17 class IMAPConnectionWorker; 18 class IMAPFolder; 19 namespace IMAP { 20 class Protocol; 21 } 22 23 24 typedef std::map<BString, IMAPFolder*> FolderMap; 25 26 27 class IMAPProtocol : public BInboundMailProtocol { 28 public: 29 IMAPProtocol( 30 const BMailAccountSettings& settings); 31 virtual ~IMAPProtocol(); 32 33 status_t CheckSubscribedFolders( 34 IMAP::Protocol& protocol, bool idle); 35 void WorkerQuit(IMAPConnectionWorker* worker); 36 37 void MessageStored(IMAPFolder& folder, 38 entry_ref& ref, BFile& stream, 39 uint32 fetchFlags, BMessage& attributes); 40 41 virtual status_t SyncMessages(); 42 virtual status_t FetchBody(const entry_ref& ref); 43 virtual status_t MarkMessageAsRead(const entry_ref& ref, 44 read_flags flags = B_READ); 45 virtual status_t DeleteMessage(const entry_ref& ref); 46 virtual status_t AppendMessage(const entry_ref& ref); 47 48 virtual void MessageReceived(BMessage* message); 49 50 protected: 51 void ReadyToRun(); 52 53 private: 54 IMAPFolder* _CreateFolder(const BString& mailbox, 55 const BString& separator); 56 status_t _EnqueueCheckMailboxes(); 57 58 protected: 59 Settings fSettings; 60 BObjectList<IMAPConnectionWorker> fWorkers; 61 FolderMap fFolders; 62 }; 63 64 65 #endif // IMAP_PROTOCOL_H 66