xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/pop3/POP3.h (revision 8180539313400693e1cf17a9059f8212c7d7b010)
17135c4f8SAxel Dörfler /*
2*81805393SAxel Dörfler  * Copyright 2007-2016, Haiku Inc. All Rights Reserved.
37135c4f8SAxel Dörfler  * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
47135c4f8SAxel Dörfler  * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
57135c4f8SAxel Dörfler  *
67135c4f8SAxel Dörfler  * Distributed under the terms of the MIT License.
77135c4f8SAxel Dörfler  */
87135c4f8SAxel Dörfler #ifndef POP3_H
97135c4f8SAxel Dörfler #define POP3_H
107135c4f8SAxel Dörfler 
117135c4f8SAxel Dörfler 
127135c4f8SAxel Dörfler #include <map>
137135c4f8SAxel Dörfler #include <vector>
147135c4f8SAxel Dörfler 
157135c4f8SAxel Dörfler #include <DataIO.h>
167135c4f8SAxel Dörfler #include <List.h>
177135c4f8SAxel Dörfler #include <String.h>
18715bf3d1SAxel Dörfler #include <StringList.h>
197135c4f8SAxel Dörfler #include <View.h>
207135c4f8SAxel Dörfler 
21715bf3d1SAxel Dörfler #include <MailProtocol.h>
22715bf3d1SAxel Dörfler #include <MailSettings.h>
237135c4f8SAxel Dörfler 
247135c4f8SAxel Dörfler 
257135c4f8SAxel Dörfler class BSocket;
267135c4f8SAxel Dörfler 
277135c4f8SAxel Dörfler 
28715bf3d1SAxel Dörfler class POP3Protocol : public BInboundMailProtocol {
297135c4f8SAxel Dörfler public:
30715bf3d1SAxel Dörfler 								POP3Protocol(
31715bf3d1SAxel Dörfler 									const BMailAccountSettings& settings);
327135c4f8SAxel Dörfler 								~POP3Protocol();
337135c4f8SAxel Dörfler 
347135c4f8SAxel Dörfler 			status_t			Connect();
357135c4f8SAxel Dörfler 			status_t			Disconnect();
367135c4f8SAxel Dörfler 
377135c4f8SAxel Dörfler 			status_t			SyncMessages();
387135c4f8SAxel Dörfler 
39d6ce6060SAxel Dörfler 			status_t			Retrieve(int32 message, BPositionIO* to);
40d6ce6060SAxel Dörfler 			status_t			GetHeader(int32 message, BPositionIO* to);
41d6ce6060SAxel Dörfler 			void				Delete(int32 index);
427135c4f8SAxel Dörfler 
437135c4f8SAxel Dörfler protected:
44*81805393SAxel Dörfler 	virtual	status_t			HandleFetchBody(const entry_ref& ref,
45*81805393SAxel Dörfler 									const BMessenger& replyTo);
46*81805393SAxel Dörfler 	virtual	status_t			HandleDeleteMessage(const entry_ref& ref);
47*81805393SAxel Dörfler 
487135c4f8SAxel Dörfler 			// pop3 methods
497135c4f8SAxel Dörfler 			status_t			Open(const char* server, int port,
507135c4f8SAxel Dörfler 									int protocol);
517135c4f8SAxel Dörfler 			status_t			Login(const char* uid, const char* password,
527135c4f8SAxel Dörfler 									int method);
537135c4f8SAxel Dörfler 
547135c4f8SAxel Dörfler 			size_t				MessageSize(int32 index);
557135c4f8SAxel Dörfler 			status_t			Stat();
567135c4f8SAxel Dörfler 			int32				Messages(void);
577135c4f8SAxel Dörfler 			size_t				MailDropSize(void);
587135c4f8SAxel Dörfler 			void				CheckForDeletedMessages();
597135c4f8SAxel Dörfler 
607135c4f8SAxel Dörfler 			status_t			RetrieveInternal(const char* command,
61d6ce6060SAxel Dörfler 									int32 message, BPositionIO* to,
627135c4f8SAxel Dörfler 									bool showProgress);
637135c4f8SAxel Dörfler 
64a9de7eceSAxel Dörfler 			ssize_t				ReceiveLine(BString& line);
657135c4f8SAxel Dörfler 			status_t			SendCommand(const char* cmd);
667135c4f8SAxel Dörfler 			void				MD5Digest(unsigned char* in, char* out);
677135c4f8SAxel Dörfler 
687135c4f8SAxel Dörfler private:
697135c4f8SAxel Dörfler 			status_t			_RetrieveUniqueIDs();
707135c4f8SAxel Dörfler 			void				_ReadManifest();
717135c4f8SAxel Dörfler 			void				_WriteManifest();
727135c4f8SAxel Dörfler 
737135c4f8SAxel Dörfler private:
747135c4f8SAxel Dörfler 			BString				fLog;
757135c4f8SAxel Dörfler 			int32				fNumMessages;
767135c4f8SAxel Dörfler 			size_t				fMailDropSize;
77b9962ceaSJérôme Duval 			std::vector<size_t>	fSizes;
78a9de7eceSAxel Dörfler 			off_t				fTotalSize;
797135c4f8SAxel Dörfler 			BMessage			fSettings;
807135c4f8SAxel Dörfler 
817135c4f8SAxel Dörfler 			BStringList			fManifest;
827135c4f8SAxel Dörfler 			BStringList			fUniqueIDs;
837135c4f8SAxel Dörfler 
847135c4f8SAxel Dörfler 			BString				fDestinationDir;
857135c4f8SAxel Dörfler 			int32				fFetchBodyLimit;
867135c4f8SAxel Dörfler 
877135c4f8SAxel Dörfler 			BSocket*			fServerConnection;
887135c4f8SAxel Dörfler 			bool				fUseSSL;
897135c4f8SAxel Dörfler };
907135c4f8SAxel Dörfler 
917135c4f8SAxel Dörfler 
92715bf3d1SAxel Dörfler extern "C" status_t pop3_smtp_auth(const BMailAccountSettings& settings);
937135c4f8SAxel Dörfler 
947135c4f8SAxel Dörfler 
957135c4f8SAxel Dörfler #endif	/* POP3_H */
96