kmail
kmmsgpart.h
Go to the documentation of this file.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 <qstring.h> 00026 #include <qcstring.h> 00027 #include <qdict.h> 00028 00029 template <typename T> 00030 class QValueList; 00031 class QTextCodec; 00032 class DwString; 00033 00034 class KMMessagePart 00035 { 00036 public: 00037 KMMessagePart(); 00038 KMMessagePart( QDataStream & stream ); 00039 virtual ~KMMessagePart(); 00040 00042 void clear(); 00043 00046 void duplicate( const KMMessagePart & msgPart ); 00047 00049 QCString body(void) const; 00050 void setBody(const QCString &aStr); 00051 DwString dwBody() const; 00052 void setBody(const DwString &aStr); 00053 // warning, doesn't detach from 'arr' 00054 void setBody(const QByteArray &arr); 00055 00059 void setBodyFromUnicode( const QString & str ); 00060 00063 QString bodyToUnicode(const QTextCodec* codec=0) const; 00064 00068 QByteArray bodyDecodedBinary(void) const; 00069 00072 QCString bodyDecoded(void) const; 00073 00083 void setBodyAndGuessCte(const QByteArray& aBuf, 00084 QValueList<int>& allowedCte, 00085 bool allow8Bit = false, 00086 bool willBeSigned = false); 00088 void setBodyAndGuessCte(const QCString& aBuf, 00089 QValueList<int>& allowedCte, 00090 bool allow8Bit = false, 00091 bool willBeSigned = false); 00092 00097 void setBodyEncodedBinary(const QByteArray& aStr); 00098 00106 void setBodyEncoded(const QCString& aStr); 00107 00112 void setMessageBody( const QByteArray & aBuf ); 00113 00115 int decodedSize(void) const; 00116 00120 QCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; } 00121 void setOriginalContentTypeStr( const QCString& txt ) 00122 { 00123 mOriginalContentTypeStr = txt; 00124 } 00125 QCString typeStr() const { return mType; } 00126 void setTypeStr( const QCString & aStr ) { mType = aStr; } 00127 int type() const; 00128 void setType(int aType); 00130 QCString subtypeStr() const { return mSubtype; } 00131 void setSubtypeStr( const QCString & aStr ) { mSubtype = aStr; } 00132 int subtype() const; 00133 void setSubtype(int aSubtype); 00134 00136 QCString contentId() const { return mContentId; } 00137 void setContentId( const QCString & aStr ) { mContentId = aStr; } 00138 00142 void magicSetType(bool autoDecode=TRUE); 00143 00146 QCString parameterAttribute(void) const; 00147 QString parameterValue(void) const; 00148 void setParameter(const QCString &attribute, const QString &value); 00149 00150 QCString additionalCTypeParamStr(void) const 00151 { 00152 return mAdditionalCTypeParamStr; 00153 } 00154 void setAdditionalCTypeParamStr( const QCString ¶m ) 00155 { 00156 mAdditionalCTypeParamStr = param; 00157 } 00158 00162 QString iconName( int size = KIcon::Desktop ) const; 00163 00167 QCString contentTransferEncodingStr(void) const; 00168 int contentTransferEncoding(void) const; 00169 void setContentTransferEncodingStr(const QCString &aStr); 00170 void setContentTransferEncoding(int aCte); 00171 00174 QCString cteStr(void) const { return contentTransferEncodingStr(); } 00175 int cte(void) const { return contentTransferEncoding(); } 00176 void setCteStr(const QCString& aStr) { setContentTransferEncodingStr(aStr); } 00177 void setCte(int aCte) { setContentTransferEncoding(aCte); } 00178 00179 00181 QString contentDescription() const; 00182 QCString contentDescriptionEncoded() const { return mContentDescription; } 00183 void setContentDescription(const QString &aStr); 00184 00186 QCString contentDisposition() const { return mContentDisposition; } 00187 void setContentDisposition( const QCString & cd ) { mContentDisposition = cd; } 00188 00190 QCString charset() const { return mCharset; } 00191 00193 void setCharset( const QCString & c ); 00194 00196 const QTextCodec * codec() const; 00197 00199 QString name() const { return mName; } 00200 void setName( const QString & name ) { mName = name; } 00201 00204 QString fileName(void) const; 00205 00207 QString partSpecifier() const { return mPartSpecifier; } 00208 00210 void setPartSpecifier( const QString & 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 QCString mOriginalContentTypeStr; 00235 QCString mType; 00236 QCString mSubtype; 00237 QCString mCte; 00238 QCString mContentDescription; 00239 QCString mContentDisposition; 00240 QCString mContentId; 00241 QByteArray mBody; 00242 QCString mAdditionalCTypeParamStr; 00243 QString mName; 00244 QCString mParameterAttribute; 00245 QString mParameterValue; 00246 QCString mCharset; 00247 QString mPartSpecifier; 00248 mutable int mBodyDecodedSize; 00249 KMMessagePart* mParent; 00250 bool mLoadHeaders; 00251 bool mLoadPart; 00252 }; 00253 00254 00255 #endif /*kmmsgpart_h*/