summaryrefslogtreecommitdiff
path: root/noncore/net
authorllornkcor <llornkcor>2003-06-09 01:48:19 (UTC)
committer llornkcor <llornkcor>2003-06-09 01:48:19 (UTC)
commit69a1d4d6b5b16fa3c014fad0a30d5893eced6963 (patch) (unidiff)
treec63fa8f9042de2e9d5e252fbcca17b6570bbdfe9 /noncore/net
parent364e6e65b4c3b4ceec2b1b6688f2ca2b3dce4560 (diff)
downloadopie-69a1d4d6b5b16fa3c014fad0a30d5893eced6963.zip
opie-69a1d4d6b5b16fa3c014fad0a30d5893eced6963.tar.gz
opie-69a1d4d6b5b16fa3c014fad0a30d5893eced6963.tar.bz2
patch from wim delvaux.
Diffstat (limited to 'noncore/net') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/emailclient.cpp2
-rw-r--r--noncore/net/mailit/emailhandler.cpp15
2 files changed, 11 insertions, 6 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
@@ -248,49 +248,49 @@ void EmailClient::cancel()
248} 248}
249 249
250AddressList* EmailClient::getAdrListRef() 250AddressList* 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
256void EmailClient::enqueMail(const Email &mail) 256void 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
279void EmailClient::sendQuedMail() 279void 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();
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
@@ -50,50 +50,52 @@ EmailHandler::EmailHandler()
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
70void EmailHandler::sendMail(QList<Email> *mailList) 70void 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
94void EmailHandler::setAccount(MailAccount account) 96void EmailHandler::setAccount(MailAccount account)
95{ 97{
96 mailAccount = account; 98 mailAccount = account;
97} 99}
98 100
99void EmailHandler::getMail() 101void EmailHandler::getMail()
@@ -421,52 +423,55 @@ int EmailHandler::parse64base(char *src, char *bufOut) {
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
440int EmailHandler::encodeMime(Email *mail) 442int 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