summaryrefslogtreecommitdiffstats
path: root/korn/mailsubject.h
blob: 6e4c214b37cb5ed5ff0dc96c49daf56f7a192bfc (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
#ifndef MailSubject_h
#define MailSubject_h

class TQTextCodec;

class KMailDrop;

#include "mailid.h"



/**
 * A KornMailSubject instance represents a single mail. It stores 
 * its id, sender, subject, header, size and date and possibly its
 * mail body
 */
class KornMailSubject
{
	KornMailId * 	_id;
	KMailDrop *     _drop;
	TQString		_subject;
	TQString		_sender;
	TQString		_header;
	int 		_size;
	int		_date;
	bool 		_fullMessage;
public:
	/**
	 * KornMailSubject default constructor
	 */
	KornMailSubject();

	/**
	 * KornMailSubject constructor
	 * @param id id of the mail. The KornMailId instance should
	 * not be touched or deleted afterwards. It is destroyed by
	 * KornMailSubject's destructor.
	 * @param drop The KMailDrop.
	 */
	KornMailSubject(KornMailId * id, KMailDrop * drop);

	/**
	 * KornMailSubject copy constructor. All data of the source
	 * KornMailSubject instance are cloned.
	 * @param src KornMailSubject to copy from
	 */
	KornMailSubject(const KornMailSubject & src);

	/**
	 * replaces the contents of this by the contents of another
	 * KornMailSubject instance.  All data of the source
	 * KornMailSubject instance are cloned.
	 * @param src KornMailSubject to copy from
	 */
	KornMailSubject & operator= (const KornMailSubject & src);
	
	/**
	 * KornMailSubject destructor
	 */
	virtual ~KornMailSubject();

	/**
	 * Return the mail id.
	 * @return the mail id.
	 */
	const KornMailId * getId() const {return _id;}

	/**
	 * Set the mails subject.
	 * @param subject the mails subject.
	 */
	void setSubject(const TQString & subject) {_subject = subject;}

	/**
	 * Return the subject.
	 * @return the subject.
	 */
	const TQString & getSubject() const {return _subject;}

	/**
	 * Set the mails sender.
	 * @param sender the mails sender.
	 */
	void setSender(const TQString & sender) {_sender = sender;}

	/**
	 * Return the sender.
	 * @return the sender.
	 */
	const TQString & getSender() const {return _sender;}

	/**
	 * Set the mails header and (if possible) body.
	 * @param header the mails header with or without body (see fullMessage parameter).
	 * @param fullMessage true, if header contains the message body as well, false otherwise.
	 */
	void setHeader(const TQString & header, bool fullMessage) {_header = header; _fullMessage = fullMessage;}

	/**
	 * Return the header or the full message (if isHeaderFullMessage() is true).
	 * @return the header or the full message.
	 */
	const TQString & getHeader() const {return _header;}

	/**
	 * Return true, if the header contains the header and the full message.
	 * Return false if the header just contains the header.
	 * @return see above.
	 */
	bool isHeaderFullMessage() const {return _fullMessage;}

	/**
	 * Set the size of the full mail.
	 * @param the mails full size.
	 */
	void setSize(int size) {_size = size;}

	/**
	 * Return the size of the full mail.
	 * @return the size of the full mail.
	 */
	int getSize() const {return _size;}

	/**
	 * Set the mails date in seconds since 1970-01-01 00:00:00.
	 * @param date the mails date.
	 */
	void setDate(int date) {_date = date;}

	/**
	 * Return the mails date in seconds since 1970-01-01 00:00:00.
	 * @return the mails date.
	 */
	int getDate() const {return _date;}

	/**
	 * Return a string representation of this (for debugging purposes only)
	 * @return a string representation
	 */
	TQString toString() const;
	
	/**
	 * Sets the KMailDrop field.
	 * @param drop The KMailDrop-object
	 */
	void setMailDrop( KMailDrop* drop ) { _drop = drop; }
	
	/**
	 * Returns the KMailDrop instance of the Maildrop which owns the subject
	 */
	KMailDrop* getMailDrop() const { return _drop; }

        /**
         * decodes headers using decodeRFC2047String
         */
        void decodeHeaders();

private:

        /**
         * Decode a string based on RFC2047
         */
        TQString decodeRFC2047String(const TQCString& aStr);

        /**
         * Unfolding a string (basically changing tabs to spaces
         */
        TQCString unfold( const TQCString & header );

        /**
         * Returns true if the parameter is a blank (or tab)
         *
         * Note from KMail's code, where this function is taken from:
         * don't rely on isblank(), which is a GNU extension in
         * <cctype>. But if someone wants to write a configure test for
         * isblank(), we can then rename this function to isblank and #ifdef
         * it's definition...
         */
        inline bool isBlank( char ch ) { return ch == ' ' || ch == '\t' ; }

        /**
         * ??
         */
        const TQTextCodec* codecForName(const TQCString& _str);
};

#endif