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 
00110  void setMessageBody( const QByteArray & aBuf );
00111 
00113   int decodedSize(void) const;
00114 
00118   QCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; }
00119   void setOriginalContentTypeStr( const QCString& txt )
00120   {
00121     mOriginalContentTypeStr = txt;
00122   }
00123   QCString typeStr() const { return mType; }
00124   void setTypeStr( const QCString & aStr ) { mType = aStr; }
00125   int type() const;
00126   void setType(int aType);
00128   QCString subtypeStr() const { return mSubtype; }
00129   void setSubtypeStr( const QCString & aStr ) { mSubtype = aStr; }
00130   int subtype() const;
00131   void setSubtype(int aSubtype);
00132 
00134   QCString contentId() const { return mContentId; }
00135   void setContentId( const QCString & aStr ) { mContentId = aStr; }
00136 
00140   void magicSetType(bool autoDecode=TRUE);
00141 
00144   QCString parameterAttribute(void) const;
00145   QString parameterValue(void) const;
00146   void setParameter(const QCString &attribute, const QString &value);
00147 
00148   QCString additionalCTypeParamStr(void) const
00149   {
00150     return mAdditionalCTypeParamStr;
00151   }
00152   void setAdditionalCTypeParamStr( const QCString &param )
00153   {
00154     mAdditionalCTypeParamStr = param;
00155   }
00156 
00160   QString iconName() const;
00161 
00165   QCString contentTransferEncodingStr(void) const;
00166   int  contentTransferEncoding(void) const;
00167   void setContentTransferEncodingStr(const QCString &aStr);
00168   void setContentTransferEncoding(int aCte);
00169 
00172   QCString cteStr(void) const { return contentTransferEncodingStr(); }
00173   int cte(void) const { return contentTransferEncoding(); }
00174   void setCteStr(const QCString& aStr) { setContentTransferEncodingStr(aStr); }
00175   void setCte(int aCte) { setContentTransferEncoding(aCte); }
00176 
00177 
00179   QString contentDescription() const;
00180   QCString contentDescriptionEncoded() const { return mContentDescription; }
00181   void setContentDescription(const QString &aStr);
00182 
00184   QCString contentDisposition() const { return mContentDisposition; }
00185   void setContentDisposition( const QCString & cd ) { mContentDisposition = cd; }
00186 
00188   QCString charset() const { return mCharset; }
00189 
00191   void setCharset( const QCString & c );
00192 
00194   const QTextCodec * codec() const;
00195 
00197   QString name() const { return mName; }
00198   void setName( const QString & name ) { mName = name; }
00199 
00202   QString fileName(void) const;
00203 
00205   QString partSpecifier() const { return mPartSpecifier; }
00206 
00208   void setPartSpecifier( const QString & part ) { mPartSpecifier = part; }
00209 
00211   bool isComplete() { return (!mBody.isNull()); }
00212 
00214   KMMessagePart* parent() { return mParent; }
00215 
00217   void setParent( KMMessagePart* part ) { mParent = part; }
00218 
00220   bool loadHeaders() { return mLoadHeaders; }
00221 
00223   void setLoadHeaders( bool load ) { mLoadHeaders = load; }
00224 
00226   bool loadPart() { return mLoadPart; }
00227 
00229   void setLoadPart( bool load ) { mLoadPart = load; }
00230 
00231 protected:
00232   QCString mOriginalContentTypeStr;
00233   QCString mType;
00234   QCString mSubtype;
00235   QCString mCte;
00236   QCString mContentDescription;
00237   QCString mContentDisposition;
00238   QCString mContentId;
00239   QByteArray mBody;
00240   QCString mAdditionalCTypeParamStr;
00241   QString mName;
00242   QCString mParameterAttribute;
00243   QString mParameterValue;
00244   QCString mCharset;
00245   QString mPartSpecifier;
00246   mutable int mBodyDecodedSize;
00247   KMMessagePart* mParent;
00248   bool mLoadHeaders;
00249   bool mLoadPart;
00250 };
00251 
00252 
00253 #endif /*kmmsgpart_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys