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 477135c4f8SAxel Dörfler // pop3 methods 487135c4f8SAxel Dörfler status_t Open(const char* server, int port, 497135c4f8SAxel Dörfler int protocol); 507135c4f8SAxel Dörfler status_t Login(const char* uid, const char* password, 517135c4f8SAxel Dörfler int method); 527135c4f8SAxel Dörfler 537135c4f8SAxel Dörfler size_t MessageSize(int32 index); 547135c4f8SAxel Dörfler status_t Stat(); 557135c4f8SAxel Dörfler int32 Messages(void); 567135c4f8SAxel Dörfler size_t MailDropSize(void); 577135c4f8SAxel Dörfler void CheckForDeletedMessages(); 587135c4f8SAxel Dörfler 597135c4f8SAxel Dörfler status_t RetrieveInternal(const char* command, 60d6ce6060SAxel Dörfler int32 message, BPositionIO* to, 617135c4f8SAxel Dörfler bool showProgress); 627135c4f8SAxel Dörfler 63a9de7eceSAxel Dörfler ssize_t ReceiveLine(BString& line); 647135c4f8SAxel Dörfler status_t SendCommand(const char* cmd); 657135c4f8SAxel Dörfler void MD5Digest(unsigned char* in, char* out); 667135c4f8SAxel Dörfler 677135c4f8SAxel Dörfler private: 687135c4f8SAxel Dörfler status_t _RetrieveUniqueIDs(); 697135c4f8SAxel Dörfler void _ReadManifest(); 707135c4f8SAxel Dörfler void _WriteManifest(); 717135c4f8SAxel Dörfler 727135c4f8SAxel Dörfler private: 737135c4f8SAxel Dörfler BString fLog; 747135c4f8SAxel Dörfler int32 fNumMessages; 757135c4f8SAxel Dörfler size_t fMailDropSize; 76b9962ceaSJérôme Duval std::vector<size_t> fSizes; 77a9de7eceSAxel Dörfler off_t fTotalSize; 787135c4f8SAxel Dörfler BMessage fSettings; 797135c4f8SAxel Dörfler 807135c4f8SAxel Dörfler BStringList fManifest; 817135c4f8SAxel Dörfler BStringList fUniqueIDs; 827135c4f8SAxel Dörfler 837135c4f8SAxel Dörfler BString fDestinationDir; 847135c4f8SAxel Dörfler int32 fFetchBodyLimit; 857135c4f8SAxel Dörfler 867135c4f8SAxel Dörfler BSocket* fServerConnection; 877135c4f8SAxel Dörfler bool fUseSSL; 887135c4f8SAxel Dörfler }; 897135c4f8SAxel Dörfler 907135c4f8SAxel Dörfler 91715bf3d1SAxel Dörfler extern "C" status_t pop3_smtp_auth(const BMailAccountSettings& settings); 927135c4f8SAxel Dörfler 937135c4f8SAxel Dörfler 947135c4f8SAxel Dörfler #endif /* POP3_H */ 95