KMIME Library
kmime_header_parsing.h
00001 /* -*- c++ -*- 00002 kmime_header_parsing.h 00003 00004 KMime, the KDE Internet mail/usenet news message library. 00005 Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __KMIME_HEADER_PARSING_H__ 00024 #define __KMIME_HEADER_PARSING_H__ 00025 00026 #include <QtCore/QString> 00027 #include <QtCore/QPair> 00028 00029 #include <kdatetime.h> 00030 00031 #include "kmime_export.h" 00032 00033 template <typename K, typename V> class QMap; 00034 class QStringList; 00035 00036 namespace KMime { 00037 00038 namespace Headers { 00039 class Base; 00040 } 00041 00042 namespace Types { 00043 00044 // for when we can't make up our mind what to use... 00045 // FIXME: Remove this thing, we should _always_ know whether we are handling a 00046 // byte array or a string. 00047 // In most places where this is used, it should simply be replaced by QByteArray 00048 struct KMIME_EXPORT QStringOrQPair { 00049 QStringOrQPair() : qstring(), qpair( 0, 0 ) {} 00050 QString qstring; 00051 QPair<const char*,int> qpair; 00052 }; 00053 00054 struct KMIME_EXPORT AddrSpec { 00055 QString asString() const; 00057 QString asPrettyString() const; 00058 bool isEmpty() const; 00059 QString localPart; 00060 QString domain; 00061 }; 00062 typedef QList<AddrSpec> AddrSpecList; 00063 00068 class KMIME_EXPORT Mailbox 00069 { 00070 public: 00071 typedef QList<Mailbox> List; 00072 00077 QByteArray address() const; 00078 00079 AddrSpec addrSpec() const; 00080 00084 QString name() const; 00085 00089 void setAddress( const AddrSpec &addr ); 00090 00094 void setAddress( const QByteArray &addr ); 00095 00099 void setName( const QString &name ); 00100 00104 void setNameFrom7Bit( const QByteArray &name, 00105 const QByteArray &defaultCharset = QByteArray() ); 00106 00110 bool hasAddress() const; 00111 00115 bool hasName() const; 00116 00122 QString prettyAddress() const; 00123 00128 //AK_REVIEW: remove this enum 00129 enum Quoting { 00130 QuoteNever, 00131 00132 00133 QuoteWhenNecessary, 00134 00135 QuoteAlways 00136 }; 00137 00143 // TODO: KDE5: BIC: remove other prettyAddress() overload, and make it None the default 00144 // parameter here 00145 //AK_REVIEW: replace by 'QString quotedAddress() const' 00146 QString prettyAddress( Quoting quoting ) const; 00147 00151 void fromUnicodeString( const QString &s ); 00152 00156 void from7BitString( const QByteArray &s ); 00157 00163 QByteArray as7BitString( const QByteArray &encCharset ) const; 00164 00165 private: 00166 QString mDisplayName; 00167 AddrSpec mAddrSpec; 00168 }; 00169 00170 typedef QList<Mailbox> MailboxList; 00171 00172 struct KMIME_EXPORT Address { 00173 QString displayName; 00174 MailboxList mailboxList; 00175 }; 00176 typedef QList<Address> AddressList; 00177 00178 } // namespace KMime::Types 00179 00180 namespace HeaderParsing { 00181 00197 KMIME_EXPORT bool parseEncodedWord( const char* &scursor, 00198 const char * const send, 00199 QString &result, QByteArray &language, 00200 QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(), 00201 bool forceCS = false ); 00202 00203 // 00204 // The parsing squad: 00205 // 00206 00209 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send, 00210 QString &result, bool allow8Bit=false ); 00211 00212 KMIME_EXPORT bool parseAtom( const char* &scursor, const char * const send, 00213 QPair<const char*,int> &result, 00214 bool allow8Bit=false ); 00215 00218 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send, 00219 QString &result, bool allow8Bit=false ); 00220 00221 KMIME_EXPORT bool parseToken( const char* &scursor, const char * const send, 00222 QPair<const char*,int> &result, 00223 bool allow8Bit=false ); 00224 00226 KMIME_EXPORT bool parseGenericQuotedString( const char* &scursor, 00227 const char* const send, 00228 QString &result, bool isCRLF, 00229 const char openChar='"', 00230 const char closeChar='"' ); 00231 00233 KMIME_EXPORT bool parseComment( const char* &scursor, const char * const send, 00234 QString &result, bool isCRLF=false, 00235 bool reallySave=true ); 00236 00252 KMIME_EXPORT bool parsePhrase( const char* &scursor, const char * const send, 00253 QString &result, bool isCRLF=false ); 00254 00267 KMIME_EXPORT bool parseDotAtom( const char* &scursor, const char * const send, 00268 QString &result, bool isCRLF=false ); 00269 00284 KMIME_EXPORT void eatCFWS( const char* &scursor, const char * const send, 00285 bool isCRLF ); 00286 00287 KMIME_EXPORT bool parseDomain( const char* &scursor, const char * const send, 00288 QString &result, bool isCRLF=false ); 00289 00290 KMIME_EXPORT bool parseObsRoute( const char* &scursor, const char * const send, 00291 QStringList &result, bool isCRLF=false, 00292 bool save=false ); 00293 00294 KMIME_EXPORT bool parseAddrSpec( const char* &scursor, const char * const send, 00295 Types::AddrSpec &result, bool isCRLF=false ); 00296 00297 KMIME_EXPORT bool parseAngleAddr( const char* &scursor, const char * const send, 00298 Types::AddrSpec &result, bool isCRLF=false ); 00299 00316 KMIME_EXPORT bool parseMailbox( const char* &scursor, const char * const send, 00317 Types::Mailbox &result, bool isCRLF=false ); 00318 00319 KMIME_EXPORT bool parseGroup( const char* &scursor, const char * const send, 00320 Types::Address &result, bool isCRLF=false ); 00321 00322 KMIME_EXPORT bool parseAddress( const char* &scursor, const char * const send, 00323 Types::Address &result, bool isCRLF=false ); 00324 00325 KMIME_EXPORT bool parseAddressList( const char* &scursor, 00326 const char * const send, 00327 Types::AddressList &result, 00328 bool isCRLF=false ); 00329 00330 KMIME_EXPORT bool parseParameter( const char* &scursor, const char * const send, 00331 QPair<QString,Types::QStringOrQPair> &result, 00332 bool isCRLF=false ); 00333 00334 KMIME_EXPORT bool parseParameterList( const char* &scursor, 00335 const char * const send, 00336 QMap<QString,QString> &result, 00337 bool isCRLF=false ); 00338 00339 KMIME_EXPORT bool parseRawParameterList( const char* &scursor, 00340 const char * const send, 00341 QMap<QString,Types::QStringOrQPair> &result, 00342 bool isCRLF=false ); 00343 00349 KMIME_EXPORT bool parseParameterListWithCharset( const char* &scursor, 00350 const char * const send, 00351 QMap<QString,QString> &result, 00352 QByteArray& charset, bool isCRLF=false ); 00353 00361 KMIME_EXPORT int parseDigits( const char* &scursor, const char* const send, int &result ); 00362 00363 KMIME_EXPORT bool parseTime( const char* &scursor, const char * const send, 00364 int &hour, int &min, int &sec, 00365 long int &secsEastOfGMT, 00366 bool &timeZoneKnown, bool isCRLF=false ); 00367 00368 KMIME_EXPORT bool parseDateTime( const char* &scursor, const char * const send, 00369 KDateTime &result, bool isCRLF=false ); 00370 00377 KMIME_EXPORT KMime::Headers::Base *extractFirstHeader( QByteArray &head ); 00378 00389 KMIME_EXPORT void extractHeaderAndBody( const QByteArray &content, 00390 QByteArray &header, QByteArray &body ); 00391 00392 00393 } // namespace HeaderParsing 00394 00395 } // namespace KMime 00396 00397 #endif // __KMIME_HEADER_PARSING_H__ 00398
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:41:33 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:41:33 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.