1 /* 2 * Copyright 2007-2013, Haiku Inc. All Rights Reserved. 3 * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved. 4 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de> 5 * 6 * Distributed under the terms of the MIT License. 7 */ 8 #ifndef POP3_H 9 #define POP3_H 10 11 12 #include <map> 13 #include <vector> 14 15 #include <DataIO.h> 16 #include <List.h> 17 #include <String.h> 18 #include <StringList.h> 19 #include <View.h> 20 21 #include <MailProtocol.h> 22 #include <MailSettings.h> 23 24 25 class BSocket; 26 27 28 class POP3Protocol : public BInboundMailProtocol { 29 public: 30 POP3Protocol( 31 const BMailAccountSettings& settings); 32 ~POP3Protocol(); 33 34 status_t Connect(); 35 status_t Disconnect(); 36 37 status_t SyncMessages(); 38 status_t FetchBody(const entry_ref& ref); 39 status_t DeleteMessage(const entry_ref& ref); 40 41 status_t Retrieve(int32 message, BPositionIO* to); 42 status_t GetHeader(int32 message, BPositionIO* to); 43 void Delete(int32 index); 44 45 protected: 46 // pop3 methods 47 status_t Open(const char* server, int port, 48 int protocol); 49 status_t Login(const char* uid, const char* password, 50 int method); 51 52 size_t MessageSize(int32 index); 53 status_t Stat(); 54 int32 Messages(void); 55 size_t MailDropSize(void); 56 void CheckForDeletedMessages(); 57 58 status_t RetrieveInternal(const char* command, 59 int32 message, BPositionIO* to, 60 bool showProgress); 61 62 ssize_t ReceiveLine(BString& line); 63 status_t SendCommand(const char* cmd); 64 void MD5Digest(unsigned char* in, char* out); 65 66 private: 67 status_t _RetrieveUniqueIDs(); 68 void _ReadManifest(); 69 void _WriteManifest(); 70 71 private: 72 BString fLog; 73 int32 fNumMessages; 74 size_t fMailDropSize; 75 std::vector<size_t> fSizes; 76 off_t fTotalSize; 77 BMessage fSettings; 78 79 BStringList fManifest; 80 BStringList fUniqueIDs; 81 82 BString fDestinationDir; 83 int32 fFetchBodyLimit; 84 85 BSocket* fServerConnection; 86 bool fUseSSL; 87 }; 88 89 90 extern "C" status_t pop3_smtp_auth(const BMailAccountSettings& settings); 91 92 93 #endif /* POP3_H */ 94