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

KMIME Library

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 #include <QtCore/QList>
29 
30 #include <kdatetime.h>
31 
32 #include "kmime_export.h"
33 
34 template <typename K, typename V> class QMap;
35 class QStringList;
36 
37 namespace KMime {
38 
39 namespace Headers {
40  class Base;
41 }
42 
43 namespace Types {
44 
45 // for when we can't make up our mind what to use...
46 // FIXME: Remove this thing, we should _always_ know whether we are handling a
47 // byte array or a string.
48 // In most places where this is used, it should simply be replaced by QByteArray
49 struct KMIME_EXPORT QStringOrQPair {
50  QStringOrQPair() : qstring(), qpair( 0, 0 ) {}
51  QString qstring;
52  QPair<const char*, int> qpair;
53 };
54 
55 struct KMIME_EXPORT AddrSpec {
56  QString asString() const;
58  QString asPrettyString() const;
59  bool isEmpty() const;
60  QString localPart;
61  QString domain;
62 };
63 typedef QList<AddrSpec> AddrSpecList;
64 
69 class KMIME_EXPORT Mailbox
70 {
71  public:
72  typedef QList<Mailbox> List;
73 
78  QByteArray address() const;
79 
80  AddrSpec addrSpec() const;
81 
85  QString name() const;
86 
90  void setAddress( const AddrSpec &addr );
91 
95  void setAddress( const QByteArray &addr );
96 
100  void setName( const QString &name );
101 
105  void setNameFrom7Bit( const QByteArray &name,
106  const QByteArray &defaultCharset = QByteArray() );
107 
111  bool hasAddress() const;
112 
116  bool hasName() const;
117 
123  QString prettyAddress() const;
124 
129  //AK_REVIEW: remove this enum
130  enum Quoting {
131  QuoteNever,
132  QuoteWhenNecessary,
135  QuoteAlways
137  };
138 
144  // TODO: KDE5: BIC: remove other prettyAddress() overload, and make it None the default
145  // parameter here
146  //AK_REVIEW: replace by 'QString quotedAddress() const'
147  QString prettyAddress( Quoting quoting ) const;
148 
152  void fromUnicodeString( const QString &s );
153 
157  void from7BitString( const QByteArray &s );
158 
164  QByteArray as7BitString( const QByteArray &encCharset ) const;
165 
166  private:
167  QString mDisplayName;
168  AddrSpec mAddrSpec;
169 };
170 
171 typedef QList<Mailbox> MailboxList;
172 
173 struct KMIME_EXPORT Address {
174  QString displayName;
175  MailboxList mailboxList;
176 };
177 typedef QList<Address> AddressList;
178 
179 } // namespace KMime::Types
180 
181 namespace HeaderParsing {
182 
198 KMIME_EXPORT bool parseEncodedWord( const char* &scursor,
199  const char * const send,
200  QString &result, QByteArray &language,
201  QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(),
202  bool forceCS = false );
203 
204 //
205 // The parsing squad:
206 //
207 
210 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send,
211  QString &result, bool allow8Bit=false );
212 
213 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send,
214  QPair<const char*,int> &result,
215  bool allow8Bit=false );
216 
219 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send,
220  QString &result, bool allow8Bit=false );
221 
222 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send,
223  QPair<const char*,int> &result,
224  bool allow8Bit=false );
225 
227 KMIME_EXPORT bool parseGenericQuotedString( const char* &scursor,
228  const char* const send,
229  QString &result, bool isCRLF,
230  const char openChar='"',
231  const char closeChar='"' );
232 
234 KMIME_EXPORT bool parseComment( const char* &scursor, const char * const send,
235  QString &result, bool isCRLF=false,
236  bool reallySave=true );
237 
253 KMIME_EXPORT bool parsePhrase( const char* &scursor, const char * const send,
254  QString &result, bool isCRLF=false );
255 
268 KMIME_EXPORT bool parseDotAtom( const char* &scursor, const char * const send,
269  QString &result, bool isCRLF=false );
270 
285 KMIME_EXPORT void eatCFWS( const char* &scursor, const char * const send,
286  bool isCRLF );
287 
288 KMIME_EXPORT bool parseDomain( const char* &scursor, const char * const send,
289  QString &result, bool isCRLF=false );
290 
291 KMIME_EXPORT bool parseObsRoute( const char* &scursor, const char * const send,
292  QStringList &result, bool isCRLF=false,
293  bool save=false );
294 
295 KMIME_EXPORT bool parseAddrSpec( const char* &scursor, const char * const send,
296  Types::AddrSpec &result, bool isCRLF=false );
297 
298 KMIME_EXPORT bool parseAngleAddr( const char* &scursor, const char * const send,
299  Types::AddrSpec &result, bool isCRLF=false );
300 
317 KMIME_EXPORT bool parseMailbox( const char* &scursor, const char * const send,
318  Types::Mailbox &result, bool isCRLF=false );
319 
320 KMIME_EXPORT bool parseGroup( const char* &scursor, const char * const send,
321  Types::Address &result, bool isCRLF=false );
322 
323 KMIME_EXPORT bool parseAddress( const char* &scursor, const char * const send,
324  Types::Address &result, bool isCRLF=false );
325 
326 KMIME_EXPORT bool parseAddressList( const char* &scursor,
327  const char * const send,
328  Types::AddressList &result,
329  bool isCRLF=false );
330 
331 KMIME_EXPORT bool parseParameter( const char* &scursor, const char * const send,
332  QPair<QString,Types::QStringOrQPair> &result,
333  bool isCRLF=false );
334 
335 KMIME_EXPORT bool parseParameterList( const char* &scursor,
336  const char * const send,
337  QMap<QString,QString> &result,
338  bool isCRLF=false );
339 
340 KMIME_EXPORT bool parseRawParameterList( const char* &scursor,
341  const char * const send,
342  QMap<QString,Types::QStringOrQPair> &result,
343  bool isCRLF=false );
344 
350 KMIME_EXPORT bool parseParameterListWithCharset( const char* &scursor,
351  const char * const send,
352  QMap<QString,QString> &result,
353  QByteArray& charset, bool isCRLF=false );
354 
362 KMIME_EXPORT int parseDigits( const char* &scursor, const char* const send, int &result );
363 
364 KMIME_EXPORT bool parseTime( const char* &scursor, const char * const send,
365  int &hour, int &min, int &sec,
366  long int &secsEastOfGMT,
367  bool &timeZoneKnown, bool isCRLF=false );
368 
369 KMIME_EXPORT bool parseDateTime( const char* &scursor, const char * const send,
370  KDateTime &result, bool isCRLF=false );
371 
378 KMIME_EXPORT KMime::Headers::Base *extractFirstHeader( QByteArray &head );
379 
390 KMIME_EXPORT void extractHeaderAndBody( const QByteArray &content,
391  QByteArray &header, QByteArray &body );
392 
393 
394 } // namespace HeaderParsing
395 
396 } // namespace KMime
397 
398 #endif // __KMIME_HEADER_PARSING_H__
399 
KMime::Types::Mailbox
Represents an (email address, display name) pair according RFC 2822, section 3.4. ...
Definition: kmime_header_parsing.h:69
KMime::Headers::Base
Baseclass of all header-classes.
Definition: kmime_headers.h:124
KMime::Types::Mailbox::Quoting
Quoting
Describes how display names should be quoted.
Definition: kmime_header_parsing.h:130
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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