-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index a086dfc..2144899 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -1,447 +1,447 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | smtpClient = new SmtpClient(); | 42 | smtpClient = new SmtpClient(); |
43 | popClient = new PopClient(); | 43 | popClient = new PopClient(); |
44 | 44 | ||
45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, | 45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, |
46 | SIGNAL(smtpError(int)) ); | 46 | SIGNAL(smtpError(int)) ); |
47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
49 | SIGNAL(updateSmtpStatus(const QString &)) ); | 49 | SIGNAL(updateSmtpStatus(const QString &)) ); |
50 | 50 | ||
51 | connect(popClient, SIGNAL(errorOccurred(int)), this, | 51 | connect(popClient, SIGNAL(errorOccurred(int)), this, |
52 | SIGNAL(popError(int)) ); | 52 | SIGNAL(popError(int)) ); |
53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
56 | SIGNAL(updatePopStatus(const QString &)) ); | 56 | SIGNAL(updatePopStatus(const QString &)) ); |
57 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 57 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
58 | SIGNAL(mailTransfered(int)) ); | 58 | SIGNAL(mailTransfered(int)) ); |
59 | 59 | ||
60 | 60 | ||
61 | //relaying size information | 61 | //relaying size information |
62 | connect(popClient, SIGNAL(currentMailSize(int)), | 62 | connect(popClient, SIGNAL(currentMailSize(int)), |
63 | this, SIGNAL(currentMailSize(int)) ); | 63 | this, SIGNAL(currentMailSize(int)) ); |
64 | connect(popClient, SIGNAL(downloadedSize(int)), | 64 | connect(popClient, SIGNAL(downloadedSize(int)), |
65 | this, SIGNAL(downloadedSize(int)) ); | 65 | this, SIGNAL(downloadedSize(int)) ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void EmailHandler::sendMail(QList<Email> *mailList) | 68 | void EmailHandler::sendMail(QList<Email> *mailList) |
69 | { | 69 | { |
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | if (mailAccount.synchronize) { |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 115 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
116 | } else { | 116 | } else { |
117 | popClient->removeSynchronize(); | 117 | popClient->removeSynchronize(); |
118 | } | 118 | } |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, 2000); //less than 2000, download all | 121 | popClient->headersOnly(headers, 2000); //less than 2000, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 122 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 123 | } |
124 | 124 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 125 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 126 | { |
127 | if (mailList->count() == 0) { //should not occur though | 127 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 128 | emit mailTransfered(0); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | headers = FALSE; | 132 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 133 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 134 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 135 | popClient->setSelectedMails(mailList); |
136 | } | 136 | } |
137 | 137 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
139 | { | 139 | { |
140 | Email mail; | 140 | Email mail; |
141 | 141 | ||
142 | mail.rawMail = message; | 142 | mail.rawMail = message; |
143 | mail.serverId = id; | 143 | mail.serverId = id; |
144 | mail.size = size; | 144 | mail.size = size; |
145 | mail.downloaded = complete; | 145 | mail.downloaded = complete; |
146 | 146 | ||
147 | emit mailArrived(mail, FALSE); | 147 | emit mailArrived(mail, FALSE); |
148 | } | 148 | } |
149 | 149 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 151 | { |
152 | QString temp, boundary; | 152 | QString temp, boundary; |
153 | int pos; | 153 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 154 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | qWarning(in.right(temp.length())); | 166 | qWarning(in.right(temp.length())); |
167 | qWarning(" . added at end of email as separator"); | 167 | qWarning(" . added at end of email as separator"); |
168 | mail->rawMail += temp; | 168 | mail->rawMail += temp; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
173 | pos = in.find(delimiter, 0, FALSE); | 173 | pos = in.find(delimiter, 0, FALSE); |
174 | header = in.left(pos); | 174 | header = in.left(pos); |
175 | body = in.right(in.length() - pos - delimiter.length()); | 175 | body = in.right(in.length() - pos - delimiter.length()); |
176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
177 | body.truncate(body.length()-2); | 177 | body.truncate(body.length()-2); |
178 | 178 | ||
179 | TextParser p(header, lineShift); | 179 | TextParser p(header, lineShift); |
180 | 180 | ||
181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
182 | pos++; | 182 | pos++; |
183 | if (p.separatorAt(pos) == ' ') { | 183 | if (p.separatorAt(pos) == ' ') { |
184 | mail->from = p.getString(&pos, '<'); | 184 | mail->from = p.getString(&pos, '<', false); |
185 | mail->from = mail->from.stripWhiteSpace(); | 185 | mail->from = mail->from.stripWhiteSpace(); |
186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
187 | mail->from = mail->from.left(mail->from.length() - 1); | 187 | mail->from = mail->from.left(mail->from.length() - 1); |
188 | mail->from = mail->from.right(mail->from.length() - 1); | 188 | mail->from = mail->from.right(mail->from.length() - 1); |
189 | } | 189 | } |
190 | pos++; | 190 | pos++; |
191 | mail->fromMail = p.getString(&pos, '>'); | 191 | mail->fromMail = p.getString(&pos, '>', false); |
192 | } else { | 192 | } else { |
193 | if ((p.separatorAt(pos) == '<') | 193 | if ((p.separatorAt(pos) == '<') |
194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
195 | pos++; | 195 | pos++; |
196 | pos++; | 196 | pos++; |
197 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 197 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
199 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 199 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
200 | mail->from=mail->fromMail; | 200 | mail->from=mail->fromMail; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 203 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
204 | pos++; | 204 | pos++; |
205 | mail->subject = p.getString(&pos, 'z', TRUE); | 205 | mail->subject = p.getString(&pos, 'z', TRUE); |
206 | } | 206 | } |
207 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 207 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
208 | pos++; | 208 | pos++; |
209 | mail->date = p.getString(&pos, 'z', true); | 209 | mail->date = p.getString(&pos, 'z', true); |
210 | } | 210 | } |
211 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) { | 211 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) { |
212 | pos++; | 212 | pos++; |
213 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 213 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
214 | } | 214 | } |
215 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 215 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
216 | pos++; | 216 | pos++; |
217 | if ( (p.wordAt(pos).upper() == "ID") && | 217 | if ( (p.wordAt(pos).upper() == "ID") && |
218 | (p.separatorAt(pos) == ':') ) { | 218 | (p.separatorAt(pos) == ':') ) { |
219 | 219 | ||
220 | id = p.getString(&pos, 'z', TRUE); | 220 | id = p.getString(&pos, 'z', TRUE); |
221 | mail->id = id; | 221 | mail->id = id; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | pos = 0; | 225 | pos = 0; |
226 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 226 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
227 | pos++; | 227 | pos++; |
228 | if ( (p.wordAt(pos).upper() == "VERSION") && | 228 | if ( (p.wordAt(pos).upper() == "VERSION") && |
229 | (p.separatorAt(pos) == ':') ) { | 229 | (p.separatorAt(pos) == ':') ) { |
230 | pos++; | 230 | pos++; |
231 | if (p.getString(&pos, 'z', true) == "1.0") { | 231 | if (p.getString(&pos, 'z', true) == "1.0") { |
232 | mail->mimeType = 1; | 232 | mail->mimeType = 1; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | if (mail->mimeType == 1) { | 237 | if (mail->mimeType == 1) { |
238 | boundary = ""; | 238 | boundary = ""; |
239 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 239 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
240 | pos++; | 240 | pos++; |
241 | boundary = p.getString(&pos, 'z', true); | 241 | boundary = p.getString(&pos, 'z', true); |
242 | if (boundary[0] == '"') { | 242 | if (boundary[0] == '"') { |
243 | boundary = boundary.left(boundary.length() - 1); //strip " | 243 | boundary = boundary.left(boundary.length() - 1); //strip " |
244 | boundary = boundary.right(boundary.length() - 1); //strip " | 244 | boundary = boundary.right(boundary.length() - 1); //strip " |
245 | } | 245 | } |
246 | boundary = "--" + boundary; //create boundary field | 246 | boundary = "--" + boundary; //create boundary field |
247 | } | 247 | } |
248 | 248 | ||
249 | if (boundary == "") { //fooled by Mime-Version | 249 | if (boundary == "") { //fooled by Mime-Version |
250 | mail->body = body; | 250 | mail->body = body; |
251 | mail->bodyPlain = body; | 251 | mail->bodyPlain = body; |
252 | return mail; | 252 | return mail; |
253 | } | 253 | } |
254 | 254 | ||
255 | while (body.length() > 0) { | 255 | while (body.length() > 0) { |
256 | pos = body.find(boundary, 0, FALSE); | 256 | pos = body.find(boundary, 0, FALSE); |
257 | pos = body.find(delimiter, pos, FALSE); | 257 | pos = body.find(delimiter, pos, FALSE); |
258 | mimeHeader = body.left(pos); | 258 | mimeHeader = body.left(pos); |
259 | mimeBody = body.right(body.length() - pos - delimiter.length()); | 259 | mimeBody = body.right(body.length() - pos - delimiter.length()); |
260 | TextParser bp(mimeHeader, lineShift); | 260 | TextParser bp(mimeHeader, lineShift); |
261 | 261 | ||
262 | contentType = ""; | 262 | contentType = ""; |
263 | contentAttribute = ""; | 263 | contentAttribute = ""; |
264 | fileName = ""; | 264 | fileName = ""; |
265 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { | 265 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { |
266 | pos++; | 266 | pos++; |
267 | if ( (bp.wordAt(pos).upper() == "TYPE") && | 267 | if ( (bp.wordAt(pos).upper() == "TYPE") && |
268 | (bp.separatorAt(pos) == ':') ) { | 268 | (bp.separatorAt(pos) == ':') ) { |
269 | contentType = bp.nextWord().upper(); | 269 | contentType = bp.nextWord().upper(); |
270 | if (bp.nextSeparator() == '/') | 270 | if (bp.nextSeparator() == '/') |
271 | contentAttribute = bp.nextWord().upper(); | 271 | contentAttribute = bp.nextWord().upper(); |
272 | content = contentType + "/" + contentAttribute; | 272 | content = contentType + "/" + contentAttribute; |
273 | } | 273 | } |
274 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { | 274 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { |
275 | pos++; | 275 | pos++; |
276 | encoding = bp.getString(&pos, 'z', TRUE); | 276 | encoding = bp.getString(&pos, 'z', TRUE); |
277 | } | 277 | } |
278 | 278 | ||
279 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { | 279 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { |
280 | pos++; | 280 | pos++; |
281 | fileName = bp.getString(&pos, 'z', TRUE); | 281 | fileName = bp.getString(&pos, 'z', TRUE); |
282 | fileName = fileName.right(fileName.length() - 1); | 282 | fileName = fileName.right(fileName.length() - 1); |
283 | fileName = fileName.left(fileName.length() - 1); | 283 | fileName = fileName.left(fileName.length() - 1); |
284 | } | 284 | } |
285 | 285 | ||
286 | } | 286 | } |
287 | pos = mimeBody.find(boundary, 0, FALSE); | 287 | pos = mimeBody.find(boundary, 0, FALSE); |
288 | if (pos == -1) //should not occur, malformed mail | 288 | if (pos == -1) //should not occur, malformed mail |
289 | pos = mimeBody.length(); | 289 | pos = mimeBody.length(); |
290 | body = mimeBody.right(mimeBody.length() - pos); | 290 | body = mimeBody.right(mimeBody.length() - pos); |
291 | mimeBody = mimeBody.left(pos); | 291 | mimeBody = mimeBody.left(pos); |
292 | 292 | ||
293 | if (fileName != "") { //attatchments of some type, audio, image etc. | 293 | if (fileName != "") { //attatchments of some type, audio, image etc. |
294 | 294 | ||
295 | Enclosure e; | 295 | Enclosure e; |
296 | e.id = enclosureId; | 296 | e.id = enclosureId; |
297 | e.originalName = fileName; | 297 | e.originalName = fileName; |
298 | e.contentType = contentType; | 298 | e.contentType = contentType; |
299 | e.contentAttribute = contentAttribute; | 299 | e.contentAttribute = contentAttribute; |
300 | e.encoding = encoding; | 300 | e.encoding = encoding; |
301 | e.body = mimeBody; | 301 | e.body = mimeBody; |
302 | e.saved = FALSE; | 302 | e.saved = FALSE; |
303 | mail->addEnclosure(&e); | 303 | mail->addEnclosure(&e); |
304 | enclosureId++; | 304 | enclosureId++; |
305 | 305 | ||
306 | } else if (contentType == "TEXT") { | 306 | } else if (contentType == "TEXT") { |
307 | if (contentAttribute == "PLAIN") { | 307 | if (contentAttribute == "PLAIN") { |
308 | mail->body = mimeBody; | 308 | mail->body = mimeBody; |
309 | mail->bodyPlain = mimeBody; | 309 | mail->bodyPlain = mimeBody; |
310 | } | 310 | } |
311 | if (contentAttribute == "HTML") { | 311 | if (contentAttribute == "HTML") { |
312 | mail->body = mimeBody; | 312 | mail->body = mimeBody; |
313 | } | 313 | } |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } else { | 316 | } else { |
317 | mail->bodyPlain = body; | 317 | mail->bodyPlain = body; |
318 | mail->body = body; | 318 | mail->body = body; |
319 | } | 319 | } |
320 | return TRUE; | 320 | return TRUE; |
321 | } | 321 | } |
322 | 322 | ||
323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
324 | { | 324 | { |
325 | QFile f(ePtr->path + ePtr->name); | 325 | QFile f(ePtr->path + ePtr->name); |
326 | char src[4]; | 326 | char src[4]; |
327 | char *destPtr; | 327 | char *destPtr; |
328 | QByteArray buffer; | 328 | QByteArray buffer; |
329 | uint bufCount, pos, decodedCount, size, x; | 329 | uint bufCount, pos, decodedCount, size, x; |
330 | 330 | ||
331 | if (! f.open(IO_WriteOnly) ) { | 331 | if (! f.open(IO_WriteOnly) ) { |
332 | qWarning("could not save: " + ePtr->path + ePtr->name); | 332 | qWarning("could not save: " + ePtr->path + ePtr->name); |
333 | return FALSE; | 333 | return FALSE; |
334 | } | 334 | } |
335 | 335 | ||
336 | if (ePtr->encoding.upper() == "BASE64") { | 336 | if (ePtr->encoding.upper() == "BASE64") { |
337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
338 | buffer.resize(size); | 338 | buffer.resize(size); |
339 | bufCount = 0; | 339 | bufCount = 0; |
340 | pos = 0; | 340 | pos = 0; |
341 | destPtr = buffer.data(); | 341 | destPtr = buffer.data(); |
342 | 342 | ||
343 | while (pos < ePtr->body.length()) { | 343 | while (pos < ePtr->body.length()) { |
344 | decodedCount = 4; | 344 | decodedCount = 4; |
345 | x = 0; | 345 | x = 0; |
346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
347 | src[x] = ePtr->body[pos].latin1(); | 347 | src[x] = ePtr->body[pos].latin1(); |
348 | pos++; | 348 | pos++; |
349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
350 | x--; | 350 | x--; |
351 | x++; | 351 | x++; |
352 | } | 352 | } |
353 | if (x > 1) { | 353 | if (x > 1) { |
354 | decodedCount = parse64base(src, destPtr); | 354 | decodedCount = parse64base(src, destPtr); |
355 | destPtr += decodedCount; | 355 | destPtr += decodedCount; |
356 | bufCount += decodedCount; | 356 | bufCount += decodedCount; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | buffer.resize(bufCount); //set correct length of file | 360 | buffer.resize(bufCount); //set correct length of file |
361 | f.writeBlock(buffer); | 361 | f.writeBlock(buffer); |
362 | } else { | 362 | } else { |
363 | QTextStream t(&f); | 363 | QTextStream t(&f); |
364 | t << ePtr->body; | 364 | t << ePtr->body; |
365 | } | 365 | } |
366 | return TRUE; | 366 | return TRUE; |
367 | } | 367 | } |
368 | 368 | ||
369 | int EmailHandler::parse64base(char *src, char *bufOut) { | 369 | int EmailHandler::parse64base(char *src, char *bufOut) { |
370 | 370 | ||
371 | char c, z; | 371 | char c, z; |
372 | char li[4]; | 372 | char li[4]; |
373 | int processed; | 373 | int processed; |
374 | 374 | ||
375 | //conversion table withouth table... | 375 | //conversion table withouth table... |
376 | for (int x = 0; x < 4; x++) { | 376 | for (int x = 0; x < 4; x++) { |
377 | c = src[x]; | 377 | c = src[x]; |
378 | 378 | ||
379 | if ( (int) c >= 'A' && (int) c <= 'Z') | 379 | if ( (int) c >= 'A' && (int) c <= 'Z') |
380 | li[x] = (int) c - (int) 'A'; | 380 | li[x] = (int) c - (int) 'A'; |
381 | if ( (int) c >= 'a' && (int) c <= 'z') | 381 | if ( (int) c >= 'a' && (int) c <= 'z') |
382 | li[x] = (int) c - (int) 'a' + 26; | 382 | li[x] = (int) c - (int) 'a' + 26; |
383 | if ( (int) c >= '0' && (int) c <= '9') | 383 | if ( (int) c >= '0' && (int) c <= '9') |
384 | li[x] = (int) c - (int) '0' + 52; | 384 | li[x] = (int) c - (int) '0' + 52; |
385 | if (c == '+') | 385 | if (c == '+') |
386 | li[x] = 62; | 386 | li[x] = 62; |
387 | if (c == '/') | 387 | if (c == '/') |
388 | li[x] = 63; | 388 | li[x] = 63; |
389 | } | 389 | } |
390 | 390 | ||
391 | processed = 1; | 391 | processed = 1; |
392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
393 | bufOut[0] <<= 2; | 393 | bufOut[0] <<= 2; |
394 | z = li[1] >> 4; | 394 | z = li[1] >> 4; |
395 | bufOut[0] = bufOut[0] | z; //first byte retrived | 395 | bufOut[0] = bufOut[0] | z; //first byte retrived |
396 | 396 | ||
397 | if (src[2] != '=') { | 397 | if (src[2] != '=') { |
398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
399 | bufOut[1] <<= 4; | 399 | bufOut[1] <<= 4; |
400 | z = li[2] >> 2; | 400 | z = li[2] >> 2; |
401 | bufOut[1] = bufOut[1] | z; //second byte retrived | 401 | bufOut[1] = bufOut[1] | z; //second byte retrived |
402 | processed++; | 402 | processed++; |
403 | 403 | ||
404 | if (src[3] != '=') { | 404 | if (src[3] != '=') { |
405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
406 | bufOut[2] <<= 6; | 406 | bufOut[2] <<= 6; |
407 | z = li[3]; | 407 | z = li[3]; |
408 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 408 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
409 | processed++; | 409 | processed++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | return processed; | 412 | return processed; |
413 | } | 413 | } |
414 | 414 | ||
415 | int EmailHandler::encodeMime(Email *mail) { | 415 | int EmailHandler::encodeMime(Email *mail) { |
416 | QString fileName, fileType, contentType, newBody, boundary; | 416 | QString fileName, fileType, contentType, newBody, boundary; |
417 | Enclosure *ePtr; | 417 | Enclosure *ePtr; |
418 | 418 | ||
419 | QString userName = mailAccount.name; | 419 | QString userName = mailAccount.name; |
420 | userName += " <" + mailAccount.emailAddress + ">"; | 420 | userName += " <" + mailAccount.emailAddress + ">"; |
421 | 421 | ||
422 | //add standard headers | 422 | //add standard headers |
423 | newBody = "From: " + userName + "\r\nTo: "; | 423 | newBody = "From: " + userName + "\r\nTo: "; |
424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
425 | newBody += *it + " "; | 425 | newBody += *it + " "; |
426 | } | 426 | } |
427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
428 | 428 | ||
429 | if (mail->files.count() == 0) { //just a simple mail | 429 | if (mail->files.count() == 0) { //just a simple mail |
430 | newBody += "\r\n" + mail->body; | 430 | newBody += "\r\n" + mail->body; |
431 | mail->rawMail = newBody; | 431 | mail->rawMail = newBody; |
432 | return 0; | 432 | return 0; |
433 | } | 433 | } |
434 | 434 | ||
435 | //Build mime encoded mail | 435 | //Build mime encoded mail |
436 | boundary = "-----4345=next_bound=0495----"; | 436 | boundary = "-----4345=next_bound=0495----"; |
437 | 437 | ||
438 | newBody += "Mime-Version: 1.0\r\n"; | 438 | newBody += "Mime-Version: 1.0\r\n"; |
439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
440 | boundary + "\"\r\n\r\n"; | 440 | boundary + "\"\r\n\r\n"; |
441 | 441 | ||
442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
444 | newBody += mail->body; | 444 | newBody += mail->body; |
445 | 445 | ||
446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
447 | fileName = ePtr->originalName; | 447 | fileName = ePtr->originalName; |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index a086dfc..2144899 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -1,447 +1,447 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | smtpClient = new SmtpClient(); | 42 | smtpClient = new SmtpClient(); |
43 | popClient = new PopClient(); | 43 | popClient = new PopClient(); |
44 | 44 | ||
45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, | 45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, |
46 | SIGNAL(smtpError(int)) ); | 46 | SIGNAL(smtpError(int)) ); |
47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
49 | SIGNAL(updateSmtpStatus(const QString &)) ); | 49 | SIGNAL(updateSmtpStatus(const QString &)) ); |
50 | 50 | ||
51 | connect(popClient, SIGNAL(errorOccurred(int)), this, | 51 | connect(popClient, SIGNAL(errorOccurred(int)), this, |
52 | SIGNAL(popError(int)) ); | 52 | SIGNAL(popError(int)) ); |
53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
56 | SIGNAL(updatePopStatus(const QString &)) ); | 56 | SIGNAL(updatePopStatus(const QString &)) ); |
57 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 57 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
58 | SIGNAL(mailTransfered(int)) ); | 58 | SIGNAL(mailTransfered(int)) ); |
59 | 59 | ||
60 | 60 | ||
61 | //relaying size information | 61 | //relaying size information |
62 | connect(popClient, SIGNAL(currentMailSize(int)), | 62 | connect(popClient, SIGNAL(currentMailSize(int)), |
63 | this, SIGNAL(currentMailSize(int)) ); | 63 | this, SIGNAL(currentMailSize(int)) ); |
64 | connect(popClient, SIGNAL(downloadedSize(int)), | 64 | connect(popClient, SIGNAL(downloadedSize(int)), |
65 | this, SIGNAL(downloadedSize(int)) ); | 65 | this, SIGNAL(downloadedSize(int)) ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void EmailHandler::sendMail(QList<Email> *mailList) | 68 | void EmailHandler::sendMail(QList<Email> *mailList) |
69 | { | 69 | { |
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | if (mailAccount.synchronize) { |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 115 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
116 | } else { | 116 | } else { |
117 | popClient->removeSynchronize(); | 117 | popClient->removeSynchronize(); |
118 | } | 118 | } |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, 2000); //less than 2000, download all | 121 | popClient->headersOnly(headers, 2000); //less than 2000, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 122 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 123 | } |
124 | 124 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 125 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 126 | { |
127 | if (mailList->count() == 0) { //should not occur though | 127 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 128 | emit mailTransfered(0); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | headers = FALSE; | 132 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 133 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 134 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 135 | popClient->setSelectedMails(mailList); |
136 | } | 136 | } |
137 | 137 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
139 | { | 139 | { |
140 | Email mail; | 140 | Email mail; |
141 | 141 | ||
142 | mail.rawMail = message; | 142 | mail.rawMail = message; |
143 | mail.serverId = id; | 143 | mail.serverId = id; |
144 | mail.size = size; | 144 | mail.size = size; |
145 | mail.downloaded = complete; | 145 | mail.downloaded = complete; |
146 | 146 | ||
147 | emit mailArrived(mail, FALSE); | 147 | emit mailArrived(mail, FALSE); |
148 | } | 148 | } |
149 | 149 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 151 | { |
152 | QString temp, boundary; | 152 | QString temp, boundary; |
153 | int pos; | 153 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 154 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | qWarning(in.right(temp.length())); | 166 | qWarning(in.right(temp.length())); |
167 | qWarning(" . added at end of email as separator"); | 167 | qWarning(" . added at end of email as separator"); |
168 | mail->rawMail += temp; | 168 | mail->rawMail += temp; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
173 | pos = in.find(delimiter, 0, FALSE); | 173 | pos = in.find(delimiter, 0, FALSE); |
174 | header = in.left(pos); | 174 | header = in.left(pos); |
175 | body = in.right(in.length() - pos - delimiter.length()); | 175 | body = in.right(in.length() - pos - delimiter.length()); |
176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
177 | body.truncate(body.length()-2); | 177 | body.truncate(body.length()-2); |
178 | 178 | ||
179 | TextParser p(header, lineShift); | 179 | TextParser p(header, lineShift); |
180 | 180 | ||
181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
182 | pos++; | 182 | pos++; |
183 | if (p.separatorAt(pos) == ' ') { | 183 | if (p.separatorAt(pos) == ' ') { |
184 | mail->from = p.getString(&pos, '<'); | 184 | mail->from = p.getString(&pos, '<', false); |
185 | mail->from = mail->from.stripWhiteSpace(); | 185 | mail->from = mail->from.stripWhiteSpace(); |
186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
187 | mail->from = mail->from.left(mail->from.length() - 1); | 187 | mail->from = mail->from.left(mail->from.length() - 1); |
188 | mail->from = mail->from.right(mail->from.length() - 1); | 188 | mail->from = mail->from.right(mail->from.length() - 1); |
189 | } | 189 | } |
190 | pos++; | 190 | pos++; |
191 | mail->fromMail = p.getString(&pos, '>'); | 191 | mail->fromMail = p.getString(&pos, '>', false); |
192 | } else { | 192 | } else { |
193 | if ((p.separatorAt(pos) == '<') | 193 | if ((p.separatorAt(pos) == '<') |
194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
195 | pos++; | 195 | pos++; |
196 | pos++; | 196 | pos++; |
197 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 197 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
199 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 199 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
200 | mail->from=mail->fromMail; | 200 | mail->from=mail->fromMail; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 203 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
204 | pos++; | 204 | pos++; |
205 | mail->subject = p.getString(&pos, 'z', TRUE); | 205 | mail->subject = p.getString(&pos, 'z', TRUE); |
206 | } | 206 | } |
207 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 207 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
208 | pos++; | 208 | pos++; |
209 | mail->date = p.getString(&pos, 'z', true); | 209 | mail->date = p.getString(&pos, 'z', true); |
210 | } | 210 | } |
211 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) { | 211 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) { |
212 | pos++; | 212 | pos++; |
213 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 213 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
214 | } | 214 | } |
215 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 215 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
216 | pos++; | 216 | pos++; |
217 | if ( (p.wordAt(pos).upper() == "ID") && | 217 | if ( (p.wordAt(pos).upper() == "ID") && |
218 | (p.separatorAt(pos) == ':') ) { | 218 | (p.separatorAt(pos) == ':') ) { |
219 | 219 | ||
220 | id = p.getString(&pos, 'z', TRUE); | 220 | id = p.getString(&pos, 'z', TRUE); |
221 | mail->id = id; | 221 | mail->id = id; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | pos = 0; | 225 | pos = 0; |
226 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 226 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
227 | pos++; | 227 | pos++; |
228 | if ( (p.wordAt(pos).upper() == "VERSION") && | 228 | if ( (p.wordAt(pos).upper() == "VERSION") && |
229 | (p.separatorAt(pos) == ':') ) { | 229 | (p.separatorAt(pos) == ':') ) { |
230 | pos++; | 230 | pos++; |
231 | if (p.getString(&pos, 'z', true) == "1.0") { | 231 | if (p.getString(&pos, 'z', true) == "1.0") { |
232 | mail->mimeType = 1; | 232 | mail->mimeType = 1; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | if (mail->mimeType == 1) { | 237 | if (mail->mimeType == 1) { |
238 | boundary = ""; | 238 | boundary = ""; |
239 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 239 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
240 | pos++; | 240 | pos++; |
241 | boundary = p.getString(&pos, 'z', true); | 241 | boundary = p.getString(&pos, 'z', true); |
242 | if (boundary[0] == '"') { | 242 | if (boundary[0] == '"') { |
243 | boundary = boundary.left(boundary.length() - 1); //strip " | 243 | boundary = boundary.left(boundary.length() - 1); //strip " |
244 | boundary = boundary.right(boundary.length() - 1); //strip " | 244 | boundary = boundary.right(boundary.length() - 1); //strip " |
245 | } | 245 | } |
246 | boundary = "--" + boundary; //create boundary field | 246 | boundary = "--" + boundary; //create boundary field |
247 | } | 247 | } |
248 | 248 | ||
249 | if (boundary == "") { //fooled by Mime-Version | 249 | if (boundary == "") { //fooled by Mime-Version |
250 | mail->body = body; | 250 | mail->body = body; |
251 | mail->bodyPlain = body; | 251 | mail->bodyPlain = body; |
252 | return mail; | 252 | return mail; |
253 | } | 253 | } |
254 | 254 | ||
255 | while (body.length() > 0) { | 255 | while (body.length() > 0) { |
256 | pos = body.find(boundary, 0, FALSE); | 256 | pos = body.find(boundary, 0, FALSE); |
257 | pos = body.find(delimiter, pos, FALSE); | 257 | pos = body.find(delimiter, pos, FALSE); |
258 | mimeHeader = body.left(pos); | 258 | mimeHeader = body.left(pos); |
259 | mimeBody = body.right(body.length() - pos - delimiter.length()); | 259 | mimeBody = body.right(body.length() - pos - delimiter.length()); |
260 | TextParser bp(mimeHeader, lineShift); | 260 | TextParser bp(mimeHeader, lineShift); |
261 | 261 | ||
262 | contentType = ""; | 262 | contentType = ""; |
263 | contentAttribute = ""; | 263 | contentAttribute = ""; |
264 | fileName = ""; | 264 | fileName = ""; |
265 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { | 265 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { |
266 | pos++; | 266 | pos++; |
267 | if ( (bp.wordAt(pos).upper() == "TYPE") && | 267 | if ( (bp.wordAt(pos).upper() == "TYPE") && |
268 | (bp.separatorAt(pos) == ':') ) { | 268 | (bp.separatorAt(pos) == ':') ) { |
269 | contentType = bp.nextWord().upper(); | 269 | contentType = bp.nextWord().upper(); |
270 | if (bp.nextSeparator() == '/') | 270 | if (bp.nextSeparator() == '/') |
271 | contentAttribute = bp.nextWord().upper(); | 271 | contentAttribute = bp.nextWord().upper(); |
272 | content = contentType + "/" + contentAttribute; | 272 | content = contentType + "/" + contentAttribute; |
273 | } | 273 | } |
274 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { | 274 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { |
275 | pos++; | 275 | pos++; |
276 | encoding = bp.getString(&pos, 'z', TRUE); | 276 | encoding = bp.getString(&pos, 'z', TRUE); |
277 | } | 277 | } |
278 | 278 | ||
279 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { | 279 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { |
280 | pos++; | 280 | pos++; |
281 | fileName = bp.getString(&pos, 'z', TRUE); | 281 | fileName = bp.getString(&pos, 'z', TRUE); |
282 | fileName = fileName.right(fileName.length() - 1); | 282 | fileName = fileName.right(fileName.length() - 1); |
283 | fileName = fileName.left(fileName.length() - 1); | 283 | fileName = fileName.left(fileName.length() - 1); |
284 | } | 284 | } |
285 | 285 | ||
286 | } | 286 | } |
287 | pos = mimeBody.find(boundary, 0, FALSE); | 287 | pos = mimeBody.find(boundary, 0, FALSE); |
288 | if (pos == -1) //should not occur, malformed mail | 288 | if (pos == -1) //should not occur, malformed mail |
289 | pos = mimeBody.length(); | 289 | pos = mimeBody.length(); |
290 | body = mimeBody.right(mimeBody.length() - pos); | 290 | body = mimeBody.right(mimeBody.length() - pos); |
291 | mimeBody = mimeBody.left(pos); | 291 | mimeBody = mimeBody.left(pos); |
292 | 292 | ||
293 | if (fileName != "") { //attatchments of some type, audio, image etc. | 293 | if (fileName != "") { //attatchments of some type, audio, image etc. |
294 | 294 | ||
295 | Enclosure e; | 295 | Enclosure e; |
296 | e.id = enclosureId; | 296 | e.id = enclosureId; |
297 | e.originalName = fileName; | 297 | e.originalName = fileName; |
298 | e.contentType = contentType; | 298 | e.contentType = contentType; |
299 | e.contentAttribute = contentAttribute; | 299 | e.contentAttribute = contentAttribute; |
300 | e.encoding = encoding; | 300 | e.encoding = encoding; |
301 | e.body = mimeBody; | 301 | e.body = mimeBody; |
302 | e.saved = FALSE; | 302 | e.saved = FALSE; |
303 | mail->addEnclosure(&e); | 303 | mail->addEnclosure(&e); |
304 | enclosureId++; | 304 | enclosureId++; |
305 | 305 | ||
306 | } else if (contentType == "TEXT") { | 306 | } else if (contentType == "TEXT") { |
307 | if (contentAttribute == "PLAIN") { | 307 | if (contentAttribute == "PLAIN") { |
308 | mail->body = mimeBody; | 308 | mail->body = mimeBody; |
309 | mail->bodyPlain = mimeBody; | 309 | mail->bodyPlain = mimeBody; |
310 | } | 310 | } |
311 | if (contentAttribute == "HTML") { | 311 | if (contentAttribute == "HTML") { |
312 | mail->body = mimeBody; | 312 | mail->body = mimeBody; |
313 | } | 313 | } |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } else { | 316 | } else { |
317 | mail->bodyPlain = body; | 317 | mail->bodyPlain = body; |
318 | mail->body = body; | 318 | mail->body = body; |
319 | } | 319 | } |
320 | return TRUE; | 320 | return TRUE; |
321 | } | 321 | } |
322 | 322 | ||
323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
324 | { | 324 | { |
325 | QFile f(ePtr->path + ePtr->name); | 325 | QFile f(ePtr->path + ePtr->name); |
326 | char src[4]; | 326 | char src[4]; |
327 | char *destPtr; | 327 | char *destPtr; |
328 | QByteArray buffer; | 328 | QByteArray buffer; |
329 | uint bufCount, pos, decodedCount, size, x; | 329 | uint bufCount, pos, decodedCount, size, x; |
330 | 330 | ||
331 | if (! f.open(IO_WriteOnly) ) { | 331 | if (! f.open(IO_WriteOnly) ) { |
332 | qWarning("could not save: " + ePtr->path + ePtr->name); | 332 | qWarning("could not save: " + ePtr->path + ePtr->name); |
333 | return FALSE; | 333 | return FALSE; |
334 | } | 334 | } |
335 | 335 | ||
336 | if (ePtr->encoding.upper() == "BASE64") { | 336 | if (ePtr->encoding.upper() == "BASE64") { |
337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
338 | buffer.resize(size); | 338 | buffer.resize(size); |
339 | bufCount = 0; | 339 | bufCount = 0; |
340 | pos = 0; | 340 | pos = 0; |
341 | destPtr = buffer.data(); | 341 | destPtr = buffer.data(); |
342 | 342 | ||
343 | while (pos < ePtr->body.length()) { | 343 | while (pos < ePtr->body.length()) { |
344 | decodedCount = 4; | 344 | decodedCount = 4; |
345 | x = 0; | 345 | x = 0; |
346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
347 | src[x] = ePtr->body[pos].latin1(); | 347 | src[x] = ePtr->body[pos].latin1(); |
348 | pos++; | 348 | pos++; |
349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
350 | x--; | 350 | x--; |
351 | x++; | 351 | x++; |
352 | } | 352 | } |
353 | if (x > 1) { | 353 | if (x > 1) { |
354 | decodedCount = parse64base(src, destPtr); | 354 | decodedCount = parse64base(src, destPtr); |
355 | destPtr += decodedCount; | 355 | destPtr += decodedCount; |
356 | bufCount += decodedCount; | 356 | bufCount += decodedCount; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | buffer.resize(bufCount); //set correct length of file | 360 | buffer.resize(bufCount); //set correct length of file |
361 | f.writeBlock(buffer); | 361 | f.writeBlock(buffer); |
362 | } else { | 362 | } else { |
363 | QTextStream t(&f); | 363 | QTextStream t(&f); |
364 | t << ePtr->body; | 364 | t << ePtr->body; |
365 | } | 365 | } |
366 | return TRUE; | 366 | return TRUE; |
367 | } | 367 | } |
368 | 368 | ||
369 | int EmailHandler::parse64base(char *src, char *bufOut) { | 369 | int EmailHandler::parse64base(char *src, char *bufOut) { |
370 | 370 | ||
371 | char c, z; | 371 | char c, z; |
372 | char li[4]; | 372 | char li[4]; |
373 | int processed; | 373 | int processed; |
374 | 374 | ||
375 | //conversion table withouth table... | 375 | //conversion table withouth table... |
376 | for (int x = 0; x < 4; x++) { | 376 | for (int x = 0; x < 4; x++) { |
377 | c = src[x]; | 377 | c = src[x]; |
378 | 378 | ||
379 | if ( (int) c >= 'A' && (int) c <= 'Z') | 379 | if ( (int) c >= 'A' && (int) c <= 'Z') |
380 | li[x] = (int) c - (int) 'A'; | 380 | li[x] = (int) c - (int) 'A'; |
381 | if ( (int) c >= 'a' && (int) c <= 'z') | 381 | if ( (int) c >= 'a' && (int) c <= 'z') |
382 | li[x] = (int) c - (int) 'a' + 26; | 382 | li[x] = (int) c - (int) 'a' + 26; |
383 | if ( (int) c >= '0' && (int) c <= '9') | 383 | if ( (int) c >= '0' && (int) c <= '9') |
384 | li[x] = (int) c - (int) '0' + 52; | 384 | li[x] = (int) c - (int) '0' + 52; |
385 | if (c == '+') | 385 | if (c == '+') |
386 | li[x] = 62; | 386 | li[x] = 62; |
387 | if (c == '/') | 387 | if (c == '/') |
388 | li[x] = 63; | 388 | li[x] = 63; |
389 | } | 389 | } |
390 | 390 | ||
391 | processed = 1; | 391 | processed = 1; |
392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
393 | bufOut[0] <<= 2; | 393 | bufOut[0] <<= 2; |
394 | z = li[1] >> 4; | 394 | z = li[1] >> 4; |
395 | bufOut[0] = bufOut[0] | z; //first byte retrived | 395 | bufOut[0] = bufOut[0] | z; //first byte retrived |
396 | 396 | ||
397 | if (src[2] != '=') { | 397 | if (src[2] != '=') { |
398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
399 | bufOut[1] <<= 4; | 399 | bufOut[1] <<= 4; |
400 | z = li[2] >> 2; | 400 | z = li[2] >> 2; |
401 | bufOut[1] = bufOut[1] | z; //second byte retrived | 401 | bufOut[1] = bufOut[1] | z; //second byte retrived |
402 | processed++; | 402 | processed++; |
403 | 403 | ||
404 | if (src[3] != '=') { | 404 | if (src[3] != '=') { |
405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
406 | bufOut[2] <<= 6; | 406 | bufOut[2] <<= 6; |
407 | z = li[3]; | 407 | z = li[3]; |
408 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 408 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
409 | processed++; | 409 | processed++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | return processed; | 412 | return processed; |
413 | } | 413 | } |
414 | 414 | ||
415 | int EmailHandler::encodeMime(Email *mail) { | 415 | int EmailHandler::encodeMime(Email *mail) { |
416 | QString fileName, fileType, contentType, newBody, boundary; | 416 | QString fileName, fileType, contentType, newBody, boundary; |
417 | Enclosure *ePtr; | 417 | Enclosure *ePtr; |
418 | 418 | ||
419 | QString userName = mailAccount.name; | 419 | QString userName = mailAccount.name; |
420 | userName += " <" + mailAccount.emailAddress + ">"; | 420 | userName += " <" + mailAccount.emailAddress + ">"; |
421 | 421 | ||
422 | //add standard headers | 422 | //add standard headers |
423 | newBody = "From: " + userName + "\r\nTo: "; | 423 | newBody = "From: " + userName + "\r\nTo: "; |
424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
425 | newBody += *it + " "; | 425 | newBody += *it + " "; |
426 | } | 426 | } |
427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
428 | 428 | ||
429 | if (mail->files.count() == 0) { //just a simple mail | 429 | if (mail->files.count() == 0) { //just a simple mail |
430 | newBody += "\r\n" + mail->body; | 430 | newBody += "\r\n" + mail->body; |
431 | mail->rawMail = newBody; | 431 | mail->rawMail = newBody; |
432 | return 0; | 432 | return 0; |
433 | } | 433 | } |
434 | 434 | ||
435 | //Build mime encoded mail | 435 | //Build mime encoded mail |
436 | boundary = "-----4345=next_bound=0495----"; | 436 | boundary = "-----4345=next_bound=0495----"; |
437 | 437 | ||
438 | newBody += "Mime-Version: 1.0\r\n"; | 438 | newBody += "Mime-Version: 1.0\r\n"; |
439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
440 | boundary + "\"\r\n\r\n"; | 440 | boundary + "\"\r\n\r\n"; |
441 | 441 | ||
442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
444 | newBody += mail->body; | 444 | newBody += mail->body; |
445 | 445 | ||
446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
447 | fileName = ePtr->originalName; | 447 | fileName = ePtr->originalName; |