• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

kioslave/imap4

  • kioslave
  • imap4
mimeheader.h
1/***************************************************************************
2 mimeheader.h - description
3 -------------------
4 begin : Fri Oct 20 2000
5 copyright : (C) 2000 by Sven Carstens
6 email : s.carstens@gmx.de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef MIMEHEADER_H
19#define MIMEHEADER_H
20
21#include <QList>
22#include <QHash>
23#include <QByteArray>
24
25#include "mimehdrline.h"
26#include "mimeio.h"
27
28#include <kimap/rfccodecs.h>
29using namespace KIMAP;
30
35class mimeHeader
36{
37public:
38 mimeHeader ();
39 virtual ~ mimeHeader ();
40
41 virtual void addHdrLine (mimeHdrLine *);
42 virtual void outputHeader (mimeIO &);
43 virtual void outputPart (mimeIO &);
44
45
46 QByteArray outputParameter (QHash < QString, QString > &);
47
48// int parsePart (mimeIO &, const QString&);
49// int parseBody (mimeIO &, QByteArray &, const QString&, bool mbox = false);
50
51 // parse a header. returns true if it had a leading 'From ' line
52 bool parseHeader (mimeIO &);
53
54 QString getDispositionParm (const QByteArray&);
55 void setDispositionParm (const QByteArray&, const QString&);
56 QHashIterator < QString, QString > getDispositionIterator ();
57
58 QString getTypeParm (const QByteArray&);
59 void setTypeParm (const QByteArray&, const QString&);
60 QHashIterator < QString, QString > getTypeIterator ();
61
62 // recursively serialize all important contents to the QDataStream
63 void serialize(QDataStream& stream);
64
65 const QByteArray& getType ()
66 {
67 return _contentType;
68 }
69 void setType (const QByteArray& _str)
70 {
71 _contentType = _str;
72 }
73
74 const QByteArray& getDescription ()
75 {
76 return _contentDescription;
77 }
78 void setDescription( const QByteArray& _str )
79 {
80 _contentDescription = _str;
81 }
82
83 const QByteArray& getDisposition ()
84 {
85 return _contentDisposition;
86 }
87 void setDisposition( const QByteArray& _str )
88 {
89 _contentDisposition = _str;
90 }
91
92 const QByteArray& getEncoding ()
93 {
94 return _contentEncoding;
95 }
96 void setEncoding (const QByteArray &_str )
97 {
98 _contentEncoding = _str;
99 }
100
101 const QByteArray& getMD5 ()
102 {
103 return _contentMD5;
104 }
105 void setMD5 (const QByteArray & _str)
106 {
107 _contentMD5 = _str;
108 }
109
110 const QByteArray& getID ()
111 {
112 return _contentID;
113 }
114 void setID (const QByteArray & _str)
115 {
116 _contentID = _str;
117 }
118
119 unsigned long getLength ()
120 {
121 return contentLength;
122 }
123 void setLength (unsigned long _len)
124 {
125 contentLength = _len;
126 }
127
128 const QString & getPartSpecifier ()
129 {
130 return partSpecifier;
131 }
132 void setPartSpecifier (const QString & _str)
133 {
134 partSpecifier = _str;
135 }
136
137 QListIterator < mimeHdrLine *> getOriginalIterator ();
138 QListIterator < mimeHdrLine *> getAdditionalIterator ();
139 void setContent (const QByteArray &aContent)
140 {
141 mimeContent = aContent;
142 }
143 QByteArray getContent ()
144 {
145 return mimeContent;
146 }
147
148 QByteArray getBody ()
149 {
150 return preMultipartBody + postMultipartBody;
151 }
152 QByteArray getPreBody ()
153 {
154 return preMultipartBody;
155 }
156 void setPreBody (QByteArray & inBody)
157 {
158 preMultipartBody = inBody;
159 }
160
161 QByteArray getPostBody ()
162 {
163 return postMultipartBody;
164 }
165 void setPostBody (QByteArray & inBody)
166 {
167 postMultipartBody = inBody;
168 contentLength = inBody.length ();
169 }
170
171 mimeHeader *getNestedMessage ()
172 {
173 return nestedMessage;
174 }
175 void setNestedMessage (mimeHeader * inPart, bool destroy = true)
176 {
177 if ( nestedMessage && destroy ) {
178 delete nestedMessage;
179 }
180 nestedMessage = inPart;
181 }
182
183// mimeHeader *getNestedPart() { return nestedPart; };
184 void addNestedPart (mimeHeader * inPart)
185 {
186 nestedParts.append( inPart );
187 }
188 QListIterator < mimeHeader *> getNestedIterator ()
189 {
190 return QListIterator < mimeHeader *> ( nestedParts );
191 }
192
193 // clears all parts and deletes them from memory
194 void clearNestedParts ()
195 {
196 nestedParts.clear();
197 }
198
199 // clear all parameters to content-type
200 void clearTypeParameters ()
201 {
202 typeList.clear();
203 }
204
205 // clear all parameters to content-disposition
206 void clearDispositionParameters ()
207 {
208 dispositionList.clear ();
209 }
210
211 // return the specified body part or NULL
212 mimeHeader *bodyPart (const QString &);
213
214#ifdef KMAIL_COMPATIBLE
215 ulong msgSize ()
216 {
217 return contentLength;
218 }
219 uint numBodyParts ()
220 {
221 return nestedParts.count();
222 }
223 mimeHeader *bodyPart (int which, mimeHeader ** ret = NULL)
224 {
225 if ( ret ) {
226 ( *ret ) = nestedParts.at( which );
227 }
228 return nestedParts.at( which );
229 }
230 void write (const QString &)
231 {
232 }
233 QString typeStr ()
234 {
235 return QString( contentType.left( contentType.find( '/' ) ) );
236 }
237 void setTypeStr (const QString & _str)
238 {
239 contentType = QByteArray( _str.toLatin1() ) + "/" + subtypeStr().toLatin1();
240 }
241 QString subtypeStr ()
242 {
243 return QString( contentType.right( contentType.length() - contentType.find( '/' ) - 1 ) );
244 }
245 void setSubtypeStr (const QString & _str)
246 {
247 contentType = QByteArray( typeStr().toLatin1() ) + "/" + _str.toLatin1();
248 }
249 QString cteStr ()
250 {
251 return QString( getEncoding() );
252 }
253 void setCteStr (const QString & _str)
254 {
255 setEncoding( _str.toLatin1() );
256 }
257 QString contentDisposition ()
258 {
259 return QString( _contentDisposition );
260 }
261 QString body ()
262 {
263 return QString( postMultipartBody );
264 }
265 QString charset ()
266 {
267 return getTypeParm( "charset" );
268 }
269 QString bodyDecoded ();
270 void setBodyEncoded (const QByteArray &);
271 void setBodyEncodedBinary (const QByteArray &);
272 QByteArray bodyDecodedBinary ();
273 QString name ()
274 {
275 return QString( getTypeParm( "name" ) );
276 }
277 void setName (const QString & _str)
278 {
279 setTypeParm( "name", _str );
280 }
281 QString fileName ()
282 {
283 return QString( getDispositionParm( "filename" ) );
284 }
285 QString contentDescription ()
286 {
287 return QString( RfcCodecs::decodeRFC2047String( _contentDescription ) );
288 }
289 void setContentDescription (const QString & _str)
290 {
291 _contentDescription = RfcCodecs::encodeRFC2047String( _str ).toLatin1();
292 }
293 QString msgIdMD5 ()
294 {
295 return QString( contentMD5 );
296 }
297 QString iconName ();
298 QString magicSetType (bool aAutoDecode = true);
299 QString headerAsString ();
300 ulong size ()
301 {
302 return 0;
303 }
304 void fromString (const QByteArray &)
305 {;
306 }
307 void setContentDisposition (const QString & _str)
308 {
309 setDisposition( _str.toLatin1() );
310 }
311#endif
312
313protected:
314 static void addParameter (const QByteArray&, QHash < QString, QString > &);
315 static QString getParameter (const QByteArray&, QHash < QString, QString > &);
316 static void setParameter (const QByteArray&, const QString&, QHash < QString, QString > &);
317
318 QList < mimeHdrLine *> originalHdrLines;
319
320private:
321 QList < mimeHdrLine *> additionalHdrLines;
322 QHash < QString, QString > typeList;
323 QHash < QString, QString > dispositionList;
324 QByteArray _contentType;
325 QByteArray _contentDisposition;
326 QByteArray _contentEncoding;
327 QByteArray _contentDescription;
328 QByteArray _contentID;
329 QByteArray _contentMD5;
330 unsigned int contentLength;
331 QByteArray mimeContent;
332 QByteArray preMultipartBody;
333 QByteArray postMultipartBody;
334 mimeHeader *nestedMessage;
335 QList < mimeHeader *> nestedParts;
336 QString partSpecifier;
337
338};
339
340#endif
mimeHdrLine
Definition: mimehdrline.h:29
mimeHeader
Definition: mimeheader.h:36
mimeIO
Definition: mimeio.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kioslave/imap4

Skip menu "kioslave/imap4"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal