17135c4f8SAxel Dörfler /* 2a9de7eceSAxel Dörfler * Copyright 2007-2013, 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 status_t FetchBody(const entry_ref& ref); 397135c4f8SAxel Dörfler status_t DeleteMessage(const entry_ref& ref); 407135c4f8SAxel Dörfler 41*d6ce6060SAxel Dörfler status_t Retrieve(int32 message, BPositionIO* to); 42*d6ce6060SAxel Dörfler status_t GetHeader(int32 message, BPositionIO* to); 43*d6ce6060SAxel Dörfler void Delete(int32 index); 447135c4f8SAxel Dörfler 457135c4f8SAxel Dörfler protected: 467135c4f8SAxel Dörfler // pop3 methods 477135c4f8SAxel Dörfler status_t Open(const char* server, int port, 487135c4f8SAxel Dörfler int protocol); 497135c4f8SAxel Dörfler status_t Login(const char* uid, const char* password, 507135c4f8SAxel Dörfler int method); 517135c4f8SAxel Dörfler 527135c4f8SAxel Dörfler size_t MessageSize(int32 index); 537135c4f8SAxel Dörfler status_t Stat(); 547135c4f8SAxel Dörfler int32 Messages(void); 557135c4f8SAxel Dörfler size_t MailDropSize(void); 567135c4f8SAxel Dörfler void CheckForDeletedMessages(); 577135c4f8SAxel Dörfler 587135c4f8SAxel Dörfler status_t RetrieveInternal(const char* command, 59*d6ce6060SAxel Dörfler int32 message, BPositionIO* to, 607135c4f8SAxel Dörfler bool showProgress); 617135c4f8SAxel Dörfler 62a9de7eceSAxel Dörfler ssize_t ReceiveLine(BString& line); 637135c4f8SAxel Dörfler status_t SendCommand(const char* cmd); 647135c4f8SAxel Dörfler void MD5Digest(unsigned char* in, char* out); 657135c4f8SAxel Dörfler 667135c4f8SAxel Dörfler private: 677135c4f8SAxel Dörfler status_t _RetrieveUniqueIDs(); 687135c4f8SAxel Dörfler void _ReadManifest(); 697135c4f8SAxel Dörfler void _WriteManifest(); 707135c4f8SAxel Dörfler 717135c4f8SAxel Dörfler private: 727135c4f8SAxel Dörfler BString fLog; 737135c4f8SAxel Dörfler int32 fNumMessages; 747135c4f8SAxel Dörfler size_t fMailDropSize; 757135c4f8SAxel Dörfler BList fSizes; 76a9de7eceSAxel Dörfler off_t fTotalSize; 777135c4f8SAxel Dörfler BMessage fSettings; 787135c4f8SAxel Dörfler 797135c4f8SAxel Dörfler BStringList fManifest; 807135c4f8SAxel Dörfler BStringList fUniqueIDs; 817135c4f8SAxel Dörfler 827135c4f8SAxel Dörfler BString fDestinationDir; 837135c4f8SAxel Dörfler int32 fFetchBodyLimit; 847135c4f8SAxel Dörfler 857135c4f8SAxel Dörfler BSocket* fServerConnection; 867135c4f8SAxel Dörfler bool fUseSSL; 877135c4f8SAxel Dörfler }; 887135c4f8SAxel Dörfler 897135c4f8SAxel Dörfler 90715bf3d1SAxel Dörfler extern "C" status_t pop3_smtp_auth(const BMailAccountSettings& settings); 917135c4f8SAxel Dörfler 927135c4f8SAxel Dörfler 937135c4f8SAxel Dörfler #endif /* POP3_H */ 94