1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org> 2 3 #ifndef HEADER_H 4 #define HEADER_H 5 6 #include "list.h" 7 #include "field.h" 8 9 10 class EString; 11 class Address; 12 class ContentType; 13 class ContentTransferEncoding; 14 class ContentDisposition; 15 class ContentLanguage; 16 class AddressField; 17 class Date; 18 19 20 class Header 21 : public Garbage 22 { 23 public: 24 enum Mode { Rfc2822, Mime }; 25 Header( Mode ); 26 27 Mode mode() const; 28 bool valid() const; 29 EString error() const; 30 31 void add( HeaderField * ); 32 void add( const EString &, const EString & ); 33 void removeField( HeaderField::Type ); 34 void removeField( const char * ); 35 36 List< HeaderField > * fields() const; 37 HeaderField * field( HeaderField::Type, uint = 0 ) const; 38 HeaderField * field( const char *, uint = 0 ) const; 39 AddressField * addressField( HeaderField::Type, uint = 0 ) const; 40 41 Date * date( HeaderField::Type = HeaderField::Date ) const; 42 EString subject() const; 43 EString inReplyTo() const; 44 EString messageId( HeaderField::Type = HeaderField::MessageId ) const; 45 List< Address > * addresses( HeaderField::Type ) const; 46 ContentType * contentType() const; 47 ContentTransferEncoding * contentTransferEncoding() const; 48 ContentDisposition * contentDisposition() const; 49 ContentLanguage * contentLanguage() const; 50 EString contentDescription() const; 51 EString contentLocation() const; 52 53 bool needsUnicode() const; 54 55 void simplify(); 56 void repair(); 57 void repair( class Multipart *, const EString & ); 58 void fix8BitFields( class Codec * ); 59 60 EString asText( bool ) const; 61 62 enum DefaultType { TextPlain, MessageRfc822 }; 63 void setDefaultType( DefaultType ); 64 DefaultType defaultType() const; 65 66 private: 67 class HeaderData * d; 68 69 void verify() const; 70 void appendField( EString &, HeaderField *, bool avoidUtf8 ) const; 71 }; 72 73 74 #endif 75