kmail

kmmsgpart.h
1 /*
2  * kmail: KDE mail client
3  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 #ifndef kmmsgpart_h
21 #define kmmsgpart_h
22 
23 #include <kiconloader.h>
24 
25 #include <tqstring.h>
26 #include <tqcstring.h>
27 #include <tqdict.h>
28 
29 template <typename T>
30 class TQValueList;
31 class TQTextCodec;
32 class DwString;
33 
34 class KMMessagePart
35 {
36 public:
37  KMMessagePart();
38  KMMessagePart( TQDataStream & stream );
39  virtual ~KMMessagePart();
40 
42  void clear();
43 
46  void duplicate( const KMMessagePart & msgPart );
47 
49  TQCString body(void) const;
50  void setBody(const TQCString &aStr);
51  DwString dwBody() const;
52  void setBody(const DwString &aStr);
53  // warning, doesn't detach from 'arr'
54  void setBody(const TQByteArray &arr);
55 
59  void setBodyFromUnicode( const TQString & str );
60 
63  TQString bodyToUnicode(const TQTextCodec* codec=0) const;
64 
68  TQByteArray bodyDecodedBinary(void) const;
69 
72  TQCString bodyDecoded(void) const;
73 
83  void setBodyAndGuessCte(const TQByteArray& aBuf,
84  TQValueList<int>& allowedCte,
85  bool allow8Bit = false,
86  bool willBeSigned = false);
88  void setBodyAndGuessCte(const TQCString& aBuf,
89  TQValueList<int>& allowedCte,
90  bool allow8Bit = false,
91  bool willBeSigned = false);
92 
97  void setBodyEncodedBinary(const TQByteArray& aStr);
98 
106  void setBodyEncoded(const TQCString& aStr);
107 
112  void setMessageBody( const TQByteArray & aBuf );
113 
115  int decodedSize(void) const;
116 
120  TQCString originalContentTypeStr(void) const { return mOriginalContentTypeStr; }
121  void setOriginalContentTypeStr( const TQCString& txt )
122  {
123  mOriginalContentTypeStr = txt;
124  }
125  TQCString typeStr() const { return mType; }
126  void setTypeStr( const TQCString & aStr ) { mType = aStr; }
127  int type() const;
128  void setType(int aType);
130  TQCString subtypeStr() const { return mSubtype; }
131  void setSubtypeStr( const TQCString & aStr ) { mSubtype = aStr; }
132  int subtype() const;
133  void setSubtype(int aSubtype);
134 
136  TQCString contentId() const { return mContentId; }
137  void setContentId( const TQCString & aStr ) { mContentId = aStr; }
138 
142  void magicSetType(bool autoDecode=TRUE);
143 
146  TQCString parameterAttribute(void) const;
147  TQString parameterValue(void) const;
148  void setParameter(const TQCString &attribute, const TQString &value);
149 
150  TQCString additionalCTypeParamStr(void) const
151  {
152  return mAdditionalCTypeParamStr;
153  }
154  void setAdditionalCTypeParamStr( const TQCString &param )
155  {
156  mAdditionalCTypeParamStr = param;
157  }
158 
162  TQString iconName( int size = TDEIcon::Desktop ) const;
163 
167  TQCString contentTransferEncodingStr(void) const;
168  int contentTransferEncoding(void) const;
169  void setContentTransferEncodingStr(const TQCString &aStr);
170  void setContentTransferEncoding(int aCte);
171 
174  TQCString cteStr(void) const { return contentTransferEncodingStr(); }
175  int cte(void) const { return contentTransferEncoding(); }
176  void setCteStr(const TQCString& aStr) { setContentTransferEncodingStr(aStr); }
177  void setCte(int aCte) { setContentTransferEncoding(aCte); }
178 
179 
181  TQString contentDescription() const;
182  TQCString contentDescriptionEncoded() const { return mContentDescription; }
183  void setContentDescription(const TQString &aStr);
184 
186  TQCString contentDisposition() const { return mContentDisposition; }
187  void setContentDisposition( const TQCString & cd ) { mContentDisposition = cd; }
188 
190  TQCString charset() const { return mCharset; }
191 
193  void setCharset( const TQCString & c );
194 
196  const TQTextCodec * codec() const;
197 
199  TQString name() const { return mName; }
200  void setName( const TQString & name ) { mName = name; }
201 
204  TQString fileName(void) const;
205 
207  TQString partSpecifier() const { return mPartSpecifier; }
208 
210  void setPartSpecifier( const TQString & part ) { mPartSpecifier = part; }
211 
213  bool isComplete() { return (!mBody.isNull()); }
214 
216  KMMessagePart* parent() { return mParent; }
217 
219  void setParent( KMMessagePart* part ) { mParent = part; }
220 
222  bool loadHeaders() { return mLoadHeaders; }
223 
225  void setLoadHeaders( bool load ) { mLoadHeaders = load; }
226 
228  bool loadPart() { return mLoadPart; }
229 
231  void setLoadPart( bool load ) { mLoadPart = load; }
232 
233 protected:
234  TQCString mOriginalContentTypeStr;
235  TQCString mType;
236  TQCString mSubtype;
237  TQCString mCte;
238  TQCString mContentDescription;
239  TQCString mContentDisposition;
240  TQCString mContentId;
241  TQByteArray mBody;
242  TQCString mAdditionalCTypeParamStr;
243  TQString mName;
244  TQCString mParameterAttribute;
245  TQString mParameterValue;
246  TQCString mCharset;
247  TQString mPartSpecifier;
248  mutable int mBodyDecodedSize;
249  KMMessagePart* mParent;
250  bool mLoadHeaders;
251  bool mLoadPart;
252 };
253 
254 
255 #endif /*kmmsgpart_h*/