1 /*
2 ** Copyright 2002, Double Precision Inc.
3 **
4 ** See COPYING for distribution information.
5 */
6 #ifndef libmail_imapfetchhandler_H
7 #define libmail_imapfetchhandler_H
8 
9 #include	"config.h"
10 #include	"imap.H"
11 #include	"imaphandler.H"
12 
13 LIBMAIL_START
14 
15 ///////////////////////////////////////////////////////////////////////////
16 //
17 //  A helper class for processing IMAP FETCH.
18 
19 class imapFetchHandler : public imapCommandHandler {
20 
21 	mail::callback::message &callback;
22 
23 	std::string name;
24 
25 	imap *imapAccount;
26 
27 	std::string failmsg;
28 
29 public:
30 	int counter;
31 
32 	std::queue<std::pair<std::string, std::string> > commands;
33 
34 	imapFetchHandler(mail::callback::message &callbackArg,
35 			       std::string nameArg);
36 
37 	~imapFetchHandler();
38 
39 	bool untaggedMessage(imap &imapAccount, std::string name);
40 
41 	bool taggedMessage(imap &imapAccount, std::string name,
42 			   std::string message,
43 			   bool okfail, std::string errmsg);
44 
45 	void installed(imap &imapArg);
46 
47 	void messageTextCallback(size_t messageNum, std::string text);
48 	void messageEnvelopeCallback(size_t messageNumber,
49 				     const envelope &envelope);
50 	void messageReferencesCallback(size_t messageNumber,
51 				       const std::vector<std::string>
52 				       &references);
53 	void messageStructureCallback(size_t messageNumber,
54 				      const mimestruct &messageStructure);
55 
56 	void messageArrivalDateCallback(size_t messageNumber,
57 					time_t datetime);
58 
59 	void messageSizeCallback(size_t messageNumber,
60 				 unsigned long messagesize);
61 
62 	void timedOut(const char *);
63 
64 	size_t messageTextEstimatedSize;
65 	size_t messageTextCompleted;
66 	size_t messageCntDone;
67 	size_t messageCntTotal;
68 private:
69 	const char *getName();
70 };
71 
72 LIBMAIL_END
73 
74 #endif
75