kmime_headers_obs.h
00001 /* 00002 kmime_headers.h 00003 00004 KMime, the KDE internet mail/usenet news message library. 00005 Copyright (c) 2001 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 as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software Foundation, 00014 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US 00015 */ 00016 #ifndef __KMIME_HEADERS_OBS_H__ 00017 #define __KMIME_HEADERS_OBS_H__ 00018 00019 #if defined(KMIME_NEW_STYPE_CLASSTREE) 00020 #error You cannot use this file with the new header classes! 00021 #endif 00022 00023 #include <tdepimmacros.h> 00024 00026 class KDE_EXPORT MessageID : public Base { 00027 00028 public: 00029 MessageID() : Base() {} 00030 MessageID(Content *p) : Base(p) {} 00031 MessageID(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00032 MessageID(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00033 ~MessageID() {} 00034 00035 virtual void from7BitString(const TQCString &s); 00036 virtual TQCString as7BitString(bool incType=true); 00037 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00038 virtual TQString asUnicodeString(); 00039 virtual void clear() { m_id.resize(0); } 00040 virtual bool isEmpty() { return (m_id.isEmpty()); } 00041 virtual const char* type() { return "Message-Id"; } 00042 00043 void generate(const TQCString &fqdn); 00044 00045 protected: 00046 TQCString m_id; 00047 00048 }; 00049 00051 class KDE_EXPORT Supersedes : public MessageID { 00052 00053 public: 00054 Supersedes() : MessageID() {} 00055 Supersedes(Content *p) : MessageID(p) {} 00056 Supersedes(Content *p, const TQCString &s) : MessageID(p,s) {} 00057 Supersedes(Content *p, const TQString &s) : MessageID(p,s) {} 00058 ~Supersedes() {} 00059 00060 virtual const char* type() { return "Supersedes"; } 00061 00062 }; 00063 00066 class KDE_EXPORT AddressField : public Base { 00067 00068 public: 00069 AddressField() : Base() {} 00070 AddressField(Content *p) : Base(p) {} 00071 AddressField(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00072 AddressField(Content *p, const TQString &s, const TQCString &cs) : Base(p) { fromUnicodeString(s, cs); } 00073 AddressField(const AddressField &a): Base(a.p_arent) { n_ame=a.n_ame; e_mail=a.e_mail.copy(); e_ncCS=a.e_ncCS; } 00074 ~AddressField() {} 00075 00076 AddressField& operator=(const AddressField &a) { n_ame=a.n_ame; e_mail=a.e_mail.copy(); e_ncCS=a.e_ncCS; return (*this); } 00077 00078 virtual void from7BitString(const TQCString &s); 00079 virtual TQCString as7BitString(bool incType=true); 00080 virtual void fromUnicodeString(const TQString &s, const TQCString &cs); 00081 virtual TQString asUnicodeString(); 00082 virtual void clear() { n_ame.truncate(0); e_mail.resize(0); } 00083 virtual bool isEmpty() { return (e_mail.isEmpty() && n_ame.isEmpty()); } 00084 00085 bool hasName() { return ( !n_ame.isEmpty() ); } 00086 bool hasEmail() { return ( !e_mail.isEmpty() ); } 00087 TQString name() { return n_ame; } 00088 TQCString nameAs7Bit(); 00089 TQCString email() { return e_mail; } 00090 void setName(const TQString &s) { n_ame=s; } 00091 void setNameFrom7Bit(const TQCString &s); 00092 void setEmail(const TQCString &s) { e_mail=s; } 00093 00094 protected: 00095 TQString n_ame; 00096 TQCString e_mail; 00097 }; 00098 typedef TQPtrList<AddressField> ObsAddressList; 00099 00101 class KDE_EXPORT From : public AddressField { 00102 00103 public: 00104 From() : AddressField() {} 00105 From(Content *p) : AddressField(p) {} 00106 From(Content *p, const TQCString &s) : AddressField(p,s) {} 00107 From(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {} 00108 ~From() {} 00109 00110 virtual const char* type() { return "From"; } 00111 }; 00112 00113 00115 class KDE_EXPORT ReplyTo : public AddressField { 00116 00117 public: 00118 ReplyTo() : AddressField() {} 00119 ReplyTo(Content *p) : AddressField(p) {} 00120 ReplyTo(Content *p, const TQCString &s) : AddressField(p,s) {} 00121 ReplyTo(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {} 00122 ~ReplyTo() {} 00123 00124 virtual const char* type() { return "Reply-To"; } 00125 00126 }; 00127 00128 00131 class KDE_EXPORT MailCopiesTo : public AddressField { 00132 00133 public: 00134 MailCopiesTo() : AddressField() {} 00135 MailCopiesTo(Content *p) : AddressField(p) {} 00136 MailCopiesTo(Content *p, const TQCString &s) : AddressField(p,s) {} 00137 MailCopiesTo(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {} 00138 ~MailCopiesTo() {} 00139 00140 bool isValid(); 00141 bool alwaysCopy(); 00142 bool neverCopy(); 00143 00144 virtual const char* type() { return "Mail-Copies-To"; } 00145 00146 }; 00147 00149 class KDE_EXPORT To : public Base { 00150 00151 public: 00152 To() : Base(),a_ddrList(0) {} 00153 To(Content *p) : Base(p),a_ddrList(0) {} 00154 To(Content *p, const TQCString &s) : Base(p),a_ddrList(0) { from7BitString(s); } 00155 To(Content *p, const TQString &s, const TQCString &cs) : Base(p),a_ddrList(0) { fromUnicodeString(s,cs); } 00156 ~To() { delete a_ddrList; } 00157 00158 virtual void from7BitString(const TQCString &s); 00159 virtual TQCString as7BitString(bool incType=true); 00160 virtual void fromUnicodeString(const TQString &s, const TQCString &cs); 00161 virtual TQString asUnicodeString(); 00162 virtual void clear() { delete a_ddrList; a_ddrList=0; } 00163 virtual bool isEmpty() { return (!a_ddrList || a_ddrList->isEmpty() 00164 || a_ddrList->first()->isEmpty()); } 00165 virtual const char* type() { return "To"; } 00166 00167 void addAddress(const AddressField &a); 00168 void emails(TQStrList *l); 00169 void names(TQStringList *l); 00170 void displayNames(TQStringList *l); 00171 00172 protected: 00173 ObsAddressList *a_ddrList; 00174 00175 }; 00176 00177 00179 class KDE_EXPORT CC : public To { 00180 00181 public: 00182 CC() : To() {} 00183 CC(Content *p) : To(p) {} 00184 CC(Content *p, const TQCString &s) : To(p,s) {} 00185 CC(Content *p, const TQString &s, const TQCString &cs) : To(p,s,cs) {} 00186 ~CC() {} 00187 00188 virtual const char* type() { return "CC"; } 00189 00190 }; 00191 00192 00194 class KDE_EXPORT BCC : public To { 00195 00196 public: 00197 BCC() : To() {} 00198 BCC(Content *p) : To(p) {} 00199 BCC(Content *p, const TQCString &s) : To(p,s) {} 00200 BCC(Content *p, const TQString &s, const TQCString &cs) : To(p,s,cs) {} 00201 ~BCC() {} 00202 00203 virtual const char* type() { return "BCC"; } 00204 00205 }; 00206 00208 class KDE_EXPORT References : public Base { 00209 00210 public: 00211 References() : Base(),p_os(-1) {} 00212 References(Content *p) : Base(p),p_os(-1) {} 00213 References(Content *p, const TQCString &s) : Base(p),p_os(-1) { from7BitString(s); } 00214 References(Content *p, const TQString &s) : Base(p),p_os(-1) { fromUnicodeString(s, Latin1); } 00215 ~References() {} 00216 00217 virtual void from7BitString(const TQCString &s); 00218 virtual TQCString as7BitString(bool incType=true); 00219 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00220 virtual TQString asUnicodeString(); 00221 virtual void clear() { r_ef.resize(0); p_os=0; } 00222 virtual bool isEmpty() { return (r_ef.isEmpty()); } 00223 virtual const char* type() { return "References"; } 00224 00225 int count(); 00226 TQCString first(); 00227 TQCString next(); 00228 TQCString at(unsigned int i); 00229 void append(const TQCString &s); 00230 00231 protected: 00232 TQCString r_ef; 00233 int p_os; 00234 00235 }; 00236 00238 class KDE_EXPORT ContentType : public Base { 00239 00240 public: 00241 ContentType() : Base(),m_imeType("invalid/invalid"),c_ategory(CCsingle) {} 00242 ContentType(Content *p) : Base(p),m_imeType("invalid/invalid"),c_ategory(CCsingle) {} 00243 ContentType(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00244 ContentType(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00245 ~ContentType() {} 00246 00247 virtual void from7BitString(const TQCString &s); 00248 virtual TQCString as7BitString(bool incType=true); 00249 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00250 virtual TQString asUnicodeString(); 00251 virtual void clear() { m_imeType.resize(0); p_arams.resize(0); } 00252 virtual bool isEmpty() { return (m_imeType.isEmpty()); } 00253 virtual const char* type() { return "Content-Type"; } 00254 00255 00256 //mime-type handling 00257 TQCString mimeType() { return m_imeType; } 00258 TQCString mediaType(); 00259 TQCString subType(); 00260 void setMimeType(const TQCString &s); 00261 bool isMediatype(const char *s); 00262 bool isSubtype(const char *s); 00263 bool isText(); 00264 bool isPlainText(); 00265 bool isHTMLText(); 00266 bool isImage(); 00267 bool isMultipart(); 00268 bool isPartial(); 00269 00270 //parameter handling 00271 TQCString charset(); 00272 void setCharset(const TQCString &s); 00273 TQCString boundary(); 00274 void setBoundary(const TQCString &s); 00275 TQString name(); 00276 void setName(const TQString &s, const TQCString &cs); 00277 TQCString id(); 00278 void setId(const TQCString &s); 00279 int partialNumber(); 00280 int partialCount(); 00281 void setPartialParams(int total, int number); 00282 00283 //category 00284 contentCategory category() { return c_ategory; } 00285 void setCategory(contentCategory c) { c_ategory=c; } 00286 00287 protected: 00288 TQCString getParameter(const char *name); 00289 void setParameter(const TQCString &name, const TQCString &value, bool doubleQuotes=false); 00290 TQCString m_imeType, p_arams; 00291 contentCategory c_ategory; 00292 00293 }; 00294 00295 00297 class KDE_EXPORT CTEncoding : public Base { 00298 00299 public: 00300 CTEncoding() : Base(),c_te(CE7Bit),d_ecoded(true) {} 00301 CTEncoding(Content *p) : Base(p),c_te(CE7Bit),d_ecoded(true) {} 00302 CTEncoding(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00303 CTEncoding(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); } 00304 ~CTEncoding() {} 00305 00306 virtual void from7BitString(const TQCString &s); 00307 virtual TQCString as7BitString(bool incType=true); 00308 virtual void fromUnicodeString(const TQString &s, const TQCString&); 00309 virtual TQString asUnicodeString(); 00310 virtual void clear() { d_ecoded=true; c_te=CE7Bit; } 00311 virtual const char* type() { return "Content-Transfer-Encoding"; } 00312 00313 contentEncoding cte() { return c_te; } 00314 void setCte(contentEncoding e) { c_te=e; } 00315 bool decoded() { return d_ecoded; } 00316 void setDecoded(bool d=true) { d_ecoded=d; } 00317 bool needToEncode() { return (d_ecoded && (c_te==CEquPr || c_te==CEbase64)); } 00318 00319 protected: 00320 contentEncoding c_te; 00321 bool d_ecoded; 00322 00323 }; 00324 00325 00327 class KDE_EXPORT CDisposition : public Base { 00328 00329 public: 00330 CDisposition() : Base(),d_isp(CDinline) {} 00331 CDisposition(Content *p) : Base(p),d_isp(CDinline) {} 00332 CDisposition(Content *p, const TQCString &s) : Base(p) { from7BitString(s); } 00333 CDisposition(Content *p, const TQString &s, const TQCString &cs) : Base(p) { fromUnicodeString(s, cs); } 00334 ~CDisposition() {} 00335 00336 virtual void from7BitString(const TQCString &s); 00337 virtual TQCString as7BitString(bool incType=true); 00338 virtual void fromUnicodeString(const TQString &s, const TQCString &cs); 00339 virtual TQString asUnicodeString(); 00340 virtual void clear() { f_ilename.truncate(0); d_isp=CDinline; } 00341 virtual const char* type() { return "Content-Disposition"; } 00342 00343 contentDisposition disposition() { return d_isp; } 00344 void setDisposition(contentDisposition d) { d_isp=d; } 00345 bool isAttachment() { return (d_isp==CDattachment); } 00346 00347 TQString filename() { return f_ilename; } 00348 void setFilename(const TQString &s) { f_ilename=s; } 00349 00350 protected: 00351 contentDisposition d_isp; 00352 TQString f_ilename; 00353 00354 }; 00355 00356 00358 class KDE_EXPORT CDescription : public Generics::GUnstructured { 00359 00360 public: 00361 CDescription() : Generics::GUnstructured() {} 00362 CDescription( Content * p ) : Generics::GUnstructured( p ) {} 00363 CDescription( Content * p, const TQCString & s ) 00364 : Generics::GUnstructured( p, s ) {}; 00365 CDescription( Content * p, const TQString & s, const TQCString & cs ) 00366 : Generics::GUnstructured( p, s, cs ) {} 00367 ~CDescription() {} 00368 00369 virtual const char* type() { return "Content-Description"; } 00370 }; 00371 00372 #endif // __KMIME_HEADERS_OBS_H__