author | alwin <alwin> | 2003-12-13 02:35:48 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-13 02:35:48 (UTC) |
commit | f689ef512cfc0a56fead4839a6b2e24a6ee282e0 (patch) (unidiff) | |
tree | c06b5e75d237bba3c5569d24bfa138faef1c38b9 | |
parent | c7749c503736091d0472e11b5bb0a8a82232bd61 (diff) | |
download | opie-f689ef512cfc0a56fead4839a6b2e24a6ee282e0.zip opie-f689ef512cfc0a56fead4839a6b2e24a6ee282e0.tar.gz opie-f689ef512cfc0a56fead4839a6b2e24a6ee282e0.tar.bz2 |
using QValueList<T> instead of QList<T> for body parts
(gives a better handling for const and non-const values and
so on)
-rw-r--r-- | noncore/net/mail/ProgrammersDoc/ReceivingMails.dia | bin | 3474 -> 3472 bytes | |||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 6 |
5 files changed, 16 insertions, 18 deletions
diff --git a/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia b/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia index a4a5fb6..4e63dc6 100644 --- a/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia +++ b/noncore/net/mail/ProgrammersDoc/ReceivingMails.dia | |||
Binary files differ | |||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index f56bb63..9c312e9 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,211 +1,210 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | 7 | init(); |
8 | } | 8 | } |
9 | 9 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::RecMail(const RecMail&old) |
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
12 | { | 12 | { |
13 | init(); | 13 | init(); |
14 | copy_old(old); | 14 | copy_old(old); |
15 | qDebug("Copy constructor RecMail"); | 15 | qDebug("Copy constructor RecMail"); |
16 | } | 16 | } |
17 | 17 | ||
18 | void RecMail::copy_old(const RecMail&old) | 18 | void RecMail::copy_old(const RecMail&old) |
19 | { | 19 | { |
20 | subject = old.subject; | 20 | subject = old.subject; |
21 | date = old.date; | 21 | date = old.date; |
22 | mbox = old.mbox; | 22 | mbox = old.mbox; |
23 | msg_id = old.msg_id; | 23 | msg_id = old.msg_id; |
24 | msg_size = old.msg_size; | 24 | msg_size = old.msg_size; |
25 | msg_number = old.msg_number; | 25 | msg_number = old.msg_number; |
26 | from = old.from; | 26 | from = old.from; |
27 | msg_flags = old.msg_flags; | 27 | msg_flags = old.msg_flags; |
28 | to = old.to; | 28 | to = old.to; |
29 | cc = old.cc; | 29 | cc = old.cc; |
30 | bcc = old.bcc; | 30 | bcc = old.bcc; |
31 | } | 31 | } |
32 | 32 | ||
33 | void RecMail::init() | 33 | void RecMail::init() |
34 | { | 34 | { |
35 | to.clear(); | 35 | to.clear(); |
36 | cc.clear(); | 36 | cc.clear(); |
37 | bcc.clear(); | 37 | bcc.clear(); |
38 | } | 38 | } |
39 | 39 | ||
40 | void RecMail::setTo(const QStringList&list) | 40 | void RecMail::setTo(const QStringList&list) |
41 | { | 41 | { |
42 | to = list; | 42 | to = list; |
43 | } | 43 | } |
44 | 44 | ||
45 | const QStringList&RecMail::To()const | 45 | const QStringList&RecMail::To()const |
46 | { | 46 | { |
47 | return to; | 47 | return to; |
48 | } | 48 | } |
49 | 49 | ||
50 | void RecMail::setCC(const QStringList&list) | 50 | void RecMail::setCC(const QStringList&list) |
51 | { | 51 | { |
52 | cc = list; | 52 | cc = list; |
53 | } | 53 | } |
54 | 54 | ||
55 | const QStringList&RecMail::CC()const | 55 | const QStringList&RecMail::CC()const |
56 | { | 56 | { |
57 | return cc; | 57 | return cc; |
58 | } | 58 | } |
59 | 59 | ||
60 | void RecMail::setBcc(const QStringList&list) | 60 | void RecMail::setBcc(const QStringList&list) |
61 | { | 61 | { |
62 | bcc = list; | 62 | bcc = list; |
63 | } | 63 | } |
64 | 64 | ||
65 | const QStringList& RecMail::Bcc()const | 65 | const QStringList& RecMail::Bcc()const |
66 | { | 66 | { |
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | m_Parameters.clear(); | 73 | m_Parameters.clear(); |
74 | m_poslist.clear(); | 74 | m_poslist.clear(); |
75 | } | 75 | } |
76 | 76 | ||
77 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | void RecPart::setLines(unsigned int lines) | 81 | void RecPart::setLines(unsigned int lines) |
82 | { | 82 | { |
83 | m_lines = lines; | 83 | m_lines = lines; |
84 | } | 84 | } |
85 | 85 | ||
86 | const unsigned int RecPart::Lines()const | 86 | const unsigned int RecPart::Lines()const |
87 | { | 87 | { |
88 | return m_lines; | 88 | return m_lines; |
89 | } | 89 | } |
90 | 90 | ||
91 | const QString& RecPart::Type()const | 91 | const QString& RecPart::Type()const |
92 | { | 92 | { |
93 | return m_type; | 93 | return m_type; |
94 | } | 94 | } |
95 | 95 | ||
96 | void RecPart::setType(const QString&type) | 96 | void RecPart::setType(const QString&type) |
97 | { | 97 | { |
98 | m_type = type; | 98 | m_type = type; |
99 | } | 99 | } |
100 | 100 | ||
101 | const QString& RecPart::Subtype()const | 101 | const QString& RecPart::Subtype()const |
102 | { | 102 | { |
103 | return m_subtype; | 103 | return m_subtype; |
104 | } | 104 | } |
105 | 105 | ||
106 | void RecPart::setSubtype(const QString&subtype) | 106 | void RecPart::setSubtype(const QString&subtype) |
107 | { | 107 | { |
108 | m_subtype = subtype; | 108 | m_subtype = subtype; |
109 | } | 109 | } |
110 | 110 | ||
111 | const QString& RecPart::Identifier()const | 111 | const QString& RecPart::Identifier()const |
112 | { | 112 | { |
113 | return m_identifier; | 113 | return m_identifier; |
114 | } | 114 | } |
115 | 115 | ||
116 | void RecPart::setIdentifier(const QString&identifier) | 116 | void RecPart::setIdentifier(const QString&identifier) |
117 | { | 117 | { |
118 | m_identifier = identifier; | 118 | m_identifier = identifier; |
119 | } | 119 | } |
120 | 120 | ||
121 | const QString& RecPart::Encoding()const | 121 | const QString& RecPart::Encoding()const |
122 | { | 122 | { |
123 | return m_encoding; | 123 | return m_encoding; |
124 | } | 124 | } |
125 | 125 | ||
126 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
127 | { | 127 | { |
128 | m_encoding = encoding; | 128 | m_encoding = encoding; |
129 | } | 129 | } |
130 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | 131 | void RecPart::setParameters(const part_plist_t&list) |
132 | { | 132 | { |
133 | m_Parameters = list; | 133 | m_Parameters = list; |
134 | } | 134 | } |
135 | 135 | ||
136 | const part_plist_t& RecPart::Parameters()const | 136 | const part_plist_t& RecPart::Parameters()const |
137 | { | 137 | { |
138 | return m_Parameters; | 138 | return m_Parameters; |
139 | } | 139 | } |
140 | 140 | ||
141 | void RecPart::addParameter(const QString&key,const QString&value) | 141 | void RecPart::addParameter(const QString&key,const QString&value) |
142 | { | 142 | { |
143 | m_Parameters[key]=value; | 143 | m_Parameters[key]=value; |
144 | } | 144 | } |
145 | 145 | ||
146 | const QString RecPart::searchParamter(const QString&key)const | 146 | const QString RecPart::searchParamter(const QString&key)const |
147 | { | 147 | { |
148 | QString value(""); | 148 | QString value(""); |
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 149 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
150 | if (it != m_Parameters.end()) { | 150 | if (it != m_Parameters.end()) { |
151 | value = it.data(); | 151 | value = it.data(); |
152 | } | 152 | } |
153 | return value; | 153 | return value; |
154 | } | 154 | } |
155 | 155 | ||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 156 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
157 | { | 157 | { |
158 | m_poslist = poslist; | 158 | m_poslist = poslist; |
159 | } | 159 | } |
160 | 160 | ||
161 | const QValueList<int>& RecPart::Positionlist()const | 161 | const QValueList<int>& RecPart::Positionlist()const |
162 | { | 162 | { |
163 | return m_poslist; | 163 | return m_poslist; |
164 | } | 164 | } |
165 | 165 | ||
166 | RecBody::RecBody() | 166 | RecBody::RecBody() |
167 | : m_BodyText(),m_PartsList(),m_description() | 167 | : m_BodyText(),m_PartsList(),m_description() |
168 | { | 168 | { |
169 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.clear(); |
170 | } | 170 | } |
171 | 171 | ||
172 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
173 | { | 173 | { |
174 | } | 174 | } |
175 | 175 | ||
176 | void RecBody::setBodytext(const QString&bodyText) | 176 | void RecBody::setBodytext(const QString&bodyText) |
177 | { | 177 | { |
178 | m_BodyText = bodyText; | 178 | m_BodyText = bodyText; |
179 | } | 179 | } |
180 | 180 | ||
181 | const QString& RecBody::Bodytext()const | 181 | const QString& RecBody::Bodytext()const |
182 | { | 182 | { |
183 | return m_BodyText; | 183 | return m_BodyText; |
184 | } | 184 | } |
185 | 185 | ||
186 | void RecBody::setParts(const QList<RecPart>&parts) | 186 | void RecBody::setParts(const QValueList<RecPart>&parts) |
187 | { | 187 | { |
188 | m_PartsList.clear(); | ||
188 | m_PartsList = parts; | 189 | m_PartsList = parts; |
189 | m_PartsList.setAutoDelete(true); | ||
190 | } | 190 | } |
191 | 191 | ||
192 | const QList<RecPart>& RecBody::Parts()const | 192 | const QValueList<RecPart>& RecBody::Parts()const |
193 | { | 193 | { |
194 | return m_PartsList; | 194 | return m_PartsList; |
195 | } | 195 | } |
196 | 196 | ||
197 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
198 | { | 198 | { |
199 | RecPart*p = new RecPart(part); | 199 | m_PartsList.append(part); |
200 | m_PartsList.append(p); | ||
201 | } | 200 | } |
202 | 201 | ||
203 | void RecBody::setDescription(const RecPart&des) | 202 | void RecBody::setDescription(const RecPart&des) |
204 | { | 203 | { |
205 | m_description = des; | 204 | m_description = des; |
206 | } | 205 | } |
207 | 206 | ||
208 | const RecPart& RecBody::Description()const | 207 | const RecPart& RecBody::Description()const |
209 | { | 208 | { |
210 | return m_description; | 209 | return m_description; |
211 | } | 210 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 60db527..f308bc7 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,128 +1,128 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
15 | #include <qmap.h> | 15 | #include <qmap.h> |
16 | #include <qvaluelist.h> | 16 | #include <qvaluelist.h> |
17 | 17 | ||
18 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
19 | /* Attention! | 19 | /* Attention! |
20 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
21 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
22 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
23 | Mailbodies can be real large. So we request them when | 23 | Mailbodies can be real large. So we request them when |
24 | needed from the mail-wrapper class direct from the server itself | 24 | needed from the mail-wrapper class direct from the server itself |
25 | (imap) or from a file-based cache (pop3?) | 25 | (imap) or from a file-based cache (pop3?) |
26 | So there is no interface "const QString&body()" but you should | 26 | So there is no interface "const QString&body()" but you should |
27 | make a request to the mailwrapper with this class as parameter to | 27 | make a request to the mailwrapper with this class as parameter to |
28 | get the body. Same words for the attachments. | 28 | get the body. Same words for the attachments. |
29 | */ | 29 | */ |
30 | class RecMail | 30 | class RecMail |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | RecMail(); | 33 | RecMail(); |
34 | RecMail(const RecMail&old); | 34 | RecMail(const RecMail&old); |
35 | virtual ~RecMail(){} | 35 | virtual ~RecMail(){} |
36 | 36 | ||
37 | const int getNumber()const{return msg_number;} | 37 | const int getNumber()const{return msg_number;} |
38 | void setNumber(int number){msg_number=number;} | 38 | void setNumber(int number){msg_number=number;} |
39 | const QString&getDate()const{ return date; } | 39 | const QString&getDate()const{ return date; } |
40 | void setDate( const QString&a ) { date = a; } | 40 | void setDate( const QString&a ) { date = a; } |
41 | const QString&getFrom()const{ return from; } | 41 | const QString&getFrom()const{ return from; } |
42 | void setFrom( const QString&a ) { from = a; } | 42 | void setFrom( const QString&a ) { from = a; } |
43 | const QString&getSubject()const { return subject; } | 43 | const QString&getSubject()const { return subject; } |
44 | void setSubject( const QString&s ) { subject = s; } | 44 | void setSubject( const QString&s ) { subject = s; } |
45 | const QString&getMbox()const{return mbox;} | 45 | const QString&getMbox()const{return mbox;} |
46 | void setMbox(const QString&box){mbox = box;} | 46 | void setMbox(const QString&box){mbox = box;} |
47 | void setMsgid(const QString&id){msg_id=id;} | 47 | void setMsgid(const QString&id){msg_id=id;} |
48 | const QString&Msgid()const{return msg_id;} | 48 | const QString&Msgid()const{return msg_id;} |
49 | void setReplyto(const QString&reply){replyto=reply;} | 49 | void setReplyto(const QString&reply){replyto=reply;} |
50 | const QString&Replyto()const{return replyto;} | 50 | const QString&Replyto()const{return replyto;} |
51 | void setMsgsize(int size){msg_size = size;} | 51 | void setMsgsize(int size){msg_size = size;} |
52 | const int Msgsize()const{return msg_size;} | 52 | const int Msgsize()const{return msg_size;} |
53 | 53 | ||
54 | 54 | ||
55 | void setTo(const QStringList&list); | 55 | void setTo(const QStringList&list); |
56 | const QStringList&To()const; | 56 | const QStringList&To()const; |
57 | void setCC(const QStringList&list); | 57 | void setCC(const QStringList&list); |
58 | const QStringList&CC()const; | 58 | const QStringList&CC()const; |
59 | void setBcc(const QStringList&list); | 59 | void setBcc(const QStringList&list); |
60 | const QStringList&Bcc()const; | 60 | const QStringList&Bcc()const; |
61 | const QBitArray&getFlags()const{return msg_flags;} | 61 | const QBitArray&getFlags()const{return msg_flags;} |
62 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 62 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | QString subject,date,from,mbox,msg_id,replyto; | 65 | QString subject,date,from,mbox,msg_id,replyto; |
66 | int msg_number,msg_size; | 66 | int msg_number,msg_size; |
67 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
68 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
69 | void init(); | 69 | void init(); |
70 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | 73 | typedef QMap<QString,QString> part_plist_t; |
74 | 74 | ||
75 | class RecPart | 75 | class RecPart |
76 | { | 76 | { |
77 | protected: | 77 | protected: |
78 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
79 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | 80 | part_plist_t m_Parameters; |
81 | /* describes the position in the mail */ | 81 | /* describes the position in the mail */ |
82 | QValueList<int> m_poslist; | 82 | QValueList<int> m_poslist; |
83 | 83 | ||
84 | public: | 84 | public: |
85 | RecPart(); | 85 | RecPart(); |
86 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
87 | 87 | ||
88 | const QString&Type()const; | 88 | const QString&Type()const; |
89 | void setType(const QString&type); | 89 | void setType(const QString&type); |
90 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
91 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
92 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
93 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
94 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
95 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
96 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
97 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | 98 | ||
99 | void setParameters(const part_plist_t&list); | 99 | void setParameters(const part_plist_t&list); |
100 | const part_plist_t&Parameters()const; | 100 | const part_plist_t&Parameters()const; |
101 | void addParameter(const QString&key,const QString&value); | 101 | void addParameter(const QString&key,const QString&value); |
102 | const QString searchParamter(const QString&key)const; | 102 | const QString searchParamter(const QString&key)const; |
103 | void setPositionlist(const QValueList<int>&poslist); | 103 | void setPositionlist(const QValueList<int>&poslist); |
104 | const QValueList<int>& Positionlist()const; | 104 | const QValueList<int>& Positionlist()const; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class RecBody | 107 | class RecBody |
108 | { | 108 | { |
109 | protected: | 109 | protected: |
110 | QString m_BodyText; | 110 | QString m_BodyText; |
111 | QList<RecPart> m_PartsList; | 111 | QValueList<RecPart> m_PartsList; |
112 | RecPart m_description; | 112 | RecPart m_description; |
113 | 113 | ||
114 | public: | 114 | public: |
115 | RecBody(); | 115 | RecBody(); |
116 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
117 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
118 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
119 | 119 | ||
120 | void setDescription(const RecPart&des); | 120 | void setDescription(const RecPart&des); |
121 | const RecPart& Description()const; | 121 | const RecPart& Description()const; |
122 | 122 | ||
123 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QValueList<RecPart>&parts); |
124 | const QList<RecPart>& Parts()const; | 124 | const QValueList<RecPart>& Parts()const; |
125 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
126 | }; | 126 | }; |
127 | 127 | ||
128 | #endif | 128 | #endif |
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index f56bb63..9c312e9 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -1,211 +1,210 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 5 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
6 | { | 6 | { |
7 | init(); | 7 | init(); |
8 | } | 8 | } |
9 | 9 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::RecMail(const RecMail&old) |
11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 11 | :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
12 | { | 12 | { |
13 | init(); | 13 | init(); |
14 | copy_old(old); | 14 | copy_old(old); |
15 | qDebug("Copy constructor RecMail"); | 15 | qDebug("Copy constructor RecMail"); |
16 | } | 16 | } |
17 | 17 | ||
18 | void RecMail::copy_old(const RecMail&old) | 18 | void RecMail::copy_old(const RecMail&old) |
19 | { | 19 | { |
20 | subject = old.subject; | 20 | subject = old.subject; |
21 | date = old.date; | 21 | date = old.date; |
22 | mbox = old.mbox; | 22 | mbox = old.mbox; |
23 | msg_id = old.msg_id; | 23 | msg_id = old.msg_id; |
24 | msg_size = old.msg_size; | 24 | msg_size = old.msg_size; |
25 | msg_number = old.msg_number; | 25 | msg_number = old.msg_number; |
26 | from = old.from; | 26 | from = old.from; |
27 | msg_flags = old.msg_flags; | 27 | msg_flags = old.msg_flags; |
28 | to = old.to; | 28 | to = old.to; |
29 | cc = old.cc; | 29 | cc = old.cc; |
30 | bcc = old.bcc; | 30 | bcc = old.bcc; |
31 | } | 31 | } |
32 | 32 | ||
33 | void RecMail::init() | 33 | void RecMail::init() |
34 | { | 34 | { |
35 | to.clear(); | 35 | to.clear(); |
36 | cc.clear(); | 36 | cc.clear(); |
37 | bcc.clear(); | 37 | bcc.clear(); |
38 | } | 38 | } |
39 | 39 | ||
40 | void RecMail::setTo(const QStringList&list) | 40 | void RecMail::setTo(const QStringList&list) |
41 | { | 41 | { |
42 | to = list; | 42 | to = list; |
43 | } | 43 | } |
44 | 44 | ||
45 | const QStringList&RecMail::To()const | 45 | const QStringList&RecMail::To()const |
46 | { | 46 | { |
47 | return to; | 47 | return to; |
48 | } | 48 | } |
49 | 49 | ||
50 | void RecMail::setCC(const QStringList&list) | 50 | void RecMail::setCC(const QStringList&list) |
51 | { | 51 | { |
52 | cc = list; | 52 | cc = list; |
53 | } | 53 | } |
54 | 54 | ||
55 | const QStringList&RecMail::CC()const | 55 | const QStringList&RecMail::CC()const |
56 | { | 56 | { |
57 | return cc; | 57 | return cc; |
58 | } | 58 | } |
59 | 59 | ||
60 | void RecMail::setBcc(const QStringList&list) | 60 | void RecMail::setBcc(const QStringList&list) |
61 | { | 61 | { |
62 | bcc = list; | 62 | bcc = list; |
63 | } | 63 | } |
64 | 64 | ||
65 | const QStringList& RecMail::Bcc()const | 65 | const QStringList& RecMail::Bcc()const |
66 | { | 66 | { |
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | m_Parameters.clear(); | 73 | m_Parameters.clear(); |
74 | m_poslist.clear(); | 74 | m_poslist.clear(); |
75 | } | 75 | } |
76 | 76 | ||
77 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | void RecPart::setLines(unsigned int lines) | 81 | void RecPart::setLines(unsigned int lines) |
82 | { | 82 | { |
83 | m_lines = lines; | 83 | m_lines = lines; |
84 | } | 84 | } |
85 | 85 | ||
86 | const unsigned int RecPart::Lines()const | 86 | const unsigned int RecPart::Lines()const |
87 | { | 87 | { |
88 | return m_lines; | 88 | return m_lines; |
89 | } | 89 | } |
90 | 90 | ||
91 | const QString& RecPart::Type()const | 91 | const QString& RecPart::Type()const |
92 | { | 92 | { |
93 | return m_type; | 93 | return m_type; |
94 | } | 94 | } |
95 | 95 | ||
96 | void RecPart::setType(const QString&type) | 96 | void RecPart::setType(const QString&type) |
97 | { | 97 | { |
98 | m_type = type; | 98 | m_type = type; |
99 | } | 99 | } |
100 | 100 | ||
101 | const QString& RecPart::Subtype()const | 101 | const QString& RecPart::Subtype()const |
102 | { | 102 | { |
103 | return m_subtype; | 103 | return m_subtype; |
104 | } | 104 | } |
105 | 105 | ||
106 | void RecPart::setSubtype(const QString&subtype) | 106 | void RecPart::setSubtype(const QString&subtype) |
107 | { | 107 | { |
108 | m_subtype = subtype; | 108 | m_subtype = subtype; |
109 | } | 109 | } |
110 | 110 | ||
111 | const QString& RecPart::Identifier()const | 111 | const QString& RecPart::Identifier()const |
112 | { | 112 | { |
113 | return m_identifier; | 113 | return m_identifier; |
114 | } | 114 | } |
115 | 115 | ||
116 | void RecPart::setIdentifier(const QString&identifier) | 116 | void RecPart::setIdentifier(const QString&identifier) |
117 | { | 117 | { |
118 | m_identifier = identifier; | 118 | m_identifier = identifier; |
119 | } | 119 | } |
120 | 120 | ||
121 | const QString& RecPart::Encoding()const | 121 | const QString& RecPart::Encoding()const |
122 | { | 122 | { |
123 | return m_encoding; | 123 | return m_encoding; |
124 | } | 124 | } |
125 | 125 | ||
126 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
127 | { | 127 | { |
128 | m_encoding = encoding; | 128 | m_encoding = encoding; |
129 | } | 129 | } |
130 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | 131 | void RecPart::setParameters(const part_plist_t&list) |
132 | { | 132 | { |
133 | m_Parameters = list; | 133 | m_Parameters = list; |
134 | } | 134 | } |
135 | 135 | ||
136 | const part_plist_t& RecPart::Parameters()const | 136 | const part_plist_t& RecPart::Parameters()const |
137 | { | 137 | { |
138 | return m_Parameters; | 138 | return m_Parameters; |
139 | } | 139 | } |
140 | 140 | ||
141 | void RecPart::addParameter(const QString&key,const QString&value) | 141 | void RecPart::addParameter(const QString&key,const QString&value) |
142 | { | 142 | { |
143 | m_Parameters[key]=value; | 143 | m_Parameters[key]=value; |
144 | } | 144 | } |
145 | 145 | ||
146 | const QString RecPart::searchParamter(const QString&key)const | 146 | const QString RecPart::searchParamter(const QString&key)const |
147 | { | 147 | { |
148 | QString value(""); | 148 | QString value(""); |
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | 149 | part_plist_t::ConstIterator it = m_Parameters.find(key); |
150 | if (it != m_Parameters.end()) { | 150 | if (it != m_Parameters.end()) { |
151 | value = it.data(); | 151 | value = it.data(); |
152 | } | 152 | } |
153 | return value; | 153 | return value; |
154 | } | 154 | } |
155 | 155 | ||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | 156 | void RecPart::setPositionlist(const QValueList<int>&poslist) |
157 | { | 157 | { |
158 | m_poslist = poslist; | 158 | m_poslist = poslist; |
159 | } | 159 | } |
160 | 160 | ||
161 | const QValueList<int>& RecPart::Positionlist()const | 161 | const QValueList<int>& RecPart::Positionlist()const |
162 | { | 162 | { |
163 | return m_poslist; | 163 | return m_poslist; |
164 | } | 164 | } |
165 | 165 | ||
166 | RecBody::RecBody() | 166 | RecBody::RecBody() |
167 | : m_BodyText(),m_PartsList(),m_description() | 167 | : m_BodyText(),m_PartsList(),m_description() |
168 | { | 168 | { |
169 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.clear(); |
170 | } | 170 | } |
171 | 171 | ||
172 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
173 | { | 173 | { |
174 | } | 174 | } |
175 | 175 | ||
176 | void RecBody::setBodytext(const QString&bodyText) | 176 | void RecBody::setBodytext(const QString&bodyText) |
177 | { | 177 | { |
178 | m_BodyText = bodyText; | 178 | m_BodyText = bodyText; |
179 | } | 179 | } |
180 | 180 | ||
181 | const QString& RecBody::Bodytext()const | 181 | const QString& RecBody::Bodytext()const |
182 | { | 182 | { |
183 | return m_BodyText; | 183 | return m_BodyText; |
184 | } | 184 | } |
185 | 185 | ||
186 | void RecBody::setParts(const QList<RecPart>&parts) | 186 | void RecBody::setParts(const QValueList<RecPart>&parts) |
187 | { | 187 | { |
188 | m_PartsList.clear(); | ||
188 | m_PartsList = parts; | 189 | m_PartsList = parts; |
189 | m_PartsList.setAutoDelete(true); | ||
190 | } | 190 | } |
191 | 191 | ||
192 | const QList<RecPart>& RecBody::Parts()const | 192 | const QValueList<RecPart>& RecBody::Parts()const |
193 | { | 193 | { |
194 | return m_PartsList; | 194 | return m_PartsList; |
195 | } | 195 | } |
196 | 196 | ||
197 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
198 | { | 198 | { |
199 | RecPart*p = new RecPart(part); | 199 | m_PartsList.append(part); |
200 | m_PartsList.append(p); | ||
201 | } | 200 | } |
202 | 201 | ||
203 | void RecBody::setDescription(const RecPart&des) | 202 | void RecBody::setDescription(const RecPart&des) |
204 | { | 203 | { |
205 | m_description = des; | 204 | m_description = des; |
206 | } | 205 | } |
207 | 206 | ||
208 | const RecPart& RecBody::Description()const | 207 | const RecPart& RecBody::Description()const |
209 | { | 208 | { |
210 | return m_description; | 209 | return m_description; |
211 | } | 210 | } |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index 60db527..f308bc7 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -1,128 +1,128 @@ | |||
1 | #ifndef __MAIL_TYPES_H | 1 | #ifndef __MAIL_TYPES_H |
2 | #define __MAIL_TYPES_H | 2 | #define __MAIL_TYPES_H |
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
15 | #include <qmap.h> | 15 | #include <qmap.h> |
16 | #include <qvaluelist.h> | 16 | #include <qvaluelist.h> |
17 | 17 | ||
18 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
19 | /* Attention! | 19 | /* Attention! |
20 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
21 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
22 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
23 | Mailbodies can be real large. So we request them when | 23 | Mailbodies can be real large. So we request them when |
24 | needed from the mail-wrapper class direct from the server itself | 24 | needed from the mail-wrapper class direct from the server itself |
25 | (imap) or from a file-based cache (pop3?) | 25 | (imap) or from a file-based cache (pop3?) |
26 | So there is no interface "const QString&body()" but you should | 26 | So there is no interface "const QString&body()" but you should |
27 | make a request to the mailwrapper with this class as parameter to | 27 | make a request to the mailwrapper with this class as parameter to |
28 | get the body. Same words for the attachments. | 28 | get the body. Same words for the attachments. |
29 | */ | 29 | */ |
30 | class RecMail | 30 | class RecMail |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | RecMail(); | 33 | RecMail(); |
34 | RecMail(const RecMail&old); | 34 | RecMail(const RecMail&old); |
35 | virtual ~RecMail(){} | 35 | virtual ~RecMail(){} |
36 | 36 | ||
37 | const int getNumber()const{return msg_number;} | 37 | const int getNumber()const{return msg_number;} |
38 | void setNumber(int number){msg_number=number;} | 38 | void setNumber(int number){msg_number=number;} |
39 | const QString&getDate()const{ return date; } | 39 | const QString&getDate()const{ return date; } |
40 | void setDate( const QString&a ) { date = a; } | 40 | void setDate( const QString&a ) { date = a; } |
41 | const QString&getFrom()const{ return from; } | 41 | const QString&getFrom()const{ return from; } |
42 | void setFrom( const QString&a ) { from = a; } | 42 | void setFrom( const QString&a ) { from = a; } |
43 | const QString&getSubject()const { return subject; } | 43 | const QString&getSubject()const { return subject; } |
44 | void setSubject( const QString&s ) { subject = s; } | 44 | void setSubject( const QString&s ) { subject = s; } |
45 | const QString&getMbox()const{return mbox;} | 45 | const QString&getMbox()const{return mbox;} |
46 | void setMbox(const QString&box){mbox = box;} | 46 | void setMbox(const QString&box){mbox = box;} |
47 | void setMsgid(const QString&id){msg_id=id;} | 47 | void setMsgid(const QString&id){msg_id=id;} |
48 | const QString&Msgid()const{return msg_id;} | 48 | const QString&Msgid()const{return msg_id;} |
49 | void setReplyto(const QString&reply){replyto=reply;} | 49 | void setReplyto(const QString&reply){replyto=reply;} |
50 | const QString&Replyto()const{return replyto;} | 50 | const QString&Replyto()const{return replyto;} |
51 | void setMsgsize(int size){msg_size = size;} | 51 | void setMsgsize(int size){msg_size = size;} |
52 | const int Msgsize()const{return msg_size;} | 52 | const int Msgsize()const{return msg_size;} |
53 | 53 | ||
54 | 54 | ||
55 | void setTo(const QStringList&list); | 55 | void setTo(const QStringList&list); |
56 | const QStringList&To()const; | 56 | const QStringList&To()const; |
57 | void setCC(const QStringList&list); | 57 | void setCC(const QStringList&list); |
58 | const QStringList&CC()const; | 58 | const QStringList&CC()const; |
59 | void setBcc(const QStringList&list); | 59 | void setBcc(const QStringList&list); |
60 | const QStringList&Bcc()const; | 60 | const QStringList&Bcc()const; |
61 | const QBitArray&getFlags()const{return msg_flags;} | 61 | const QBitArray&getFlags()const{return msg_flags;} |
62 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 62 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | QString subject,date,from,mbox,msg_id,replyto; | 65 | QString subject,date,from,mbox,msg_id,replyto; |
66 | int msg_number,msg_size; | 66 | int msg_number,msg_size; |
67 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
68 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
69 | void init(); | 69 | void init(); |
70 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | 73 | typedef QMap<QString,QString> part_plist_t; |
74 | 74 | ||
75 | class RecPart | 75 | class RecPart |
76 | { | 76 | { |
77 | protected: | 77 | protected: |
78 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
79 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | 80 | part_plist_t m_Parameters; |
81 | /* describes the position in the mail */ | 81 | /* describes the position in the mail */ |
82 | QValueList<int> m_poslist; | 82 | QValueList<int> m_poslist; |
83 | 83 | ||
84 | public: | 84 | public: |
85 | RecPart(); | 85 | RecPart(); |
86 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
87 | 87 | ||
88 | const QString&Type()const; | 88 | const QString&Type()const; |
89 | void setType(const QString&type); | 89 | void setType(const QString&type); |
90 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
91 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
92 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
93 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
94 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
95 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
96 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
97 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | 98 | ||
99 | void setParameters(const part_plist_t&list); | 99 | void setParameters(const part_plist_t&list); |
100 | const part_plist_t&Parameters()const; | 100 | const part_plist_t&Parameters()const; |
101 | void addParameter(const QString&key,const QString&value); | 101 | void addParameter(const QString&key,const QString&value); |
102 | const QString searchParamter(const QString&key)const; | 102 | const QString searchParamter(const QString&key)const; |
103 | void setPositionlist(const QValueList<int>&poslist); | 103 | void setPositionlist(const QValueList<int>&poslist); |
104 | const QValueList<int>& Positionlist()const; | 104 | const QValueList<int>& Positionlist()const; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class RecBody | 107 | class RecBody |
108 | { | 108 | { |
109 | protected: | 109 | protected: |
110 | QString m_BodyText; | 110 | QString m_BodyText; |
111 | QList<RecPart> m_PartsList; | 111 | QValueList<RecPart> m_PartsList; |
112 | RecPart m_description; | 112 | RecPart m_description; |
113 | 113 | ||
114 | public: | 114 | public: |
115 | RecBody(); | 115 | RecBody(); |
116 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
117 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
118 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
119 | 119 | ||
120 | void setDescription(const RecPart&des); | 120 | void setDescription(const RecPart&des); |
121 | const RecPart& Description()const; | 121 | const RecPart& Description()const; |
122 | 122 | ||
123 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QValueList<RecPart>&parts); |
124 | const QList<RecPart>& Parts()const; | 124 | const QValueList<RecPart>& Parts()const; |
125 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
126 | }; | 126 | }; |
127 | 127 | ||
128 | #endif | 128 | #endif |