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/contentDispositionField.hpp"
25 #include "vmime/exception.hpp"
26
27
28 namespace vmime
29 {
30
31
contentDispositionField()32 contentDispositionField::contentDispositionField()
33 {
34 }
35
36
contentDispositionField(contentDispositionField &)37 contentDispositionField::contentDispositionField(contentDispositionField&)
38 : parameterizedHeaderField()
39 {
40 }
41
42
hasCreationDate() const43 bool contentDispositionField::hasCreationDate() const
44 {
45 return hasParameter("creation-date");
46 }
47
48
getCreationDate() const49 const datetime contentDispositionField::getCreationDate() const
50 {
51 shared_ptr <parameter> param = findParameter("creation-date");
52
53 if (param)
54 return param->getValueAs <datetime>();
55 else
56 return datetime::now();
57 }
58
59
setCreationDate(const datetime & creationDate)60 void contentDispositionField::setCreationDate(const datetime& creationDate)
61 {
62 getParameter("creation-date")->setValue(creationDate);
63 }
64
65
hasModificationDate() const66 bool contentDispositionField::hasModificationDate() const
67 {
68 return hasParameter("modification-date");
69 }
70
71
getModificationDate() const72 const datetime contentDispositionField::getModificationDate() const
73 {
74 shared_ptr <parameter> param = findParameter("modification-date");
75
76 if (param)
77 return param->getValueAs <datetime>();
78 else
79 return datetime::now();
80 }
81
82
setModificationDate(const datetime & modificationDate)83 void contentDispositionField::setModificationDate(const datetime& modificationDate)
84 {
85 getParameter("modification-date")->setValue(modificationDate);
86 }
87
88
hasReadDate() const89 bool contentDispositionField::hasReadDate() const
90 {
91 return hasParameter("read-date");
92 }
93
94
getReadDate() const95 const datetime contentDispositionField::getReadDate() const
96 {
97 shared_ptr <parameter> param = findParameter("read-date");
98
99 if (param)
100 return param->getValueAs <datetime>();
101 else
102 return datetime::now();
103 }
104
105
setReadDate(const datetime & readDate)106 void contentDispositionField::setReadDate(const datetime& readDate)
107 {
108 getParameter("read-date")->setValue(readDate);
109 }
110
111
hasFilename() const112 bool contentDispositionField::hasFilename() const
113 {
114 return hasParameter("filename");
115 }
116
117
getFilename() const118 const word contentDispositionField::getFilename() const
119 {
120 shared_ptr <parameter> param = findParameter("filename");
121
122 if (param)
123 return param->getValue();
124 else
125 return word();
126 }
127
128
setFilename(const word & filename)129 void contentDispositionField::setFilename(const word& filename)
130 {
131 getParameter("filename")->setValue(filename);
132 }
133
134
hasSize() const135 bool contentDispositionField::hasSize() const
136 {
137 return hasParameter("size");
138 }
139
140
getSize() const141 const string contentDispositionField::getSize() const
142 {
143 shared_ptr <parameter> param = findParameter("size");
144
145 if (param)
146 return param->getValue().getBuffer();
147 else
148 return "";
149 }
150
151
setSize(const string & size)152 void contentDispositionField::setSize(const string& size)
153 {
154 getParameter("size")->setValue(word(size, vmime::charsets::US_ASCII));
155 }
156
157
158 } // vmime
159