xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPConnectionWorker.h (revision adbe8fc944d2568ba87d7603e921115830ef1416)
1 /*
2  * Copyright 2011-2013, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef IMAP_CONNECTION_WORKER_H
6 #define IMAP_CONNECTION_WORKER_H
7 
8 
9 #include <Locker.h>
10 #include <String.h>
11 
12 #include "Protocol.h"
13 
14 
15 class IMAPProtocol;
16 class Settings;
17 
18 
19 class IMAPConnectionWorker {
20 public:
21 								IMAPConnectionWorker(IMAPProtocol& owner,
22 									const Settings& settings,
23 									bool main = false);
24 	virtual						~IMAPConnectionWorker();
25 
26 			uint32				CountMailboxes() const;
27 			void				AddMailbox(const BString& name);
28 			void				RemoveMailbox(const BString& name);
29 
30 			bool				IsMain() const { return fMain; }
31 
32 			status_t			Start();
33 			void				Stop();
34 
35 private:
36 			status_t			_Worker();
37 	static	status_t			_Worker(void* self);
38 
39 private:
40 			IMAPProtocol&		fOwner;
41 			const Settings&		fSettings;
42 			IMAP::Protocol		fProtocol;
43 			BString				fIdleBox;
44 			StringList			fOtherBoxes;
45 
46 			BLocker				fLocker;
47 			thread_id			fThread;
48 			bool				fMain;
49 			bool				fStopped;
50 };
51 
52 
53 #endif	// IMAP_CONNECTION_WORKER_H
54