libkmime

kmime_header_parsing.h

00001 /*  -*- c++ -*-
00002     kmime_header_parsing.h
00003 
00004     This file is part of KMime, the KDE internet mail/usenet news message library.
00005     Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org>
00006 
00007     KMime is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMime is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this library; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this library with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #ifndef __KMIME_HEADER_PARSING_H__
00033 #define __KMIME_HEADER_PARSING_H__
00034 
00035 #include <qstring.h>
00036 #include <qpair.h>
00037 #include <qvaluelist.h>
00038 
00039 #include <time.h>
00040 
00041 #include <kdepimmacros.h>
00042 
00043 template <typename K, typename V> class QMap;
00044 class QStringList;
00045 
00046 namespace KMime {
00047 
00048 namespace Types {
00049 
00050   // for when we can't make up our mind what to use...
00051   struct KDE_EXPORT QStringOrQPair {
00052     QStringOrQPair() : qstring(), qpair(0,0) {}
00053     QString qstring;
00054     QPair<const char*,int> qpair;
00055   };
00056 
00057   struct KDE_EXPORT AddrSpec {
00058     QString asString() const;
00059     QString localPart;
00060     QString domain;
00061   };
00062   typedef QValueList<AddrSpec> AddrSpecList;
00063 
00064   struct KDE_EXPORT Mailbox {
00065     QString displayName;
00066     AddrSpec addrSpec;
00067   };
00068   typedef QValueList<Mailbox> MailboxList;
00069 
00070   struct KDE_EXPORT Address {
00071     QString displayName;
00072     MailboxList mailboxList;
00073   };
00074   typedef QValueList<Address> AddressList;
00075 
00076   struct KDE_EXPORT DateTime {
00077     time_t time;            // secs since 1.1.1970, 0:00 UTC/GMT
00078     long int secsEastOfGMT; // timezone
00079     bool timeZoneKnown;     // do we know the timezone? (e.g. on -0000)
00080   };
00081 
00082 } // namespace KMime::Types
00083 
00084 namespace HeaderParsing {
00085 
00100   bool parseEncodedWord( const char* & scursor, const char * const send,
00101              QString & result, QCString & language ) KDE_EXPORT;
00102   //
00103   // The parsing squad:
00104   //
00105 
00108   bool parseAtom( const char* & scursor, const char * const send,
00109           QString & result, bool allow8Bit=false ) KDE_EXPORT;
00110   bool parseAtom( const char* & scursor, const char * const send,
00111           QPair<const char*,int> & result, bool allow8Bit=false ) KDE_EXPORT;
00114   bool parseToken( const char* & scursor, const char * const send,
00115            QString & result, bool allow8Bit=false ) KDE_EXPORT;
00116   bool parseToken( const char* & scursor, const char * const send,
00117            QPair<const char*,int> & result, bool allow8Bit=false ) KDE_EXPORT;
00119   bool parseGenericQuotedString( const char* & scursor, const char* const send,
00120                  QString & result, bool isCRLF,
00121                  const char openChar='"',
00122                  const char closeChar='"' ) KDE_EXPORT;
00124   bool parseComment( const char* & scursor, const char * const send,
00125              QString & result, bool isCRLF=false, bool reallySave=true ) KDE_EXPORT;
00131   bool parsePhrase( const char* & scursor, const char * const send,
00132             QString & result, bool isCRLF=false ) KDE_EXPORT;
00135   bool parseDotAtom( const char* & scursor, const char * const send,
00136              QString & result, bool isCRLF=false ) KDE_EXPORT;
00137 
00147   void eatCFWS( const char* & scursor, const char * const send, bool isCRLF ) KDE_EXPORT;
00148 
00149   bool parseDomain( const char* & scursor, const char * const send,
00150             QString & result, bool isCRLF=false ) KDE_EXPORT;
00151   bool parseObsRoute( const char* & scursor, const char * const send,
00152               QStringList & result,
00153               bool isCRLF=false, bool save=false ) KDE_EXPORT;
00154   bool parseAddrSpec( const char* & scursor, const char * const send,
00155               Types::AddrSpec & result, bool isCRLF=false ) KDE_EXPORT;
00156   bool parseAngleAddr( const char* & scursor, const char * const send,
00157                Types::AddrSpec & result, bool isCRLF=false ) KDE_EXPORT;
00158   bool parseMailbox( const char* & scursor, const char * const send,
00159              Types::Mailbox & result, bool isCRLF=false ) KDE_EXPORT;
00160   bool parseGroup( const char* & scursor, const char * const send,
00161            Types::Address & result, bool isCRLF=false ) KDE_EXPORT;
00162   bool parseAddress( const char* & scursor, const char * const send,
00163              Types::Address & result, bool isCRLF=false ) KDE_EXPORT;
00164   bool parseAddressList( const char* & scursor, const char * const send,
00165              Types::AddressList & result, bool isCRLF=false ) KDE_EXPORT;
00166 
00167   bool parseParameter( const char* & scursor, const char * const send,
00168                QPair<QString,Types::QStringOrQPair> & result,
00169                bool isCRLF=false ) KDE_EXPORT;
00170   bool parseParameterList( const char* & scursor, const char * const send,
00171                QMap<QString,QString> & result, bool isCRLF=false ) KDE_EXPORT;
00172 
00173   bool parseRawParameterList( const char* & scursor, const char * const send,
00174                   QMap<QString,Types::QStringOrQPair> & result,
00175                   bool isCRLF=false ) KDE_EXPORT;
00176   
00177   bool parseTime( const char* & scursor, const char * const send,
00178           int & hour, int & min, int & sec, long int & secsEastOfGMT,
00179           bool & timeZoneKnown, bool isCRLF=false ) KDE_EXPORT;
00180 
00181   bool parseDateTime( const char* & scursor, const char * const send,
00182               Types::DateTime & result, bool isCRLF=false ) KDE_EXPORT;
00183 
00184 #if 0
00185   bool tryToMakeAnySenseOfDateString( const char* & scursor,
00186                       const char * const send,
00187                       time_t & result, bool isCRLF=false );
00188 #endif
00189 
00190 } // namespace HeaderParsing
00191 
00192 } // namespace KMime
00193 
00194 
00195 #endif // __KMIME_HEADER_PARSING_H__
00196 
KDE Home | KDE Accessibility Home | Description of Access Keys