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 #include "vmime/config.hpp"
25 
26 
27 #if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
28 
29 
30 #include "vmime/net/imap/IMAPMessageStructure.hpp"
31 #include "vmime/net/imap/IMAPMessagePart.hpp"
32 
33 
34 namespace vmime {
35 namespace net {
36 namespace imap {
37 
38 
IMAPMessageStructure()39 IMAPMessageStructure::IMAPMessageStructure()
40 {
41 }
42 
43 
IMAPMessageStructure(const IMAPParser::body * body)44 IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body)
45 {
46 	m_parts.push_back(IMAPMessagePart::create(null, 0, body));
47 }
48 
49 
IMAPMessageStructure(shared_ptr<IMAPMessagePart> parent,const std::vector<IMAPParser::body * > & list)50 IMAPMessageStructure::IMAPMessageStructure(shared_ptr <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
51 {
52 	size_t number = 0;
53 
54 	for (std::vector <IMAPParser::body*>::const_iterator
55 	     it = list.begin() ; it != list.end() ; ++it, ++number)
56 	{
57 		m_parts.push_back(IMAPMessagePart::create(parent, number, *it));
58 	}
59 }
60 
61 
getPartAt(const size_t x) const62 shared_ptr <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
63 {
64 	return m_parts[x];
65 }
66 
67 
getPartAt(const size_t x)68 shared_ptr <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
69 {
70 	return m_parts[x];
71 }
72 
73 
getPartCount() const74 size_t IMAPMessageStructure::getPartCount() const
75 {
76 	return m_parts.size();
77 }
78 
79 
80 // static
emptyStructure()81 shared_ptr <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
82 {
83 	static shared_ptr <IMAPMessageStructure> emptyStructure = make_shared <IMAPMessageStructure>();
84 	return emptyStructure;
85 }
86 
87 
88 } // imap
89 } // net
90 } // vmime
91 
92 
93 #endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_IMAP
94 
95