kmmsgpart.h
00001 /* -*- mode: C++ -*- 00002 * kmail: KDE mail client 00003 * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 */ 00020 #ifndef kmmsgpart_h 00021 #define kmmsgpart_h 00022 00023 #include <kiconloader.h> 00024 00025 #include <tqstring.h> 00026 #include <tqcstring.h> 00027 #include <tqdict.h> 00028 00029 template <typename T> 00030 class TQValueList; 00031 class TQTextCodec; 00032 class DwString; 00033 00034 class KMMessagePart 00035 { 00036 public: 00037 KMMessagePart(); 00038 KMMessagePart( TQDataStream & stream ); 00039 virtual ~KMMessagePart(); 00040 00042 void clear(); 00043 00046 void duplicate( const KMMessagePart & msgPart ); 00047 00049 TQCString body(void) const; 00050 void setBody(const TQCString &aStr); 00051 DwString dwBody() const; 00052 void setBody(const DwString &aStr); 00053 // warning, doesn't detach from 'arr' 00054 void setBody(const TQByteArray &arr); 00055 00059 void setBodyFromUnicode( const TQString & str ); 00060 00063 TQString bodyToUnicode(const TQTextCodec* codec=0) const; 00064 00068 TQByteArray bodyDecodedBinary(void) const; 00069 00072 TQCString bodyDecoded(void) const; 00073 00083 void setBodyAndGuessCte(const TQByteArray& aBuf, 00084 TQValueList<int>& allowedCte, 00085 bool allow8Bit = false, 00086 bool willBeSigned = false); 00088 void setBodyAndGuessCte(const TQCString& aBuf, 00089 TQValueList<int>& allowedCte, 00090 bool allow8Bit = false, 00091 bool willBeSigned = false); 00092 00097 void setBodyEncodedBinary(const TQByteArray& aStr); 00098 00106 void setBodyEncoded(const TQCString& aStr); 00107 00112 void setMessageBody( const TQByteArray & aBuf ); 00113 00115 int decodedSize(void) const; 00116 00120 TQCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; } 00121 void setOriginalContentTypeStr( const TQCString& txt ) 00122 { 00123 mOriginalContentTypeStr = txt; 00124 } 00125 TQCString typeStr() const { return mType; } 00126 void setTypeStr( const TQCString & aStr ) { mType = aStr; } 00127 int type() const; 00128 void setType(int aType); 00130 TQCString subtypeStr() const { return mSubtype; } 00131 void setSubtypeStr( const TQCString & aStr ) { mSubtype = aStr; } 00132 int subtype() const; 00133 void setSubtype(int aSubtype); 00134 00136 TQCString contentId() const { return mContentId; } 00137 void setContentId( const TQCString & aStr ) { mContentId = aStr; } 00138 00142 void magicSetType(bool autoDecode=TRUE); 00143 00146 TQCString parameterAttribute(void) const; 00147 TQString parameterValue(void) const; 00148 void setParameter(const TQCString &attribute, const TQString &value); 00149 00150 TQCString additionalCTypeParamStr(void) const 00151 { 00152 return mAdditionalCTypeParamStr; 00153 } 00154 void setAdditionalCTypeParamStr( const TQCString ¶m ) 00155 { 00156 mAdditionalCTypeParamStr = param; 00157 } 00158 00162 TQString iconName( int size = TDEIcon::Desktop ) const; 00163 00167 TQCString contentTransferEncodingStr(void) const; 00168 int contentTransferEncoding(void) const; 00169 void setContentTransferEncodingStr(const TQCString &aStr); 00170 void setContentTransferEncoding(int aCte); 00171 00174 TQCString cteStr(void) const { return contentTransferEncodingStr(); } 00175 int cte(void) const { return contentTransferEncoding(); } 00176 void setCteStr(const TQCString& aStr) { setContentTransferEncodingStr(aStr); } 00177 void setCte(int aCte) { setContentTransferEncoding(aCte); } 00178 00179 00181 TQString contentDescription() const; 00182 TQCString contentDescriptionEncoded() const { return mContentDescription; } 00183 void setContentDescription(const TQString &aStr); 00184 00186 TQCString contentDisposition() const { return mContentDisposition; } 00187 void setContentDisposition( const TQCString & cd ) { mContentDisposition = cd; } 00188 00190 TQCString charset() const { return mCharset; } 00191 00193 void setCharset( const TQCString & c ); 00194 00196 const TQTextCodec * codec() const; 00197 00199 TQString name() const { return mName; } 00200 void setName( const TQString & name ) { mName = name; } 00201 00204 TQString fileName(void) const; 00205 00207 TQString partSpecifier() const { return mPartSpecifier; } 00208 00210 void setPartSpecifier( const TQString & part ) { mPartSpecifier = part; } 00211 00213 bool isComplete() { return (!mBody.isNull()); } 00214 00216 KMMessagePart* parent() { return mParent; } 00217 00219 void setParent( KMMessagePart* part ) { mParent = part; } 00220 00222 bool loadHeaders() { return mLoadHeaders; } 00223 00225 void setLoadHeaders( bool load ) { mLoadHeaders = load; } 00226 00228 bool loadPart() { return mLoadPart; } 00229 00231 void setLoadPart( bool load ) { mLoadPart = load; } 00232 00233 protected: 00234 TQCString mOriginalContentTypeStr; 00235 TQCString mType; 00236 TQCString mSubtype; 00237 TQCString mCte; 00238 TQCString mContentDescription; 00239 TQCString mContentDisposition; 00240 TQCString mContentId; 00241 TQByteArray mBody; 00242 TQCString mAdditionalCTypeParamStr; 00243 TQString mName; 00244 TQCString mParameterAttribute; 00245 TQString mParameterValue; 00246 TQCString mCharset; 00247 TQString mPartSpecifier; 00248 mutable int mBodyDecodedSize; 00249 KMMessagePart* mParent; 00250 bool mLoadHeaders; 00251 bool mLoadPart; 00252 }; 00253 00254 00255 #endif /*kmmsgpart_h*/