xref: /haiku/src/add-ons/mail_daemon/inbound_protocols/pop3/MessageIO.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
1 /* MessageIO - Glue code for reading/writing messages directly from the
2 ** protocols but present a BPositionIO interface to the caller, while caching
3 ** the data read/written in a slave file.
4 **
5 ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
6 */
7 #ifndef ZOIDBERG_MAIL_MESSAGE_IO_H
8 #define ZOIDBERG_MAIL_MESSAGE_IO_H
9 
10 
11 #include <DataIO.h>
12 #include <Path.h>
13 #include <Message.h>
14 
15 #include "pop3.h"
16 
17 
18 class BMailMessageIO : public BPositionIO {
19 public:
20 								BMailMessageIO(POP3Protocol* protocol,
21 									BPositionIO* dump_to, int32 seq_id);
22 								~BMailMessageIO();
23 
24 		//----BPositionIO
25 	virtual	ssize_t				ReadAt(off_t pos, void *buffer,
26 									size_t amountToRead);
27 	virtual	ssize_t				WriteAt(off_t pos, const void *buffer,
28 									size_t amountToWrite);
29 
30 	virtual off_t				Seek(off_t position, uint32 seek_mode);
31 	virtual	off_t				Position() const;
32 
33 private:
34 			void				ResetSize(void);
35 
36 			BPositionIO*		slave;
37 			int32				message_id;
38 			POP3Protocol*		fProtocol;
39 
40 			size_t size;
41 
42 			enum MessageIOStateEnum {
43 				READ_HEADER_NEXT,
44 				READ_BODY_NEXT,
45 				ALL_READING_DONE
46 			} state;
47 };
48 
49 #endif	/* ZOIDBERG_MAIL_MESSAGE_IO_H */
50