16 #ifndef __KMIME_CONTENT_H__
17 #define __KMIME_CONTENT_H__
23 class KMime::Headers::ContentType;
24 class KMime::Headers::CTEncoding;
25 class KMime::Headers::CDisposition;
26 class KMime::Headers::List;
29 #include "kmime_util.h"
30 #include "kmime_headers.h"
32 #include <tqtextstream.h>
47 enum articleType { ATmimeContent,
62 typedef TQPtrList<KMime::Content> List;
65 Content(
const TQCString &h,
const TQCString &b);
69 virtual articleType type() {
return ATmimeContent; }
72 bool hasContent() {
return ( !h_ead.isEmpty() && (!b_ody.isEmpty() || (c_ontents && !c_ontents->isEmpty())) ); }
73 void setContent(TQStrList *l);
74 void setContent(
const TQCString &s);
76 virtual void assemble();
80 TQCString head() {
return h_ead; }
85 virtual bool removeHeader(
const char *type);
86 bool hasHeader(
const char *type) {
return (getHeaderByType(type)!=0); }
87 Headers::ContentType* contentType(
bool create=
true) { Headers::ContentType *p=0;
return getHeaderInstance(p, create); }
88 Headers::CTEncoding* contentTransferEncoding(
bool create=
true) { Headers::CTEncoding *p=0;
return getHeaderInstance(p, create); }
89 Headers::CDisposition* contentDisposition(
bool create=
true) { Headers::CDisposition *p=0;
return getHeaderInstance(p, create); }
90 Headers::CDescription* contentDescription(
bool create=
true) { Headers::CDescription *p=0;
return getHeaderInstance(p, create); }
96 TQCString body() {
return b_ody; }
97 void setBody(
const TQCString & str ) { b_ody = str; }
98 TQCString encodedContent(
bool useCrLf=
false);
99 TQByteArray decodedContent();
100 void decodedText(TQString &s,
bool trimText=
false,
101 bool removeTrailingNewlines=
false);
102 void decodedText(TQStringList &s,
bool trimText=
false,
103 bool removeTrailingNewlines=
false);
104 void fromUnicodeString(
const TQString &s);
107 void attachments(List *dst,
bool incAlternatives=
false);
108 void addContent(
Content *c,
bool prepend=
false);
109 void removeContent(
Content *c,
bool del=
false);
110 void changeEncoding(Headers::contentEncoding e);
115 void toStream(TQTextStream &ts,
bool scrambleFromLines=
false);
119 TQCString defaultCharset() {
return TQCString(d_efaultCS); }
120 void setDefaultCharset(
const TQCString &cs);
124 bool forceDefaultCS() {
return f_orceDefaultCS; }
129 virtual void setForceDefaultCS(
bool b);
133 TQCString rawHeader(
const char *name);
135 template <
class T> T* getHeaderInstance(T *ptr,
bool create);
140 Headers::Base::List *h_eaders;
141 const char *d_efaultCS;
142 bool f_orceDefaultCS;
149 template <
class T> T* Content::getHeaderInstance(T *ptr,
bool create)
153 ptr=
static_cast <T*
> (getHeaderByType(dummy.type()));
157 h_eaders=
new Headers::Base::List();
158 h_eaders->setAutoDelete(
true);
160 h_eaders->append(ptr);
Base class for messages in mime format It contains all the enums, static functions and parser-classes...
This class encapsulates a mime-encoded content.