-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 15 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 15 |
4 files changed, 22 insertions, 12 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 749a4e9..90664bb 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -176,193 +176,193 @@ void EmailClient::init() | |||
176 | // grid_2->setMargin( 11 ); | 176 | // grid_2->setMargin( 11 ); |
177 | 177 | ||
178 | inboxView = new QListView( widget, "inboxView" ); | 178 | inboxView = new QListView( widget, "inboxView" ); |
179 | inboxView->addColumn( tr( "From" ) ); | 179 | inboxView->addColumn( tr( "From" ) ); |
180 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
181 | inboxView->addColumn( tr( "Date" ) ); | 181 | inboxView->addColumn( tr( "Date" ) ); |
182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
183 | inboxView->setAllColumnsShowFocus(TRUE); | 183 | inboxView->setAllColumnsShowFocus(TRUE); |
184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" | 184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" |
185 | "It keeps the fetched mail which can be \n" | 185 | "It keeps the fetched mail which can be \n" |
186 | "viewed by double clicking the entry.\n" | 186 | "viewed by double clicking the entry.\n" |
187 | "blue attachment icon shows whether this \n" | 187 | "blue attachment icon shows whether this \n" |
188 | "mailhas attachments.\n")); | 188 | "mailhas attachments.\n")); |
189 | 189 | ||
190 | grid_2->addWidget( inboxView, 2, 0 ); | 190 | grid_2->addWidget( inboxView, 2, 0 ); |
191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
192 | 192 | ||
193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
194 | grid_3 = new QGridLayout( widget_2 ); | 194 | grid_3 = new QGridLayout( widget_2 ); |
195 | // grid_3->setSpacing(6); | 195 | // grid_3->setSpacing(6); |
196 | // grid_3->setMargin( 11 ); | 196 | // grid_3->setMargin( 11 ); |
197 | 197 | ||
198 | outboxView = new QListView( widget_2, "outboxView" ); | 198 | outboxView = new QListView( widget_2, "outboxView" ); |
199 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
200 | outboxView->addColumn( tr( "Subject" ) ); | 200 | outboxView->addColumn( tr( "Subject" ) ); |
201 | outboxView->setAllColumnsShowFocus(TRUE); | 201 | outboxView->setAllColumnsShowFocus(TRUE); |
202 | 202 | ||
203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" | 203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" |
204 | "It keeps the queued mails to send which can be \n" | 204 | "It keeps the queued mails to send which can be \n" |
205 | "reviewed by double clicking the entry.")); | 205 | "reviewed by double clicking the entry.")); |
206 | grid_3->addWidget( outboxView, 0, 0 ); | 206 | grid_3->addWidget( outboxView, 0, 0 ); |
207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
208 | 208 | ||
209 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void EmailClient::initStatusBar(QWidget* parent) | 213 | void EmailClient::initStatusBar(QWidget* parent) |
214 | { | 214 | { |
215 | statusBar = new QStatusBar(parent); | 215 | statusBar = new QStatusBar(parent); |
216 | statusBar->setSizeGripEnabled(FALSE); | 216 | statusBar->setSizeGripEnabled(FALSE); |
217 | 217 | ||
218 | status1Label = new QLabel( tr("Idle"), statusBar); | 218 | status1Label = new QLabel( tr("Idle"), statusBar); |
219 | status2Label = new QLabel("", statusBar); | 219 | status2Label = new QLabel("", statusBar); |
220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
221 | status2Label, SLOT(setText(const QString &)) ); | 221 | status2Label, SLOT(setText(const QString &)) ); |
222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
223 | status2Label, SLOT(setText(const QString &)) ); | 223 | status2Label, SLOT(setText(const QString &)) ); |
224 | 224 | ||
225 | progressBar = new QProgressBar(statusBar); | 225 | progressBar = new QProgressBar(statusBar); |
226 | 226 | ||
227 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 227 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
228 | this, SLOT(setTotalSize(int)) ); | 228 | this, SLOT(setTotalSize(int)) ); |
229 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 229 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
230 | this, SLOT(setMailSize(int)) ); | 230 | this, SLOT(setMailSize(int)) ); |
231 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 231 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
232 | this, SLOT(setDownloadedSize(int)) ); | 232 | this, SLOT(setDownloadedSize(int)) ); |
233 | 233 | ||
234 | statusBar->addWidget(status1Label); | 234 | statusBar->addWidget(status1Label); |
235 | statusBar->addWidget(progressBar); | 235 | statusBar->addWidget(progressBar); |
236 | statusBar->addWidget(status2Label); | 236 | statusBar->addWidget(status2Label); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void EmailClient::compose() | 240 | void EmailClient::compose() |
241 | { | 241 | { |
242 | emit composeRequested(); | 242 | emit composeRequested(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EmailClient::cancel() | 245 | void EmailClient::cancel() |
246 | { | 246 | { |
247 | emailHandler->cancel(); | 247 | emailHandler->cancel(); |
248 | } | 248 | } |
249 | 249 | ||
250 | AddressList* EmailClient::getAdrListRef() | 250 | AddressList* EmailClient::getAdrListRef() |
251 | { | 251 | { |
252 | return addressList; | 252 | return addressList; |
253 | } | 253 | } |
254 | 254 | ||
255 | //this needs to be rewritten to syncronize with outboxView | 255 | //this needs to be rewritten to syncronize with outboxView |
256 | void EmailClient::enqueMail(const Email &mail) | 256 | void EmailClient::enqueMail(const Email &mail) |
257 | { | 257 | { |
258 | if (accountList.count() == 0) { | 258 | if (accountList.count() == 0) { |
259 | QMessageBox::warning(qApp->activeWindow(), | 259 | QMessageBox::warning(qApp->activeWindow(), |
260 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 260 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (accountList.count() > 0) { | 264 | if (accountList.count() > 0) { |
265 | currentAccount = accountList.first(); | 265 | currentAccount = accountList.first(); |
266 | qWarning("using account " + currentAccount->name); | 266 | qWarning("using account " + currentAccount->name); |
267 | } | 267 | } |
268 | 268 | ||
269 | Email addMail = mail; | 269 | Email addMail = mail; |
270 | addMail.from = currentAccount->name; | 270 | addMail.from = currentAccount->name; |
271 | addMail.fromMail = currentAccount->emailAddress; | 271 | addMail.fromMail = currentAccount->emailAddress; |
272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 272 | addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); |
273 | item = new EmailListItem(outboxView, addMail, false); | 273 | item = new EmailListItem(outboxView, addMail, false); |
274 | 274 | ||
275 | mailboxView->setCurrentTab(1); | 275 | mailboxView->setCurrentTab(1); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | void EmailClient::sendQuedMail() | 279 | void EmailClient::sendQuedMail() |
280 | { | 280 | { |
281 | int count = 0; | 281 | int count = 0; |
282 | 282 | ||
283 | if (accountList.count() == 0) { | 283 | if (accountList.count() == 0) { |
284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //traverse listview, find messages to send | 287 | //traverse listview, find messages to send |
288 | if (! sending) { | 288 | if (! sending) { |
289 | item = (EmailListItem *) outboxView->firstChild(); | 289 | item = (EmailListItem *) outboxView->firstChild(); |
290 | if (item != NULL) { | 290 | if (item != NULL) { |
291 | while (item != NULL) { | 291 | while (item != NULL) { |
292 | quedMessages.append(item->getMail()); | 292 | quedMessages.append(item->getMail()); |
293 | item = (EmailListItem *) item->nextSibling(); | 293 | item = (EmailListItem *) item->nextSibling(); |
294 | count++; | 294 | count++; |
295 | } | 295 | } |
296 | setMailAccount(); | 296 | setMailAccount(); |
297 | emailHandler->sendMail(&quedMessages); | 297 | emailHandler->sendMail(&quedMessages); |
298 | sending = TRUE; | 298 | sending = TRUE; |
299 | sendMailButton->setEnabled(FALSE); | 299 | sendMailButton->setEnabled(FALSE); |
300 | cancelButton->setEnabled(TRUE); | 300 | cancelButton->setEnabled(TRUE); |
301 | } else { | 301 | } else { |
302 | qWarning("sendQuedMail(): no messages to send"); | 302 | qWarning("sendQuedMail(): no messages to send"); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::setMailAccount() | 307 | void EmailClient::setMailAccount() |
308 | { | 308 | { |
309 | emailHandler->setAccount(*currentAccount); | 309 | emailHandler->setAccount(*currentAccount); |
310 | } | 310 | } |
311 | 311 | ||
312 | void EmailClient::mailSent() | 312 | void EmailClient::mailSent() |
313 | { | 313 | { |
314 | sending = FALSE; | 314 | sending = FALSE; |
315 | sendMailButton->setEnabled(TRUE); | 315 | sendMailButton->setEnabled(TRUE); |
316 | 316 | ||
317 | quedMessages.clear(); | 317 | quedMessages.clear(); |
318 | outboxView->clear(); //should be moved to an sentBox | 318 | outboxView->clear(); //should be moved to an sentBox |
319 | } | 319 | } |
320 | 320 | ||
321 | void EmailClient::getNewMail() { | 321 | void EmailClient::getNewMail() { |
322 | 322 | ||
323 | if (accountList.count() == 0) { | 323 | if (accountList.count() == 0) { |
324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
325 | "You must create an account", "OK\n"); | 325 | "You must create an account", "OK\n"); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | 328 | ||
329 | setMailAccount(); | 329 | setMailAccount(); |
330 | 330 | ||
331 | receiving = TRUE; | 331 | receiving = TRUE; |
332 | previewingMail = TRUE; | 332 | previewingMail = TRUE; |
333 | getMailButton->setEnabled(FALSE); | 333 | getMailButton->setEnabled(FALSE); |
334 | cancelButton->setEnabled(TRUE); | 334 | cancelButton->setEnabled(TRUE); |
335 | selectAccountMenu->setEnabled(FALSE); | 335 | selectAccountMenu->setEnabled(FALSE); |
336 | 336 | ||
337 | status1Label->setText(currentAccount->accountName + " headers"); | 337 | status1Label->setText(currentAccount->accountName + " headers"); |
338 | progressBar->reset(); | 338 | progressBar->reset(); |
339 | 339 | ||
340 | //get any previous mails not downloaded and add to queue | 340 | //get any previous mails not downloaded and add to queue |
341 | /*mailDownloadList.clear(); | 341 | /*mailDownloadList.clear(); |
342 | Email *mailPtr; | 342 | Email *mailPtr; |
343 | item = (EmailListItem *) inboxView->firstChild(); | 343 | item = (EmailListItem *) inboxView->firstChild(); |
344 | while (item != NULL) { | 344 | while (item != NULL) { |
345 | mailPtr = item->getMail(); | 345 | mailPtr = item->getMail(); |
346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
348 | } | 348 | } |
349 | item = (EmailListItem *) item->nextSibling(); | 349 | item = (EmailListItem *) item->nextSibling(); |
350 | }*/ | 350 | }*/ |
351 | 351 | ||
352 | emailHandler->getMailHeaders(); | 352 | emailHandler->getMailHeaders(); |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void EmailClient::getAllNewMail() | 356 | void EmailClient::getAllNewMail() |
357 | { | 357 | { |
358 | allAccounts = TRUE; | 358 | allAccounts = TRUE; |
359 | currentAccount = accountList.first(); | 359 | currentAccount = accountList.first(); |
360 | getNewMail(); | 360 | getNewMail(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
364 | { | 364 | { |
365 | Enclosure *ePtr; | 365 | Enclosure *ePtr; |
366 | Email newMail; | 366 | Email newMail; |
367 | int thisMailId; | 367 | int thisMailId; |
368 | emailHandler->parse( mail.rawMail, lineShift, &newMail); | 368 | emailHandler->parse( mail.rawMail, lineShift, &newMail); |
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 5b8bda1..06e978d 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -1,171 +1,173 @@ | |||
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 | qDebug("EMailHandler::EmailHandler"); | 42 | qDebug("EMailHandler::EmailHandler"); |
43 | 43 | ||
44 | smtpClient = new SmtpClient(); | 44 | smtpClient = new SmtpClient(); |
45 | popClient = new PopClient(); | 45 | popClient = new PopClient(); |
46 | 46 | ||
47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, | 47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, |
48 | SIGNAL(smtpError(int, const QString &)) ); | 48 | SIGNAL(smtpError(int, const QString &)) ); |
49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
51 | SIGNAL(updateSmtpStatus(const QString &)) ); | 51 | SIGNAL(updateSmtpStatus(const QString &)) ); |
52 | 52 | ||
53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, | 53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, |
54 | SIGNAL(popError(int, const QString &)) ); | 54 | SIGNAL(popError(int, const QString &)) ); |
55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
58 | SIGNAL(updatePopStatus(const QString &)) ); | 58 | SIGNAL(updatePopStatus(const QString &)) ); |
59 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 59 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
60 | SIGNAL(mailTransfered(int)) ); | 60 | SIGNAL(mailTransfered(int)) ); |
61 | 61 | ||
62 | 62 | ||
63 | //relaying size information | 63 | //relaying size information |
64 | connect(popClient, SIGNAL(currentMailSize(int)), | 64 | connect(popClient, SIGNAL(currentMailSize(int)), |
65 | this, SIGNAL(currentMailSize(int)) ); | 65 | this, SIGNAL(currentMailSize(int)) ); |
66 | connect(popClient, SIGNAL(downloadedSize(int)), | 66 | connect(popClient, SIGNAL(downloadedSize(int)), |
67 | this, SIGNAL(downloadedSize(int)) ); | 67 | this, SIGNAL(downloadedSize(int)) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void EmailHandler::sendMail(QList<Email> *mailList) | 70 | void EmailHandler::sendMail(QList<Email> *mailList) |
71 | { | 71 | { |
72 | Email *currentMail; | 72 | Email *currentMail; |
73 | QString temp; | 73 | QString temp; |
74 | QString userName = mailAccount.name; | 74 | QString userName = QString::null; |
75 | userName += " <" + mailAccount.emailAddress + ">"; | 75 | // not supported by ALL SMTP servers in the MAIL From field |
76 | // userName = "\""+mailAccount.name+"\""; | ||
77 | userName += "<" + mailAccount.emailAddress + ">"; | ||
76 | 78 | ||
77 | for (currentMail = mailList->first(); currentMail != 0; | 79 | for (currentMail = mailList->first(); currentMail != 0; |
78 | currentMail = mailList->next()) { | 80 | currentMail = mailList->next()) { |
79 | 81 | ||
80 | if (encodeMime(currentMail) == 0) { | 82 | if (encodeMime(currentMail) == 0) { |
81 | smtpClient->addMail(userName, currentMail->subject, | 83 | smtpClient->addMail(userName, currentMail->subject, |
82 | currentMail->recipients, currentMail->rawMail); | 84 | currentMail->recipients, currentMail->rawMail); |
83 | } else { //error | 85 | } else { //error |
84 | temp = tr("Could not locate all files in \nmail with subject: ") + | 86 | temp = tr("Could not locate all files in \nmail with subject: ") + |
85 | currentMail->subject; | 87 | currentMail->subject; |
86 | temp += tr("\nMail has NOT been sent"); | 88 | temp += tr("\nMail has NOT been sent"); |
87 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
88 | 90 | ||
89 | } | 91 | } |
90 | } | 92 | } |
91 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 93 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
92 | } | 94 | } |
93 | 95 | ||
94 | void EmailHandler::setAccount(MailAccount account) | 96 | void EmailHandler::setAccount(MailAccount account) |
95 | { | 97 | { |
96 | mailAccount = account; | 98 | mailAccount = account; |
97 | } | 99 | } |
98 | 100 | ||
99 | void EmailHandler::getMail() | 101 | void EmailHandler::getMail() |
100 | { | 102 | { |
101 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
102 | if (mailAccount.synchronize) { | 104 | if (mailAccount.synchronize) { |
103 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 105 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
104 | } else { | 106 | } else { |
105 | popClient->removeSynchronize(); | 107 | popClient->removeSynchronize(); |
106 | } | 108 | } |
107 | 109 | ||
108 | headers = FALSE; | 110 | headers = FALSE; |
109 | //popClient->headersOnly(headers, 0); | 111 | //popClient->headersOnly(headers, 0); |
110 | popClient->newConnection(mailAccount.popServer, 110); | 112 | popClient->newConnection(mailAccount.popServer, 110); |
111 | } | 113 | } |
112 | 114 | ||
113 | void EmailHandler::getMailHeaders() | 115 | void EmailHandler::getMailHeaders() |
114 | { | 116 | { |
115 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
116 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); | 118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
117 | 119 | ||
118 | headers = TRUE; | 120 | headers = TRUE; |
119 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
120 | qDebug("Initiating connection"); | 122 | qDebug("Initiating connection"); |
121 | popClient->newConnection(mailAccount.popServer, 110); | 123 | popClient->newConnection(mailAccount.popServer, 110); |
122 | } | 124 | } |
123 | 125 | ||
124 | void EmailHandler::getMailByList(MailList *mailList) | 126 | void EmailHandler::getMailByList(MailList *mailList) |
125 | { | 127 | { |
126 | if (mailList->count() == 0) { //should not occur though | 128 | if (mailList->count() == 0) { //should not occur though |
127 | emit mailTransfered(0); | 129 | emit mailTransfered(0); |
128 | return; | 130 | return; |
129 | } | 131 | } |
130 | 132 | ||
131 | headers = FALSE; | 133 | headers = FALSE; |
132 | popClient->headersOnly(FALSE, 0); | 134 | popClient->headersOnly(FALSE, 0); |
133 | 135 | ||
134 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); | 136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); |
135 | popClient->setSelectedMails(mailList); | 137 | popClient->setSelectedMails(mailList); |
136 | popClient->newConnection(mailAccount.popServer, 110); | 138 | popClient->newConnection(mailAccount.popServer, 110); |
137 | } | 139 | } |
138 | 140 | ||
139 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
140 | { | 142 | { |
141 | Email mail; | 143 | Email mail; |
142 | 144 | ||
143 | mail.rawMail = message; | 145 | mail.rawMail = message; |
144 | mail.serverId = id; | 146 | mail.serverId = id; |
145 | mail.size = size; | 147 | mail.size = size; |
146 | mail.downloaded = complete; | 148 | mail.downloaded = complete; |
147 | 149 | ||
148 | emit mailArrived(mail, FALSE); | 150 | emit mailArrived(mail, FALSE); |
149 | } | 151 | } |
150 | 152 | ||
151 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) | 153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) |
152 | { | 154 | { |
153 | QString temp, boundary; | 155 | QString temp, boundary; |
154 | int pos; | 156 | int pos; |
155 | QString delimiter, header, body, mimeHeader, mimeBody; | 157 | QString delimiter, header, body, mimeHeader, mimeBody; |
156 | QString content, contentType, contentAttribute, id, encoding; | 158 | QString content, contentType, contentAttribute, id, encoding; |
157 | QString fileName, storedName; | 159 | QString fileName, storedName; |
158 | int enclosureId = 0; | 160 | int enclosureId = 0; |
159 | 161 | ||
160 | mail->rawMail = in; | 162 | mail->rawMail = in; |
161 | mail->received = TRUE; | 163 | mail->received = TRUE; |
162 | mail->files.setAutoDelete(TRUE); | 164 | mail->files.setAutoDelete(TRUE); |
163 | 165 | ||
164 | temp = lineShift + "." + lineShift; | 166 | temp = lineShift + "." + lineShift; |
165 | 167 | ||
166 | if (in.right(temp.length()) != temp) { | 168 | if (in.right(temp.length()) != temp) { |
167 | mail->rawMail += temp; | 169 | mail->rawMail += temp; |
168 | } | 170 | } |
169 | 171 | ||
170 | 172 | ||
171 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 173 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
@@ -349,196 +351,199 @@ bool EmailHandler::getEnclosure(Enclosure *ePtr) | |||
349 | { | 351 | { |
350 | QFile f(ePtr->path + ePtr->name); | 352 | QFile f(ePtr->path + ePtr->name); |
351 | char src[4]; | 353 | char src[4]; |
352 | char *destPtr; | 354 | char *destPtr; |
353 | QByteArray buffer; | 355 | QByteArray buffer; |
354 | uint bufCount, pos, decodedCount, size, x; | 356 | uint bufCount, pos, decodedCount, size, x; |
355 | 357 | ||
356 | if (! f.open(IO_WriteOnly) ) { | 358 | if (! f.open(IO_WriteOnly) ) { |
357 | qWarning("could not save: " + ePtr->path + ePtr->name); | 359 | qWarning("could not save: " + ePtr->path + ePtr->name); |
358 | return FALSE; | 360 | return FALSE; |
359 | } | 361 | } |
360 | 362 | ||
361 | if (ePtr->encoding.upper() == "BASE64") { | 363 | if (ePtr->encoding.upper() == "BASE64") { |
362 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 364 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
363 | buffer.resize(size); | 365 | buffer.resize(size); |
364 | bufCount = 0; | 366 | bufCount = 0; |
365 | pos = 0; | 367 | pos = 0; |
366 | destPtr = buffer.data(); | 368 | destPtr = buffer.data(); |
367 | 369 | ||
368 | while (pos < ePtr->body.length()) { | 370 | while (pos < ePtr->body.length()) { |
369 | decodedCount = 4; | 371 | decodedCount = 4; |
370 | x = 0; | 372 | x = 0; |
371 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 373 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
372 | src[x] = ePtr->body[pos].latin1(); | 374 | src[x] = ePtr->body[pos].latin1(); |
373 | pos++; | 375 | pos++; |
374 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 376 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
375 | x--; | 377 | x--; |
376 | x++; | 378 | x++; |
377 | } | 379 | } |
378 | if (x > 1) { | 380 | if (x > 1) { |
379 | decodedCount = parse64base(src, destPtr); | 381 | decodedCount = parse64base(src, destPtr); |
380 | destPtr += decodedCount; | 382 | destPtr += decodedCount; |
381 | bufCount += decodedCount; | 383 | bufCount += decodedCount; |
382 | } | 384 | } |
383 | } | 385 | } |
384 | 386 | ||
385 | buffer.resize(bufCount); //set correct length of file | 387 | buffer.resize(bufCount); //set correct length of file |
386 | f.writeBlock(buffer); | 388 | f.writeBlock(buffer); |
387 | } else { | 389 | } else { |
388 | QTextStream t(&f); | 390 | QTextStream t(&f); |
389 | t << ePtr->body; | 391 | t << ePtr->body; |
390 | } | 392 | } |
391 | return TRUE; | 393 | return TRUE; |
392 | } | 394 | } |
393 | 395 | ||
394 | int EmailHandler::parse64base(char *src, char *bufOut) { | 396 | int EmailHandler::parse64base(char *src, char *bufOut) { |
395 | 397 | ||
396 | char c, z; | 398 | char c, z; |
397 | char li[4]; | 399 | char li[4]; |
398 | int processed; | 400 | int processed; |
399 | 401 | ||
400 | //conversion table withouth table... | 402 | //conversion table withouth table... |
401 | for (int x = 0; x < 4; x++) { | 403 | for (int x = 0; x < 4; x++) { |
402 | c = src[x]; | 404 | c = src[x]; |
403 | 405 | ||
404 | if ( (int) c >= 'A' && (int) c <= 'Z') | 406 | if ( (int) c >= 'A' && (int) c <= 'Z') |
405 | li[x] = (int) c - (int) 'A'; | 407 | li[x] = (int) c - (int) 'A'; |
406 | if ( (int) c >= 'a' && (int) c <= 'z') | 408 | if ( (int) c >= 'a' && (int) c <= 'z') |
407 | li[x] = (int) c - (int) 'a' + 26; | 409 | li[x] = (int) c - (int) 'a' + 26; |
408 | if ( (int) c >= '0' && (int) c <= '9') | 410 | if ( (int) c >= '0' && (int) c <= '9') |
409 | li[x] = (int) c - (int) '0' + 52; | 411 | li[x] = (int) c - (int) '0' + 52; |
410 | if (c == '+') | 412 | if (c == '+') |
411 | li[x] = 62; | 413 | li[x] = 62; |
412 | if (c == '/') | 414 | if (c == '/') |
413 | li[x] = 63; | 415 | li[x] = 63; |
414 | } | 416 | } |
415 | 417 | ||
416 | processed = 1; | 418 | processed = 1; |
417 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 419 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
418 | bufOut[0] <<= 2; | 420 | bufOut[0] <<= 2; |
419 | z = li[1] >> 4; | 421 | z = li[1] >> 4; |
420 | bufOut[0] = bufOut[0] | z; //first byte retrived | 422 | bufOut[0] = bufOut[0] | z; //first byte retrived |
421 | 423 | ||
422 | if (src[2] != '=') { | 424 | if (src[2] != '=') { |
423 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 425 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
424 | bufOut[1] <<= 4; | 426 | bufOut[1] <<= 4; |
425 | z = li[2] >> 2; | 427 | z = li[2] >> 2; |
426 | bufOut[1] = bufOut[1] | z; //second byte retrived | 428 | bufOut[1] = bufOut[1] | z; //second byte retrived |
427 | processed++; | 429 | processed++; |
428 | 430 | ||
429 | if (src[3] != '=') { | 431 | if (src[3] != '=') { |
430 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 432 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
431 | bufOut[2] <<= 6; | 433 | bufOut[2] <<= 6; |
432 | z = li[3]; | 434 | z = li[3]; |
433 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 435 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
434 | processed++; | 436 | processed++; |
435 | } | 437 | } |
436 | } | 438 | } |
437 | return processed; | 439 | return processed; |
438 | } | 440 | } |
439 | 441 | ||
440 | int EmailHandler::encodeMime(Email *mail) | 442 | int EmailHandler::encodeMime(Email *mail) |
441 | { | 443 | { |
442 | 444 | ||
443 | QString fileName, fileType, contentType, newBody, boundary; | 445 | QString fileName, fileType, contentType, newBody, boundary; |
444 | Enclosure *ePtr; | 446 | Enclosure *ePtr; |
447 | QString userName; | ||
445 | 448 | ||
446 | QString userName = mailAccount.name; | 449 | if ( ! mailAccount.name.isEmpty() ) { |
447 | if (userName.length()>0) //only embrace it if there is a user name | 450 | userName = "\"" + mailAccount.name + "\" <" + mailAccount.emailAddress + ">"; |
448 | userName += " <" + mailAccount.emailAddress + ">"; | 451 | } else { |
452 | userName = "<" + mailAccount.emailAddress + ">"; | ||
453 | } | ||
449 | 454 | ||
450 | //add standard headers | 455 | //add standard headers |
451 | newBody = "From: " + userName + "\r\nTo: "; | 456 | newBody = "From: " + userName + "\r\nTo: "; |
452 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 457 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
453 | newBody += *it + " "; | 458 | newBody += *it + " "; |
454 | } | 459 | } |
455 | 460 | ||
456 | newBody += "\r\nCC: "; | 461 | newBody += "\r\nCC: "; |
457 | 462 | ||
458 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | 463 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { |
459 | newBody += *it + " "; | 464 | newBody += *it + " "; |
460 | } | 465 | } |
461 | 466 | ||
462 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 467 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
463 | 468 | ||
464 | if (mail->files.count() == 0) { //just a simple mail | 469 | if (mail->files.count() == 0) { //just a simple mail |
465 | newBody += "\r\n" + mail->body; | 470 | newBody += "\r\n" + mail->body; |
466 | mail->rawMail = newBody; | 471 | mail->rawMail = newBody; |
467 | return 0; | 472 | return 0; |
468 | } | 473 | } |
469 | 474 | ||
470 | //Build mime encoded mail | 475 | //Build mime encoded mail |
471 | boundary = "-----4345=next_bound=0495----"; | 476 | boundary = "-----4345=next_bound=0495----"; |
472 | 477 | ||
473 | newBody += "Mime-Version: 1.0\r\n"; | 478 | newBody += "Mime-Version: 1.0\r\n"; |
474 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 479 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
475 | boundary + "\"\r\n\r\n"; | 480 | boundary + "\"\r\n\r\n"; |
476 | 481 | ||
477 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 482 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
478 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 483 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
479 | newBody += mail->body; | 484 | newBody += mail->body; |
480 | 485 | ||
481 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 486 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
482 | fileName = ePtr->originalName; | 487 | fileName = ePtr->originalName; |
483 | fileType = ePtr->contentType; | 488 | fileType = ePtr->contentType; |
484 | QFileInfo fi(fileName); | 489 | QFileInfo fi(fileName); |
485 | 490 | ||
486 | // This specification of contentType is temporary | 491 | // This specification of contentType is temporary |
487 | contentType = ""; | 492 | contentType = ""; |
488 | if (fileType == "Picture") { | 493 | if (fileType == "Picture") { |
489 | contentType = "image/x-image"; | 494 | contentType = "image/x-image"; |
490 | } else if (fileType == "Document") { | 495 | } else if (fileType == "Document") { |
491 | contentType = "text/plain"; | 496 | contentType = "text/plain"; |
492 | } else if (fileType == "Sound") { | 497 | } else if (fileType == "Sound") { |
493 | contentType = "audio/x-wav"; | 498 | contentType = "audio/x-wav"; |
494 | } else if (fileType == "Movie") { | 499 | } else if (fileType == "Movie") { |
495 | contentType = "video/mpeg"; | 500 | contentType = "video/mpeg"; |
496 | } else { | 501 | } else { |
497 | contentType = "application/octet-stream"; | 502 | contentType = "application/octet-stream"; |
498 | } | 503 | } |
499 | 504 | ||
500 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 505 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
501 | newBody += "Content-Type: " + contentType + "; name=\"" + | 506 | newBody += "Content-Type: " + contentType + "; name=\"" + |
502 | fi.fileName() + "\"\r\n"; | 507 | fi.fileName() + "\"\r\n"; |
503 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 508 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
504 | newBody += "Content-Disposition: inline; filename=\"" + | 509 | newBody += "Content-Disposition: inline; filename=\"" + |
505 | fi.fileName() + "\"\r\n\r\n"; | 510 | fi.fileName() + "\"\r\n\r\n"; |
506 | 511 | ||
507 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 512 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
508 | return -1; | 513 | return -1; |
509 | } | 514 | } |
510 | 515 | ||
511 | newBody += "\r\n\r\n--" + boundary + "--"; | 516 | newBody += "\r\n\r\n--" + boundary + "--"; |
512 | mail->rawMail = newBody; | 517 | mail->rawMail = newBody; |
513 | 518 | ||
514 | return 0; | 519 | return 0; |
515 | } | 520 | } |
516 | 521 | ||
517 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) | 522 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) |
518 | { | 523 | { |
519 | char *fileData; | 524 | char *fileData; |
520 | char *dataPtr; | 525 | char *dataPtr; |
521 | QString temp; | 526 | QString temp; |
522 | uint dataSize, count; | 527 | uint dataSize, count; |
523 | QFile f(fileName); | 528 | QFile f(fileName); |
524 | 529 | ||
525 | if (! f.open(IO_ReadOnly) ) { | 530 | if (! f.open(IO_ReadOnly) ) { |
526 | qWarning("could not open file: " + fileName); | 531 | qWarning("could not open file: " + fileName); |
527 | return -1; | 532 | return -1; |
528 | } | 533 | } |
529 | QTextStream s(&f); | 534 | QTextStream s(&f); |
530 | dataSize = f.size(); | 535 | dataSize = f.size(); |
531 | fileData = (char *) malloc(dataSize + 3); | 536 | fileData = (char *) malloc(dataSize + 3); |
532 | s.readRawBytes(fileData, dataSize); | 537 | s.readRawBytes(fileData, dataSize); |
533 | 538 | ||
534 | temp = ""; | 539 | temp = ""; |
535 | dataPtr = fileData; | 540 | dataPtr = fileData; |
536 | count = 0; | 541 | count = 0; |
537 | while (dataSize > 0) { | 542 | while (dataSize > 0) { |
538 | if (dataSize < 3) { | 543 | if (dataSize < 3) { |
539 | encode64base(dataPtr, &temp, dataSize); | 544 | encode64base(dataPtr, &temp, dataSize); |
540 | dataSize = 0; | 545 | dataSize = 0; |
541 | } else { | 546 | } else { |
542 | encode64base(dataPtr, &temp, 3); | 547 | encode64base(dataPtr, &temp, 3); |
543 | dataSize -= 3; | 548 | dataSize -= 3; |
544 | dataPtr += 3; | 549 | dataPtr += 3; |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 749a4e9..90664bb 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -176,193 +176,193 @@ void EmailClient::init() | |||
176 | // grid_2->setMargin( 11 ); | 176 | // grid_2->setMargin( 11 ); |
177 | 177 | ||
178 | inboxView = new QListView( widget, "inboxView" ); | 178 | inboxView = new QListView( widget, "inboxView" ); |
179 | inboxView->addColumn( tr( "From" ) ); | 179 | inboxView->addColumn( tr( "From" ) ); |
180 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
181 | inboxView->addColumn( tr( "Date" ) ); | 181 | inboxView->addColumn( tr( "Date" ) ); |
182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 182 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
183 | inboxView->setAllColumnsShowFocus(TRUE); | 183 | inboxView->setAllColumnsShowFocus(TRUE); |
184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" | 184 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" |
185 | "It keeps the fetched mail which can be \n" | 185 | "It keeps the fetched mail which can be \n" |
186 | "viewed by double clicking the entry.\n" | 186 | "viewed by double clicking the entry.\n" |
187 | "blue attachment icon shows whether this \n" | 187 | "blue attachment icon shows whether this \n" |
188 | "mailhas attachments.\n")); | 188 | "mailhas attachments.\n")); |
189 | 189 | ||
190 | grid_2->addWidget( inboxView, 2, 0 ); | 190 | grid_2->addWidget( inboxView, 2, 0 ); |
191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 191 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
192 | 192 | ||
193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 193 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
194 | grid_3 = new QGridLayout( widget_2 ); | 194 | grid_3 = new QGridLayout( widget_2 ); |
195 | // grid_3->setSpacing(6); | 195 | // grid_3->setSpacing(6); |
196 | // grid_3->setMargin( 11 ); | 196 | // grid_3->setMargin( 11 ); |
197 | 197 | ||
198 | outboxView = new QListView( widget_2, "outboxView" ); | 198 | outboxView = new QListView( widget_2, "outboxView" ); |
199 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
200 | outboxView->addColumn( tr( "Subject" ) ); | 200 | outboxView->addColumn( tr( "Subject" ) ); |
201 | outboxView->setAllColumnsShowFocus(TRUE); | 201 | outboxView->setAllColumnsShowFocus(TRUE); |
202 | 202 | ||
203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" | 203 | QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" |
204 | "It keeps the queued mails to send which can be \n" | 204 | "It keeps the queued mails to send which can be \n" |
205 | "reviewed by double clicking the entry.")); | 205 | "reviewed by double clicking the entry.")); |
206 | grid_3->addWidget( outboxView, 0, 0 ); | 206 | grid_3->addWidget( outboxView, 0, 0 ); |
207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 207 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
208 | 208 | ||
209 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void EmailClient::initStatusBar(QWidget* parent) | 213 | void EmailClient::initStatusBar(QWidget* parent) |
214 | { | 214 | { |
215 | statusBar = new QStatusBar(parent); | 215 | statusBar = new QStatusBar(parent); |
216 | statusBar->setSizeGripEnabled(FALSE); | 216 | statusBar->setSizeGripEnabled(FALSE); |
217 | 217 | ||
218 | status1Label = new QLabel( tr("Idle"), statusBar); | 218 | status1Label = new QLabel( tr("Idle"), statusBar); |
219 | status2Label = new QLabel("", statusBar); | 219 | status2Label = new QLabel("", statusBar); |
220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 220 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
221 | status2Label, SLOT(setText(const QString &)) ); | 221 | status2Label, SLOT(setText(const QString &)) ); |
222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 222 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
223 | status2Label, SLOT(setText(const QString &)) ); | 223 | status2Label, SLOT(setText(const QString &)) ); |
224 | 224 | ||
225 | progressBar = new QProgressBar(statusBar); | 225 | progressBar = new QProgressBar(statusBar); |
226 | 226 | ||
227 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 227 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
228 | this, SLOT(setTotalSize(int)) ); | 228 | this, SLOT(setTotalSize(int)) ); |
229 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 229 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
230 | this, SLOT(setMailSize(int)) ); | 230 | this, SLOT(setMailSize(int)) ); |
231 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 231 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
232 | this, SLOT(setDownloadedSize(int)) ); | 232 | this, SLOT(setDownloadedSize(int)) ); |
233 | 233 | ||
234 | statusBar->addWidget(status1Label); | 234 | statusBar->addWidget(status1Label); |
235 | statusBar->addWidget(progressBar); | 235 | statusBar->addWidget(progressBar); |
236 | statusBar->addWidget(status2Label); | 236 | statusBar->addWidget(status2Label); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void EmailClient::compose() | 240 | void EmailClient::compose() |
241 | { | 241 | { |
242 | emit composeRequested(); | 242 | emit composeRequested(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void EmailClient::cancel() | 245 | void EmailClient::cancel() |
246 | { | 246 | { |
247 | emailHandler->cancel(); | 247 | emailHandler->cancel(); |
248 | } | 248 | } |
249 | 249 | ||
250 | AddressList* EmailClient::getAdrListRef() | 250 | AddressList* EmailClient::getAdrListRef() |
251 | { | 251 | { |
252 | return addressList; | 252 | return addressList; |
253 | } | 253 | } |
254 | 254 | ||
255 | //this needs to be rewritten to syncronize with outboxView | 255 | //this needs to be rewritten to syncronize with outboxView |
256 | void EmailClient::enqueMail(const Email &mail) | 256 | void EmailClient::enqueMail(const Email &mail) |
257 | { | 257 | { |
258 | if (accountList.count() == 0) { | 258 | if (accountList.count() == 0) { |
259 | QMessageBox::warning(qApp->activeWindow(), | 259 | QMessageBox::warning(qApp->activeWindow(), |
260 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 260 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (accountList.count() > 0) { | 264 | if (accountList.count() > 0) { |
265 | currentAccount = accountList.first(); | 265 | currentAccount = accountList.first(); |
266 | qWarning("using account " + currentAccount->name); | 266 | qWarning("using account " + currentAccount->name); |
267 | } | 267 | } |
268 | 268 | ||
269 | Email addMail = mail; | 269 | Email addMail = mail; |
270 | addMail.from = currentAccount->name; | 270 | addMail.from = currentAccount->name; |
271 | addMail.fromMail = currentAccount->emailAddress; | 271 | addMail.fromMail = currentAccount->emailAddress; |
272 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 272 | addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); |
273 | item = new EmailListItem(outboxView, addMail, false); | 273 | item = new EmailListItem(outboxView, addMail, false); |
274 | 274 | ||
275 | mailboxView->setCurrentTab(1); | 275 | mailboxView->setCurrentTab(1); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | void EmailClient::sendQuedMail() | 279 | void EmailClient::sendQuedMail() |
280 | { | 280 | { |
281 | int count = 0; | 281 | int count = 0; |
282 | 282 | ||
283 | if (accountList.count() == 0) { | 283 | if (accountList.count() == 0) { |
284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 284 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | //traverse listview, find messages to send | 287 | //traverse listview, find messages to send |
288 | if (! sending) { | 288 | if (! sending) { |
289 | item = (EmailListItem *) outboxView->firstChild(); | 289 | item = (EmailListItem *) outboxView->firstChild(); |
290 | if (item != NULL) { | 290 | if (item != NULL) { |
291 | while (item != NULL) { | 291 | while (item != NULL) { |
292 | quedMessages.append(item->getMail()); | 292 | quedMessages.append(item->getMail()); |
293 | item = (EmailListItem *) item->nextSibling(); | 293 | item = (EmailListItem *) item->nextSibling(); |
294 | count++; | 294 | count++; |
295 | } | 295 | } |
296 | setMailAccount(); | 296 | setMailAccount(); |
297 | emailHandler->sendMail(&quedMessages); | 297 | emailHandler->sendMail(&quedMessages); |
298 | sending = TRUE; | 298 | sending = TRUE; |
299 | sendMailButton->setEnabled(FALSE); | 299 | sendMailButton->setEnabled(FALSE); |
300 | cancelButton->setEnabled(TRUE); | 300 | cancelButton->setEnabled(TRUE); |
301 | } else { | 301 | } else { |
302 | qWarning("sendQuedMail(): no messages to send"); | 302 | qWarning("sendQuedMail(): no messages to send"); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | void EmailClient::setMailAccount() | 307 | void EmailClient::setMailAccount() |
308 | { | 308 | { |
309 | emailHandler->setAccount(*currentAccount); | 309 | emailHandler->setAccount(*currentAccount); |
310 | } | 310 | } |
311 | 311 | ||
312 | void EmailClient::mailSent() | 312 | void EmailClient::mailSent() |
313 | { | 313 | { |
314 | sending = FALSE; | 314 | sending = FALSE; |
315 | sendMailButton->setEnabled(TRUE); | 315 | sendMailButton->setEnabled(TRUE); |
316 | 316 | ||
317 | quedMessages.clear(); | 317 | quedMessages.clear(); |
318 | outboxView->clear(); //should be moved to an sentBox | 318 | outboxView->clear(); //should be moved to an sentBox |
319 | } | 319 | } |
320 | 320 | ||
321 | void EmailClient::getNewMail() { | 321 | void EmailClient::getNewMail() { |
322 | 322 | ||
323 | if (accountList.count() == 0) { | 323 | if (accountList.count() == 0) { |
324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 324 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
325 | "You must create an account", "OK\n"); | 325 | "You must create an account", "OK\n"); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | 328 | ||
329 | setMailAccount(); | 329 | setMailAccount(); |
330 | 330 | ||
331 | receiving = TRUE; | 331 | receiving = TRUE; |
332 | previewingMail = TRUE; | 332 | previewingMail = TRUE; |
333 | getMailButton->setEnabled(FALSE); | 333 | getMailButton->setEnabled(FALSE); |
334 | cancelButton->setEnabled(TRUE); | 334 | cancelButton->setEnabled(TRUE); |
335 | selectAccountMenu->setEnabled(FALSE); | 335 | selectAccountMenu->setEnabled(FALSE); |
336 | 336 | ||
337 | status1Label->setText(currentAccount->accountName + " headers"); | 337 | status1Label->setText(currentAccount->accountName + " headers"); |
338 | progressBar->reset(); | 338 | progressBar->reset(); |
339 | 339 | ||
340 | //get any previous mails not downloaded and add to queue | 340 | //get any previous mails not downloaded and add to queue |
341 | /*mailDownloadList.clear(); | 341 | /*mailDownloadList.clear(); |
342 | Email *mailPtr; | 342 | Email *mailPtr; |
343 | item = (EmailListItem *) inboxView->firstChild(); | 343 | item = (EmailListItem *) inboxView->firstChild(); |
344 | while (item != NULL) { | 344 | while (item != NULL) { |
345 | mailPtr = item->getMail(); | 345 | mailPtr = item->getMail(); |
346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 347 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
348 | } | 348 | } |
349 | item = (EmailListItem *) item->nextSibling(); | 349 | item = (EmailListItem *) item->nextSibling(); |
350 | }*/ | 350 | }*/ |
351 | 351 | ||
352 | emailHandler->getMailHeaders(); | 352 | emailHandler->getMailHeaders(); |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void EmailClient::getAllNewMail() | 356 | void EmailClient::getAllNewMail() |
357 | { | 357 | { |
358 | allAccounts = TRUE; | 358 | allAccounts = TRUE; |
359 | currentAccount = accountList.first(); | 359 | currentAccount = accountList.first(); |
360 | getNewMail(); | 360 | getNewMail(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
364 | { | 364 | { |
365 | Enclosure *ePtr; | 365 | Enclosure *ePtr; |
366 | Email newMail; | 366 | Email newMail; |
367 | int thisMailId; | 367 | int thisMailId; |
368 | emailHandler->parse( mail.rawMail, lineShift, &newMail); | 368 | emailHandler->parse( mail.rawMail, lineShift, &newMail); |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 5b8bda1..06e978d 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -1,171 +1,173 @@ | |||
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 | qDebug("EMailHandler::EmailHandler"); | 42 | qDebug("EMailHandler::EmailHandler"); |
43 | 43 | ||
44 | smtpClient = new SmtpClient(); | 44 | smtpClient = new SmtpClient(); |
45 | popClient = new PopClient(); | 45 | popClient = new PopClient(); |
46 | 46 | ||
47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, | 47 | connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this, |
48 | SIGNAL(smtpError(int, const QString &)) ); | 48 | SIGNAL(smtpError(int, const QString &)) ); |
49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 49 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 50 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
51 | SIGNAL(updateSmtpStatus(const QString &)) ); | 51 | SIGNAL(updateSmtpStatus(const QString &)) ); |
52 | 52 | ||
53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, | 53 | connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this, |
54 | SIGNAL(popError(int, const QString &)) ); | 54 | SIGNAL(popError(int, const QString &)) ); |
55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 55 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 56 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 57 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
58 | SIGNAL(updatePopStatus(const QString &)) ); | 58 | SIGNAL(updatePopStatus(const QString &)) ); |
59 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 59 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
60 | SIGNAL(mailTransfered(int)) ); | 60 | SIGNAL(mailTransfered(int)) ); |
61 | 61 | ||
62 | 62 | ||
63 | //relaying size information | 63 | //relaying size information |
64 | connect(popClient, SIGNAL(currentMailSize(int)), | 64 | connect(popClient, SIGNAL(currentMailSize(int)), |
65 | this, SIGNAL(currentMailSize(int)) ); | 65 | this, SIGNAL(currentMailSize(int)) ); |
66 | connect(popClient, SIGNAL(downloadedSize(int)), | 66 | connect(popClient, SIGNAL(downloadedSize(int)), |
67 | this, SIGNAL(downloadedSize(int)) ); | 67 | this, SIGNAL(downloadedSize(int)) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void EmailHandler::sendMail(QList<Email> *mailList) | 70 | void EmailHandler::sendMail(QList<Email> *mailList) |
71 | { | 71 | { |
72 | Email *currentMail; | 72 | Email *currentMail; |
73 | QString temp; | 73 | QString temp; |
74 | QString userName = mailAccount.name; | 74 | QString userName = QString::null; |
75 | userName += " <" + mailAccount.emailAddress + ">"; | 75 | // not supported by ALL SMTP servers in the MAIL From field |
76 | // userName = "\""+mailAccount.name+"\""; | ||
77 | userName += "<" + mailAccount.emailAddress + ">"; | ||
76 | 78 | ||
77 | for (currentMail = mailList->first(); currentMail != 0; | 79 | for (currentMail = mailList->first(); currentMail != 0; |
78 | currentMail = mailList->next()) { | 80 | currentMail = mailList->next()) { |
79 | 81 | ||
80 | if (encodeMime(currentMail) == 0) { | 82 | if (encodeMime(currentMail) == 0) { |
81 | smtpClient->addMail(userName, currentMail->subject, | 83 | smtpClient->addMail(userName, currentMail->subject, |
82 | currentMail->recipients, currentMail->rawMail); | 84 | currentMail->recipients, currentMail->rawMail); |
83 | } else { //error | 85 | } else { //error |
84 | temp = tr("Could not locate all files in \nmail with subject: ") + | 86 | temp = tr("Could not locate all files in \nmail with subject: ") + |
85 | currentMail->subject; | 87 | currentMail->subject; |
86 | temp += tr("\nMail has NOT been sent"); | 88 | temp += tr("\nMail has NOT been sent"); |
87 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 89 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
88 | 90 | ||
89 | } | 91 | } |
90 | } | 92 | } |
91 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 93 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
92 | } | 94 | } |
93 | 95 | ||
94 | void EmailHandler::setAccount(MailAccount account) | 96 | void EmailHandler::setAccount(MailAccount account) |
95 | { | 97 | { |
96 | mailAccount = account; | 98 | mailAccount = account; |
97 | } | 99 | } |
98 | 100 | ||
99 | void EmailHandler::getMail() | 101 | void EmailHandler::getMail() |
100 | { | 102 | { |
101 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 103 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
102 | if (mailAccount.synchronize) { | 104 | if (mailAccount.synchronize) { |
103 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 105 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
104 | } else { | 106 | } else { |
105 | popClient->removeSynchronize(); | 107 | popClient->removeSynchronize(); |
106 | } | 108 | } |
107 | 109 | ||
108 | headers = FALSE; | 110 | headers = FALSE; |
109 | //popClient->headersOnly(headers, 0); | 111 | //popClient->headersOnly(headers, 0); |
110 | popClient->newConnection(mailAccount.popServer, 110); | 112 | popClient->newConnection(mailAccount.popServer, 110); |
111 | } | 113 | } |
112 | 114 | ||
113 | void EmailHandler::getMailHeaders() | 115 | void EmailHandler::getMailHeaders() |
114 | { | 116 | { |
115 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 117 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
116 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); | 118 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
117 | 119 | ||
118 | headers = TRUE; | 120 | headers = TRUE; |
119 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
120 | qDebug("Initiating connection"); | 122 | qDebug("Initiating connection"); |
121 | popClient->newConnection(mailAccount.popServer, 110); | 123 | popClient->newConnection(mailAccount.popServer, 110); |
122 | } | 124 | } |
123 | 125 | ||
124 | void EmailHandler::getMailByList(MailList *mailList) | 126 | void EmailHandler::getMailByList(MailList *mailList) |
125 | { | 127 | { |
126 | if (mailList->count() == 0) { //should not occur though | 128 | if (mailList->count() == 0) { //should not occur though |
127 | emit mailTransfered(0); | 129 | emit mailTransfered(0); |
128 | return; | 130 | return; |
129 | } | 131 | } |
130 | 132 | ||
131 | headers = FALSE; | 133 | headers = FALSE; |
132 | popClient->headersOnly(FALSE, 0); | 134 | popClient->headersOnly(FALSE, 0); |
133 | 135 | ||
134 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); | 136 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); |
135 | popClient->setSelectedMails(mailList); | 137 | popClient->setSelectedMails(mailList); |
136 | popClient->newConnection(mailAccount.popServer, 110); | 138 | popClient->newConnection(mailAccount.popServer, 110); |
137 | } | 139 | } |
138 | 140 | ||
139 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 141 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
140 | { | 142 | { |
141 | Email mail; | 143 | Email mail; |
142 | 144 | ||
143 | mail.rawMail = message; | 145 | mail.rawMail = message; |
144 | mail.serverId = id; | 146 | mail.serverId = id; |
145 | mail.size = size; | 147 | mail.size = size; |
146 | mail.downloaded = complete; | 148 | mail.downloaded = complete; |
147 | 149 | ||
148 | emit mailArrived(mail, FALSE); | 150 | emit mailArrived(mail, FALSE); |
149 | } | 151 | } |
150 | 152 | ||
151 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) | 153 | bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) |
152 | { | 154 | { |
153 | QString temp, boundary; | 155 | QString temp, boundary; |
154 | int pos; | 156 | int pos; |
155 | QString delimiter, header, body, mimeHeader, mimeBody; | 157 | QString delimiter, header, body, mimeHeader, mimeBody; |
156 | QString content, contentType, contentAttribute, id, encoding; | 158 | QString content, contentType, contentAttribute, id, encoding; |
157 | QString fileName, storedName; | 159 | QString fileName, storedName; |
158 | int enclosureId = 0; | 160 | int enclosureId = 0; |
159 | 161 | ||
160 | mail->rawMail = in; | 162 | mail->rawMail = in; |
161 | mail->received = TRUE; | 163 | mail->received = TRUE; |
162 | mail->files.setAutoDelete(TRUE); | 164 | mail->files.setAutoDelete(TRUE); |
163 | 165 | ||
164 | temp = lineShift + "." + lineShift; | 166 | temp = lineShift + "." + lineShift; |
165 | 167 | ||
166 | if (in.right(temp.length()) != temp) { | 168 | if (in.right(temp.length()) != temp) { |
167 | mail->rawMail += temp; | 169 | mail->rawMail += temp; |
168 | } | 170 | } |
169 | 171 | ||
170 | 172 | ||
171 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 173 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
@@ -349,196 +351,199 @@ bool EmailHandler::getEnclosure(Enclosure *ePtr) | |||
349 | { | 351 | { |
350 | QFile f(ePtr->path + ePtr->name); | 352 | QFile f(ePtr->path + ePtr->name); |
351 | char src[4]; | 353 | char src[4]; |
352 | char *destPtr; | 354 | char *destPtr; |
353 | QByteArray buffer; | 355 | QByteArray buffer; |
354 | uint bufCount, pos, decodedCount, size, x; | 356 | uint bufCount, pos, decodedCount, size, x; |
355 | 357 | ||
356 | if (! f.open(IO_WriteOnly) ) { | 358 | if (! f.open(IO_WriteOnly) ) { |
357 | qWarning("could not save: " + ePtr->path + ePtr->name); | 359 | qWarning("could not save: " + ePtr->path + ePtr->name); |
358 | return FALSE; | 360 | return FALSE; |
359 | } | 361 | } |
360 | 362 | ||
361 | if (ePtr->encoding.upper() == "BASE64") { | 363 | if (ePtr->encoding.upper() == "BASE64") { |
362 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 364 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
363 | buffer.resize(size); | 365 | buffer.resize(size); |
364 | bufCount = 0; | 366 | bufCount = 0; |
365 | pos = 0; | 367 | pos = 0; |
366 | destPtr = buffer.data(); | 368 | destPtr = buffer.data(); |
367 | 369 | ||
368 | while (pos < ePtr->body.length()) { | 370 | while (pos < ePtr->body.length()) { |
369 | decodedCount = 4; | 371 | decodedCount = 4; |
370 | x = 0; | 372 | x = 0; |
371 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 373 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
372 | src[x] = ePtr->body[pos].latin1(); | 374 | src[x] = ePtr->body[pos].latin1(); |
373 | pos++; | 375 | pos++; |
374 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 376 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
375 | x--; | 377 | x--; |
376 | x++; | 378 | x++; |
377 | } | 379 | } |
378 | if (x > 1) { | 380 | if (x > 1) { |
379 | decodedCount = parse64base(src, destPtr); | 381 | decodedCount = parse64base(src, destPtr); |
380 | destPtr += decodedCount; | 382 | destPtr += decodedCount; |
381 | bufCount += decodedCount; | 383 | bufCount += decodedCount; |
382 | } | 384 | } |
383 | } | 385 | } |
384 | 386 | ||
385 | buffer.resize(bufCount); //set correct length of file | 387 | buffer.resize(bufCount); //set correct length of file |
386 | f.writeBlock(buffer); | 388 | f.writeBlock(buffer); |
387 | } else { | 389 | } else { |
388 | QTextStream t(&f); | 390 | QTextStream t(&f); |
389 | t << ePtr->body; | 391 | t << ePtr->body; |
390 | } | 392 | } |
391 | return TRUE; | 393 | return TRUE; |
392 | } | 394 | } |
393 | 395 | ||
394 | int EmailHandler::parse64base(char *src, char *bufOut) { | 396 | int EmailHandler::parse64base(char *src, char *bufOut) { |
395 | 397 | ||
396 | char c, z; | 398 | char c, z; |
397 | char li[4]; | 399 | char li[4]; |
398 | int processed; | 400 | int processed; |
399 | 401 | ||
400 | //conversion table withouth table... | 402 | //conversion table withouth table... |
401 | for (int x = 0; x < 4; x++) { | 403 | for (int x = 0; x < 4; x++) { |
402 | c = src[x]; | 404 | c = src[x]; |
403 | 405 | ||
404 | if ( (int) c >= 'A' && (int) c <= 'Z') | 406 | if ( (int) c >= 'A' && (int) c <= 'Z') |
405 | li[x] = (int) c - (int) 'A'; | 407 | li[x] = (int) c - (int) 'A'; |
406 | if ( (int) c >= 'a' && (int) c <= 'z') | 408 | if ( (int) c >= 'a' && (int) c <= 'z') |
407 | li[x] = (int) c - (int) 'a' + 26; | 409 | li[x] = (int) c - (int) 'a' + 26; |
408 | if ( (int) c >= '0' && (int) c <= '9') | 410 | if ( (int) c >= '0' && (int) c <= '9') |
409 | li[x] = (int) c - (int) '0' + 52; | 411 | li[x] = (int) c - (int) '0' + 52; |
410 | if (c == '+') | 412 | if (c == '+') |
411 | li[x] = 62; | 413 | li[x] = 62; |
412 | if (c == '/') | 414 | if (c == '/') |
413 | li[x] = 63; | 415 | li[x] = 63; |
414 | } | 416 | } |
415 | 417 | ||
416 | processed = 1; | 418 | processed = 1; |
417 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 419 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
418 | bufOut[0] <<= 2; | 420 | bufOut[0] <<= 2; |
419 | z = li[1] >> 4; | 421 | z = li[1] >> 4; |
420 | bufOut[0] = bufOut[0] | z; //first byte retrived | 422 | bufOut[0] = bufOut[0] | z; //first byte retrived |
421 | 423 | ||
422 | if (src[2] != '=') { | 424 | if (src[2] != '=') { |
423 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 425 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
424 | bufOut[1] <<= 4; | 426 | bufOut[1] <<= 4; |
425 | z = li[2] >> 2; | 427 | z = li[2] >> 2; |
426 | bufOut[1] = bufOut[1] | z; //second byte retrived | 428 | bufOut[1] = bufOut[1] | z; //second byte retrived |
427 | processed++; | 429 | processed++; |
428 | 430 | ||
429 | if (src[3] != '=') { | 431 | if (src[3] != '=') { |
430 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 432 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
431 | bufOut[2] <<= 6; | 433 | bufOut[2] <<= 6; |
432 | z = li[3]; | 434 | z = li[3]; |
433 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 435 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
434 | processed++; | 436 | processed++; |
435 | } | 437 | } |
436 | } | 438 | } |
437 | return processed; | 439 | return processed; |
438 | } | 440 | } |
439 | 441 | ||
440 | int EmailHandler::encodeMime(Email *mail) | 442 | int EmailHandler::encodeMime(Email *mail) |
441 | { | 443 | { |
442 | 444 | ||
443 | QString fileName, fileType, contentType, newBody, boundary; | 445 | QString fileName, fileType, contentType, newBody, boundary; |
444 | Enclosure *ePtr; | 446 | Enclosure *ePtr; |
447 | QString userName; | ||
445 | 448 | ||
446 | QString userName = mailAccount.name; | 449 | if ( ! mailAccount.name.isEmpty() ) { |
447 | if (userName.length()>0) //only embrace it if there is a user name | 450 | userName = "\"" + mailAccount.name + "\" <" + mailAccount.emailAddress + ">"; |
448 | userName += " <" + mailAccount.emailAddress + ">"; | 451 | } else { |
452 | userName = "<" + mailAccount.emailAddress + ">"; | ||
453 | } | ||
449 | 454 | ||
450 | //add standard headers | 455 | //add standard headers |
451 | newBody = "From: " + userName + "\r\nTo: "; | 456 | newBody = "From: " + userName + "\r\nTo: "; |
452 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 457 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
453 | newBody += *it + " "; | 458 | newBody += *it + " "; |
454 | } | 459 | } |
455 | 460 | ||
456 | newBody += "\r\nCC: "; | 461 | newBody += "\r\nCC: "; |
457 | 462 | ||
458 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | 463 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { |
459 | newBody += *it + " "; | 464 | newBody += *it + " "; |
460 | } | 465 | } |
461 | 466 | ||
462 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 467 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
463 | 468 | ||
464 | if (mail->files.count() == 0) { //just a simple mail | 469 | if (mail->files.count() == 0) { //just a simple mail |
465 | newBody += "\r\n" + mail->body; | 470 | newBody += "\r\n" + mail->body; |
466 | mail->rawMail = newBody; | 471 | mail->rawMail = newBody; |
467 | return 0; | 472 | return 0; |
468 | } | 473 | } |
469 | 474 | ||
470 | //Build mime encoded mail | 475 | //Build mime encoded mail |
471 | boundary = "-----4345=next_bound=0495----"; | 476 | boundary = "-----4345=next_bound=0495----"; |
472 | 477 | ||
473 | newBody += "Mime-Version: 1.0\r\n"; | 478 | newBody += "Mime-Version: 1.0\r\n"; |
474 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 479 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
475 | boundary + "\"\r\n\r\n"; | 480 | boundary + "\"\r\n\r\n"; |
476 | 481 | ||
477 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 482 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
478 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 483 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
479 | newBody += mail->body; | 484 | newBody += mail->body; |
480 | 485 | ||
481 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 486 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
482 | fileName = ePtr->originalName; | 487 | fileName = ePtr->originalName; |
483 | fileType = ePtr->contentType; | 488 | fileType = ePtr->contentType; |
484 | QFileInfo fi(fileName); | 489 | QFileInfo fi(fileName); |
485 | 490 | ||
486 | // This specification of contentType is temporary | 491 | // This specification of contentType is temporary |
487 | contentType = ""; | 492 | contentType = ""; |
488 | if (fileType == "Picture") { | 493 | if (fileType == "Picture") { |
489 | contentType = "image/x-image"; | 494 | contentType = "image/x-image"; |
490 | } else if (fileType == "Document") { | 495 | } else if (fileType == "Document") { |
491 | contentType = "text/plain"; | 496 | contentType = "text/plain"; |
492 | } else if (fileType == "Sound") { | 497 | } else if (fileType == "Sound") { |
493 | contentType = "audio/x-wav"; | 498 | contentType = "audio/x-wav"; |
494 | } else if (fileType == "Movie") { | 499 | } else if (fileType == "Movie") { |
495 | contentType = "video/mpeg"; | 500 | contentType = "video/mpeg"; |
496 | } else { | 501 | } else { |
497 | contentType = "application/octet-stream"; | 502 | contentType = "application/octet-stream"; |
498 | } | 503 | } |
499 | 504 | ||
500 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 505 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
501 | newBody += "Content-Type: " + contentType + "; name=\"" + | 506 | newBody += "Content-Type: " + contentType + "; name=\"" + |
502 | fi.fileName() + "\"\r\n"; | 507 | fi.fileName() + "\"\r\n"; |
503 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 508 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
504 | newBody += "Content-Disposition: inline; filename=\"" + | 509 | newBody += "Content-Disposition: inline; filename=\"" + |
505 | fi.fileName() + "\"\r\n\r\n"; | 510 | fi.fileName() + "\"\r\n\r\n"; |
506 | 511 | ||
507 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 512 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
508 | return -1; | 513 | return -1; |
509 | } | 514 | } |
510 | 515 | ||
511 | newBody += "\r\n\r\n--" + boundary + "--"; | 516 | newBody += "\r\n\r\n--" + boundary + "--"; |
512 | mail->rawMail = newBody; | 517 | mail->rawMail = newBody; |
513 | 518 | ||
514 | return 0; | 519 | return 0; |
515 | } | 520 | } |
516 | 521 | ||
517 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) | 522 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) |
518 | { | 523 | { |
519 | char *fileData; | 524 | char *fileData; |
520 | char *dataPtr; | 525 | char *dataPtr; |
521 | QString temp; | 526 | QString temp; |
522 | uint dataSize, count; | 527 | uint dataSize, count; |
523 | QFile f(fileName); | 528 | QFile f(fileName); |
524 | 529 | ||
525 | if (! f.open(IO_ReadOnly) ) { | 530 | if (! f.open(IO_ReadOnly) ) { |
526 | qWarning("could not open file: " + fileName); | 531 | qWarning("could not open file: " + fileName); |
527 | return -1; | 532 | return -1; |
528 | } | 533 | } |
529 | QTextStream s(&f); | 534 | QTextStream s(&f); |
530 | dataSize = f.size(); | 535 | dataSize = f.size(); |
531 | fileData = (char *) malloc(dataSize + 3); | 536 | fileData = (char *) malloc(dataSize + 3); |
532 | s.readRawBytes(fileData, dataSize); | 537 | s.readRawBytes(fileData, dataSize); |
533 | 538 | ||
534 | temp = ""; | 539 | temp = ""; |
535 | dataPtr = fileData; | 540 | dataPtr = fileData; |
536 | count = 0; | 541 | count = 0; |
537 | while (dataSize > 0) { | 542 | while (dataSize > 0) { |
538 | if (dataSize < 3) { | 543 | if (dataSize < 3) { |
539 | encode64base(dataPtr, &temp, dataSize); | 544 | encode64base(dataPtr, &temp, dataSize); |
540 | dataSize = 0; | 545 | dataSize = 0; |
541 | } else { | 546 | } else { |
542 | encode64base(dataPtr, &temp, 3); | 547 | encode64base(dataPtr, &temp, 3); |
543 | dataSize -= 3; | 548 | dataSize -= 3; |
544 | dataPtr += 3; | 549 | dataPtr += 3; |