1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library.  Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23 
24 #ifndef VMIME_DEFAULTATTACHMENT_HPP_INCLUDED
25 #define VMIME_DEFAULTATTACHMENT_HPP_INCLUDED
26 
27 
28 #include "vmime/attachment.hpp"
29 #include "vmime/encoding.hpp"
30 
31 
32 namespace vmime
33 {
34 
35 
36 /** Default implementation for attachments.
37   */
38 
39 class VMIME_EXPORT defaultAttachment : public attachment
40 {
41 protected:
42 
43 	// For use in derived classes.
44 	defaultAttachment();
45 
46 public:
47 
48 	defaultAttachment(shared_ptr <const contentHandler> data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
49 	defaultAttachment(shared_ptr <const contentHandler> data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
50 	defaultAttachment(const defaultAttachment& attach);
51 
52 	~defaultAttachment();
53 
54 	defaultAttachment& operator=(const defaultAttachment& attach);
55 
56 	const mediaType getType() const;
57 	const text getDescription() const;
58 	const word getName() const;
59 	const shared_ptr <const contentHandler> getData() const;
60 	const encoding getEncoding() const;
61 
62 	shared_ptr <const object> getPart() const;
63 
64 	shared_ptr <const header> getHeader() const;
65 
66 protected:
67 
68 	mediaType m_type;                   /**< Media type (eg. "application/octet-stream") */
69 	text m_desc;                        /**< Description (eg. "The image you requested") */
70 	shared_ptr <const contentHandler> m_data;  /**< Attachment data (eg. the file contents) */
71 	encoding m_encoding;                /**< Encoding */
72 	word m_name;                        /**< Name/filename (eg. "sunset.jpg") */
73 
74 private:
75 
76 	// No need to override "generateIn", use "generatePart" instead (see below).
77 	void generateIn(shared_ptr <bodyPart> parent) const;
78 
79 protected:
80 
81 	virtual void generatePart(shared_ptr <bodyPart> part) const;
82 };
83 
84 
85 } // vmime
86 
87 
88 #endif // VMIME_DEFAULTATTACHMENT_HPP_INCLUDED
89