libkdenetwork Library API Documentation

kmime_headers.h

00001 /*  -*- c++ -*
00002     kmime_headers.h
00003 
00004     KMime, the KDE internet mail/usenet news message library.
00005     Copyright (c) 2001-2002 the KMime authors.
00006     See file AUTHORS for details
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License version 2.0 as
00010     published by the Free Software Foundation.
00011     You should have received a copy of the GNU General Public License
00012     along with this program; if not, write to the Free Software Foundation,
00013     Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
00014 */
00015 #ifndef __KMIME_HEADERS_H__
00016 #define __KMIME_HEADERS_H__
00017 
00018 // Content:
00019 //
00020 // - header's base class defining the common interface
00021 // - generic base classes for different types of fields
00022 // - incompatible, GStructured-based field classes
00023 // - compatible, GUnstructured-based field classes
00024 
00025 #include "kmime_header_parsing.h"
00026 
00027 #include <qstring.h>
00028 #include <qstrlist.h>
00029 #include <qstringlist.h>
00030 #include <qregexp.h>
00031 #include <qdatetime.h>
00032 #include <qasciidict.h>
00033 #include <qmap.h>
00034 #include <qptrlist.h>
00035 
00036 #include <time.h>
00037 
00038 namespace KMime {
00039 
00040 //forward declaration
00041 class Content;
00042 
00043 namespace Headers {
00044 
00045 
00046 enum contentCategory    { CCsingle,
00047                           CCcontainer,
00048                           CCmixedPart,
00049                           CCalternativePart };
00050 
00051 enum contentEncoding    { CE7Bit,
00052                           CE8Bit,
00053                           CEquPr,
00054                           CEbase64,
00055                           CEuuenc,
00056                           CEbinary };
00057 
00058 enum contentDisposition { CDinline,
00059                           CDattachment,
00060                           CDparallel };
00061 
00062 //often used charset
00063 static const QCString Latin1("ISO-8859-1");
00064 
00065 #define mk_trivial_subclass_with_name( subclass, subclassName, baseclass ) \
00066 class subclass : public Generics::baseclass { \
00067 public: \
00068   subclass() : Generics::baseclass() {} \
00069   subclass( Content * p ) : Generics::baseclass( p ) {} \
00070   subclass( Content * p, const QCString & s ) \
00071     : Generics::baseclass( p ) { from7BitString( s ); } \
00072   subclass( Content * p, const QString & s, const QCString & cs ) \
00073     : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \
00074   ~subclass() {} \
00075   \
00076   const char * type() const { return #subclassName; } \
00077 }
00078  
00079 #define mk_trivial_subclass( subclass, baseclass ) \
00080 mk_trivial_subclass_with_name( subclass, subclass, baseclass )
00081 
00082 #define mk_parsing_subclass_with_name( subclass, subclassName, baseclass ) \
00083 class subclass : public Generics::baseclass { \
00084 public: \
00085   subclass() : Generics::baseclass() {} \
00086   subclass( Content * p ) : Generics::baseclass( p ) {} \
00087   subclass( Content * p, const QCString & s ) \
00088     : Generics::baseclass( p ) { from7BitString( s ); } \
00089   subclass( Content * p, const QString & s, const QCString & cs ) \
00090     : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \
00091   ~subclass() {} \
00092   \
00093   const char * type() const { return #subclassName; } \
00094 protected: \
00095   bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); \
00096 }
00097 
00098 #define mk_parsing_subclass( subclass, baseclass ) \
00099 mk_parsing_subclass_with_name( subclass, subclass, baseclass )
00100 
00101 //
00102 //
00103 // HEADER'S BASE CLASS. DEFINES THE COMMON INTERFACE
00104 //
00105 //
00106 
00109 class Base {
00110 
00111   public:
00112     typedef QPtrList<Base> List;
00113 
00115     Base() : e_ncCS(0), p_arent(0) {}
00116 
00118     Base(KMime::Content *parent) : e_ncCS(0), p_arent(parent) {}
00119 
00121     virtual ~Base()  {}
00122 
00124     KMime::Content* parent()  { return p_arent; }
00125 
00127     void setParent(KMime::Content *p)  { p_arent=p; }
00128 
00132     virtual void from7BitString(const QCString&)  {}
00133 
00136     virtual QCString as7BitString(bool=true)  { return QCString(); }
00137 
00139     QCString rfc2047Charset();
00140 
00142     void setRFC2047Charset(const QCString &cs);
00143 
00145     QCString defaultCS();
00146 
00148     bool forceCS();
00149 
00151     virtual void fromUnicodeString(const QString&, const QCString&)  {}
00152 
00155     virtual QString asUnicodeString()  { return QString(); }
00156 
00158     virtual void clear()  {}
00159 
00161     virtual bool isEmpty()  { return false; }
00162 
00164     virtual const char* type()  { return ""; }
00165 
00167     bool is(const char* t)  { return (strcasecmp(t, type())==0); }
00168 
00170     bool isMimeHeader()  { return (strncasecmp(type(), "Content-", 8)==0); }
00171 
00173     bool isXHeader()  { return (strncmp(type(), "X-", 2)==0); }
00174 
00175   protected:
00176     QCString typeIntro()  { return (QCString(type())+": "); }
00177 
00178     const char *e_ncCS;
00179     Content *p_arent;
00180 
00181 };
00182 
00183 
00184 //
00185 //
00186 // GENERIC BASE CLASSES FOR DIFFERENT TYPES OF FIELDS
00187 //
00188 //
00189 
00190 namespace Generics {
00191 
00211   // known issues:
00212   // - uses old decodeRFC2047String function, instead of our own...
00213 
00214 class GUnstructured : public Base {
00215 
00216 public:
00217   GUnstructured() : Base()  {}
00218   GUnstructured( Content * p ) : Base( p ) {}
00219   GUnstructured( Content * p, const QCString & s )
00220     : Base( p ) { from7BitString(s); }
00221   GUnstructured( Content * p, const QString & s, const QCString & cs )
00222     : Base( p )  { fromUnicodeString( s, cs ); }
00223   ~GUnstructured()  {}
00224 
00225   virtual void from7BitString( const QCString& str );
00226   virtual QCString as7BitString( bool withHeaderType=true );
00227 
00228   virtual void fromUnicodeString( const QString & str,
00229                   const QCString & suggestedCharset);
00230   virtual QString asUnicodeString();
00231 
00232   virtual void clear()            { d_ecoded.truncate(0); }
00233   virtual bool isEmpty()          { return (d_ecoded.isEmpty()); }
00234 
00235 private:
00236   QString d_ecoded;
00237 };
00238 
00267 class GStructured : public Base {
00268 public:
00269   GStructured() : Base()  {}
00270   GStructured( Content * p ) : Base( p ) {}
00271   GStructured( Content * p, const QCString & s )
00272     : Base( p ) { from7BitString(s); }
00273   GStructured( Content * p, const QString & s, const QCString & cs )
00274     : Base( p )  { fromUnicodeString( s, cs ); }
00275   ~GStructured()  {}
00276 
00277   
00278 protected:
00279 #if 0
00280   // the assembly squad:
00281 
00282   bool writeAtom( char* & dcursor, const char * const dend, const QString & input );
00283   bool writeAtom( char* & dcursor, const char * const dend,
00284           const QPair<const char*,int> & input );
00285   bool writeToken( char* & dcursor, const char * const dend, const QString & input );
00286   bool writeToken( char* & dcursor, const char * const dend,
00287            const QPair<const char*int> & input );
00288 
00289   bool writeGenericQuotedString( char* & dcursor, const char * const dend,
00290                  const QString & input, bool withCRLF=false );
00291   bool writeComment( char* & dcursor, const char * const dend,
00292              const QString & input, bool withCRLF=false );
00293   bool writePhrase( char* & dcursor, const char * const dend,
00294             const QString & input, bool withCRLF=false );
00295   bool writeDotAtom( char* & dcursor, const char * const dend,
00296              const QString & input, bool withCRLF=false );
00297 #endif
00298 };
00299 
00300 
00301 class GAddress : public GStructured {
00302 public:
00303   GAddress() : GStructured()  {}
00304   GAddress( Content * p ) : GStructured( p ) {}
00305   GAddress( Content * p, const QCString & s )
00306     : GStructured( p ) { from7BitString(s); }
00307   GAddress( Content * p, const QString & s, const QCString & cs )
00308     : GStructured( p )  { fromUnicodeString( s, cs ); }
00309   ~GAddress()  {}
00310 
00311 protected:
00312 };
00313 
00314 
00317 class MailboxList : public GAddress {
00318 public:
00319   MailboxList() : GAddress()  {}
00320   MailboxList( Content * p ) : GAddress( p ) {}
00321   MailboxList( Content * p, const QCString & s )
00322     : GAddress( p ) { from7BitString(s); }
00323   MailboxList( Content * p, const QString & s, const QCString & cs )
00324     : GAddress( p )  { fromUnicodeString( s, cs ); }
00325   ~MailboxList()  {}
00326 
00327 protected:
00328   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00329 
00331   QValueList<Types::Mailbox> mMailboxList;
00332 };
00333 
00334 
00337 mk_parsing_subclass(SingleMailbox,MailboxList);
00338 
00341 class AddressList : public GAddress {
00342 public:
00343   AddressList() : GAddress()  {}
00344   AddressList( Content * p ) : GAddress( p ) {}
00345   AddressList( Content * p, const QCString & s )
00346     : GAddress( p ) { from7BitString(s); }
00347   AddressList( Content * p, const QString & s, const QCString & cs )
00348     : GAddress( p )  { fromUnicodeString( s, cs ); }
00349   ~AddressList()  {}
00350 
00351 protected:
00352   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00353 
00355   QValueList<Types::Address> mAddressList;
00356 };
00357 
00359 class GIdent : public GAddress {
00360 public:
00361   GIdent() : GAddress()  {}
00362   GIdent( Content * p ) : GAddress( p ) {}
00363   GIdent( Content * p, const QCString & s )
00364     : GAddress( p ) { from7BitString(s); }
00365   GIdent( Content * p, const QString & s, const QCString & cs )
00366     : GAddress( p )  { fromUnicodeString( s, cs ); }
00367   ~GIdent()  {}
00368 
00369 protected:
00370   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00371 
00373   QValueList<Types::AddrSpec> mMsgIdList;
00374 };
00375 
00377 mk_parsing_subclass(GSingleIdent,GIdent);
00378 
00380 class GToken : public GStructured {
00381 public:
00382   GToken() : GStructured()  {}
00383   GToken( Content * p ) : GStructured( p ) {}
00384   GToken( Content * p, const QCString & s )
00385     : GStructured( p ) { from7BitString(s); }
00386   GToken( Content * p, const QString & s, const QCString & cs )
00387     : GStructured( p )  { fromUnicodeString( s, cs ); }
00388   ~GToken()  {}
00389 
00390 protected:
00391   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00392 
00393   QCString mToken;
00394 };
00395 
00396 
00397 class GPhraseList : public GStructured {
00398 public:
00399   GPhraseList() : GStructured()  {}
00400   GPhraseList( Content * p ) : GStructured( p ) {}
00401   GPhraseList( Content * p, const QCString & s )
00402     : GStructured( p ) { from7BitString(s); }
00403   GPhraseList( Content * p, const QString & s, const QCString & cs )
00404     : GStructured( p )  { fromUnicodeString( s, cs ); }
00405   ~GPhraseList()  {}
00406 
00407 protected:
00408   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00409 
00410   QStringList mPhraseList;
00411 };
00412 
00413 class GDotAtom : public GStructured {
00414 public:
00415   GDotAtom() : GStructured()  {}
00416   GDotAtom( Content * p ) : GStructured( p ) {}
00417   GDotAtom( Content * p, const QCString & s )
00418     : GStructured( p ) { from7BitString(s); }
00419   GDotAtom( Content * p, const QString & s, const QCString & cs )
00420     : GStructured( p )  { fromUnicodeString( s, cs ); }
00421   ~GDotAtom()  {}
00422 
00423 protected:
00424   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00425 
00426   QString mDotAtom;
00427 };
00428 
00429 class GParametrized : public GStructured {
00430 public:
00431   GParametrized() : GStructured()  {}
00432   GParametrized( Content * p ) : GStructured( p ) {}
00433   GParametrized( Content * p, const QCString & s )
00434     : GStructured( p ) { from7BitString(s); }
00435   GParametrized( Content * p, const QString & s, const QCString & cs )
00436     : GStructured( p )  { fromUnicodeString( s, cs ); }
00437   ~GParametrized()  {}
00438 
00439 protected:
00440   QMap<QString,QString> mParameterHash;
00441 
00442 private:
00443 };
00444 
00445 class GContentType : public GParametrized {
00446 public:
00447   GContentType() : GParametrized()  {}
00448   GContentType( Content * p ) : GParametrized( p ) {}
00449   GContentType( Content * p, const QCString & s )
00450     : GParametrized( p ) { from7BitString(s); }
00451   GContentType( Content * p, const QString & s, const QCString & cs )
00452     : GParametrized( p )  { fromUnicodeString( s, cs ); }
00453   ~GContentType()  {}
00454 
00455 protected:
00456   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00457 
00458   QCString mMimeType;
00459   QCString mMimeSubType;
00460 };
00461 
00462 
00463 class GCISTokenWithParameterList : public GParametrized {
00464 public:
00465   GCISTokenWithParameterList() : GParametrized()  {}
00466   GCISTokenWithParameterList( Content * p ) : GParametrized( p ) {}
00467   GCISTokenWithParameterList( Content * p, const QCString & s )
00468     : GParametrized( p ) { from7BitString(s); }
00469   GCISTokenWithParameterList( Content * p, const QString & s, const QCString & cs )
00470     : GParametrized( p )  { fromUnicodeString( s, cs ); }
00471   ~GCISTokenWithParameterList()  {}
00472 
00473 protected:
00474   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00475 
00476   QCString mToken;
00477 };
00478 
00479 
00480 } // namespace Generics
00481 
00482 //
00483 //
00484 // INCOMPATIBLE, GSTRUCTURED-BASED FIELDS:
00485 //
00486 //
00487 
00488 
00490 class ReturnPath : public Generics::GAddress {
00491 public:
00492   ReturnPath() : Generics::GAddress()  {}
00493   ReturnPath( Content * p ) : Generics::GAddress( p ) {}
00494   ReturnPath( Content * p, const QCString & s )
00495     : Generics::GAddress( p ) { from7BitString(s); }
00496   ReturnPath( Content * p, const QString & s, const QCString & cs )
00497     : Generics::GAddress( p )  { fromUnicodeString( s, cs ); }
00498   ~ReturnPath()  {}
00499 
00500   const char * type() const { return "Return-Path"; }
00501 
00502 protected:
00503   bool parse( const char* & scursor, const char * const send, bool isCRLF=false );
00504 };
00505 
00506 #if defined(KMIME_NEW_STYLE_CLASSTREE)
00507 // classes whose names collide with earlier ones:
00508 
00509 // GAddress et al.:
00510 
00511 // rfc(2)822 headers:
00512 mk_trivial_subclass(From,MailboxList);
00513 mk_trivial_subclass(Sender,SingleMailbox);
00514 mk_trivial_subclass_with_name(ReplyTo,Reply-To,AddressList);
00515 mk_trivial_subclass(Cc,AddressList);
00516 mk_trivial_subclass(Bcc,AddressList);
00517 // usefor headers:
00518 mk_trivial_subclass_with_name(MailCopiesTo,Mail-Copies-To,AddressList);
00519 
00520 // GToken:
00521 
00522 mk_trivial_subclass_with_name(ContentTransferEncoding,
00523                   Content-Transfer-Encoding,GToken);
00524 
00525 // GPhraseList:
00526 
00527 mk_trivial_subclass(Keywords,GPhraseList);
00528 
00529 // GDotAtom:
00530 
00531 mk_trivial_subclass_with_name(MIMEVersion,MIME-Version,GDotAtom);
00532 
00533 // GIdent:
00534 
00535 mk_trivial_subclass_with_name(MessageID,Message-ID,GSingleIdent);
00536 mk_trivial_subclass_with_name(ContentID,Content-ID,GSingleIdent);
00537 mk_trivial_subclass(Supersedes,GSingleIdent);
00538 mk_trivial_subclass_with_name(InReplyTo,In-Reply-To,GIdent);
00539 mk_trivial_subclass(References,GIdent);
00540 
00541 // GContentType:
00542 
00543 mk_trivial_subclass_with_name(ContentType,ContentType,GContentType);
00544 
00545 // GCISTokenWithParameterList:
00546 
00547 mk_trivial_subclass_with_name(ContentDisposition,Content-Disposition,
00548                   GCISTokenWithParameterList);
00549 
00550 
00551 #endif
00552 
00553 
00554 //
00555 //
00556 // COMPATIBLE GUNSTRUCTURED-BASED FIELDS:
00557 //
00558 //
00559 
00560 
00566 class Generic : public Generics::GUnstructured {
00567 
00568   public:
00569     Generic() : Generics::GUnstructured(), t_ype(0) {}
00570     Generic(const char *t)
00571       : Generics::GUnstructured(), t_ype(0) { setType(t); }
00572     Generic(const char *t, Content *p)
00573       : Generics::GUnstructured( p ), t_ype(0) { setType(t); }
00574     Generic(const char *t, Content *p, const QCString &s)
00575       : Generics::GUnstructured( p, s ), t_ype(0) { setType(t); }
00576     Generic(const char *t, Content *p, const QString &s, const QCString &cs)
00577       : Generics::GUnstructured( p, s, cs ), t_ype(0) { setType(t); }
00578     ~Generic() { delete[] t_ype; }
00579 
00580     virtual void clear()            { delete[] t_ype; GUnstructured::clear(); }
00581     virtual bool isEmpty()          { return (t_ype==0 || GUnstructured::isEmpty()); }
00582     virtual const char* type()      { return t_ype; }
00583     void setType(const char *type);
00584 
00585   protected:
00586     char *t_ype;
00587 
00588 };
00589 
00590 
00592 class Subject : public Generics::GUnstructured {
00593 
00594   public:
00595     Subject() : Generics::GUnstructured()  {}
00596     Subject( Content * p ) : Generics::GUnstructured( p )  {}
00597     Subject( Content * p, const QCString & s )
00598       : Generics::GUnstructured( p, s ) {}
00599     Subject( Content * p, const QString & s, const QCString & cs )
00600       : Generics::GUnstructured( p, s, cs ) {}
00601     ~Subject()  {}
00602 
00603     virtual const char* type() { return "Subject"; }
00604 
00605     bool isReply() {
00606       return ( asUnicodeString().find( QString("Re:"), 0, false ) == 0 );
00607     }
00608 };
00609 
00611 class Organization : public Generics::GUnstructured {
00612 
00613   public:
00614     Organization() : Generics::GUnstructured() {}
00615     Organization( Content * p ) : Generics::GUnstructured( p ) {}
00616     Organization( Content * p, const QCString & s )
00617       : Generics::GUnstructured( p, s ) {};
00618     Organization( Content * p, const QString & s, const QCString & cs)
00619       : Generics::GUnstructured( p, s, cs ) {}
00620     ~Organization()  {}
00621 
00622     virtual const char* type()      { return "Organization"; }
00623 
00624 };
00625 
00626 //
00627 //
00628 // NOT YET CONVERTED STUFF BELOW:
00629 //
00630 //
00631 
00632 
00633 
00635 class Control : public Base {
00636 
00637   public:
00638     Control() : Base()  {}
00639     Control(Content *p) : Base(p)  {}
00640     Control(Content *p, const QCString &s) : Base(p) { from7BitString(s); }
00641     Control(Content *p, const QString &s) : Base(p)  { fromUnicodeString(s, Latin1); }
00642     ~Control()  {}
00643 
00644     virtual void from7BitString(const QCString &s);
00645     virtual QCString as7BitString(bool incType=true);
00646     virtual void fromUnicodeString(const QString &s, const QCString&);
00647     virtual QString asUnicodeString();
00648     virtual void clear()            { c_trlMsg.truncate(0); }
00649     virtual bool isEmpty()          { return (c_trlMsg.isEmpty()); }
00650     virtual const char* type()      { return "Control"; }
00651 
00652     bool isCancel()                 { return (c_trlMsg.find("cancel", 0, false)!=-1); }
00653 
00654   protected:
00655     QCString c_trlMsg;
00656 
00657 };
00658 
00660 class Date : public Base {
00661 
00662   public:
00663     Date() : Base(), t_ime(0)  {}
00664     Date(Content *p) : Base(p), t_ime(0)  {}
00665     Date(Content *p, time_t t) : Base(p), t_ime(t)  {}
00666     Date(Content *p, const QCString &s) : Base(p)  { from7BitString(s); }
00667     Date(Content *p, const QString &s) : Base(p)  { fromUnicodeString(s, Latin1); }
00668     ~Date()  {}
00669 
00670     virtual void from7BitString(const QCString &s);
00671     virtual QCString as7BitString(bool incType=true);
00672     virtual void fromUnicodeString(const QString &s, const QCString&);
00673     virtual QString asUnicodeString();
00674     virtual void clear()            { t_ime=0; }
00675     virtual bool isEmpty()          { return (t_ime==0); }
00676     virtual const char* type()      { return "Date"; }
00677 
00678     time_t unixTime()               { return t_ime; }
00679     void setUnixTime(time_t t)      { t_ime=t; }
00680     void setUnixTime()              { t_ime=time(0); }
00681     QDateTime qdt();
00682     int ageInDays();
00683     
00684   protected:
00685     time_t t_ime;
00686 
00687 };
00688 
00689 
00691 class Newsgroups : public Base {
00692 
00693   public:
00694     Newsgroups() : Base()  {}
00695     Newsgroups(Content *p) : Base(p)  {}
00696     Newsgroups(Content *p, const QCString &s) : Base(p)  { from7BitString(s); }
00697     Newsgroups(Content *p, const QString &s) : Base(p)  { fromUnicodeString(s, Latin1); }
00698     ~Newsgroups()  {}
00699 
00700     virtual void from7BitString(const QCString &s);
00701     virtual QCString as7BitString(bool incType=true);
00702     virtual void fromUnicodeString(const QString &s, const QCString&);
00703     virtual QString asUnicodeString();
00704     virtual void clear()            { g_roups.resize(0); }
00705     virtual bool isEmpty()          { return g_roups.isEmpty(); }
00706     virtual const char* type()      { return "Newsgroups"; }
00707 
00708     QCString firstGroup();
00709     bool isCrossposted()            { return ( g_roups.find(',')>-1 ); }
00710     QStringList getGroups();
00711 
00712   protected:
00713     QCString g_roups;
00714 
00715 };
00716 
00717 
00719 class FollowUpTo : public Newsgroups {
00720 
00721   public:
00722     FollowUpTo() : Newsgroups()  {}
00723     FollowUpTo(Content *p) : Newsgroups(p)  {}
00724     FollowUpTo(Content *p, const QCString &s) : Newsgroups(p,s)  {}
00725     FollowUpTo(Content *p, const QString &s) : Newsgroups(p,s)  {}
00726     ~FollowUpTo()  {}
00727 
00728     virtual const char* type()        { return "Followup-To"; }
00729 
00730 };
00731 
00732 
00734 class Lines : public Base {
00735 
00736   public:
00737     Lines() : Base(),l_ines(-1)  {}
00738     Lines(Content *p) : Base(p),l_ines(-1)  {}
00739     Lines(Content *p, unsigned int i) : Base(p),l_ines(i)  {}
00740     Lines(Content *p, const QCString &s) : Base(p)  { from7BitString(s); }
00741     Lines(Content *p, const QString &s) : Base(p)  { fromUnicodeString(s, Latin1); }
00742     ~Lines()                 {}
00743 
00744     virtual void from7BitString(const QCString &s);
00745     virtual QCString as7BitString(bool incType=true);
00746     virtual void fromUnicodeString(const QString &s, const QCString&);
00747     virtual QString asUnicodeString();
00748     virtual void clear()            { l_ines=-1; }
00749     virtual bool isEmpty()          { return (l_ines==-1); }
00750     virtual const char* type()      { return "Lines"; }
00751 
00752     int numberOfLines()             { return l_ines; }
00753     void setNumberOfLines(int i)    { l_ines=i; }
00754 
00755   protected:
00756     int l_ines;
00757 
00758 };
00759 
00760 
00761 
00763 class UserAgent : public Base {
00764 
00765   public:
00766     UserAgent() : Base()  {}
00767     UserAgent(Content *p) : Base(p)  {}
00768     UserAgent(Content *p, const QCString &s) : Base(p)  { from7BitString(s); }
00769     UserAgent(Content *p, const QString &s) : Base(p)  { fromUnicodeString(s, Latin1); }
00770     ~UserAgent()  {}
00771 
00772     virtual void from7BitString(const QCString &s);
00773     virtual QCString as7BitString(bool incType=true);
00774     virtual void fromUnicodeString(const QString &s, const QCString&);
00775     virtual QString asUnicodeString();
00776     virtual void clear()            { u_agent.resize(0); }
00777     virtual bool isEmpty()          { return (u_agent.isEmpty()); }
00778     virtual const char* type()      { return "User-Agent"; }
00779 
00780   protected:
00781     QCString u_agent;
00782 
00783 };
00784 
00785 
00786 #if !defined(KMIME_NEW_STYLE_CLASSTREE)
00787 #include "kmime_headers_obs.h"
00788 #endif
00789 }  //namespace Headers
00790 
00791 #if 0
00792 typedef Headers::Base* (*headerCreator)(void);
00793 
00809 class HeaderFactory : public QAsciiDict<headerCreator>
00810 {
00811 private:
00812   HeaderFactory();
00813   ~HeaderFactory() {}
00814   static QAsciiDict
00815 
00816 public:
00820   static Headers::Base* create( const char* aType )
00821   {
00822     if (!s_elf)
00823       s_elf = new HeaderFactory;
00824     headerCreator * hc = (*s_elf)[aType];
00825     if ( !hc )
00826       return 0;
00827     else
00828       return (*hc)();
00829   }
00830 
00835   static Headers::Base* create( const QCString& aType )
00836   {
00837     return create( aType.data() );
00838   }
00839 
00849   static Headers::Base* upgrade( Headers::Generic* aType ) { (void)aType; return new Headers::Base; }
00850 
00851 };
00852 
00853 #endif
00854 
00855 }  //namespace KMime
00856 
00857 
00858 #endif // __KMIME_HEADERS_H__
00859 
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:52:02 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003