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

KMIME Library

  • kmime
kmime_header_parsing.h
1 /* -*- c++ -*-
2  kmime_header_parsing.h
3 
4  KMime, the KDE Internet mail/usenet news message library.
5  Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef __KMIME_HEADER_PARSING_H__
24 #define __KMIME_HEADER_PARSING_H__
25 
26 #include <QtCore/QString>
27 #include <QtCore/QPair>
28 
29 #include <kdatetime.h>
30 
31 #include "kmime_export.h"
32 
33 template <typename K, typename V> class QMap;
34 class QStringList;
35 
36 namespace KMime {
37 
38 namespace Headers {
39  class Base;
40 }
41 
42 namespace Types {
43 
44 // for when we can't make up our mind what to use...
45 // FIXME: Remove this thing, we should _always_ know whether we are handling a
46 // byte array or a string.
47 // In most places where this is used, it should simply be replaced by QByteArray
48 struct KMIME_EXPORT QStringOrQPair {
49  QStringOrQPair() : qstring(), qpair( 0, 0 ) {}
50  QString qstring;
51  QPair<const char*, int> qpair;
52 };
53 
54 struct KMIME_EXPORT AddrSpec {
55  QString asString() const;
57  QString asPrettyString() const;
58  bool isEmpty() const;
59  QString localPart;
60  QString domain;
61 };
62 typedef QList<AddrSpec> AddrSpecList;
63 
68 class KMIME_EXPORT Mailbox
69 {
70  public:
71  typedef QList<Mailbox> List;
72 
77  QByteArray address() const;
78 
79  AddrSpec addrSpec() const;
80 
84  QString name() const;
85 
89  void setAddress( const AddrSpec &addr );
90 
94  void setAddress( const QByteArray &addr );
95 
99  void setName( const QString &name );
100 
104  void setNameFrom7Bit( const QByteArray &name,
105  const QByteArray &defaultCharset = QByteArray() );
106 
110  bool hasAddress() const;
111 
115  bool hasName() const;
116 
122  QString prettyAddress() const;
123 
128  //AK_REVIEW: remove this enum
129  enum Quoting {
130  QuoteNever,
131 
132 
133  QuoteWhenNecessary,
134 
135  QuoteAlways
136  };
137 
143  // TODO: KDE5: BIC: remove other prettyAddress() overload, and make it None the default
144  // parameter here
145  //AK_REVIEW: replace by 'QString quotedAddress() const'
146  QString prettyAddress( Quoting quoting ) const;
147 
151  void fromUnicodeString( const QString &s );
152 
156  void from7BitString( const QByteArray &s );
157 
163  QByteArray as7BitString( const QByteArray &encCharset ) const;
164 
165  private:
166  QString mDisplayName;
167  AddrSpec mAddrSpec;
168 };
169 
170 typedef QList<Mailbox> MailboxList;
171 
172 struct KMIME_EXPORT Address {
173  QString displayName;
174  MailboxList mailboxList;
175 };
176 typedef QList<Address> AddressList;
177 
178 } // namespace KMime::Types
179 
180 namespace HeaderParsing {
181 
197 KMIME_EXPORT bool parseEncodedWord( const char* &scursor,
198  const char * const send,
199  QString &result, QByteArray &language,
200  QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(),
201  bool forceCS = false );
202 
203 //
204 // The parsing squad:
205 //
206 
209 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send,
210  QString &result, bool allow8Bit=false );
211 
212 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send,
213  QPair<const char*,int> &result,
214  bool allow8Bit=false );
215 
218 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send,
219  QString &result, bool allow8Bit=false );
220 
221 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send,
222  QPair<const char*,int> &result,
223  bool allow8Bit=false );
224 
226 KMIME_EXPORT bool parseGenericQuotedString( const char* &scursor,
227  const char* const send,
228  QString &result, bool isCRLF,
229  const char openChar='"',
230  const char closeChar='"' );
231 
233 KMIME_EXPORT bool parseComment( const char* &scursor, const char * const send,
234  QString &result, bool isCRLF=false,
235  bool reallySave=true );
236 
252 KMIME_EXPORT bool parsePhrase( const char* &scursor, const char * const send,
253  QString &result, bool isCRLF=false );
254 
267 KMIME_EXPORT bool parseDotAtom( const char* &scursor, const char * const send,
268  QString &result, bool isCRLF=false );
269 
284 KMIME_EXPORT void eatCFWS( const char* &scursor, const char * const send,
285  bool isCRLF );
286 
287 KMIME_EXPORT bool parseDomain( const char* &scursor, const char * const send,
288  QString &result, bool isCRLF=false );
289 
290 KMIME_EXPORT bool parseObsRoute( const char* &scursor, const char * const send,
291  QStringList &result, bool isCRLF=false,
292  bool save=false );
293 
294 KMIME_EXPORT bool parseAddrSpec( const char* &scursor, const char * const send,
295  Types::AddrSpec &result, bool isCRLF=false );
296 
297 KMIME_EXPORT bool parseAngleAddr( const char* &scursor, const char * const send,
298  Types::AddrSpec &result, bool isCRLF=false );
299 
316 KMIME_EXPORT bool parseMailbox( const char* &scursor, const char * const send,
317  Types::Mailbox &result, bool isCRLF=false );
318 
319 KMIME_EXPORT bool parseGroup( const char* &scursor, const char * const send,
320  Types::Address &result, bool isCRLF=false );
321 
322 KMIME_EXPORT bool parseAddress( const char* &scursor, const char * const send,
323  Types::Address &result, bool isCRLF=false );
324 
325 KMIME_EXPORT bool parseAddressList( const char* &scursor,
326  const char * const send,
327  Types::AddressList &result,
328  bool isCRLF=false );
329 
330 KMIME_EXPORT bool parseParameter( const char* &scursor, const char * const send,
331  QPair<QString,Types::QStringOrQPair> &result,
332  bool isCRLF=false );
333 
334 KMIME_EXPORT bool parseParameterList( const char* &scursor,
335  const char * const send,
336  QMap<QString,QString> &result,
337  bool isCRLF=false );
338 
339 KMIME_EXPORT bool parseRawParameterList( const char* &scursor,
340  const char * const send,
341  QMap<QString,Types::QStringOrQPair> &result,
342  bool isCRLF=false );
343 
349 KMIME_EXPORT bool parseParameterListWithCharset( const char* &scursor,
350  const char * const send,
351  QMap<QString,QString> &result,
352  QByteArray& charset, bool isCRLF=false );
353 
361 KMIME_EXPORT int parseDigits( const char* &scursor, const char* const send, int &result );
362 
363 KMIME_EXPORT bool parseTime( const char* &scursor, const char * const send,
364  int &hour, int &min, int &sec,
365  long int &secsEastOfGMT,
366  bool &timeZoneKnown, bool isCRLF=false );
367 
368 KMIME_EXPORT bool parseDateTime( const char* &scursor, const char * const send,
369  KDateTime &result, bool isCRLF=false );
370 
377 KMIME_EXPORT KMime::Headers::Base *extractFirstHeader( QByteArray &head );
378 
389 KMIME_EXPORT void extractHeaderAndBody( const QByteArray &content,
390  QByteArray &header, QByteArray &body );
391 
392 
393 } // namespace HeaderParsing
394 
395 } // namespace KMime
396 
397 #endif // __KMIME_HEADER_PARSING_H__
398 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:45 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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