1 /* 2 * Copyright 2007-2012, Haiku, Inc. All rights reserved. 3 * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. 4 */ 5 #ifndef MAIL_MESSAGE_IO_H 6 #define MAIL_MESSAGE_IO_H 7 8 9 #include <DataIO.h> 10 #include <Message.h> 11 #include <Path.h> 12 13 #include "POP3.h" 14 15 16 class BMailMessageIO : public BPositionIO { 17 public: 18 BMailMessageIO(POP3Protocol* protocol, 19 BPositionIO* dumpTo, int32 messageID); 20 ~BMailMessageIO(); 21 22 virtual ssize_t ReadAt(off_t pos, void* buffer, 23 size_t amountToRead); 24 virtual ssize_t WriteAt(off_t pos, const void* buffer, 25 size_t amountToWrite); 26 27 virtual off_t Seek(off_t position, uint32 seekMode); 28 virtual off_t Position() const; 29 30 private: 31 void _ResetSize(); 32 33 private: 34 enum MessageIOStateEnum { 35 READ_HEADER_NEXT, 36 READ_BODY_NEXT, 37 ALL_READING_DONE 38 }; 39 40 BPositionIO* fSlave; 41 int32 fMessageID; 42 POP3Protocol* fProtocol; 43 size_t fSize; 44 MessageIOStateEnum fState; 45 }; 46 47 48 #endif /* MAIL_MESSAGE_IO_H */ 49