xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.h (revision 0d452c8f34013b611a54c746a71c05e28796eae2)
1 /*
2  * Copyright 2007-2011, 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 		//----BPositionIO
23 	virtual	ssize_t				ReadAt(off_t pos, void* buffer,
24 									size_t amountToRead);
25 	virtual	ssize_t				WriteAt(off_t pos, const void* buffer,
26 									size_t amountToWrite);
27 
28 	virtual off_t				Seek(off_t position, uint32 seekMode);
29 	virtual	off_t				Position() const;
30 
31 private:
32 			void				_ResetSize();
33 
34 private:
35 			enum MessageIOStateEnum {
36 				READ_HEADER_NEXT,
37 				READ_BODY_NEXT,
38 				ALL_READING_DONE
39 			};
40 
41 			BPositionIO*		fSlave;
42 			int32				fMessageID;
43 			POP3Protocol*		fProtocol;
44 			size_t				fSize;
45 			MessageIOStateEnum	fState;
46 };
47 
48 
49 #endif	/* MAIL_MESSAGE_IO_H */
50