1/* 2 * Copyright 2007-2011, 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 <View.h> 19 20#include "MailAddon.h" 21#include "MailProtocol.h" 22#include "MailSettings.h" 23#include <StringList.h> 24 25 26class BSocket; 27 28 29class POP3Protocol : public InboundProtocol { 30public: 31 POP3Protocol(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 *write_to); 42 status_t GetHeader(int32 message, BPositionIO *write_to); 43 void Delete(int32 num); 44 45protected: 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 *writeTo, 60 bool showProgress); 61 62 int32 ReceiveLine(BString &line); 63 status_t SendCommand(const char* cmd); 64 void MD5Digest(unsigned char *in, char *out); 65 66private: 67 status_t _UniqueIDs(); 68 void _ReadManifest(); 69 void _WriteManifest(); 70 71 BString fLog; 72 int32 fNumMessages; 73 size_t fMailDropSize; 74 BList fSizes; 75 BMessage fSettings; 76 77 BStringList fManifest; 78 BStringList fUniqueIDs; 79 80 BString fDestinationDir; 81 int32 fFetchBodyLimit; 82 83 BSocket* fServerConnection; 84 bool fUseSSL; 85}; 86 87 88extern "C" status_t pop3_smtp_auth(BMessage& settings); 89 90 91#endif /* POP3_H */ 92