1 /*
2 ** Copyright 2002, Double Precision Inc.
3 **
4 ** See COPYING for distribution information.
5 */
6 #ifndef libmail_autodecoder_H
7 #define libmail_autodecoder_H
8 
9 #include "decoder.H"
10 #include "base64.H"
11 #include "qp.H"
12 #include "namespace.H"
13 
14 //
15 // Generic MIME decoder.  A mail::decoder subclass that uses either base64
16 // or qp, where appropriate.
17 
18 LIBMAIL_START
19 
20 class autodecoder : public decoder {
21 
22 	// Declare both base64 and qp decoding members.
23 
24 	class base64 : public decodebase64 {
25 
26 		autodecoder &me;
27 
28 	public:
29 		base64(autodecoder &meArg);
30 		~base64();
31 	private:
32 		void decoded(std::string);
33 	};
34 
35 	class qp : public decodeqp {
36 		autodecoder &me;
37 
38 	public:
39 		qp(autodecoder &meArg);
40 		~qp();
41 	private:
42 		void decoded(std::string);
43 	};
44 
45 	base64 base64Decoder;
46 	qp qpDecoder;
47 
48 	decoder *decoder;	// Points to one of these two, or NULL
49 
50 public:
51 	autodecoder(std::string contentTransferEncoding);
52 	~autodecoder();
53 
54 	void decode(std::string s);
55 
56 	virtual void decoded(std::string)=0;
57 
58 };
59 
60 LIBMAIL_END
61 
62 #endif
63