|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 #include "qmessagecontentcontainer.h" |
|
42 #ifdef Q_OS_SYMBIAN |
|
43 #include "qmessagecontentcontainer_symbian_p.h" |
|
44 #elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) |
|
45 #include "qmessagecontentcontainer_maemo_p.h" |
|
46 #else |
|
47 #include "qmessagecontentcontainer_p.h" |
|
48 #endif |
|
49 |
|
50 QTM_BEGIN_NAMESPACE |
|
51 |
|
52 /*! |
|
53 \class QMessageContentContainer |
|
54 |
|
55 \brief The QMessageContentContainer class provides an interface for internet media (MIME) |
|
56 and Transport Neutral Encapsulation Format (TNEF) content that is possibly only |
|
57 partially retrieved. |
|
58 |
|
59 \ingroup messaging |
|
60 |
|
61 A QMessageContentContainer object can either directly contain media such as text, |
|
62 image, audio, video, application or message data, or contain multiple parts of content, |
|
63 but can not contain both media and multiple parts directly. |
|
64 |
|
65 Container objects can be obtained via their QMessageContentContainerId |
|
66 identifier, using the find() function of the containing QMessage object. |
|
67 |
|
68 For textual content using a recognized charset encoding textContent() will |
|
69 return the content as a unicode string. |
|
70 |
|
71 For non-multipart content content() will return the content data after decoding any |
|
72 transfer encoding used to represent binary data using 7-bit ASCII characters, such as |
|
73 quoted-printable and base64. |
|
74 |
|
75 The internet media (MIME) type of the container is returned by contentType(), |
|
76 the content subtype is returned by contentSubType(), the content type charset parameter |
|
77 is returned by contentCharset(), and the content suggested filename by suggestedFileName(). |
|
78 |
|
79 The type of a container that contains multiple parts of content must be "multipart" (case |
|
80 insensitive). A list of identifiers for directly contained parts of content is returned |
|
81 by contentIds(). |
|
82 |
|
83 An indication of the size of the container and its contents on the originating server is |
|
84 given by size(). If the content is entirely available on the device |
|
85 isContentAvailable() will return true. |
|
86 |
|
87 Non-multipart content can be serialized to a QDataStream using |
|
88 writeContentTo(), or to a QTextStream using writeTextContentTo(). |
|
89 |
|
90 A container also stores name-value pairs known as header fields. Names are ASCII strings, |
|
91 while values are charset encoded unicode strings. A list of the header fields present |
|
92 in a container is returned by headerFields(). The unicode string values associated |
|
93 with a particular header field name are returned by headerFieldValues(). |
|
94 |
|
95 \sa QMessage, QMessageContentContainerId |
|
96 */ |
|
97 |
|
98 /*! |
|
99 \fn QMessageContentContainer::QMessageContentContainer() |
|
100 |
|
101 Constructs an empty container object. |
|
102 */ |
|
103 |
|
104 /*! |
|
105 \fn QMessageContentContainer::QMessageContentContainer(const QMessageContentContainer &other) |
|
106 |
|
107 Constructs a copy of \a other. |
|
108 */ |
|
109 |
|
110 /*! |
|
111 \internal |
|
112 \fn QMessageContentContainer::operator=(const QMessageContentContainer& other) |
|
113 */ |
|
114 |
|
115 /*! |
|
116 \fn QMessageContentContainer::~QMessageContentContainer() |
|
117 |
|
118 Destroys the container object. |
|
119 */ |
|
120 |
|
121 /*! |
|
122 \fn QMessageContentContainer::contentType() const |
|
123 |
|
124 Returns the content type of the container. Common types are "text", "image", "audio", |
|
125 "video", "application", "message" and "multipart". |
|
126 |
|
127 The internet media (MIME) type of the container is "multipart" if the container directly |
|
128 contains multiple parts rather than directly contains media. |
|
129 |
|
130 \sa contentSubType(), contentCharset() |
|
131 */ |
|
132 |
|
133 /*! |
|
134 \fn QMessageContentContainer::contentSubType() const |
|
135 |
|
136 Returns the internet media (MIME) subtype of the content. |
|
137 |
|
138 \sa contentType(), contentCharset() |
|
139 */ |
|
140 |
|
141 /*! |
|
142 \fn QMessageContentContainer::contentCharset() const |
|
143 |
|
144 Returns the internet media (MIME) content charset, when defined; |
|
145 otherwise an empty array is returned. |
|
146 |
|
147 \sa contentType(), contentSubType() |
|
148 */ |
|
149 |
|
150 /*! |
|
151 \fn QMessageContentContainer::suggestedFileName() const |
|
152 |
|
153 Returns the suggested filename for the attachment, when defined; |
|
154 otherwise an empty array is returned. |
|
155 |
|
156 The default is an empty array. |
|
157 */ |
|
158 |
|
159 /*! |
|
160 \fn QMessageContentContainer::isContentAvailable() const |
|
161 |
|
162 Returns true if the entirety of the content contained is available on the device; |
|
163 otherwise returns false. |
|
164 */ |
|
165 |
|
166 /*! |
|
167 \fn QMessageContentContainer::size() const |
|
168 |
|
169 If the size of the container is known then returns an indication of the size of the container |
|
170 on the originating server, including contents; otherwise returns 0. |
|
171 */ |
|
172 |
|
173 /*! |
|
174 \fn QMessageContentContainer::textContent() const |
|
175 |
|
176 For textual content encoded with a recognized charset, returns the content as a unicode string; |
|
177 otherwise a null string is returned. |
|
178 */ |
|
179 |
|
180 /*! |
|
181 \fn QMessageContentContainer::content() const |
|
182 |
|
183 Return the content after decoding any transfer encoding used to represent binary data |
|
184 using 7-bit ASCII characters, such as quoted-printable and base64. |
|
185 |
|
186 For textual content any text charset encoding such as Shift-JIS, ISO 2022-JP, KOI8-R, |
|
187 Windows-1251 etc will not be decoded. |
|
188 |
|
189 \sa textContent() |
|
190 */ |
|
191 |
|
192 /*! |
|
193 \fn QMessageContentContainer::writeTextContent(QTextStream& out) const |
|
194 |
|
195 For a non-multipart container, writes the content as returned by textContent() |
|
196 to the stream \a out; otherwise does nothing. |
|
197 */ |
|
198 |
|
199 /*! |
|
200 \fn QMessageContentContainer::writeContent(QDataStream& out) const |
|
201 |
|
202 For a non-multipart container, writes the content as returned by content() |
|
203 to the stream \a out; otherwise does nothing. |
|
204 */ |
|
205 |
|
206 /*! |
|
207 \fn QMessageContentContainer::contentIds() const |
|
208 |
|
209 For a multipart container returns a list of identifiers for all content directly contained by |
|
210 the container; otherwise returns an empty list. |
|
211 |
|
212 \sa find(), contains() |
|
213 */ |
|
214 |
|
215 /*! |
|
216 \fn QMessageContentContainer::find(const QMessageContentContainerId &id) const |
|
217 |
|
218 If the container contains another container with identifier \a id either directly or |
|
219 recursively, then returns the value of that other container; otherwise returns an |
|
220 empty container constructed with the default constructor. |
|
221 |
|
222 \sa contains(), contentIds() |
|
223 */ |
|
224 |
|
225 /*! |
|
226 \fn bool QMessageContentContainer::contains(const QMessageContentContainerId &id) const; |
|
227 |
|
228 If the container contains content with the identifier \a id, either directly or recursively |
|
229 then returns true; otherwise returns false. |
|
230 |
|
231 \sa find(), contentIds() |
|
232 */ |
|
233 |
|
234 /*! |
|
235 \fn QMessageContentContainer::headerFieldValue(const QByteArray &name) const |
|
236 |
|
237 Returns the value of the first header field of the container with the name \a name, if any; |
|
238 otherwise returns a null string. |
|
239 |
|
240 \sa headerFields(), headerFieldValues() |
|
241 */ |
|
242 |
|
243 /*! |
|
244 \fn QMessageContentContainer::headerFieldValues(const QByteArray &name) const |
|
245 |
|
246 Returns a list of values of header fields with the name \a name, if any; |
|
247 otherwise returns an empty list. |
|
248 |
|
249 \sa headerFields(), headerFieldValue() |
|
250 */ |
|
251 |
|
252 /*! |
|
253 \fn QMessageContentContainer::headerFields() const |
|
254 |
|
255 Returns a list of names of header fields of the container. |
|
256 |
|
257 \sa headerFieldValue(), headerFieldValues() |
|
258 */ |
|
259 |
|
260 QTM_END_NAMESPACE |