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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 <tqstring.h> 00028 #include <tqstrlist.h> 00029 #include <tqstringlist.h> 00030 #include <tqregexp.h> 00031 #include <tqdatetime.h> 00032 #include <tqasciidict.h> 00033 #include <tqmap.h> 00034 #include <tqptrlist.h> 00035 00036 #include <time.h> 00037 00038 #include <kdepimmacros.h> 00039 00040 namespace KMime { 00041 00042 //forward declaration 00043 class Content; 00044 00045 namespace Headers { 00046 00047 00048 enum contentCategory { CCsingle, 00049 CCcontainer, 00050 CCmixedPart, 00051 CCalternativePart }; 00052 00053 enum contentEncoding { CE7Bit, 00054 CE8Bit, 00055 CEquPr, 00056 CEbase64, 00057 CEuuenc, 00058 CEbinary }; 00059 00060 enum contentDisposition { CDinline, 00061 CDattachment, 00062 CDparallel }; 00063 00064 //often used charset 00065 static const TQCString Latin1("ISO-8859-1"); 00066 00067 #define mk_trivial_subclass_with_name( subclass, subclassName, baseclass ) \ 00068 class subclass : public Generics::baseclass { \ 00069 public: \ 00070 subclass() : Generics::baseclass() {} \ 00071 subclass( Content * p ) : Generics::baseclass( p ) {} \ 00072 subclass( Content * p, const TQCString & s ) \ 00073 : Generics::baseclass( p ) { from7BitString( s ); } \ 00074 subclass( Content * p, const TQString & s, const TQCString & cs ) \ 00075 : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \ 00076 ~subclass() {} \ 00077 \ 00078 const char * type() const { return #subclassName; } \ 00079 } 00080 00081 #define mk_trivial_subclass( subclass, baseclass ) \ 00082 mk_trivial_subclass_with_name( subclass, subclass, baseclass ) 00083 00084 #define mk_parsing_subclass_with_name( subclass, subclassName, baseclass ) \ 00085 class subclass : public Generics::baseclass { \ 00086 public: \ 00087 subclass() : Generics::baseclass() {} \ 00088 subclass( Content * p ) : Generics::baseclass( p ) {} \ 00089 subclass( Content * p, const TQCString & s ) \ 00090 : Generics::baseclass( p ) { from7BitString( s ); } \ 00091 subclass( Content * p, const TQString & s, const TQCString & cs ) \ 00092 : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \ 00093 ~subclass() {} \ 00094 \ 00095 const char * type() const { return #subclassName; } \ 00096 protected: \ 00097 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); \ 00098 } 00099 00100 #define mk_parsing_subclass( subclass, baseclass ) \ 00101 mk_parsing_subclass_with_name( subclass, subclass, baseclass ) 00102 00103 // 00104 // 00105 // HEADER'S BASE CLASS. DEFINES THE COMMON INTERFACE 00106 // 00107 // 00108 00111 class KDE_EXPORT Base { 00112 00113 public: 00114 typedef TQPtrList<Base> List; 00115 00117 Base() : e_ncCS(0), p_arent(0) {} 00118 00120 Base(KMime::Content *parent) : e_ncCS(0), p_arent(parent) {} 00121 00123 virtual ~Base() {} 00124 00126 KMime::Content* parent() { return p_arent; } 00127 00129 void setParent(KMime::Content *p) { p_arent=p; } 00130 00134 virtual void from7BitString(const TQCString&) {} 00135 00138 virtual TQCString as7BitString(bool=true) { return TQCString(); } 00139 00141 TQCString rfc2047Charset(); 00142 00144 void setRFC2047Charset(const TQCString &cs); 00145 00147 TQCString defaultCS(); 00148 00150 bool forceCS(); 00151 00153 virtual void fromUnicodeString(const TQString&, const TQCString&) {} 00154 00157 virtual TQString asUnicodeString() { return TQString(); } 00158 00160 virtual void clear() {} 00161 00163 virtual bool isEmpty() { return false; } 00164 00166 virtual const char* type() { return ""; } 00167 00169 bool is(const char* t) { return (strcasecmp(t, type())==0); } 00170 00172 bool isMimeHeader() { return (strncasecmp(type(), "Content-", 8)==0); } 00173 00175 bool isXHeader() { return (strncmp(type(), "X-", 2)==0); } 00176 00177 protected: 00178 TQCString typeIntro() { return (TQCString(type())+": "); } 00179 00180 const char *e_ncCS; 00181 Content *p_arent; 00182 00183 }; 00184 00185 00186 // 00187 // 00188 // GENERIC BASE CLASSES FOR DIFFERENT TYPES OF FIELDS 00189 // 00190 // 00191 00192 namespace Generics { 00193 00213 // known issues: 00214 // - uses old decodeRFC2047String function, instead of our own... 00215 00216 class KDE_EXPORT GUnstructured : public Base { 00217 00218 public: 00219 GUnstructured() : Base() {} 00220 GUnstructured( Content * p ) : Base( p ) {} 00221 GUnstructured( Content * p, const TQCString & s ) 00222 : Base( p ) { from7BitString(s); } 00223 GUnstructured( Content * p, const TQString & s, const TQCString & cs ) 00224 : Base( p ) { fromUnicodeString( s, cs ); } 00225 ~GUnstructured() {} 00226 00227 virtual void from7BitString( const TQCString& str ); 00228 virtual TQCString as7BitString( bool withHeaderType=true ); 00229 00230 virtual void fromUnicodeString( const TQString & str, 00231 const TQCString & suggestedCharset); 00232 virtual TQString asUnicodeString(); 00233 00234 virtual void clear() { d_ecoded.truncate(0); } 00235 virtual bool isEmpty() { return (d_ecoded.isEmpty()); } 00236 00237 private: 00238 TQString d_ecoded; 00239 }; 00240 00269 class KDE_EXPORT GStructured : public Base { 00270 public: 00271 GStructured() : Base() {} 00272 GStructured( Content * p ) : Base( p ) {} 00273 GStructured( Content * p, const TQCString & s ) 00274 : Base( p ) { from7BitString(s); } 00275 GStructured( Content * p, const TQString & s, const TQCString & cs ) 00276 : Base( p ) { fromUnicodeString( s, cs ); } 00277 ~GStructured() {} 00278 00279 00280 protected: 00281 #if 0 00282 // the assembly squad: 00283 00284 bool writeAtom( char* & dcursor, const char * const dend, const TQString & input ); 00285 bool writeAtom( char* & dcursor, const char * const dend, 00286 const TQPair<const char*,int> & input ); 00287 bool writeToken( char* & dcursor, const char * const dend, const TQString & input ); 00288 bool writeToken( char* & dcursor, const char * const dend, 00289 const TQPair<const char*int> & input ); 00290 00291 bool writeGenericQuotedString( char* & dcursor, const char * const dend, 00292 const TQString & input, bool withCRLF=false ); 00293 bool writeComment( char* & dcursor, const char * const dend, 00294 const TQString & input, bool withCRLF=false ); 00295 bool writePhrase( char* & dcursor, const char * const dend, 00296 const TQString & input, bool withCRLF=false ); 00297 bool writeDotAtom( char* & dcursor, const char * const dend, 00298 const TQString & input, bool withCRLF=false ); 00299 #endif 00300 }; 00301 00302 00303 class KDE_EXPORT GAddress : public GStructured { 00304 public: 00305 GAddress() : GStructured() {} 00306 GAddress( Content * p ) : GStructured( p ) {} 00307 GAddress( Content * p, const TQCString & s ) 00308 : GStructured( p ) { from7BitString(s); } 00309 GAddress( Content * p, const TQString & s, const TQCString & cs ) 00310 : GStructured( p ) { fromUnicodeString( s, cs ); } 00311 ~GAddress() {} 00312 00313 protected: 00314 }; 00315 00316 00319 class KDE_EXPORT MailboxList : public GAddress { 00320 public: 00321 MailboxList() : GAddress() {} 00322 MailboxList( Content * p ) : GAddress( p ) {} 00323 MailboxList( Content * p, const TQCString & s ) 00324 : GAddress( p ) { from7BitString(s); } 00325 MailboxList( Content * p, const TQString & s, const TQCString & cs ) 00326 : GAddress( p ) { fromUnicodeString( s, cs ); } 00327 ~MailboxList() {} 00328 00329 protected: 00330 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00331 00333 TQValueList<Types::Mailbox> mMailboxList; 00334 }; 00335 00336 00339 mk_parsing_subclass(SingleMailbox,MailboxList); 00340 00343 class KDE_EXPORT AddressList : public GAddress { 00344 public: 00345 AddressList() : GAddress() {} 00346 AddressList( Content * p ) : GAddress( p ) {} 00347 AddressList( Content * p, const TQCString & s ) 00348 : GAddress( p ) { from7BitString(s); } 00349 AddressList( Content * p, const TQString & s, const TQCString & cs ) 00350 : GAddress( p ) { fromUnicodeString( s, cs ); } 00351 ~AddressList() {} 00352 00353 protected: 00354 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00355 00357 TQValueList<Types::Address> mAddressList; 00358 }; 00359 00361 class KDE_EXPORT GIdent : public GAddress { 00362 public: 00363 GIdent() : GAddress() {} 00364 GIdent( Content * p ) : GAddress( p ) {} 00365 GIdent( Content * p, const TQCString & s ) 00366 : GAddress( p ) { from7BitString(s); } 00367 GIdent( Content * p, const TQString & s, const TQCString & cs ) 00368 : GAddress( p ) { fromUnicodeString( s, cs ); } 00369 ~GIdent() {} 00370 00371 protected: 00372 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00373 00375 TQValueList<Types::AddrSpec> mMsgIdList; 00376 }; 00377 00379 mk_parsing_subclass(GSingleIdent,GIdent); 00380 00382 class KDE_EXPORT GToken : public GStructured { 00383 public: 00384 GToken() : GStructured() {} 00385 GToken( Content * p ) : GStructured( p ) {} 00386 GToken( Content * p, const TQCString & s ) 00387 : GStructured( p ) { from7BitString(s); } 00388 GToken( Content * p, const TQString & s, const TQCString & cs ) 00389 : GStructured( p ) { fromUnicodeString( s, cs ); } 00390 ~GToken() {} 00391 00392 protected: 00393 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00394 00395 TQCString mToken; 00396 }; 00397 00398 00399 class KDE_EXPORT GPhraseList : public GStructured { 00400 public: 00401 GPhraseList() : GStructured() {} 00402 GPhraseList( Content * p ) : GStructured( p ) {} 00403 GPhraseList( Content * p, const TQCString & s ) 00404 : GStructured( p ) { from7BitString(s); } 00405 GPhraseList( Content * p, const TQString & s, const TQCString & cs ) 00406 : GStructured( p ) { fromUnicodeString( s, cs ); } 00407 ~GPhraseList() {} 00408 00409 protected: 00410 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00411 00412 TQStringList mPhraseList; 00413 }; 00414 00415 class KDE_EXPORT GDotAtom : public GStructured { 00416 public: 00417 GDotAtom() : GStructured() {} 00418 GDotAtom( Content * p ) : GStructured( p ) {} 00419 GDotAtom( Content * p, const TQCString & s ) 00420 : GStructured( p ) { from7BitString(s); } 00421 GDotAtom( Content * p, const TQString & s, const TQCString & cs ) 00422 : GStructured( p ) { fromUnicodeString( s, cs ); } 00423 ~GDotAtom() {} 00424 00425 protected: 00426 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00427 00428 TQString mDotAtom; 00429 }; 00430 00431 class KDE_EXPORT GParametrized : public GStructured { 00432 public: 00433 GParametrized() : GStructured() {} 00434 GParametrized( Content * p ) : GStructured( p ) {} 00435 GParametrized( Content * p, const TQCString & s ) 00436 : GStructured( p ) { from7BitString(s); } 00437 GParametrized( Content * p, const TQString & s, const TQCString & cs ) 00438 : GStructured( p ) { fromUnicodeString( s, cs ); } 00439 ~GParametrized() {} 00440 00441 protected: 00442 TQMap<TQString,TQString> mParameterHash; 00443 00444 private: 00445 }; 00446 00447 class KDE_EXPORT GContentType : public GParametrized { 00448 public: 00449 GContentType() : GParametrized() {} 00450 GContentType( Content * p ) : GParametrized( p ) {} 00451 GContentType( Content * p, const TQCString & s ) 00452 : GParametrized( p ) { from7BitString(s); } 00453 GContentType( Content * p, const TQString & s, const TQCString & cs ) 00454 : GParametrized( p ) { fromUnicodeString( s, cs ); } 00455 ~GContentType() {} 00456 00457 protected: 00458 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00459 00460 TQCString mMimeType; 00461 TQCString mMimeSubType; 00462 }; 00463 00464 00465 class KDE_EXPORT GCISTokenWithParameterList : public GParametrized { 00466 public: 00467 GCISTokenWithParameterList() : GParametrized() {} 00468 GCISTokenWithParameterList( Content * p ) : GParametrized( p ) {} 00469 GCISTokenWithParameterList( Content * p, const TQCString & s ) 00470 : GParametrized( p ) { from7BitString(s); } 00471 GCISTokenWithParameterList( Content * p, const TQString & s, const TQCString & cs ) 00472 : GParametrized( p ) { fromUnicodeString( s, cs ); } 00473 ~GCISTokenWithParameterList() {} 00474 00475 protected: 00476 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00477 00478 TQCString mToken; 00479 }; 00480 00481 00482 } // namespace Generics 00483 00484 // 00485 // 00486 // INCOMPATIBLE, GSTRUCTURED-BASED FIELDS: 00487 // 00488 // 00489 00490 00492 class KDE_EXPORT ReturnPath : public Generics::GAddress { 00493 public: 00494 ReturnPath() : Generics::GAddress() {} 00495 ReturnPath( Content * p ) : Generics::GAddress( p ) {} 00496 ReturnPath( Content * p, const TQCString & s ) 00497 : Generics::GAddress( p ) { from7BitString(s); } 00498 ReturnPath( Content * p, const TQString & s, const TQCString & cs ) 00499 : Generics::GAddress( p ) { fromUnicodeString( s, cs ); } 00500 ~ReturnPath() {} 00501 00502 const char * type() const { return "Return-Path"; } 00503 00504 protected: 00505 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); 00506 }; 00507 00508 #if defined(KMIME_NEW_STYLE_CLASSTREE) 00509 // classes whose names collide with earlier ones: 00510 00511 // GAddress et al.: 00512 00513 // rfc(2)822 headers: 00514 mk_trivial_subclass(From,MailboxList); 00515 mk_trivial_subclass(Sender,SingleMailbox); 00516 mk_trivial_subclass_with_name(ReplyTo,Reply-To,AddressList); 00517 mk_trivial_subclass(Cc,AddressList); 00518 mk_trivial_subclass(Bcc,AddressList); 00519 // usefor headers: 00520 mk_trivial_subclass_with_name(MailCopiesTo,Mail-Copies-To,AddressList); 00521 00522 // GToken: 00523 00524 mk_trivial_subclass_with_name(ContentTransferEncoding, 00525 Content-Transfer-Encoding,GToken); 00526 00527 // GPhraseList: 00528 00529 mk_trivial_subclass(Keywords,GPhraseList); 00530 00531 // GDotAtom: 00532 00533 mk_trivial_subclass_with_name(MIMEVersion,MIME-Version,GDotAtom); 00534 00535 // GIdent: 00536 00537 mk_trivial_subclass_with_name(MessageID,Message-ID,GSingleIdent); 00538 mk_trivial_subclass_with_name(ContentID,Content-ID,GSingleIdent); 00539 mk_trivial_subclass(Supersedes,GSingleIdent); 00540 mk_trivial_subclass_with_name(InReplyTo,In-Reply-To,GIdent); 00541 mk_trivial_subclass(References,GIdent); 00542 00543 // GContentType: 00544 00545 mk_trivial_subclass_with_name(ContentType,ContentType,GContentType); 00546 00547 // GCISTokenWithParameterList: 00548 00549 mk_trivial_subclass_with_name(ContentDisposition,Content-Disposition, 00550 GCISTokenWithParameterList); 00551 00552 00553 #endif 00554 00555 00556 // 00557 // 00558 // COMPATIBLE GUNSTRUCTURED-BASED FIELDS: 00559 // 00560 // 00561 00562 00568 class KDE_EXPORT Generic : public Generics::GUnstructured { 00569 00570 public: 00571 Generic() : Generics::GUnstructured(), t_ype(0) {} 00572 Generic(const char *t) 00573 : Generics::GUnstructured(), t_ype(0) { setType(t); } 00574 Generic(const char *t, Content *p) 00575 : Generics::GUnstructured( p ), t_ype(0) { setType(t); } 00576 Generic(const char *t, Content *p, const TQCString &s) 00577 : Generics::GUnstructured( p, s ), t_ype(0) { setType(t); } 00578 Generic(const char *t, Content *p, const TQString &s, const TQCString &cs) 00579 : Generics::GUnstructured( p, s, cs ), t_ype(0) { setType(t); } 00580 ~Generic() { delete[] t_ype; } 00581 00582 virtual void clear() { delete[] t_ype; GUnstructured::clear(); } 00583 virtual bool isEmpty() { return (t_ype==0 || GUnstructured::isEmpty()); } 00584 virtual const char* type() { return t_ype; } 00585 void setType(const char *type); 00586 00587 protected: 00588 char *t_ype; 00589 00590 }; 00591 00592 00594 class KDE_EXPORT Subject : public Generics::GUnstructured { 00595 00596 public: 00597 Subject() : Generics::GUnstructured() {} 00598 Subject( Content * p ) : Generics::GUnstructured( p ) {} 00599 Subject( Content * p, const TQCString & s ) 00600 : Generics::GUnstructured( p, s ) {} 00601 Subject( Content * p, const TQString & s, const TQCString & cs ) 00602 : Generics::GUnstructured( p, s, cs ) {} 00603 ~Subject() {} 00604 00605 virtual const char* type() { return "Subject"; } 00606 00607 bool isReply() { 00608 return ( asUnicodeString().find( TQString("Re:"), 0, false ) == 0 ); 00609 } 00610 }; 00611 00613 class KDE_EXPORT Organization : public Generics::GUnstructured { 00614 00615 public: 00616 Organization() : Generics::GUnstructured() {} 00617 Organization( Content * p ) : Generics::GUnstructured( p ) {} 00618 Organization( Content * p, const TQCString & s ) 00619 : Generics::GUnstructured( p, s ) {}; 00620 Organization( Content * p, const TQString & s, const TQCString & cs) 00621 : Generics::GUnstructured( p, s, cs ) {} 00622 ~Organization() {} 00623 00624 virtual const char* type() { return "Organization"; } 00625 00626 }; 00627 00628 // 00629 // 00630 // NOT YET CONVERTED STUFF BELOW: 00631 // 00632 // 00633 00634 00635 00637 class KDE_EXPORT Control : public Base { 00638 00639 public: 00640 Control() : Base() {} 00641 Control(Content *p) : Base(p) {} 00642 Control(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00643 Control(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00644 ~Control() {} 00645 00646 virtual void from7BitString(const TQCString &s); 00647 virtual TQCString as7BitString(bool incType=true); 00648 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00649 virtual TQString asUnicodeString(); 00650 virtual void clear() { c_trlMsg.truncate(0); } 00651 virtual bool isEmpty() { return (c_trlMsg.isEmpty()); } 00652 virtual const char* type() { return "Control"; } 00653 00654 bool isCancel() { return (c_trlMsg.find("cancel", 0, false)!=-1); } 00655 00656 protected: 00657 TQCString c_trlMsg; 00658 00659 }; 00660 00662 class KDE_EXPORT Date : public Base { 00663 00664 public: 00665 Date() : Base(), t_ime(0) {} 00666 Date(Content *p) : Base(p), t_ime(0) {} 00667 Date(Content *p, time_t t) : Base(p), t_ime(t) {} 00668 Date(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00669 Date(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00670 ~Date() {} 00671 00672 virtual void from7BitString(const TQCString &s); 00673 virtual TQCString as7BitString(bool incType=true); 00674 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00675 virtual TQString asUnicodeString(); 00676 virtual void clear() { t_ime=0; } 00677 virtual bool isEmpty() { return (t_ime==0); } 00678 virtual const char* type() { return "Date"; } 00679 00680 time_t unixTime() { return t_ime; } 00681 void setUnixTime(time_t t) { t_ime=t; } 00682 void setUnixTime() { t_ime=time(0); } 00683 TQDateTime qdt(); 00684 int ageInDays(); 00685 00686 protected: 00687 time_t t_ime; 00688 00689 }; 00690 00691 00693 class KDE_EXPORT Newsgroups : public Base { 00694 00695 public: 00696 Newsgroups() : Base() {} 00697 Newsgroups(Content *p) : Base(p) {} 00698 Newsgroups(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00699 Newsgroups(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00700 ~Newsgroups() {} 00701 00702 virtual void from7BitString(const TQCString &s); 00703 virtual TQCString as7BitString(bool incType=true); 00704 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00705 virtual TQString asUnicodeString(); 00706 virtual void clear() { g_roups.resize(0); } 00707 virtual bool isEmpty() { return g_roups.isEmpty(); } 00708 virtual const char* type() { return "Newsgroups"; } 00709 00710 TQCString firstGroup(); 00711 bool isCrossposted() { return ( g_roups.find(',')>-1 ); } 00712 TQStringList getGroups(); 00713 00714 protected: 00715 TQCString g_roups; 00716 00717 }; 00718 00719 00721 class KDE_EXPORT FollowUpTo : public Newsgroups { 00722 00723 public: 00724 FollowUpTo() : Newsgroups() {} 00725 FollowUpTo(Content *p) : Newsgroups(p) {} 00726 FollowUpTo(Content *p, const TQCString &s) : Newsgroups(p,s) {} 00727 FollowUpTo(Content *p, const TQString &s) : Newsgroups(p,s) {} 00728 ~FollowUpTo() {} 00729 00730 virtual const char* type() { return "Followup-To"; } 00731 00732 }; 00733 00734 00736 class KDE_EXPORT Lines : public Base { 00737 00738 public: 00739 Lines() : Base(),l_ines(-1) {} 00740 Lines(Content *p) : Base(p),l_ines(-1) {} 00741 Lines(Content *p, unsigned int i) : Base(p),l_ines(i) {} 00742 Lines(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00743 Lines(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00744 ~Lines() {} 00745 00746 virtual void from7BitString(const TQCString &s); 00747 virtual TQCString as7BitString(bool incType=true); 00748 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00749 virtual TQString asUnicodeString(); 00750 virtual void clear() { l_ines=-1; } 00751 virtual bool isEmpty() { return (l_ines==-1); } 00752 virtual const char* type() { return "Lines"; } 00753 00754 int numberOfLines() { return l_ines; } 00755 void setNumberOfLines(int i) { l_ines=i; } 00756 00757 protected: 00758 int l_ines; 00759 00760 }; 00761 00762 00763 00765 class KDE_EXPORT UserAgent : public Base { 00766 00767 public: 00768 UserAgent() : Base() {} 00769 UserAgent(Content *p) : Base(p) {} 00770 UserAgent(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00771 UserAgent(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00772 ~UserAgent() {} 00773 00774 virtual void from7BitString(const TQCString &s); 00775 virtual TQCString as7BitString(bool incType=true); 00776 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00777 virtual TQString asUnicodeString(); 00778 virtual void clear() { u_agent.resize(0); } 00779 virtual bool isEmpty() { return (u_agent.isEmpty()); } 00780 virtual const char* type() { return "User-Agent"; } 00781 00782 protected: 00783 TQCString u_agent; 00784 00785 }; 00786 00787 00788 #if !defined(KMIME_NEW_STYLE_CLASSTREE) 00789 #include "kmime_headers_obs.h" 00790 #endif 00791 } //namespace Headers 00792 00793 #if 0 00794 typedef Headers::Base* (*headerCreator)(void); 00795 00811 class HeaderFactory : public TQAsciiDict<headerCreator> 00812 { 00813 private: 00814 HeaderFactory(); 00815 ~HeaderFactory() {} 00816 static TQAsciiDict 00817 00818 public: 00822 static Headers::Base* create( const char* aType ) 00823 { 00824 if (!s_elf) 00825 s_elf = new HeaderFactory; 00826 headerCreator * hc = (*s_elf)[aType]; 00827 if ( !hc ) 00828 return 0; 00829 else 00830 return (*hc)(); 00831 } 00832 00837 static Headers::Base* create( const TQCString& aType ) 00838 { 00839 return create( aType.data() ); 00840 } 00841 00851 static Headers::Base* upgrade( Headers::Generic* aType ) { (void)aType; return new Headers::Base; } 00852 00853 }; 00854 00855 #endif 00856 00857 } //namespace KMime 00858 00859 00860 #endif // __KMIME_HEADERS_H__ 00861