15 #ifndef __KMIME_HEADERS_H__
16 #define __KMIME_HEADERS_H__
25 #include "kmime_header_parsing.h"
28 #include <tqstrlist.h>
29 #include <tqstringlist.h>
31 #include <tqdatetime.h>
32 #include <tqasciidict.h>
34 #include <tqptrlist.h>
38 #include <tdemacros.h>
48 enum contentCategory { CCsingle,
53 enum contentEncoding { CE7Bit,
60 enum contentDisposition { CDinline,
65 static const TQCString Latin1( "ISO-8859-1");
67 #define mk_trivial_subclass_with_name( subclass, subclassName, baseclass ) \
68 class subclass : public Generics::baseclass { \
70 subclass() : Generics::baseclass() {} \
71 subclass( Content * p ) : Generics::baseclass( p ) {} \
72 subclass( Content * p, const TQCString & s ) \
73 : Generics::baseclass( p ) { from7BitString( s ); } \
74 subclass( Content * p, const TQString & s, const TQCString & cs ) \
75 : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \
78 const char * type() const { return #subclassName; } \
81 #define mk_trivial_subclass( subclass, baseclass ) \
82 mk_trivial_subclass_with_name( subclass, subclass, baseclass )
84 #define mk_parsing_subclass_with_name( subclass, subclassName, baseclass ) \
85 class subclass : public Generics::baseclass { \
87 subclass() : Generics::baseclass() {} \
88 subclass( Content * p ) : Generics::baseclass( p ) {} \
89 subclass( Content * p, const TQCString & s ) \
90 : Generics::baseclass( p ) { from7BitString( s ); } \
91 subclass( Content * p, const TQString & s, const TQCString & cs ) \
92 : Generics::baseclass( p ) { fromUnicodeString( s, cs ); } \
95 const char * type() const { return #subclassName; } \
97 bool parse( const char* & scursor, const char * const send, bool isCRLF=false ); \
100 #define mk_parsing_subclass( subclass, baseclass ) \
101 mk_parsing_subclass_with_name( subclass, subclass, baseclass )
114 typedef TQPtrList<Base> List;
117 Base() : e_ncCS(0), p_arent(0) {}
141 TQCString rfc2047Charset();
144 void setRFC2047Charset( const TQCString &cs);
147 TQCString defaultCS();
166 virtual const char* type() { return ""; }
169 bool is( const char* t) { return (strcasecmp(t, type())==0); }
172 bool isMimeHeader() { return (strncasecmp(type(), "Content-", 8)==0); }
175 bool isXHeader() { return (strncmp(type(), "X-", 2)==0); }
178 TQCString typeIntro() { return (TQCString(type())+ ": "); }
222 : Base( p ) { from7BitString(s); }
224 : Base( p ) { fromUnicodeString( s, cs ); }
227 virtual void from7BitString( const TQCString& str );
228 virtual TQCString as7BitString( bool withHeaderType= true );
230 virtual void fromUnicodeString( const TQString & str,
231 const TQCString & suggestedCharset);
232 virtual TQString asUnicodeString();
234 virtual void clear() { d_ecoded.truncate(0); }
235 virtual bool isEmpty() { return (d_ecoded.isEmpty()); }
274 : Base( p ) { from7BitString(s); }
276 : Base( p ) { fromUnicodeString( s, cs ); }
284 bool writeAtom( char* & dcursor, const char * const dend, const TQString & input );
285 bool writeAtom( char* & dcursor, const char * const dend,
286 const TQPair<const char*,int> & input );
287 bool writeToken( char* & dcursor, const char * const dend, const TQString & input );
288 bool writeToken( char* & dcursor, const char * const dend,
289 const TQPair<const char*int> & input );
291 bool writeGenericQuotedString( char* & dcursor, const char * const dend,
292 const TQString & input, bool withCRLF= false );
293 bool writeComment( char* & dcursor, const char * const dend,
294 const TQString & input, bool withCRLF= false );
295 bool writePhrase( char* & dcursor, const char * const dend,
296 const TQString & input, bool withCRLF= false );
297 bool writeDotAtom( char* & dcursor, const char * const dend,
298 const TQString & input, bool withCRLF= false );
306 GAddress( Content * p ) : GStructured( p ) {}
307 GAddress( Content * p, const TQCString & s )
308 : GStructured( p ) { from7BitString(s); }
309 GAddress( Content * p, const TQString & s, const TQCString & cs )
310 : GStructured( p ) { fromUnicodeString( s, cs ); }
324 : GAddress( p ) { from7BitString(s); }
326 : GAddress( p ) { fromUnicodeString( s, cs ); }
330 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
348 : GAddress( p ) { from7BitString(s); }
350 : GAddress( p ) { fromUnicodeString( s, cs ); }
354 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
361 class TDE_EXPORT GIdent : public GAddress {
366 : GAddress( p ) { from7BitString(s); }
367 GIdent( Content * p, const TQString & s, const TQCString & cs )
368 : GAddress( p ) { fromUnicodeString( s, cs ); }
372 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
379 mk_parsing_subclass(GSingleIdent, GIdent);
388 GToken( Content * p, const TQString & s, const TQCString & cs )
393 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
399 class TDE_EXPORT GPhraseList : public GStructured {
402 GPhraseList( Content * p ) : GStructured( p ) {}
403 GPhraseList( Content * p, const TQCString & s )
404 : GStructured( p ) { from7BitString(s); }
405 GPhraseList( Content * p, const TQString & s, const TQCString & cs )
406 : GStructured( p ) { fromUnicodeString( s, cs ); }
410 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
412 TQStringList mPhraseList;
415 class TDE_EXPORT GDotAtom : public GStructured {
417 GDotAtom() : GStructured() {}
418 GDotAtom( Content * p ) : GStructured( p ) {}
419 GDotAtom( Content * p, const TQCString & s )
420 : GStructured( p ) { from7BitString(s); }
421 GDotAtom( Content * p, const TQString & s, const TQCString & cs )
422 : GStructured( p ) { fromUnicodeString( s, cs ); }
426 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
431 class TDE_EXPORT GParametrized : public GStructured {
433 GParametrized() : GStructured() {}
434 GParametrized( Content * p ) : GStructured( p ) {}
435 GParametrized( Content * p, const TQCString & s )
436 : GStructured( p ) { from7BitString(s); }
437 GParametrized( Content * p, const TQString & s, const TQCString & cs )
438 : GStructured( p ) { fromUnicodeString( s, cs ); }
442 TQMap<TQString,TQString> mParameterHash;
447 class TDE_EXPORT GContentType : public GParametrized {
449 GContentType() : GParametrized() {}
450 GContentType( Content * p ) : GParametrized( p ) {}
451 GContentType( Content * p, const TQCString & s )
452 : GParametrized( p ) { from7BitString(s); }
453 GContentType( Content * p, const TQString & s, const TQCString & cs )
454 : GParametrized( p ) { fromUnicodeString( s, cs ); }
458 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
461 TQCString mMimeSubType;
465 class TDE_EXPORT GCISTokenWithParameterList : public GParametrized {
467 GCISTokenWithParameterList() : GParametrized() {}
468 GCISTokenWithParameterList( Content * p ) : GParametrized( p ) {}
469 GCISTokenWithParameterList( Content * p, const TQCString & s )
470 : GParametrized( p ) { from7BitString(s); }
471 GCISTokenWithParameterList( Content * p, const TQString & s, const TQCString & cs )
472 : GParametrized( p ) { fromUnicodeString( s, cs ); }
473 ~GCISTokenWithParameterList() {}
476 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
497 : Generics::GAddress( p ) { from7BitString(s); }
499 : Generics::GAddress( p ) { fromUnicodeString( s, cs ); }
502 const char * type() const { return "Return-Path"; }
505 bool parse( const char* & scursor, const char * const send, bool isCRLF= false );
508 #if defined(KMIME_NEW_STYLE_CLASSTREE)
514 mk_trivial_subclass( From,MailboxList);
515 mk_trivial_subclass(Sender,SingleMailbox);
516 mk_trivial_subclass_with_name( ReplyTo,Reply- To,AddressList);
517 mk_trivial_subclass(Cc,AddressList);
518 mk_trivial_subclass(Bcc,AddressList);
520 mk_trivial_subclass_with_name( MailCopiesTo,Mail-Copies- To,AddressList);
524 mk_trivial_subclass_with_name(ContentTransferEncoding,
525 Content-Transfer-Encoding,GToken);
529 mk_trivial_subclass(Keywords,GPhraseList);
533 mk_trivial_subclass_with_name(MIMEVersion,MIME-Version,GDotAtom);
537 mk_trivial_subclass_with_name( MessageID,Message-ID,GSingleIdent);
538 mk_trivial_subclass_with_name(ContentID, Content-ID,GSingleIdent);
540 mk_trivial_subclass_with_name(InReplyTo,In-Reply- To,GIdent);
549 mk_trivial_subclass_with_name(ContentDisposition, Content-Disposition,
550 GCISTokenWithParameterList);
578 Generic( const char *t, Content *p, const TQString &s, const TQCString &cs)
582 virtual void clear() { delete[] t_ype; GUnstructured::clear(); }
583 virtual bool isEmpty() { return (t_ype==0 || GUnstructured::isEmpty()); }
584 virtual const char* type() { return t_ype; }
585 void setType( const char *type);
605 virtual const char* type() { return "Subject"; }
608 return ( asUnicodeString().find( TQString( "Re:"), 0, false ) == 0 );
624 virtual const char* type() { return "Organization"; }
646 virtual void from7BitString( const TQCString &s);
647 virtual TQCString as7BitString( bool incType= true);
648 virtual void fromUnicodeString( const TQString &s, const TQCString&);
649 virtual TQString asUnicodeString();
650 virtual void clear() { c_trlMsg.truncate(0); }
651 virtual bool isEmpty() { return (c_trlMsg.isEmpty()); }
652 virtual const char* type() { return "Control"; }
654 bool isCancel() { return (c_trlMsg.find( "cancel", 0, false)!=-1); }
669 Date( Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); }
672 virtual void from7BitString( const TQCString &s);
673 virtual TQCString as7BitString( bool incType= true);
674 virtual void fromUnicodeString( const TQString &s, const TQCString&);
675 virtual TQString asUnicodeString();
678 virtual const char* type() { return "Date"; }
680 time_t unixTime() { return t_ime; }
681 void setUnixTime(time_t t) { t_ime=t; }
682 void setUnixTime() { t_ime=time(0); }
702 virtual void from7BitString( const TQCString &s);
703 virtual TQCString as7BitString( bool incType= true);
704 virtual void fromUnicodeString( const TQString &s, const TQCString&);
705 virtual TQString asUnicodeString();
706 virtual void clear() { g_roups.resize(0); }
707 virtual bool isEmpty() { return g_roups.isEmpty(); }
708 virtual const char* type() { return "Newsgroups"; }
710 TQCString firstGroup();
711 bool isCrossposted() { return ( g_roups.find( ',')>-1 ); }
712 TQStringList getGroups();
730 virtual const char* type() { return "Followup-To"; }
743 Lines( Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); }
746 virtual void from7BitString( const TQCString &s);
747 virtual TQCString as7BitString( bool incType= true);
748 virtual void fromUnicodeString( const TQString &s, const TQCString&);
749 virtual TQString asUnicodeString();
751 virtual bool isEmpty() { return (l_ines==-1); }
752 virtual const char* type() { return "Lines"; }
754 int numberOfLines() { return l_ines; }
755 void setNumberOfLines( int i) { l_ines=i; }
774 virtual void from7BitString( const TQCString &s);
775 virtual TQCString as7BitString( bool incType= true);
776 virtual void fromUnicodeString( const TQString &s, const TQCString&);
777 virtual TQString asUnicodeString();
778 virtual void clear() { u_agent.resize(0); }
779 virtual bool isEmpty() { return (u_agent.isEmpty()); }
780 virtual const char* type() { return "User-Agent"; }
788 #if !defined(KMIME_NEW_STYLE_CLASSTREE)
789 #include "kmime_headers_obs.h"
794 typedef Headers::Base* (*headerCreator)(void);
811 class HeaderFactory : public TQAsciiDict<headerCreator>
822 static Headers::Base* create( const char* aType )
825 s_elf = new HeaderFactory;
826 headerCreator * hc = (*s_elf)[aType];
837 static Headers::Base* create( const TQCString& aType )
839 return create( aType.data() );
851 static Headers::Base* upgrade( Headers::Generic* aType ) { (void)aType; return new Headers::Base; }
Represents a "Content-Type" header.
Represent a "From" header.
This class encapsulates a mime-encoded content.
Represents a "Mail-Copies-To" header http://www.newsreaders.com/misc/mail-copies-to....
Represents a "Message-Id" header.
Represents a "References" header.
Represents a "Reply-To" header.
Represents a "Supersedes" header.
Represents a "To" header.
|