summaryrefslogtreecommitdiffstats
path: root/kioslaves/imap4/mailheader.h
blob: 633d61b78fe288eda67fcee8af2fd923f8339dac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/***************************************************************************
                          mailheader.h  -  description
                             -------------------
    begin                : Tue Oct 24 2000
    copyright            : (C) 2000 by Sven Carstens
    email                : s.carstens@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef MAILHEADER_H
#define MAILHEADER_H

#include "mimeheader.h"
#include "mailaddress.h"
#include "mimeio.h"
#include "rfcdecoder.h"

/**
  *@author Sven Carstens
  */

class mailHeader:public mimeHeader
{
public:
  mailHeader ();
  ~mailHeader ();

  virtual void addHdrLine (mimeHdrLine *);
  virtual void outputHeader (mimeIO &);

  void addTo (const mailAddress & _adr)
  {
    toAdr.append (new mailAddress (_adr));
  }
  void addCC (const mailAddress & _adr)
  {
    ccAdr.append (new mailAddress (_adr));
  }
  void addBCC (const mailAddress & _adr)
  {
    bccAdr.append (new mailAddress (_adr));
  }

  void setFrom (const mailAddress & _adr)
  {
    fromAdr = _adr;
  }
  void setSender (const mailAddress & _adr)
  {
    senderAdr = _adr;
  }
  void setReturnPath (const mailAddress & _adr)
  {
    returnpathAdr = _adr;
  }
  void setReplyTo (const mailAddress & _adr)
  {
    replytoAdr = _adr;
  }

  const TQCString& getMessageId ()
  {
    return messageID;
  }
  void setMessageId (const TQCString & _str)
  {
    messageID = _str;
  }

  const TQCString& getInReplyTo ()
  {
    return inReplyTo;
  }
  void setInReplyTo (const TQCString & _str)
  {
    inReplyTo = _str;
  }

  const TQCString& getReferences ()
  {
    return references;
  }
  void setReferences (const TQCString & _str)
  {
    references = _str;
  }

  /**
   * set a unicode subject
   */
  void setSubject (const TQString & _str)
  {
    _subject = rfcDecoder::encodeRFC2047String(_str).latin1();
  }
  /** 
   * set a encoded subject
   */
  void setSubjectEncoded (const TQCString & _str)
  {
    _subject = _str.simplifyWhiteSpace();
  }

  /** 
   * get the unicode subject
   */
  const TQString getSubject ()
  {
    return rfcDecoder::decodeRFC2047String(_subject);
  }
  /**
   * get the encoded subject
   */
  const TQCString& getSubjectEncoded ()
  {
    return _subject;
  }

  /**
   * set the date
   */
  void setDate (const TQCString & _str)
  {
    mDate = _str;
  }

  /**
   * get the date
   */
  const TQCString& date ()
  {
    return mDate;
  }

  static int parseAddressList (const char *, TQPtrList < mailAddress > *);
  static TQCString getAddressStr (TQPtrList < mailAddress > *);
  TQPtrList < mailAddress > &to ()
  {
    return toAdr;
  }
  TQPtrList < mailAddress > &cc ()
  {
    return ccAdr;
  }
  TQPtrList < mailAddress > &bcc ()
  {
    return bccAdr;
  }
#ifdef KMAIL_COMPATIBLE
  TQString subject ()
  {
    return getSubject ();
  }
  const mailAddress & from ()
  {
    return fromAdr;
  }
  const mailAddress & replyTo ()
  {
    return replytoAdr;
  }
  void readConfig (void)
  {;
  }
#endif

private:
  TQPtrList < mailAddress > toAdr;
  TQPtrList < mailAddress > ccAdr;
  TQPtrList < mailAddress > bccAdr;
  mailAddress fromAdr;
  mailAddress senderAdr;
  mailAddress returnpathAdr;
  mailAddress replytoAdr;
  TQCString _subject;
  TQCString mDate;
  int gmt_offset;
  TQCString messageID;
  TQCString inReplyTo;
  TQCString references;
};

#endif