libkmime

kmime_headers_obs.h
1 /*
2  kmime_headers.h
3 
4  KMime, the KDE internet mail/usenet news message library.
5  Copyright (c) 2001 the KMime authors.
6  See file AUTHORS for details
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 */
16 #ifndef __KMIME_HEADERS_OBS_H__
17 #define __KMIME_HEADERS_OBS_H__
18 
19 #if defined(KMIME_NEW_STYPE_CLASSTREE)
20 #error You cannot use this file with the new header classes!
21 #endif
22 
23 #include <tdemacros.h>
24 
26 class TDE_EXPORT MessageID : public Base {
27 
28  public:
29  MessageID() : Base() {}
30  MessageID(Content *p) : Base(p) {}
31  MessageID(Content *p, const TQCString &s) : Base(p) { from7BitString(s); }
32  MessageID(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); }
33  ~MessageID() {}
34 
35  virtual void from7BitString(const TQCString &s);
36  virtual TQCString as7BitString(bool incType=true);
37  virtual void fromUnicodeString(const TQString &s, const TQCString&);
38  virtual TQString asUnicodeString();
39  virtual void clear() { m_id.resize(0); }
40  virtual bool isEmpty() { return (m_id.isEmpty()); }
41  virtual const char* type() { return "Message-Id"; }
42 
43  void generate(const TQCString &fqdn);
44 
45  protected:
46  TQCString m_id;
47 
48 };
49 
51 class TDE_EXPORT Supersedes : public MessageID {
52 
53  public:
54  Supersedes() : MessageID() {}
55  Supersedes(Content *p) : MessageID(p) {}
56  Supersedes(Content *p, const TQCString &s) : MessageID(p,s) {}
57  Supersedes(Content *p, const TQString &s) : MessageID(p,s) {}
58  ~Supersedes() {}
59 
60  virtual const char* type() { return "Supersedes"; }
61 
62 };
63 
66 class TDE_EXPORT AddressField : public Base {
67 
68  public:
69  AddressField() : Base() {}
70  AddressField(Content *p) : Base(p) {}
71  AddressField(Content *p, const TQCString &s) : Base(p) { from7BitString(s); }
72  AddressField(Content *p, const TQString &s, const TQCString &cs) : Base(p) { fromUnicodeString(s, cs); }
73  AddressField(const AddressField &a): Base(a.p_arent) { n_ame=a.n_ame; e_mail=a.e_mail.copy(); e_ncCS=a.e_ncCS; }
74  ~AddressField() {}
75 
76  AddressField& operator=(const AddressField &a) { n_ame=a.n_ame; e_mail=a.e_mail.copy(); e_ncCS=a.e_ncCS; return (*this); }
77 
78  virtual void from7BitString(const TQCString &s);
79  virtual TQCString as7BitString(bool incType=true);
80  virtual void fromUnicodeString(const TQString &s, const TQCString &cs);
81  virtual TQString asUnicodeString();
82  virtual void clear() { n_ame.truncate(0); e_mail.resize(0); }
83  virtual bool isEmpty() { return (e_mail.isEmpty() && n_ame.isEmpty()); }
84 
85  bool hasName() { return ( !n_ame.isEmpty() ); }
86  bool hasEmail() { return ( !e_mail.isEmpty() ); }
87  TQString name() { return n_ame; }
88  TQCString nameAs7Bit();
89  TQCString email() { return e_mail; }
90  void setName(const TQString &s) { n_ame=s; }
91  void setNameFrom7Bit(const TQCString &s);
92  void setEmail(const TQCString &s) { e_mail=s; }
93 
94  protected:
95  TQString n_ame;
96  TQCString e_mail;
97 };
98 typedef TQPtrList<AddressField> ObsAddressList;
99 
101 class TDE_EXPORT From : public AddressField {
102 
103  public:
104  From() : AddressField() {}
105  From(Content *p) : AddressField(p) {}
106  From(Content *p, const TQCString &s) : AddressField(p,s) {}
107  From(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {}
108  ~From() {}
109 
110  virtual const char* type() { return "From"; }
111 };
112 
113 
115 class TDE_EXPORT ReplyTo : public AddressField {
116 
117  public:
118  ReplyTo() : AddressField() {}
119  ReplyTo(Content *p) : AddressField(p) {}
120  ReplyTo(Content *p, const TQCString &s) : AddressField(p,s) {}
121  ReplyTo(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {}
122  ~ReplyTo() {}
123 
124  virtual const char* type() { return "Reply-To"; }
125 
126 };
127 
128 
131 class TDE_EXPORT MailCopiesTo : public AddressField {
132 
133  public:
134  MailCopiesTo() : AddressField() {}
135  MailCopiesTo(Content *p) : AddressField(p) {}
136  MailCopiesTo(Content *p, const TQCString &s) : AddressField(p,s) {}
137  MailCopiesTo(Content *p, const TQString &s, const TQCString &cs) : AddressField(p,s,cs) {}
138  ~MailCopiesTo() {}
139 
140  bool isValid();
141  bool alwaysCopy();
142  bool neverCopy();
143 
144  virtual const char* type() { return "Mail-Copies-To"; }
145 
146 };
147 
149 class TDE_EXPORT To : public Base {
150 
151  public:
152  To() : Base(),a_ddrList(0) {}
153  To(Content *p) : Base(p),a_ddrList(0) {}
154  To(Content *p, const TQCString &s) : Base(p),a_ddrList(0) { from7BitString(s); }
155  To(Content *p, const TQString &s, const TQCString &cs) : Base(p),a_ddrList(0) { fromUnicodeString(s,cs); }
156  ~To() { delete a_ddrList; }
157 
158  virtual void from7BitString(const TQCString &s);
159  virtual TQCString as7BitString(bool incType=true);
160  virtual void fromUnicodeString(const TQString &s, const TQCString &cs);
161  virtual TQString asUnicodeString();
162  virtual void clear() { delete a_ddrList; a_ddrList=0; }
163  virtual bool isEmpty() { return (!a_ddrList || a_ddrList->isEmpty()
164  || a_ddrList->first()->isEmpty()); }
165  virtual const char* type() { return "To"; }
166 
167  void addAddress(const AddressField &a);
168  void emails(TQStrList *l);
169  void names(TQStringList *l);
170  void displayNames(TQStringList *l);
171 
172  protected:
173  ObsAddressList *a_ddrList;
174 
175 };
176 
177 
179 class TDE_EXPORT CC : public To {
180 
181  public:
182  CC() : To() {}
183  CC(Content *p) : To(p) {}
184  CC(Content *p, const TQCString &s) : To(p,s) {}
185  CC(Content *p, const TQString &s, const TQCString &cs) : To(p,s,cs) {}
186  ~CC() {}
187 
188  virtual const char* type() { return "CC"; }
189 
190 };
191 
192 
194 class TDE_EXPORT BCC : public To {
195 
196  public:
197  BCC() : To() {}
198  BCC(Content *p) : To(p) {}
199  BCC(Content *p, const TQCString &s) : To(p,s) {}
200  BCC(Content *p, const TQString &s, const TQCString &cs) : To(p,s,cs) {}
201  ~BCC() {}
202 
203  virtual const char* type() { return "BCC"; }
204 
205 };
206 
208 class TDE_EXPORT References : public Base {
209 
210  public:
211  References() : Base(),p_os(-1) {}
212  References(Content *p) : Base(p),p_os(-1) {}
213  References(Content *p, const TQCString &s) : Base(p),p_os(-1) { from7BitString(s); }
214  References(Content *p, const TQString &s) : Base(p),p_os(-1) { fromUnicodeString(s, Latin1); }
215  ~References() {}
216 
217  virtual void from7BitString(const TQCString &s);
218  virtual TQCString as7BitString(bool incType=true);
219  virtual void fromUnicodeString(const TQString &s, const TQCString&);
220  virtual TQString asUnicodeString();
221  virtual void clear() { r_ef.resize(0); p_os=0; }
222  virtual bool isEmpty() { return (r_ef.isEmpty()); }
223  virtual const char* type() { return "References"; }
224 
225  int count();
226  TQCString first();
227  TQCString next();
228  TQCString at(unsigned int i);
229  void append(const TQCString &s);
230 
231  protected:
232  TQCString r_ef;
233  int p_os;
234 
235 };
236 
238 class TDE_EXPORT ContentType : public Base {
239 
240  public:
241  ContentType() : Base(),m_imeType("invalid/invalid"),c_ategory(CCsingle) {}
242  ContentType(Content *p) : Base(p),m_imeType("invalid/invalid"),c_ategory(CCsingle) {}
243  ContentType(Content *p, const TQCString &s) : Base(p) { from7BitString(s); }
244  ContentType(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); }
245  ~ContentType() {}
246 
247  virtual void from7BitString(const TQCString &s);
248  virtual TQCString as7BitString(bool incType=true);
249  virtual void fromUnicodeString(const TQString &s, const TQCString&);
250  virtual TQString asUnicodeString();
251  virtual void clear() { m_imeType.resize(0); p_arams.resize(0); }
252  virtual bool isEmpty() { return (m_imeType.isEmpty()); }
253  virtual const char* type() { return "Content-Type"; }
254 
255 
256  //mime-type handling
257  TQCString mimeType() { return m_imeType; }
258  TQCString mediaType();
259  TQCString subType();
260  void setMimeType(const TQCString &s);
261  bool isMediatype(const char *s);
262  bool isSubtype(const char *s);
263  bool isText();
264  bool isPlainText();
265  bool isHTMLText();
266  bool isImage();
267  bool isMultipart();
268  bool isPartial();
269 
270  //parameter handling
271  TQCString charset();
272  void setCharset(const TQCString &s);
273  TQCString boundary();
274  void setBoundary(const TQCString &s);
275  TQString name();
276  void setName(const TQString &s, const TQCString &cs);
277  TQCString id();
278  void setId(const TQCString &s);
279  int partialNumber();
280  int partialCount();
281  void setPartialParams(int total, int number);
282 
283  //category
284  contentCategory category() { return c_ategory; }
285  void setCategory(contentCategory c) { c_ategory=c; }
286 
287  protected:
288  TQCString getParameter(const char *name);
289  void setParameter(const TQCString &name, const TQCString &value, bool doubleQuotes=false);
290  TQCString m_imeType, p_arams;
291  contentCategory c_ategory;
292 
293 };
294 
295 
297 class TDE_EXPORT CTEncoding : public Base {
298 
299  public:
300  CTEncoding() : Base(),c_te(CE7Bit),d_ecoded(true) {}
301  CTEncoding(Content *p) : Base(p),c_te(CE7Bit),d_ecoded(true) {}
302  CTEncoding(Content *p, const TQCString &s) : Base(p) { from7BitString(s); }
303  CTEncoding(Content *p, const TQString &s) : Base(p) { fromUnicodeString(s, Latin1); }
304  ~CTEncoding() {}
305 
306  virtual void from7BitString(const TQCString &s);
307  virtual TQCString as7BitString(bool incType=true);
308  virtual void fromUnicodeString(const TQString &s, const TQCString&);
309  virtual TQString asUnicodeString();
310  virtual void clear() { d_ecoded=true; c_te=CE7Bit; }
311  virtual const char* type() { return "Content-Transfer-Encoding"; }
312 
313  contentEncoding cte() { return c_te; }
314  void setCte(contentEncoding e) { c_te=e; }
315  bool decoded() { return d_ecoded; }
316  void setDecoded(bool d=true) { d_ecoded=d; }
317  bool needToEncode() { return (d_ecoded && (c_te==CEquPr || c_te==CEbase64)); }
318 
319  protected:
320  contentEncoding c_te;
321  bool d_ecoded;
322 
323 };
324 
325 
327 class TDE_EXPORT CDisposition : public Base {
328 
329  public:
330  CDisposition() : Base(),d_isp(CDinline) {}
331  CDisposition(Content *p) : Base(p),d_isp(CDinline) {}
332  CDisposition(Content *p, const TQCString &s) : Base(p) { from7BitString(s); }
333  CDisposition(Content *p, const TQString &s, const TQCString &cs) : Base(p) { fromUnicodeString(s, cs); }
334  ~CDisposition() {}
335 
336  virtual void from7BitString(const TQCString &s);
337  virtual TQCString as7BitString(bool incType=true);
338  virtual void fromUnicodeString(const TQString &s, const TQCString &cs);
339  virtual TQString asUnicodeString();
340  virtual void clear() { f_ilename.truncate(0); d_isp=CDinline; }
341  virtual const char* type() { return "Content-Disposition"; }
342 
343  contentDisposition disposition() { return d_isp; }
344  void setDisposition(contentDisposition d) { d_isp=d; }
345  bool isAttachment() { return (d_isp==CDattachment); }
346 
347  TQString filename() { return f_ilename; }
348  void setFilename(const TQString &s) { f_ilename=s; }
349 
350  protected:
351  contentDisposition d_isp;
352  TQString f_ilename;
353 
354 };
355 
356 
358 class TDE_EXPORT CDescription : public Generics::GUnstructured {
359 
360  public:
361  CDescription() : Generics::GUnstructured() {}
362  CDescription( Content * p ) : Generics::GUnstructured( p ) {}
363  CDescription( Content * p, const TQCString & s )
364  : Generics::GUnstructured( p, s ) {};
365  CDescription( Content * p, const TQString & s, const TQCString & cs )
366  : Generics::GUnstructured( p, s, cs ) {}
367  ~CDescription() {}
368 
369  virtual const char* type() { return "Content-Description"; }
370 };
371 
372 #endif // __KMIME_HEADERS_OBS_H__
This class encapsulates an address-field, containing an email-address and a real name.
Represents a "BCC" header.
Represents a "CC" header.
Represents a "Content-Description" header.
Represents a "Content-Disposition" header.
Represents a "Content-Transfer-Encoding" header.
Represents a "Content-Type" header.
Represent a "From" header.
Represents a "Mail-Copies-To" header http://www.newsreaders.com/misc/mail-copies-to....
Represents a "Message-Id" header.
Represents a "References" header.
Represents a "Reply-To" header.
Represents a "Supersedes" header.
Represents a "To" header.