kmail
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 <qstring.h> 00024 #include <qcstring.h> 00025 #include <qdict.h> 00026 00027 template <typename T> 00028 class QValueList; 00029 class QTextCodec; 00030 class DwString; 00031 00032 class KMMessagePart 00033 { 00034 public: 00035 KMMessagePart(); 00036 KMMessagePart( QDataStream & stream ); 00037 virtual ~KMMessagePart(); 00038 00040 void clear(); 00041 00044 void duplicate( const KMMessagePart & msgPart ); 00045 00047 QCString body(void) const; 00048 void setBody(const QCString &aStr); 00049 DwString dwBody() const; 00050 void setBody(const DwString &aStr); 00051 // warning, doesn't detach from 'arr' 00052 void setBody(const QByteArray &arr); 00053 00057 void setBodyFromUnicode( const QString & str ); 00058 00061 QString bodyToUnicode(const QTextCodec* codec=0) const; 00062 00066 QByteArray bodyDecodedBinary(void) const; 00067 00070 QCString bodyDecoded(void) const; 00071 00081 void setBodyAndGuessCte(const QByteArray& aBuf, 00082 QValueList<int>& allowedCte, 00083 bool allow8Bit = false, 00084 bool willBeSigned = false); 00086 void setBodyAndGuessCte(const QCString& aBuf, 00087 QValueList<int>& allowedCte, 00088 bool allow8Bit = false, 00089 bool willBeSigned = false); 00090 00095 void setBodyEncodedBinary(const QByteArray& aStr); 00096 00104 void setBodyEncoded(const QCString& aStr); 00105 00107 int decodedSize(void) const; 00108 00112 QCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; } 00113 void setOriginalContentTypeStr( const QCString& txt ) 00114 { 00115 mOriginalContentTypeStr = txt; 00116 } 00117 QCString typeStr() const { return mType; } 00118 void setTypeStr( const QCString & aStr ) { mType = aStr; } 00119 int type() const; 00120 void setType(int aType); 00122 QCString subtypeStr() const { return mSubtype; } 00123 void setSubtypeStr( const QCString & aStr ) { mSubtype = aStr; } 00124 int subtype() const; 00125 void setSubtype(int aSubtype); 00126 00128 QCString contentId() const { return mContentId; } 00129 void setContentId( const QCString & aStr ) { mContentId = aStr; } 00130 00134 void magicSetType(bool autoDecode=TRUE); 00135 00138 QCString parameterAttribute(void) const; 00139 QString parameterValue(void) const; 00140 void setParameter(const QCString &attribute, const QString &value); 00141 00142 QCString additionalCTypeParamStr(void) const 00143 { 00144 return mAdditionalCTypeParamStr; 00145 } 00146 void setAdditionalCTypeParamStr( const QCString ¶m ) 00147 { 00148 mAdditionalCTypeParamStr = param; 00149 } 00150 00154 QString iconName() const; 00155 00159 QCString contentTransferEncodingStr(void) const; 00160 int contentTransferEncoding(void) const; 00161 void setContentTransferEncodingStr(const QCString &aStr); 00162 void setContentTransferEncoding(int aCte); 00163 00166 QCString cteStr(void) const { return contentTransferEncodingStr(); } 00167 int cte(void) const { return contentTransferEncoding(); } 00168 void setCteStr(const QCString& aStr) { setContentTransferEncodingStr(aStr); } 00169 void setCte(int aCte) { setContentTransferEncoding(aCte); } 00170 00171 00173 QString contentDescription() const; 00174 QCString contentDescriptionEncoded() const { return mContentDescription; } 00175 void setContentDescription(const QString &aStr); 00176 00178 QCString contentDisposition() const { return mContentDisposition; } 00179 void setContentDisposition( const QCString & cd ) { mContentDisposition = cd; } 00180 00182 QCString charset() const { return mCharset; } 00183 00185 void setCharset( const QCString & c ); 00186 00188 const QTextCodec * codec() const; 00189 00191 QString name() const { return mName; } 00192 void setName( const QString & name ) { mName = name; } 00193 00196 QString fileName(void) const; 00197 00199 QString partSpecifier() const { return mPartSpecifier; } 00200 00202 void setPartSpecifier( const QString & part ) { mPartSpecifier = part; } 00203 00205 bool isComplete() { return (!mBody.isNull()); } 00206 00208 KMMessagePart* parent() { return mParent; } 00209 00211 void setParent( KMMessagePart* part ) { mParent = part; } 00212 00214 bool loadHeaders() { return mLoadHeaders; } 00215 00217 void setLoadHeaders( bool load ) { mLoadHeaders = load; } 00218 00220 bool loadPart() { return mLoadPart; } 00221 00223 void setLoadPart( bool load ) { mLoadPart = load; } 00224 00225 protected: 00226 QCString mOriginalContentTypeStr; 00227 QCString mType; 00228 QCString mSubtype; 00229 QCString mCte; 00230 QCString mContentDescription; 00231 QCString mContentDisposition; 00232 QCString mContentId; 00233 QByteArray mBody; 00234 QCString mAdditionalCTypeParamStr; 00235 QString mName; 00236 QCString mParameterAttribute; 00237 QString mParameterValue; 00238 QCString mCharset; 00239 QString mPartSpecifier; 00240 mutable int mBodyDecodedSize; 00241 KMMessagePart* mParent; 00242 bool mLoadHeaders; 00243 bool mLoadPart; 00244 }; 00245 00246 00247 #endif /*kmmsgpart_h*/