1 /*
2 ** Copyright 2002, Double Precision Inc.
3 **
4 ** See COPYING for distribution information.
5 */
6 #ifndef libmail_genericdecode_H
7 #define libmail_genericdecode_H
8 
9 #include "libmail_config.h"
10 #include "mail.H"
11 #include "generic.H"
12 #include "autodecoder.H"
13 
14 #include "base64.H"
15 #include "qp.H"
16 
17 ///////////////////////////////////////////////////////////////////////////
18 //
19 // A helper object for the generic readMessageContentDecoded method
20 // implementation.  The mail::autodecoder() superclass handles the actual
21 // decoding task.  The decoded() method forwards the decoded data to the
22 // original application callback object.
23 //
24 // This helper object also conveniently subclasses mail::callback::message,
25 // nicely forwarding the retrieved MIME content to mail::autodecoder.
26 // It is dynamically allocated, and after its success() or fail() method is
27 // invoked, the message is obediently passed along to the original
28 // callback function, and afterwards this object destroys itself.
29 
30 class mail::generic::Decode : public mail::autodecoder,
31 		     public mail::callback::message {
32 
33 	mail::callback::message &originalCallback;
34 
35 public:
36 	Decode(mail::callback::message &callback, std::string transferEncoding);
37 	~Decode();
38 
39 private:
40 	size_t messageNum;
41 
42 	void decoded(std::string buffer);
43 	void messageTextCallback(size_t n, std::string text);
44 	void reportProgress(size_t bytesCompleted,
45 			    size_t bytesEstimatedTotal,
46 
47 			    size_t messagesCompleted,
48 			    size_t messagesEstimatedTotal);
49 
50 	void fail(std::string message);
51 	void success(std::string message);
52 };
53 
54 #endif
55