summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/emailclient.cpp
authorgroucho <groucho>2003-04-24 11:19:11 (UTC)
committer groucho <groucho>2003-04-24 11:19:11 (UTC)
commit9671975e21266e3bfa6f3c793a3278b67cea34b7 (patch) (unidiff)
tree876c77939cfd0e00fc844b1b5af09b2978564a6d /noncore/unsupported/mailit/emailclient.cpp
parent51e782b9658de61dc02579e115a9c62f396609a3 (diff)
downloadopie-9671975e21266e3bfa6f3c793a3278b67cea34b7.zip
opie-9671975e21266e3bfa6f3c793a3278b67cea34b7.tar.gz
opie-9671975e21266e3bfa6f3c793a3278b67cea34b7.tar.bz2
- reworked size filtering
- started reworking offline download - better tab focus switching - Hello "Whats this" capability - Fixed parsing of To: header files (no more Delivered-To: and Reply-To: matches) - Good bye Settings.txt, hello Config Objects and encrypted passwords - Translation improvements (added trs) - Parser optimizations
Diffstat (limited to 'noncore/unsupported/mailit/emailclient.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp219
1 files changed, 98 insertions, 121 deletions
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index ad1e0b4..23059cf 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -25,2 +25,3 @@
25#include <qaction.h> 25#include <qaction.h>
26#include <qwhatsthis.h>
26#include <qpe/resource.h> 27#include <qpe/resource.h>
@@ -84,2 +85,3 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
84 85
86 mailboxView->setCurrentTab(0); //ensure that inbox has focus
85} 87}
@@ -115,2 +117,3 @@ void EmailClient::init()
115 progressBar = new QProgressBar(statusBar); 117 progressBar = new QProgressBar(statusBar);
118
116 connect(emailHandler, SIGNAL(mailboxSize(int)), 119 connect(emailHandler, SIGNAL(mailboxSize(int)),
@@ -129,2 +132,3 @@ void EmailClient::init()
129 bar = new QToolBar(this); 132 bar = new QToolBar(this);
133 QWhatsThis::add(bar,tr("Main operation toolbar"));
130 bar->setHorizontalStretchable( TRUE ); 134 bar->setHorizontalStretchable( TRUE );
@@ -150,22 +154,6 @@ void EmailClient::init()
150 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); 154 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar);
151 //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); 155 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account."));
152 // setAccountButton->addTo(bar);
153 //setAccountButton->addTo(mail);
154
155 /*idCount = 0;
156
157 for (MailAccount* accountPtr = accountList.first(); accountPtr != 0;
158 accountPtr = accountList.next()) {
159 156
160 selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount);
161 idCount++;
162 }*/
163 getMailButton->setPopup(selectAccountMenu); 157 getMailButton->setPopup(selectAccountMenu);
164 158
165
166 /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0);
167 connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) );
168 getMailButton->addTo(bar);*/
169 //getMailButton->addTo(mail);
170
171 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); 159 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
@@ -174,2 +162,3 @@ void EmailClient::init()
174 sendMailButton->addTo(mail); 162 sendMailButton->addTo(mail);
163 sendMailButton->setWhatsThis("Send mail queued in the outbox");
175 164
@@ -179,2 +168,3 @@ void EmailClient::init()
179 composeButton->addTo(mail); 168 composeButton->addTo(mail);
169 composeButton->setWhatsThis("Compose a new mail");
180 170
@@ -185,2 +175,4 @@ void EmailClient::init()
185 cancelButton->setEnabled(FALSE); 175 cancelButton->setEnabled(FALSE);
176 cancelButton->setWhatsThis("Stop the currently active mail transfer");
177
186 178
@@ -189,2 +181,3 @@ void EmailClient::init()
189 deleteButton->addTo(bar); 181 deleteButton->addTo(bar);
182 deleteButton->setWhatsThis("Remove the currently selected eMail(s)");
190 183
@@ -203,2 +196,4 @@ void EmailClient::init()
203 inboxView->setAllColumnsShowFocus(TRUE); 196 inboxView->setAllColumnsShowFocus(TRUE);
197 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n It keeps the fetched mail which can be viewed by double clicking the entry.\n"
198 " A blue attachment icon shows whether this mail has attachments."));
204 199
@@ -217,2 +212,3 @@ void EmailClient::init()
217 212
213 QWhatsThis::add(outboxView,QWidget::tr("This is the oubox view.\n It keeps the queued mails to send which can be reviewed by double clicking the entry."));
218 grid_3->addWidget( outboxView, 0, 0 ); 214 grid_3->addWidget( outboxView, 0, 0 );
@@ -222,3 +218,2 @@ void EmailClient::init()
222 218
223 mailboxView->setCurrentTab(0);
224} 219}
@@ -326,3 +321,3 @@ void EmailClient::getNewMail() {
326 //get any previous mails not downloaded and add to queue 321 //get any previous mails not downloaded and add to queue
327/* mailDownloadList.clear(); 322 mailDownloadList.clear();
328 Email *mailPtr; 323 Email *mailPtr;
@@ -335,5 +330,6 @@ void EmailClient::getNewMail() {
335 item = (EmailListItem *) item->nextSibling(); 330 item = (EmailListItem *) item->nextSibling();
336 }*/ 331 }
337 332
338 emailHandler->getMailHeaders(); 333 emailHandler->getMailHeaders();
334
339} 335}
@@ -353,6 +349,6 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
353 emailHandler->parse(mail.rawMail, lineShift, &newMail); 349 emailHandler->parse(mail.rawMail, lineShift, &newMail);
354
355 mailconf->setGroup(newMail.id); 350 mailconf->setGroup(newMail.id);
356 351
357 if (fromDisk) { 352 if (fromDisk)
353 {
358 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 354 newMail.downloaded = mailconf->readBoolEntry("downloaded");
@@ -361,3 +357,5 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
361 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 357 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
362 } else { //mail arrived from server 358 }
359 else
360 { //mail arrived from server
363 newMail.serverId = mail.serverId; 361 newMail.serverId = mail.serverId;
@@ -380,3 +378,3 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
380 //header is not reloaded 378 //header is not reloaded
381 if (currentAccount->synchronize) 379 if ((currentAccount)&&(currentAccount->synchronize))
382 currentAccount->lastServerMailCount++; 380 currentAccount->lastServerMailCount++;
@@ -388,9 +386,11 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
388 386
389 addressList->addContact(newMail.fromMail, newMail.from); 387 //addressList->addContact(newMail.fromMail, newMail.from);
390 } else if (!fromDisk) { //body to header arrived
391 mailconf->writeEntry("downloaded", TRUE);
392 } 388 }
389
390 mailconf->writeEntry("downloaded", newMail.downloaded);
391
393 QString stringMailId; 392 QString stringMailId;
394 stringMailId.setNum(thisMailId); 393 stringMailId.setNum(thisMailId);
395 //se if any attatchments needs to be stored 394 //see if any attatchments needs to be stored
395
396 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { 396 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
@@ -428,6 +428,12 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
428 } 428 }
429 if (!previewingMail && !fromDisk) { 429
430 bool found=false;
431
432 if (!fromDisk)
433 {
434
430 Email *mailPtr; 435 Email *mailPtr;
431 item = (EmailListItem *) inboxView->firstChild(); 436 item = (EmailListItem *) inboxView->firstChild();
432 while (item != NULL) { 437 while ((item != NULL)&&(!found))
438 {
433 mailPtr = item->getMail(); 439 mailPtr = item->getMail();
@@ -436,2 +442,3 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
436 emit mailUpdated(item->getMail()); 442 emit mailUpdated(item->getMail());
443 found = true;
437 } 444 }
@@ -439,7 +446,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
439 } 446 }
440 } else {
441 item = new EmailListItem(inboxView, newMail, TRUE);
442 if (!newMail.downloaded)
443 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
444 } 447 }
448 if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE);
449
450 /*if (!newMail.downloaded)
451 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
445 452
@@ -452,3 +459,3 @@ void EmailClient::allMailArrived(int count)
452 // not previewing means all mailtransfer has been done 459 // not previewing means all mailtransfer has been done
453 if (!previewingMail) { 460 /*if (!previewingMail) {*/
454 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 461 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
@@ -468,3 +475,3 @@ void EmailClient::allMailArrived(int count)
468 } 475 }
469 } 476 //}
470 477
@@ -475,3 +482,3 @@ void EmailClient::allMailArrived(int count)
475 482
476 emailHandler->getMailByList(&mailDownloadList); 483 //emailHandler->getMailByList(&mailDownloadList);
477 484
@@ -543,3 +550,3 @@ void EmailClient::inboxItemSelected()
543{ 550{
544 killTimer(timerID); 551 //killTimer(timerID);
545 552
@@ -553,3 +560,3 @@ void EmailClient::outboxItemSelected()
553{ 560{
554 killTimer(timerID); 561 //killTimer(timerID);
555 562
@@ -569,4 +576,2 @@ void EmailClient::readMail()
569 QFile f(getPath(FALSE) + "inbox.txt"); 576 QFile f(getPath(FALSE) + "inbox.txt");
570// QFileInfo fi(f);
571 //qDebug( f.name());
572 577
@@ -624,3 +629,2 @@ void EmailClient::saveMail(QString fileName, QListView *view)
624 item = (EmailListItem *) view->firstChild(); 629 item = (EmailListItem *) view->firstChild();
625 //qDebug (QString("Write : ") );
626 QTextStream t(&f); 630 QTextStream t(&f);
@@ -628,4 +632,2 @@ void EmailClient::saveMail(QString fileName, QListView *view)
628 mail = item->getMail(); 632 mail = item->getMail();
629 //qDebug(mail->rawMail);
630 //qDebug(mail->recipients.first());
631 t << mail->rawMail; 633 t << mail->rawMail;
@@ -664,62 +666,39 @@ void EmailClient::readSettings()
664{ 666{
665 TextParser *p; 667 int y,acc_count, accountPos=0;
666 QString s;
667 int pos, accountPos, y;
668 QFile f( getPath(FALSE) + "settings.txt");
669
670 if ( f.open(IO_ReadOnly) ) { // file opened successfully
671 QTextStream t( &f ); // use a text stream
672 s = t.read();
673 f.close();
674
675 p = new TextParser(s, "\n");
676
677 accountPos = 0;
678 while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) {
679 accountPos++;
680 if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 )
681 account.accountName = p->getString(& ++pos, 'z', TRUE);
682 if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1)
683 account.name = p->getString(& ++pos, 'z', TRUE);
684 if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1)
685 account.emailAddress = p->getString(& ++pos, 'z', TRUE);
686 if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1)
687 account.popUserName = p->getString(& ++pos, 'z', TRUE);
688 if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1)
689 account.popPasswd = p->getString(& ++pos, 'z', TRUE);
690 if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1)
691 account.popServer = p->getString(& ++pos, 'z', TRUE);
692 if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1)
693 account.smtpServer = p->getString(& ++pos, 'z', TRUE);
694 if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) {
695 s = p->getString(& ++pos, 'z', TRUE);
696 account.id = s.toInt();
697 }
698 668
669 mailconf->setGroup("mailitglobal");
670 acc_count=mailconf->readNumEntry("Accounts",0);
671
672 for (int accountPos = 0;accountPos<acc_count ; accountPos++)
673 {
674 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ...
675 account.accountName = mailconf->readEntry("AccName","");
676 account.name = mailconf->readEntry("UserName","");
677 account.emailAddress = mailconf->readEntry("Email","");
678 account.popUserName = mailconf->readEntry("POPUser","");
679 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
680 account.popServer = mailconf->readEntry("POPServer","");
681 account.smtpServer = mailconf->readEntry("SMTPServer","");
682 account.id = mailconf->readNumEntry("AccountId",0);
683 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
699 account.lastServerMailCount = 0; 684 account.lastServerMailCount = 0;
700 account.synchronize = FALSE; 685 account.synchronize = FALSE;
701 if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) {
702 if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") {
703 account.synchronize = TRUE;
704 if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) {
705 s = p->getString(& ++pos, 'z', TRUE);
706 account.lastServerMailCount = s.toInt();
707 }
708 }
709 }
710 686
711 if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { 687 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
712 account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); 688 if (account.synchronize)
689 {
690 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
713 } 691 }
714 692
715
716 accountList.append(&account); 693 accountList.append(&account);
717 } 694 }
718 delete p; 695
719 }
720 mailconf->setGroup("mailitglobal"); 696 mailconf->setGroup("mailitglobal");
721 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { 697
698 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
699 {
722 mailIdCount = y; 700 mailIdCount = y;
723 } 701 }
724 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { 702 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
703 {
725 accountIdCount = y; 704 accountIdCount = y;
@@ -730,40 +709,38 @@ void EmailClient::saveSettings()
730{ 709{
731 710 int acc_count=0;
732 QString temp;
733 QFile f( getPath(FALSE) + "settings.txt");
734 MailAccount *accountPtr; 711 MailAccount *accountPtr;
735 712
736 if (! f.open(IO_WriteOnly) ) { 713
737 qWarning("could not save settings file"); 714 if (!mailconf)
715 {
716 qWarning("could not save settings");
738 return; 717 return;
739 } 718 }
740 QTextStream t(&f);
741 t << "#Settings for OPIE Mailit program\n";
742 719
743 for (accountPtr = accountList.first(); accountPtr != 0; 720 for (accountPtr = accountList.first(); accountPtr != 0;
744 accountPtr = accountList.next()) { 721 accountPtr = accountList.next())
745 722 {
746 t << "accountStart;\n"; 723 mailconf->setGroup("Account_"+QString::number(++acc_count));
747 t << "AccountName: " + accountPtr->accountName + "\n"; 724 mailconf->writeEntry("AccName",accountPtr->accountName );
748 t << "Name: " + accountPtr->name + "\n"; 725 mailconf->writeEntry("UserName",accountPtr->name);
749 t << "Email: " + accountPtr->emailAddress + "\n"; 726 mailconf->writeEntry("Email",accountPtr->emailAddress);
750 t << "POPUser: " + accountPtr->popUserName + "\n"; 727 mailconf->writeEntry("POPUser",accountPtr->popUserName);
751 t << "POPPAssword: " + accountPtr->popPasswd + "\n"; 728 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd);
752 t << "POPServer: " + accountPtr->popServer + "\n"; 729 mailconf->writeEntry("POPServer",accountPtr->popServer);
753 t << "SMTPServer: " + accountPtr->smtpServer + "\n"; 730 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer);
754 t << "AccountId: " << accountPtr->id << "\n"; 731 mailconf->writeEntry("AccountId",accountPtr->id);
755 if (accountPtr->synchronize) { 732 if (accountPtr->synchronize)
756 t << "Synchronize: Yes\n"; 733 {
757 t << "LastServerMailCount: "; 734 mailconf->writeEntry("Synchronize","Yes");
758 t << accountPtr->lastServerMailCount << "\n"; 735 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit);
759 } else { 736 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount);
760 t << "Synchronize: No\n"; 737 }
738 else
739 {
740 mailconf->writeEntry("Synchronize", "No");
761 } 741 }
762 t << "SyncLimit: ";
763 t << accountPtr->syncLimit << "\n";
764 t << "accountEnd;\n";
765 } 742 }
766 f.close();
767 743
768 mailconf->setGroup("mailitglobal"); 744 mailconf->setGroup("mailitglobal");
745 mailconf->writeEntry("Accounts",acc_count);
769 mailconf->writeEntry("mailidcount", mailIdCount); 746 mailconf->writeEntry("mailidcount", mailIdCount);