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 00031 class KMMessagePart 00032 { 00033 public: 00034 KMMessagePart(); 00035 KMMessagePart( QDataStream & stream ); 00036 virtual ~KMMessagePart(); 00037 00039 void clear(); 00040 00043 void duplicate( const KMMessagePart & msgPart ); 00044 00046 QCString body(void) const; 00047 void setBody(const QCString &aStr); 00048 00052 void setBodyFromUnicode( const QString & str ); 00053 00056 QString bodyToUnicode(const QTextCodec* codec=0) const; 00057 00061 virtual QByteArray bodyDecodedBinary(void) const; 00062 00065 virtual QCString bodyDecoded(void) const; 00066 00076 virtual void setBodyAndGuessCte(const QByteArray& aBuf, 00077 QValueList<int>& allowedCte, 00078 bool allow8Bit = false, 00079 bool willBeSigned = false); 00081 virtual void setBodyAndGuessCte(const QCString& aBuf, 00082 QValueList<int>& allowedCte, 00083 bool allow8Bit = false, 00084 bool willBeSigned = false); 00085 00088 virtual void setBodyEncodedBinary(const QByteArray& aStr); 00089 00092 virtual void setBodyEncoded(const QCString& aStr); 00093 00095 virtual int decodedSize(void) const; 00096 00100 QCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; } 00101 void setOriginalContentTypeStr( const QCString& txt ) 00102 { 00103 mOriginalContentTypeStr = txt; 00104 } 00105 QCString typeStr() const { return mType; } 00106 void setTypeStr( const QCString & aStr ) { mType = aStr; } 00107 int type() const; 00108 void setType(int aType); 00110 QCString subtypeStr() const { return mSubtype; } 00111 void setSubtypeStr( const QCString & aStr ) { mSubtype = aStr; } 00112 int subtype() const; 00113 void setSubtype(int aSubtype); 00114 00116 QCString contentId() const { return mContentId; } 00117 void setContentId( const QCString & aStr ) { mContentId = aStr; } 00118 00122 void magicSetType(bool autoDecode=TRUE); 00123 00126 QCString parameterAttribute(void) const; 00127 QString parameterValue(void) const; 00128 void setParameter(const QCString &attribute, const QString &value); 00129 00130 QCString additionalCTypeParamStr(void) const 00131 { 00132 return mAdditionalCTypeParamStr; 00133 } 00134 void setAdditionalCTypeParamStr( const QCString ¶m ) 00135 { 00136 mAdditionalCTypeParamStr = param; 00137 } 00138 00142 QString iconName() const; 00143 00147 QCString contentTransferEncodingStr(void) const; 00148 int contentTransferEncoding(void) const; 00149 void setContentTransferEncodingStr(const QCString &aStr); 00150 void setContentTransferEncoding(int aCte); 00151 00154 QCString cteStr(void) const { return contentTransferEncodingStr(); } 00155 int cte(void) const { return contentTransferEncoding(); } 00156 void setCteStr(const QCString& aStr) { setContentTransferEncodingStr(aStr); } 00157 void setCte(int aCte) { setContentTransferEncoding(aCte); } 00158 00159 00161 QString contentDescription() const; 00162 QCString contentDescriptionEncoded() const { return mContentDescription; } 00163 void setContentDescription(const QString &aStr); 00164 00166 QCString contentDisposition() const { return mContentDisposition; } 00167 void setContentDisposition( const QCString & cd ) { mContentDisposition = cd; } 00168 00170 QCString charset() const { return mCharset; } 00171 00173 void setCharset( const QCString & c ); 00174 00176 const QTextCodec * codec() const; 00177 00179 QString name() const { return mName; } 00180 void setName( const QString & name ) { mName = name; } 00181 00184 QString fileName(void) const; 00185 00187 QString partSpecifier() const { return mPartSpecifier; } 00188 00190 void setPartSpecifier( const QString & part ) { mPartSpecifier = part; } 00191 00193 bool isComplete() { return (!mBody.isNull()); } 00194 00196 KMMessagePart* parent() { return mParent; } 00197 00199 void setParent( KMMessagePart* part ) { mParent = part; } 00200 00202 bool loadHeaders() { return mLoadHeaders; } 00203 00205 void setLoadHeaders( bool load ) { mLoadHeaders = load; } 00206 00208 bool loadPart() { return mLoadPart; } 00209 00211 void setLoadPart( bool load ) { mLoadPart = load; } 00212 00213 protected: 00214 QCString mOriginalContentTypeStr; 00215 QCString mType; 00216 QCString mSubtype; 00217 QCString mCte; 00218 QCString mContentDescription; 00219 QCString mContentDisposition; 00220 QCString mContentId; 00221 QByteArray mBody; 00222 QCString mAdditionalCTypeParamStr; 00223 QString mName; 00224 QCString mParameterAttribute; 00225 QString mParameterValue; 00226 QCString mCharset; 00227 QString mPartSpecifier; 00228 mutable int mBodyDecodedSize; 00229 KMMessagePart* mParent; 00230 bool mLoadHeaders; 00231 bool mLoadPart; 00232 }; 00233 00234 00235 #endif /*kmmsgpart_h*/