-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 75 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.h | 3 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 16 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.h | 1 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/net/mailit/popclient.cpp | 80 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 28 |
7 files changed, 104 insertions, 125 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 23059cf..dff1888 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -341,49 +341,49 @@ void EmailClient::getAllNewMail() | |||
341 | getNewMail(); | 341 | getNewMail(); |
342 | } | 342 | } |
343 | 343 | ||
344 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 344 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
345 | { | 345 | { |
346 | Enclosure *ePtr; | 346 | Enclosure *ePtr; |
347 | Email newMail; | 347 | Email newMail; |
348 | int thisMailId; | 348 | int thisMailId; |
349 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 349 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
350 | mailconf->setGroup(newMail.id); | 350 | mailconf->setGroup(newMail.id); |
351 | 351 | ||
352 | if (fromDisk) | 352 | if (fromDisk) |
353 | { | 353 | { |
354 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 354 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
355 | newMail.size = mailconf->readNumEntry("size"); | 355 | newMail.size = mailconf->readNumEntry("size"); |
356 | newMail.serverId = mailconf->readNumEntry("serverid"); | 356 | newMail.serverId = mailconf->readNumEntry("serverid"); |
357 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 357 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
358 | } | 358 | } |
359 | else | 359 | else |
360 | { //mail arrived from server | 360 | { //mail arrived from server |
361 | newMail.serverId = mail.serverId; | 361 | newMail.serverId = mail.serverId; |
362 | newMail.size = mail.size; | 362 | newMail.size = mail.size; |
363 | newMail.downloaded = mail.downloaded; | 363 | newMail.downloaded = mail.downloaded; |
364 | 364 | ||
365 | newMail.fromAccountId = currentAccount->id; | 365 | newMail.fromAccountId = emailHandler->getAccount()->id; |
366 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 366 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
367 | } | 367 | } |
368 | 368 | ||
369 | //add if read or not | 369 | //add if read or not |
370 | newMail.read = mailconf->readBoolEntry("mailread"); | 370 | newMail.read = mailconf->readBoolEntry("mailread"); |
371 | 371 | ||
372 | //check if new mail | 372 | //check if new mail |
373 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 373 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
374 | thisMailId = mailIdCount; | 374 | thisMailId = mailIdCount; |
375 | mailIdCount++; | 375 | mailIdCount++; |
376 | 376 | ||
377 | //set server count, so that if the user aborts, the new | 377 | //set server count, so that if the user aborts, the new |
378 | //header is not reloaded | 378 | //header is not reloaded |
379 | if ((currentAccount)&&(currentAccount->synchronize)) | 379 | if ((currentAccount)&&(currentAccount->synchronize)) |
380 | currentAccount->lastServerMailCount++; | 380 | currentAccount->lastServerMailCount++; |
381 | 381 | ||
382 | mailconf->writeEntry("internalmailid", thisMailId); | 382 | mailconf->writeEntry("internalmailid", thisMailId); |
383 | mailconf->writeEntry("downloaded", newMail.downloaded); | 383 | mailconf->writeEntry("downloaded", newMail.downloaded); |
384 | mailconf->writeEntry("size", (int) newMail.size); | 384 | mailconf->writeEntry("size", (int) newMail.size); |
385 | mailconf->writeEntry("serverid", newMail.serverId); | 385 | mailconf->writeEntry("serverid", newMail.serverId); |
386 | 386 | ||
387 | //addressList->addContact(newMail.fromMail, newMail.from); | 387 | //addressList->addContact(newMail.fromMail, newMail.from); |
388 | } | 388 | } |
389 | 389 | ||
@@ -459,53 +459,53 @@ void EmailClient::allMailArrived(int count) | |||
459 | // not previewing means all mailtransfer has been done | 459 | // not previewing means all mailtransfer has been done |
460 | /*if (!previewingMail) {*/ | 460 | /*if (!previewingMail) {*/ |
461 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 461 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
462 | emit newCaption("Mailit - " + currentAccount->accountName); | 462 | emit newCaption("Mailit - " + currentAccount->accountName); |
463 | getNewMail(); | 463 | getNewMail(); |
464 | return; | 464 | return; |
465 | } else { | 465 | } else { |
466 | allAccounts = FALSE; | 466 | allAccounts = FALSE; |
467 | receiving = FALSE; | 467 | receiving = FALSE; |
468 | getMailButton->setEnabled(TRUE); | 468 | getMailButton->setEnabled(TRUE); |
469 | cancelButton->setEnabled(FALSE); | 469 | cancelButton->setEnabled(FALSE); |
470 | selectAccountMenu->setEnabled(TRUE); | 470 | selectAccountMenu->setEnabled(TRUE); |
471 | status1Label->setText("Idle"); | 471 | status1Label->setText("Idle"); |
472 | 472 | ||
473 | progressBar->reset(); | 473 | progressBar->reset(); |
474 | return; | 474 | return; |
475 | } | 475 | } |
476 | //} | 476 | //} |
477 | 477 | ||
478 | // all headers downloaded from server, start downloading remaining mails | 478 | // all headers downloaded from server, start downloading remaining mails |
479 | previewingMail = FALSE; | 479 | previewingMail = FALSE; |
480 | status1Label->setText(currentAccount->accountName); | 480 | status1Label->setText(currentAccount->accountName); |
481 | progressBar->reset(); | 481 | progressBar->reset(); |
482 | 482 | ||
483 | //emailHandler->getMailByList(&mailDownloadList); | 483 | |
484 | |||
485 | mailboxView->setCurrentTab(0); | 484 | mailboxView->setCurrentTab(0); |
486 | } | 485 | } |
487 | 486 | ||
487 | |||
488 | void EmailClient::moveMailFront(Email *mailPtr) | 488 | void EmailClient::moveMailFront(Email *mailPtr) |
489 | { | 489 | { |
490 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 490 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
491 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 491 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void EmailClient::smtpError(int code) | 495 | void EmailClient::smtpError(int code) |
496 | { | 496 | { |
497 | QString temp; | 497 | QString temp; |
498 | 498 | ||
499 | if (code == ErrUnknownResponse) | 499 | if (code == ErrUnknownResponse) |
500 | temp = "Unknown response from server"; | 500 | temp = "Unknown response from server"; |
501 | 501 | ||
502 | if (code == QSocket::ErrHostNotFound) | 502 | if (code == QSocket::ErrHostNotFound) |
503 | temp = "host not found"; | 503 | temp = "host not found"; |
504 | if (code == QSocket::ErrConnectionRefused) | 504 | if (code == QSocket::ErrConnectionRefused) |
505 | temp = "connection refused"; | 505 | temp = "connection refused"; |
506 | if (code == QSocket::ErrSocketRead) | 506 | if (code == QSocket::ErrSocketRead) |
507 | temp = "socket packet error"; | 507 | temp = "socket packet error"; |
508 | 508 | ||
509 | if (code != ErrCancel) { | 509 | if (code != ErrCancel) { |
510 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 510 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
511 | } else { | 511 | } else { |
@@ -643,49 +643,49 @@ void EmailClient::saveMail(QString fileName, QListView *view) | |||
643 | //paths for mailit, is settings, inbox, enclosures | 643 | //paths for mailit, is settings, inbox, enclosures |
644 | QString EmailClient::getPath(bool enclosurePath) | 644 | QString EmailClient::getPath(bool enclosurePath) |
645 | { | 645 | { |
646 | QString basePath = "qtmail"; | 646 | QString basePath = "qtmail"; |
647 | QString enclosures = "enclosures"; | 647 | QString enclosures = "enclosures"; |
648 | 648 | ||
649 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 649 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
650 | if ( !dir.exists() ) | 650 | if ( !dir.exists() ) |
651 | dir.mkdir( dir.path() ); | 651 | dir.mkdir( dir.path() ); |
652 | 652 | ||
653 | if (enclosurePath) { | 653 | if (enclosurePath) { |
654 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 654 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
655 | 655 | ||
656 | if ( !dir.exists() ) | 656 | if ( !dir.exists() ) |
657 | dir.mkdir( dir.path() ); | 657 | dir.mkdir( dir.path() ); |
658 | 658 | ||
659 | return (dir.path() + "/"); | 659 | return (dir.path() + "/"); |
660 | 660 | ||
661 | } | 661 | } |
662 | return (dir.path() + "/"); | 662 | return (dir.path() + "/"); |
663 | } | 663 | } |
664 | 664 | ||
665 | void EmailClient::readSettings() | 665 | void EmailClient::readSettings() |
666 | { | 666 | { |
667 | int y,acc_count, accountPos=0; | 667 | int y,acc_count; |
668 | 668 | ||
669 | mailconf->setGroup("mailitglobal"); | 669 | mailconf->setGroup("mailitglobal"); |
670 | acc_count=mailconf->readNumEntry("Accounts",0); | 670 | acc_count=mailconf->readNumEntry("Accounts",0); |
671 | 671 | ||
672 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) | 672 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) |
673 | { | 673 | { |
674 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... | 674 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... |
675 | account.accountName = mailconf->readEntry("AccName",""); | 675 | account.accountName = mailconf->readEntry("AccName",""); |
676 | account.name = mailconf->readEntry("UserName",""); | 676 | account.name = mailconf->readEntry("UserName",""); |
677 | account.emailAddress = mailconf->readEntry("Email",""); | 677 | account.emailAddress = mailconf->readEntry("Email",""); |
678 | account.popUserName = mailconf->readEntry("POPUser",""); | 678 | account.popUserName = mailconf->readEntry("POPUser",""); |
679 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); | 679 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); |
680 | account.popServer = mailconf->readEntry("POPServer",""); | 680 | account.popServer = mailconf->readEntry("POPServer",""); |
681 | account.smtpServer = mailconf->readEntry("SMTPServer",""); | 681 | account.smtpServer = mailconf->readEntry("SMTPServer",""); |
682 | account.id = mailconf->readNumEntry("AccountId",0); | 682 | account.id = mailconf->readNumEntry("AccountId",0); |
683 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); | 683 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); |
684 | account.lastServerMailCount = 0; | 684 | account.lastServerMailCount = 0; |
685 | account.synchronize = FALSE; | 685 | account.synchronize = FALSE; |
686 | 686 | ||
687 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); | 687 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); |
688 | if (account.synchronize) | 688 | if (account.synchronize) |
689 | { | 689 | { |
690 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); | 690 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); |
691 | } | 691 | } |
@@ -870,112 +870,99 @@ void EmailClient::setMailSize(int size) | |||
870 | { | 870 | { |
871 | progressBar->reset(); | 871 | progressBar->reset(); |
872 | progressBar->setTotalSteps(size); | 872 | progressBar->setTotalSteps(size); |
873 | } | 873 | } |
874 | 874 | ||
875 | void EmailClient::setTotalSize(int size) | 875 | void EmailClient::setTotalSize(int size) |
876 | { | 876 | { |
877 | 877 | ||
878 | } | 878 | } |
879 | 879 | ||
880 | void EmailClient::setDownloadedSize(int size) | 880 | void EmailClient::setDownloadedSize(int size) |
881 | { | 881 | { |
882 | int total = progressBar->totalSteps(); | 882 | int total = progressBar->totalSteps(); |
883 | 883 | ||
884 | if (size < total) { | 884 | if (size < total) { |
885 | progressBar->setProgress(size); | 885 | progressBar->setProgress(size); |
886 | } else { | 886 | } else { |
887 | progressBar->setProgress(total); | 887 | progressBar->setProgress(total); |
888 | } | 888 | } |
889 | } | 889 | } |
890 | 890 | ||
891 | void EmailClient::deleteItem() | 891 | void EmailClient::deleteItem() |
892 | { | 892 | { |
893 | bool inbox=mailboxView->currentTab()==0; | 893 | bool inbox=mailboxView->currentTab()==0; |
894 | QListView* box; | ||
894 | 895 | ||
895 | EmailListItem* eli; | 896 | EmailListItem* eli; |
897 | int pos; | ||
898 | |||
899 | inbox ? box=inboxView : box=outboxView; | ||
896 | 900 | ||
897 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); | 901 | eli=(EmailListItem*)box->selectedItem(); |
898 | 902 | ||
899 | if (eli) | 903 | if (eli) |
900 | deleteMail(eli,(bool&)inbox); | 904 | { |
905 | box->setSelected(eli->itemBelow(),true);//select the previous item | ||
906 | |||
907 | deleteMail(eli,(bool&)inbox); //remove mail entry | ||
908 | } | ||
901 | } | 909 | } |
902 | 910 | ||
903 | void EmailClient::inboxItemPressed() | 911 | void EmailClient::inboxItemPressed() |
904 | { | 912 | { |
905 | //timerID=startTimer(500); | 913 | //timerID=startTimer(500); |
906 | } | 914 | } |
907 | 915 | ||
908 | void EmailClient::inboxItemReleased() | 916 | void EmailClient::inboxItemReleased() |
909 | { | 917 | { |
910 | //killTimer(timerID); | 918 | //killTimer(timerID); |
911 | } | 919 | } |
912 | 920 | ||
913 | void EmailClient::timerEvent(QTimerEvent *e) | 921 | void EmailClient::timerEvent(QTimerEvent *e) |
914 | { | 922 | { |
915 | /*killTimer(timerID); | 923 | /*killTimer(timerID); |
916 | 924 | ||
917 | 925 | ||
918 | QPopupMenu *action = new QPopupMenu(this); | 926 | QPopupMenu *action = new QPopupMenu(this); |
919 | 927 | ||
920 | int reply=0; | 928 | int reply=0; |
921 | 929 | ||
922 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | 930 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); |
923 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | 931 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); |
924 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | 932 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); |
925 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | 933 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); |
926 | 934 | ||
927 | action->exec(QCursor::pos()); | 935 | action->exec(QCursor::pos()); |
928 | 936 | ||
929 | if (action) delete action; | 937 | if (action) delete action; |
930 | */ | 938 | */ |
931 | } | 939 | } |
932 | 940 | ||
933 | Email* EmailClient::getCurrentMail() | 941 | Email* EmailClient::getCurrentMail() |
934 | { | 942 | { |
935 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 943 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
936 | if (eli!=NULL) | 944 | if (eli!=NULL) |
937 | return eli->getMail(); | 945 | return eli->getMail(); |
938 | else | 946 | else |
939 | return NULL; | 947 | return NULL; |
940 | } | 948 | } |
941 | 949 | ||
942 | /* | 950 | void EmailClient::download(Email* mail) |
943 | void EmailClient::reply() | ||
944 | { | ||
945 | Email* mail=getCurrentMail(); | ||
946 | |||
947 | if (mail!=NULL) | ||
948 | { | ||
949 | emit reply(*mail); | ||
950 | } | ||
951 | } | ||
952 | |||
953 | void EmailClient::replyAll() | ||
954 | { | ||
955 | Email* mail=getCurrentMail(); | ||
956 | |||
957 | if (mail!=NULL) | ||
958 | { | ||
959 | emit replyAll(*mail); | ||
960 | } | ||
961 | } | ||
962 | |||
963 | void EmailClient::forward() | ||
964 | { | 951 | { |
965 | Email* mail=getCurrentMail(); | 952 | MailAccount* acc=0; |
966 | 953 | ||
967 | if (mail!=NULL) | 954 | tempMailDownloadList.clear(); |
968 | { | 955 | tempMailDownloadList.sizeInsert(mail->serverId, mail->size); |
969 | emit reply(*mail); | 956 | if (accountList.count()>0) |
970 | } | 957 | qDebug("Accounts present"); |
958 | |||
959 | acc=accountList.at(mail->fromAccountId-1); | ||
960 | if (acc) | ||
961 | { | ||
962 | emailHandler->setAccount(*acc); | ||
963 | emailHandler->getMailByList(&tempMailDownloadList); | ||
964 | } | ||
965 | else | ||
966 | QMessageBox::warning(qApp->activeWindow(), | ||
967 | tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); | ||
971 | } | 968 | } |
972 | |||
973 | void EmailClient::remove() | ||
974 | { | ||
975 | Email* mail=getCurrentMail(); | ||
976 | |||
977 | if (mail!=NULL) | ||
978 | { | ||
979 | emit remove(*mail); | ||
980 | } | ||
981 | }*/ | ||
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h index 0890dcf..549683b 100644 --- a/noncore/net/mailit/emailclient.h +++ b/noncore/net/mailit/emailclient.h | |||
@@ -49,48 +49,49 @@ | |||
49 | #include "editaccount.h" | 49 | #include "editaccount.h" |
50 | #include "maillist.h" | 50 | #include "maillist.h" |
51 | #include "addresslist.h" | 51 | #include "addresslist.h" |
52 | 52 | ||
53 | #include <qpe/config.h> | 53 | #include <qpe/config.h> |
54 | 54 | ||
55 | class AccountList : public QList<MailAccount> | 55 | class AccountList : public QList<MailAccount> |
56 | { | 56 | { |
57 | public: | 57 | public: |
58 | Item newItem(Item d); | 58 | Item newItem(Item d); |
59 | private: | 59 | private: |
60 | MailAccount* dupl(MailAccount *in); | 60 | MailAccount* dupl(MailAccount *in); |
61 | MailAccount *ac; | 61 | MailAccount *ac; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | //class EmailClient : public EmailClientBase | 64 | //class EmailClient : public EmailClientBase |
65 | class EmailClient : public QMainWindow | 65 | class EmailClient : public QMainWindow |
66 | { | 66 | { |
67 | Q_OBJECT | 67 | Q_OBJECT |
68 | 68 | ||
69 | public: | 69 | public: |
70 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); | 70 | EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); |
71 | ~EmailClient(); | 71 | ~EmailClient(); |
72 | AddressList* getAdrListRef(); | 72 | AddressList* getAdrListRef(); |
73 | void download(Email*); | ||
73 | 74 | ||
74 | protected: | 75 | protected: |
75 | void timerEvent(QTimerEvent*); | 76 | void timerEvent(QTimerEvent*); |
76 | 77 | ||
77 | signals: | 78 | signals: |
78 | void composeRequested(); | 79 | void composeRequested(); |
79 | void viewEmail(QListView *, Email *); | 80 | void viewEmail(QListView *, Email *); |
80 | void mailUpdated(Email *); | 81 | void mailUpdated(Email *); |
81 | void newCaption(const QString &); | 82 | void newCaption(const QString &); |
82 | void replyRequested(Email&, bool&); | 83 | void replyRequested(Email&, bool&); |
83 | void forwardRequested(Email&); | 84 | void forwardRequested(Email&); |
84 | void removeItem(EmailListItem*, bool&); | 85 | void removeItem(EmailListItem*, bool&); |
85 | /*void reply(Email&); | 86 | /*void reply(Email&); |
86 | void replyAll(Email&); | 87 | void replyAll(Email&); |
87 | void remove(Email&); | 88 | void remove(Email&); |
88 | void forward(Email&);*/ | 89 | void forward(Email&);*/ |
89 | 90 | ||
90 | public slots: | 91 | public slots: |
91 | void compose(); | 92 | void compose(); |
92 | void cancel(); | 93 | void cancel(); |
93 | void enqueMail(const Email &mail); | 94 | void enqueMail(const Email &mail); |
94 | void setMailAccount(); | 95 | void setMailAccount(); |
95 | void sendQuedMail(); | 96 | void sendQuedMail(); |
96 | void mailSent(); | 97 | void mailSent(); |
@@ -118,48 +119,50 @@ public slots: | |||
118 | /* void reply(); | 119 | /* void reply(); |
119 | void replyAll(); | 120 | void replyAll(); |
120 | void forward(); | 121 | void forward(); |
121 | void remove();*/ | 122 | void remove();*/ |
122 | 123 | ||
123 | private: | 124 | private: |
124 | void init(); | 125 | void init(); |
125 | void readMail(); | 126 | void readMail(); |
126 | QString getPath(bool enclosurePath); | 127 | QString getPath(bool enclosurePath); |
127 | void readSettings(); | 128 | void readSettings(); |
128 | void saveSettings(); | 129 | void saveSettings(); |
129 | Email* getCurrentMail(); | 130 | Email* getCurrentMail(); |
130 | int timerID; | 131 | int timerID; |
131 | Config *mailconf; | 132 | Config *mailconf; |
132 | int newAccountId, idCount, mailIdCount; | 133 | int newAccountId, idCount, mailIdCount; |
133 | int accountIdCount; | 134 | int accountIdCount; |
134 | AccountList accountList; | 135 | AccountList accountList; |
135 | AddressList *addressList; | 136 | AddressList *addressList; |
136 | 137 | ||
137 | EditAccount *editAccountView; | 138 | EditAccount *editAccountView; |
138 | EmailListItem *item; | 139 | EmailListItem *item; |
139 | EmailHandler *emailHandler; | 140 | EmailHandler *emailHandler; |
140 | QList<Email> quedMessages; | 141 | QList<Email> quedMessages; |
141 | MailList mailDownloadList; | 142 | MailList mailDownloadList; |
143 | MailList tempMailDownloadList; | ||
144 | |||
142 | bool sending, receiving, previewingMail, allAccounts; | 145 | bool sending, receiving, previewingMail, allAccounts; |
143 | QString lineShift; | 146 | QString lineShift; |
144 | MailAccount account, *currentAccount; | 147 | MailAccount account, *currentAccount; |
145 | 148 | ||
146 | QToolBar *bar; | 149 | QToolBar *bar; |
147 | QProgressBar *progressBar; | 150 | QProgressBar *progressBar; |
148 | QStatusBar *statusBar; | 151 | QStatusBar *statusBar; |
149 | QLabel *status1Label, *status2Label; | 152 | QLabel *status1Label, *status2Label; |
150 | QToolButton *getMailButton; | 153 | QToolButton *getMailButton; |
151 | QAction *sendMailButton; | 154 | QAction *sendMailButton; |
152 | QAction *composeButton; | 155 | QAction *composeButton; |
153 | QAction *cancelButton; | 156 | QAction *cancelButton; |
154 | QAction *deleteButton; | 157 | QAction *deleteButton; |
155 | //QToolButton *setAccountButton; | 158 | //QToolButton *setAccountButton; |
156 | 159 | ||
157 | QMenuBar *mb; | 160 | QMenuBar *mb; |
158 | QPopupMenu *selectAccountMenu; | 161 | QPopupMenu *selectAccountMenu; |
159 | QPopupMenu *editAccountMenu; | 162 | QPopupMenu *editAccountMenu; |
160 | QPopupMenu *deleteAccountMenu; | 163 | QPopupMenu *deleteAccountMenu; |
161 | QPopupMenu *setAccountMenu; | 164 | QPopupMenu *setAccountMenu; |
162 | 165 | ||
163 | OTabWidget* mailboxView; | 166 | OTabWidget* mailboxView; |
164 | QListView* inboxView; | 167 | QListView* inboxView; |
165 | QListView* outboxView; | 168 | QListView* outboxView; |
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index b180051..fbbada7 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -106,110 +106,110 @@ void EmailHandler::getMail() | |||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | //popClient->headersOnly(headers, 0); | 107 | //popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); | 114 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
115 | 115 | ||
116 | headers = TRUE; | 116 | headers = TRUE; |
117 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 117 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
118 | popClient->newConnection(mailAccount.popServer, 110); | 118 | popClient->newConnection(mailAccount.popServer, 110); |
119 | } | 119 | } |
120 | 120 | ||
121 | void EmailHandler::getMailByList(MailList *mailList) | 121 | void EmailHandler::getMailByList(MailList *mailList) |
122 | { | 122 | { |
123 | if (mailList->count() == 0) { //should not occur though | 123 | if (mailList->count() == 0) { //should not occur though |
124 | emit mailTransfered(0); | 124 | emit mailTransfered(0); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | headers = FALSE; | 128 | headers = FALSE; |
129 | popClient->headersOnly(FALSE, 0); | 129 | popClient->headersOnly(FALSE, 0); |
130 | popClient->newConnection(mailAccount.popServer, 110); | 130 | |
131 | popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); | ||
131 | popClient->setSelectedMails(mailList); | 132 | popClient->setSelectedMails(mailList); |
132 | } | 133 | popClient->newConnection(mailAccount.popServer, 110); |
134 | } | ||
133 | 135 | ||
134 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete) | 136 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
135 | { | 137 | { |
136 | Email mail; | 138 | Email mail; |
137 | 139 | ||
138 | mail.rawMail = message; | 140 | mail.rawMail = message; |
139 | mail.serverId = id; | 141 | mail.serverId = id; |
140 | mail.size = size; | 142 | mail.size = size; |
141 | mail.downloaded = incomplete; | 143 | mail.downloaded = complete; |
142 | 144 | ||
143 | emit mailArrived(mail, FALSE); | 145 | emit mailArrived(mail, FALSE); |
144 | } | 146 | } |
145 | 147 | ||
146 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 148 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
147 | { | 149 | { |
148 | QString temp, boundary; | 150 | QString temp, boundary; |
149 | int pos; | 151 | int pos; |
150 | QString delimiter, header, body, mimeHeader, mimeBody; | 152 | QString delimiter, header, body, mimeHeader, mimeBody; |
151 | QString content, contentType, contentAttribute, id, encoding; | 153 | QString content, contentType, contentAttribute, id, encoding; |
152 | QString fileName, storedName; | 154 | QString fileName, storedName; |
153 | int enclosureId = 0; | 155 | int enclosureId = 0; |
154 | 156 | ||
155 | mail->rawMail = in; | 157 | mail->rawMail = in; |
156 | mail->received = TRUE; | 158 | mail->received = TRUE; |
157 | mail->files.setAutoDelete(TRUE); | 159 | mail->files.setAutoDelete(TRUE); |
158 | 160 | ||
159 | temp = lineShift + "." + lineShift; | 161 | temp = lineShift + "." + lineShift; |
160 | 162 | ||
161 | if (in.right(temp.length()) != temp) { | 163 | if (in.right(temp.length()) != temp) { |
162 | mail->rawMail += temp; | 164 | mail->rawMail += temp; |
163 | } | 165 | } |
164 | 166 | ||
165 | 167 | ||
166 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 168 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
167 | pos = in.find(delimiter, 0, FALSE); | 169 | pos = in.find(delimiter, 0, FALSE); |
168 | header = in.left(pos); | 170 | header = in.left(pos); |
169 | body = in.right(in.length() - pos - delimiter.length()); | 171 | body = in.right(in.length() - pos - delimiter.length()); |
170 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 172 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
171 | body.truncate(body.length()-2); | 173 | body.truncate(body.length()-2); |
172 | 174 | ||
173 | TextParser p(header, lineShift); | 175 | TextParser p(header, lineShift); |
174 | 176 | ||
175 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 177 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
176 | pos++; | 178 | pos++; |
177 | if (p.separatorAt(pos) == ' ') { | 179 | if (p.separatorAt(pos) == ' ') { |
178 | mail->from = p.getString(&pos, '<', false); | 180 | mail->from = p.getString(&pos, '<', false); |
179 | mail->from = mail->from.stripWhiteSpace(); | 181 | mail->from = mail->from.stripWhiteSpace(); |
180 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 182 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
181 | mail->from = mail->from.left(mail->from.length() - 1); | 183 | mail->from = mail->from.left(mail->from.length() - 1); |
182 | mail->from = mail->from.right(mail->from.length() - 1); | 184 | mail->from = mail->from.right(mail->from.length() - 1); |
183 | } | 185 | } |
184 | pos++; | 186 | pos++; |
185 | |||
186 | mail->fromMail = p.getString(&pos, '>', false); | 187 | mail->fromMail = p.getString(&pos, '>', false); |
187 | } else { | 188 | } else { |
188 | if ((p.separatorAt(pos) == '<') | 189 | if (p.separatorAt(pos) == '<') //No name.. nasty |
189 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | ||
190 | pos++; | ||
191 | pos++; | 190 | pos++; |
191 | //pos++; | ||
192 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 192 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
193 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 193 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
194 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 194 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
195 | mail->from=mail->fromMail; | 195 | mail->from=mail->fromMail; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | pos=0; | 199 | pos=0; |
200 | 200 | ||
201 | //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: | 201 | //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: |
202 | while((pos = p.find("TO",':', pos+1, TRUE))!=-1) | 202 | while((pos = p.find("TO",':', pos+1, TRUE))!=-1) |
203 | { | 203 | { |
204 | QString rec; | 204 | QString rec; |
205 | 205 | ||
206 | if (p.separatorAt(pos-1)!='-') | 206 | if (p.separatorAt(pos-1)!='-') |
207 | { | 207 | { |
208 | pos++; | 208 | pos++; |
209 | mail->recipients.append(p.getString(&pos, '\r', TRUE)); | 209 | mail->recipients.append(p.getString(&pos, '\r', TRUE)); |
210 | } | 210 | } |
211 | /*else { | 211 | /*else { |
212 | if ((p.separatorAt(pos) == '<')|| (p.separatorAt(pos) == ' ')) //No name.. nasty | 212 | if ((p.separatorAt(pos) == '<')|| (p.separatorAt(pos) == ' ')) //No name.. nasty |
213 | pos++; | 213 | pos++; |
214 | pos++; | 214 | pos++; |
215 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 215 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h index e47fd9a..b645868 100644 --- a/noncore/net/mailit/emailhandler.h +++ b/noncore/net/mailit/emailhandler.h | |||
@@ -90,48 +90,49 @@ struct MailAccount | |||
90 | QString name; | 90 | QString name; |
91 | QString emailAddress; | 91 | QString emailAddress; |
92 | QString popUserName; | 92 | QString popUserName; |
93 | QString popPasswd; | 93 | QString popPasswd; |
94 | QString popServer; | 94 | QString popServer; |
95 | QString smtpServer; | 95 | QString smtpServer; |
96 | bool synchronize; | 96 | bool synchronize; |
97 | int syncLimit; | 97 | int syncLimit; |
98 | int lastServerMailCount; | 98 | int lastServerMailCount; |
99 | int id; | 99 | int id; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | const int ErrUnknownResponse = 1001; | 102 | const int ErrUnknownResponse = 1001; |
103 | const int ErrLoginFailed = 1002; | 103 | const int ErrLoginFailed = 1002; |
104 | const int ErrCancel = 1003; | 104 | const int ErrCancel = 1003; |
105 | 105 | ||
106 | 106 | ||
107 | class EmailHandler : public QObject | 107 | class EmailHandler : public QObject |
108 | { | 108 | { |
109 | Q_OBJECT | 109 | Q_OBJECT |
110 | 110 | ||
111 | public: | 111 | public: |
112 | EmailHandler(); | 112 | EmailHandler(); |
113 | void setAccount(MailAccount account); | 113 | void setAccount(MailAccount account); |
114 | MailAccount* getAccount(){return &mailAccount;} | ||
114 | void sendMail(QList<Email> *mailList); | 115 | void sendMail(QList<Email> *mailList); |
115 | void getMail(); | 116 | void getMail(); |
116 | void getMailHeaders(); | 117 | void getMailHeaders(); |
117 | void getMailByList(MailList *mailList); | 118 | void getMailByList(MailList *mailList); |
118 | bool parse(QString in, QString lineShift, Email *mail); | 119 | bool parse(QString in, QString lineShift, Email *mail); |
119 | bool getEnclosure(Enclosure *ePtr); | 120 | bool getEnclosure(Enclosure *ePtr); |
120 | int parse64base(char *src, char *dest); | 121 | int parse64base(char *src, char *dest); |
121 | int encodeMime(Email *mail); | 122 | int encodeMime(Email *mail); |
122 | int encodeFile(QString fileName, QString *toBody); | 123 | int encodeFile(QString fileName, QString *toBody); |
123 | void encode64base(char *src, QString *dest, int len); | 124 | void encode64base(char *src, QString *dest, int len); |
124 | void cancel(); | 125 | void cancel(); |
125 | 126 | ||
126 | signals: | 127 | signals: |
127 | void mailSent(); | 128 | void mailSent(); |
128 | void smtpError(int); | 129 | void smtpError(int); |
129 | void popError(int); | 130 | void popError(int); |
130 | void mailArrived(const Email &, bool); | 131 | void mailArrived(const Email &, bool); |
131 | void updatePopStatus(const QString &); | 132 | void updatePopStatus(const QString &); |
132 | void updateSmtpStatus(const QString &); | 133 | void updateSmtpStatus(const QString &); |
133 | void mailTransfered(int); | 134 | void mailTransfered(int); |
134 | void mailboxSize(int); | 135 | void mailboxSize(int); |
135 | void currentMailSize(int); | 136 | void currentMailSize(int); |
136 | void downloadedSize(int); | 137 | void downloadedSize(int); |
137 | 138 | ||
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index 7181adf..ffee67e 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp | |||
@@ -1,139 +1,161 @@ | |||
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 <qwhatsthis.h> | 20 | #include <qwhatsthis.h> |
21 | #include <qmessagebox.h> | ||
21 | #include "mailitwindow.h" | 22 | #include "mailitwindow.h" |
22 | 23 | ||
23 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 24 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
24 | : QMainWindow(parent, name, WStyle_ContextHelp) | 25 | : QMainWindow(parent, name, WStyle_ContextHelp) |
25 | { | 26 | { |
26 | currentCaption = "Mailit"; | 27 | currentCaption = "Mailit"; |
27 | setCaption(tr(currentCaption)); | 28 | setCaption(tr(currentCaption)); |
28 | views = new QWidgetStack(this); | 29 | views = new QWidgetStack(this); |
29 | setCentralWidget(views); | 30 | setCentralWidget(views); |
30 | QWhatsThis::add(views,tr("Central view area")); | 31 | QWhatsThis::add(views,tr("Central view area")); |
31 | emailClient = new EmailClient(views, "client"); | 32 | emailClient = new EmailClient(views, "client"); |
32 | writeMail = new WriteMail(views, "writing"); | 33 | writeMail = new WriteMail(views, "writing"); |
33 | readMail = new ReadMail(views, "reading"); | 34 | readMail = new ReadMail(views, "reading"); |
34 | 35 | ||
35 | views->raiseWidget(emailClient); | 36 | views->raiseWidget(emailClient); |
36 | 37 | ||
37 | connect(emailClient, SIGNAL(composeRequested()), | 38 | connect(emailClient, SIGNAL(composeRequested()), |
38 | this, SLOT(compose()) ); | 39 | this, SLOT(compose()) ); |
39 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 40 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
40 | SLOT(viewMail(QListView *, Email *)) ); | 41 | SLOT(viewMail(QListView *, Email *)) ); |
41 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 42 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
42 | SLOT(updateMailView(Email *)) ); | 43 | SLOT(updateMailView(Email *)) ); |
43 | 44 | ||
44 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 45 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
45 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
46 | SLOT(showEmailClient()) ); | 47 | SLOT(showEmailClient()) ); |
47 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 48 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
48 | SLOT(enqueMail(const Email &)) ); | 49 | SLOT(enqueMail(const Email &)) ); |
49 | 50 | ||
50 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 51 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
51 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, | 52 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, |
52 | SLOT(composeReply(Email &, bool&)) ); | 53 | SLOT(composeReply(Email &, bool&)) ); |
53 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | 54 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, |
54 | SLOT(composeForward(Email &)) ); | 55 | SLOT(composeForward(Email &)) ); |
55 | 56 | ||
56 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 57 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
57 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 58 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
58 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 59 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
59 | SLOT(moveMailFront(Email *)) ); | 60 | SLOT(moveMailFront(Email *)) ); |
60 | 61 | ||
61 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 62 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
62 | this, SLOT(updateCaption(const QString &)) ); | 63 | this, SLOT(updateCaption(const QString &)) ); |
63 | viewingMail = FALSE; | 64 | viewingMail = FALSE; |
64 | |||
65 | } | 65 | } |
66 | 66 | ||
67 | MailItWindow::~MailItWindow() | 67 | MailItWindow::~MailItWindow() |
68 | { | 68 | { |
69 | } | 69 | } |
70 | 70 | ||
71 | void MailItWindow::closeEvent(QCloseEvent *e) | 71 | void MailItWindow::closeEvent(QCloseEvent *e) |
72 | { | 72 | { |
73 | if (views->visibleWidget() == emailClient) { | 73 | if (views->visibleWidget() == emailClient) { |
74 | e->accept(); | 74 | e->accept(); |
75 | } else { | 75 | } else { |
76 | showEmailClient(); | 76 | showEmailClient(); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void MailItWindow::compose() | 80 | void MailItWindow::compose() |
81 | { | 81 | { |
82 | viewingMail = FALSE; | 82 | viewingMail = FALSE; |
83 | emailClient->hide(); | 83 | emailClient->hide(); |
84 | readMail->hide(); | 84 | readMail->hide(); |
85 | views->raiseWidget(writeMail); | 85 | views->raiseWidget(writeMail); |
86 | writeMail->setAddressList(emailClient->getAdrListRef()); | 86 | writeMail->setAddressList(emailClient->getAdrListRef()); |
87 | writeMail->newMail(); | ||
87 | setCaption( tr( "Write mail" ) ); | 88 | setCaption( tr( "Write mail" ) ); |
88 | } | 89 | } |
89 | 90 | ||
90 | void MailItWindow::composeReply(Email &mail, bool& replyAll) | 91 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
91 | { | 92 | { |
92 | compose(); | 93 | compose(); |
93 | writeMail->reply(mail,replyAll) ; | 94 | writeMail->reply(mail,replyAll) ; |
94 | } | 95 | } |
95 | 96 | ||
96 | void MailItWindow::composeForward(Email &mail) | 97 | void MailItWindow::composeForward(Email &mail) |
97 | { | 98 | { |
98 | compose(); | 99 | compose(); |
99 | writeMail->forward(mail) ; | 100 | writeMail->forward(mail) ; |
100 | } | 101 | } |
101 | 102 | ||
102 | 103 | ||
103 | void MailItWindow::showEmailClient() | 104 | void MailItWindow::showEmailClient() |
104 | { | 105 | { |
105 | viewingMail = FALSE; | 106 | viewingMail = FALSE; |
106 | writeMail->hide(); | 107 | writeMail->hide(); |
107 | readMail->hide(); | 108 | readMail->hide(); |
108 | views->raiseWidget(emailClient); | 109 | views->raiseWidget(emailClient); |
109 | setCaption( tr(currentCaption) ); | 110 | setCaption( tr(currentCaption) ); |
110 | } | 111 | } |
111 | 112 | ||
112 | void MailItWindow::viewMail(QListView *view, Email *mail) | 113 | void MailItWindow::viewMail(QListView *view, Email *mail) |
113 | { | 114 | { |
114 | viewingMail = TRUE; | 115 | viewingMail = TRUE; |
115 | emailClient->hide(); | 116 | emailClient->hide(); |
117 | |||
118 | int result=0; | ||
119 | |||
120 | if ((mail->received)&&(!mail->downloaded)) | ||
121 | { | ||
122 | QMessageBox mb( tr("Mail not downloaded"), | ||
123 | tr("The mail you have clicked \n" | ||
124 | "has not been downloaded yet.\n " | ||
125 | "Would you like to do it now ?"), | ||
126 | QMessageBox::Information, | ||
127 | QMessageBox::Yes | QMessageBox::Default, | ||
128 | QMessageBox::No | QMessageBox::Escape,0 ); | ||
129 | |||
130 | result=mb.exec(); | ||
131 | |||
132 | if (result==QMessageBox::Yes) | ||
133 | { | ||
134 | emailClient->download(mail); | ||
135 | } | ||
136 | } | ||
137 | |||
116 | readMail->update(view, mail); | 138 | readMail->update(view, mail); |
117 | views->raiseWidget(readMail); | 139 | views->raiseWidget(readMail); |
118 | setCaption( tr( "Examine mail" ) ); | 140 | setCaption( tr( "Examine mail" ) ); |
119 | } | 141 | } |
120 | 142 | ||
121 | void MailItWindow::updateMailView(Email *mail) | 143 | void MailItWindow::updateMailView(Email *mail) |
122 | { | 144 | { |
123 | if (viewingMail) { | 145 | if (viewingMail) { |
124 | readMail->mailUpdated(mail); | 146 | readMail->mailUpdated(mail); |
125 | } | 147 | } |
126 | } | 148 | } |
127 | 149 | ||
128 | void MailItWindow::updateCaption(const QString &newCaption) | 150 | void MailItWindow::updateCaption(const QString &newCaption) |
129 | { | 151 | { |
130 | currentCaption = newCaption; | 152 | currentCaption = newCaption; |
131 | setCaption(tr(currentCaption)); | 153 | setCaption(tr(currentCaption)); |
132 | } | 154 | } |
133 | 155 | ||
134 | void MailItWindow::setDocument(const QString &_address) | 156 | void MailItWindow::setDocument(const QString &_address) |
135 | { | 157 | { |
136 | // strip leading 'mailto:' | 158 | // strip leading 'mailto:' |
137 | QString address = _address; | 159 | QString address = _address; |
138 | if (address.startsWith("mailto:")) | 160 | if (address.startsWith("mailto:")) |
139 | address = address.mid(6); | 161 | address = address.mid(6); |
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp index 67306be..6105d09 100644 --- a/noncore/net/mailit/popclient.cpp +++ b/noncore/net/mailit/popclient.cpp | |||
@@ -39,49 +39,49 @@ PopClient::PopClient() | |||
39 | receiving = FALSE; | 39 | receiving = FALSE; |
40 | synchronize = FALSE; | 40 | synchronize = FALSE; |
41 | lastSync = 0; | 41 | lastSync = 0; |
42 | headerLimit = 0; | 42 | headerLimit = 0; |
43 | preview = FALSE; | 43 | preview = FALSE; |
44 | } | 44 | } |
45 | 45 | ||
46 | PopClient::~PopClient() | 46 | PopClient::~PopClient() |
47 | { | 47 | { |
48 | delete socket; | 48 | delete socket; |
49 | delete stream; | 49 | delete stream; |
50 | } | 50 | } |
51 | 51 | ||
52 | void PopClient::newConnection(QString target, int port) | 52 | void PopClient::newConnection(QString target, int port) |
53 | { | 53 | { |
54 | if (receiving) { | 54 | if (receiving) { |
55 | qWarning("socket in use, connection refused"); | 55 | qWarning("socket in use, connection refused"); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | status = Init; | 59 | status = Init; |
60 | 60 | ||
61 | socket->connectToHost(target, port); | 61 | socket->connectToHost(target, port); |
62 | receiving = TRUE; | 62 | receiving = TRUE; |
63 | selected = FALSE; | 63 | //selected = FALSE; |
64 | 64 | ||
65 | emit updateStatus("DNS lookup"); | 65 | emit updateStatus("DNS lookup"); |
66 | } | 66 | } |
67 | 67 | ||
68 | void PopClient::setAccount(QString popUser, QString popPasswd) | 68 | void PopClient::setAccount(QString popUser, QString popPasswd) |
69 | { | 69 | { |
70 | popUserName = popUser; | 70 | popUserName = popUser; |
71 | popPassword = popPasswd; | 71 | popPassword = popPasswd; |
72 | } | 72 | } |
73 | 73 | ||
74 | void PopClient::setSynchronize(int lastCount) | 74 | void PopClient::setSynchronize(int lastCount) |
75 | { | 75 | { |
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
@@ -163,205 +163,163 @@ void PopClient::incomingData() | |||
163 | case Stat: { | 163 | case Stat: { |
164 | if (response[0] == '+') { | 164 | if (response[0] == '+') { |
165 | *stream << "STAT" << "\r\n"; | 165 | *stream << "STAT" << "\r\n"; |
166 | status = Mcnt; | 166 | status = Mcnt; |
167 | } else errorHandling(ErrLoginFailed); | 167 | } else errorHandling(ErrLoginFailed); |
168 | break; | 168 | break; |
169 | } | 169 | } |
170 | //get count of messages, eg "+OK 4 900.." -> int 4 | 170 | //get count of messages, eg "+OK 4 900.." -> int 4 |
171 | case Mcnt: { | 171 | case Mcnt: { |
172 | if (response[0] == '+') { | 172 | if (response[0] == '+') { |
173 | temp = response.replace(0, 4, ""); | 173 | temp = response.replace(0, 4, ""); |
174 | int x = temp.find(" ", 0); | 174 | int x = temp.find(" ", 0); |
175 | temp.truncate((uint) x); | 175 | temp.truncate((uint) x); |
176 | newMessages = temp.toInt(); | 176 | newMessages = temp.toInt(); |
177 | messageCount = 1; | 177 | messageCount = 1; |
178 | status = List; | 178 | status = List; |
179 | 179 | ||
180 | if (synchronize) { | 180 | if (synchronize) { |
181 | //messages deleted from server, reload all | 181 | //messages deleted from server, reload all |
182 | if (newMessages < lastSync) | 182 | if (newMessages < lastSync) |
183 | lastSync = 0; | 183 | lastSync = 0; |
184 | messageCount = 1; | 184 | messageCount = 1; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (selected) { | 187 | if (selected) { |
188 | int *ptr = mailList->first(); | 188 | int *ptr = mailList->first(); |
189 | if (ptr != 0) { | 189 | if (ptr != 0) { |
190 | newMessages++; //to ensure no early jumpout | 190 | newMessages++; //to ensure no early jumpout |
191 | messageCount = *(mailList->first()); | 191 | messageCount = *ptr; |
192 | } else newMessages = 0; | 192 | } else newMessages = 0; |
193 | } | 193 | } |
194 | |||
194 | } else errorHandling(ErrUnknownResponse); | 195 | } else errorHandling(ErrUnknownResponse); |
195 | } | 196 | } |
196 | //Read message number x, count upwards to messageCount | 197 | //Read message number x, count upwards to messageCount |
197 | case List: { | 198 | case List: { |
198 | if (messageCount <= newMessages) { | 199 | if (messageCount <= newMessages) { |
199 | *stream << "LIST " << messageCount << "\r\n"; | 200 | *stream << "LIST " << messageCount << "\r\n"; |
200 | status = Size; | 201 | status = Size; |
201 | temp2.setNum(newMessages - lastSync); | 202 | temp2.setNum(newMessages - lastSync); |
202 | temp.setNum(messageCount - lastSync); | 203 | temp.setNum(messageCount - lastSync); |
203 | if (!selected) { | 204 | if (!selected) { |
204 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 205 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
205 | } else { | 206 | } else { |
206 | //completing a previously closed transfer | 207 | //completing a previously closed transfer |
207 | if ( (messageCount - lastSync) <= 0) { | 208 | /* if ( (messageCount - lastSync) <= 0) { |
208 | temp.setNum(messageCount); | 209 | temp.setNum(messageCount); |
209 | emit updateStatus(tr("Previous message ") + temp); | 210 | emit updateStatus(tr("Previous message ") + temp); |
210 | } else { | 211 | } else {*/ |
211 | emit updateStatus(tr("Completing message ") + temp); | 212 | emit updateStatus(tr("Completing message ") + temp); |
212 | } | 213 | //} |
213 | } | 214 | } |
214 | break; | 215 | break; |
215 | } else { | 216 | } else { |
216 | emit updateStatus(tr("No new Messages")); | 217 | emit updateStatus(tr("No new Messages")); |
217 | status = Quit; | 218 | status = Quit; |
218 | } | 219 | } |
219 | } | 220 | } |
220 | //get size of message, eg "500 characters in message.." -> int 500 | 221 | //get size of message, eg "500 characters in message.." -> int 500 |
221 | case Size: { | 222 | case Size: { |
222 | if (status != Quit) { //because of idiotic switch | 223 | if (status != Quit) { //because of idiotic switch |
223 | if (response[0] == '+') { | 224 | if (response[0] == '+') { |
224 | temp = response.replace(0, 4, ""); | 225 | temp = response.replace(0, 4, ""); |
225 | int x = temp.find(" ", 0); | 226 | int x = temp.find(" ", 0); |
226 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 227 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
227 | mailSize = temp.toInt(); | 228 | mailSize = temp.toInt(); |
228 | emit currentMailSize(mailSize); | 229 | emit currentMailSize(mailSize); |
229 | 230 | ||
230 | status = Retr; | 231 | status = Retr; |
231 | } else { | 232 | } else { |
232 | //qWarning(response); | 233 | //qWarning(response); |
233 | errorHandling(ErrUnknownResponse); | 234 | errorHandling(ErrUnknownResponse); |
234 | } | 235 | } |
235 | } | 236 | } |
236 | } | 237 | } |
237 | //Read message number x, count upwards to messageCount | 238 | //Read message number x, count upwards to messageCount |
238 | case Retr: { | 239 | case Retr: { |
239 | if (status != Quit) { | 240 | if (status != Quit) { |
240 | if (mailSize <= headerLimit) | 241 | if ((selected)||(mailSize <= headerLimit)) |
241 | { | 242 | { |
242 | *stream << "RETR " << messageCount << "\r\n"; | 243 | *stream << "RETR " << messageCount << "\r\n"; |
243 | } else { //only header | 244 | } else { //only header |
244 | *stream << "TOP " << messageCount << " 0\r\n"; | 245 | *stream << "TOP " << messageCount << " 0\r\n"; |
245 | } | 246 | } |
246 | messageCount++; | 247 | messageCount++; |
247 | status = Ignore; | 248 | status = Ignore; |
248 | break; | 249 | break; |
249 | } } | 250 | } } |
250 | case Ignore: { | 251 | case Ignore: { |
251 | if (status != Quit) { //because of idiotic switch | 252 | if (status != Quit) { //because of idiotic switch |
252 | if (response[0] == '+') { | 253 | if (response[0] == '+') { |
253 | message = ""; | 254 | message = ""; |
254 | status = Read; | 255 | status = Read; |
255 | if (!socket->canReadLine()) //sync. problems | 256 | if (!socket->canReadLine()) //sync. problems |
256 | break; | 257 | break; |
257 | response = socket->readLine(); | 258 | response = socket->readLine(); |
258 | } else errorHandling(ErrUnknownResponse); | 259 | } else errorHandling(ErrUnknownResponse); |
259 | } | 260 | } |
260 | } | 261 | } |
261 | //add all incoming lines to body. When size is reached, send | 262 | //add all incoming lines to body. When size is reached, send |
262 | //message, and go back to read new message | 263 | //message, and go back to read new message |
263 | case Read: { | 264 | case Read: { |
264 | if (status != Quit) { //because of idiotic switch | 265 | if (status != Quit) { //because of idiotic switch |
265 | message += response; | 266 | message += response; |
266 | while ( socket->canReadLine() ) { | 267 | while ( socket->canReadLine() ) { |
267 | response = socket->readLine(); | 268 | response = socket->readLine(); |
268 | message += response; | 269 | message += response; |
269 | } | 270 | } |
270 | emit downloadedSize(message.length()); | 271 | emit downloadedSize(message.length()); |
271 | int x = message.find("\r\n.\r\n",-5); | 272 | int x = message.find("\r\n.\r\n",-5); |
272 | if (x == -1) { | 273 | if (x == -1) { |
273 | break; | 274 | break; |
274 | } else { //message reach entire size | 275 | } else { //message reach entire size |
275 | //complete mail downloaded | 276 | |
276 | //if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 277 | if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active |
277 | if ( mailSize <= headerLimit) | ||
278 | { | 278 | { |
279 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 279 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
280 | } else { //incomplete mail downloaded | 280 | } else { //incomplete mail downloaded |
281 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 281 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
282 | } | 282 | } |
283 | if (messageCount > newMessages) //that was the last message | 283 | |
284 | if ((messageCount > newMessages)||(selected)) //last message ? | ||
285 | { | ||
284 | status = Quit; | 286 | status = Quit; |
285 | else { //ask for new message | ||
286 | if (selected) { //grab next from queue | 287 | if (selected) { //grab next from queue |
287 | int *ptr = mailList->next(); | ||
288 | if (ptr != 0) { | ||
289 | messageCount = *ptr; | ||
290 | *stream << "LIST " << messageCount << "\r\n"; | ||
291 | status = Size; | ||
292 | //completing a previously closed transfer | ||
293 | if ( (messageCount - lastSync) <= 0) { | ||
294 | temp.setNum(messageCount); | ||
295 | emit updateStatus(tr("Previous message ") + temp); | ||
296 | } else { | ||
297 | temp.setNum(messageCount - lastSync); | ||
298 | emit updateStatus(tr("Completing message ") + temp); | ||
299 | } | ||
300 | break; | ||
301 | } else { | ||
302 | newMessages--; | 288 | newMessages--; |
303 | status = Quit; | 289 | status = Quit; |
304 | } | 290 | } |
305 | } else { | 291 | } |
292 | else | ||
293 | { | ||
306 | *stream << "LIST " << messageCount << "\r\n"; | 294 | *stream << "LIST " << messageCount << "\r\n"; |
307 | status = Size; | 295 | status = Size; |
308 | temp2.setNum(newMessages - lastSync); | 296 | temp2.setNum(newMessages - lastSync); |
309 | temp.setNum(messageCount - lastSync); | 297 | temp.setNum(messageCount - lastSync); |
310 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 298 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
311 | 299 | ||
312 | break; | 300 | break; |
313 | } | 301 | } |
314 | } | 302 | } |
315 | } | 303 | } |
316 | if (status != Quit) | 304 | if (status != Quit) |
317 | break; | 305 | break; |
318 | } | ||
319 | } | 306 | } |
320 | case Quit: { | 307 | case Quit: { |
321 | *stream << "Quit\r\n"; | 308 | *stream << "Quit\r\n"; |
322 | status = Done; | 309 | status = Done; |
323 | int newM = newMessages - lastSync; | 310 | int newM = newMessages - lastSync; |
324 | if (newM > 0) { | 311 | if (newM > 0) { |
325 | temp.setNum(newM); | 312 | temp.setNum(newM); |
326 | emit updateStatus(temp + tr(" new messages")); | 313 | emit updateStatus(temp + tr(" new messages")); |
327 | } else { | 314 | } else { |
328 | emit updateStatus(tr("No new messages")); | 315 | emit updateStatus(tr("No new messages")); |
329 | } | 316 | } |
330 | 317 | ||
331 | socket->close(); | 318 | socket->close(); |
332 | receiving = FALSE; | 319 | receiving = FALSE; |
333 | emit mailTransfered(newM); | 320 | emit mailTransfered(newM); |
334 | break; | 321 | break; |
335 | } | 322 | } |
336 | } | 323 | } |
337 | 324 | ||
338 | } | 325 | } |
339 | |||
340 | // if( bAPOPAuthentication ) | ||
341 | // { | ||
342 | // if( m_strTimeStamp.IsEmpty() ) | ||
343 | // { | ||
344 | // SetLastError("Apop error!"); | ||
345 | // return false; | ||
346 | // } | ||
347 | // strMD5Source = m_strTimeStamp+pszPassword; | ||
348 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | ||
349 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | ||
350 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | ||
351 | // if(ret == SOCKET_ERROR) | ||
352 | // { | ||
353 | // SetLastError("Socket error!"); | ||
354 | // m_bSocketOK = false; | ||
355 | // m_bConnected = false; | ||
356 | // return false; | ||
357 | // } | ||
358 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) | ||
359 | // return false; | ||
360 | // if( 0 == strResult.Find('-' , 0) ) | ||
361 | // { | ||
362 | // SetLastError("Username or Password error!"); | ||
363 | // return false; | ||
364 | // } | ||
365 | // m_bConnected = true; | ||
366 | |||
367 | // } | ||
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 0336c83..dcf0c6e 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp | |||
@@ -102,74 +102,73 @@ void WriteMail::init() | |||
102 | grid->addWidget( ToolButton13_2, 1, 2 ); | 102 | grid->addWidget( ToolButton13_2, 1, 2 ); |
103 | 103 | ||
104 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 104 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
105 | grid->addWidget( subjectInput, 1, 1 ); | 105 | grid->addWidget( subjectInput, 1, 1 ); |
106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); | 106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); |
107 | 107 | ||
108 | toInput = new QLineEdit( widget, "toInput" ); | 108 | toInput = new QLineEdit( widget, "toInput" ); |
109 | grid->addWidget( toInput, 0, 1 ); | 109 | grid->addWidget( toInput, 0, 1 ); |
110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); | 110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); |
111 | 111 | ||
112 | ccInput = new QLineEdit( widget, "ccInput" ); | 112 | ccInput = new QLineEdit( widget, "ccInput" ); |
113 | ccInput->hide(); | 113 | ccInput->hide(); |
114 | grid->addWidget( ccInput, 0, 1 ); | 114 | grid->addWidget( ccInput, 0, 1 ); |
115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); | 115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); |
116 | 116 | ||
117 | addressButton = new QToolButton( widget, "addressButton" ); | 117 | addressButton = new QToolButton( widget, "addressButton" ); |
118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
119 | addressButton->setToggleButton(TRUE); | 119 | addressButton->setToggleButton(TRUE); |
120 | grid->addWidget( addressButton, 0, 2 ); | 120 | grid->addWidget( addressButton, 0, 2 ); |
121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); | 122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); |
123 | 123 | ||
124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
126 | QWhatsThis::add(recipientsBox,QWidget::tr("Enter your mail text here")); | 126 | QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); |
127 | 127 | ||
128 | addressView = new QListView( widget, "addressView"); | 128 | addressView = new QListView( widget, "addressView"); |
129 | addressView->addColumn("Name"); | 129 | addressView->addColumn("Name"); |
130 | addressView->addColumn("EMail"); | 130 | addressView->addColumn("EMail"); |
131 | addressView->setAllColumnsShowFocus(TRUE); | 131 | addressView->setAllColumnsShowFocus(TRUE); |
132 | addressView->setMultiSelection(TRUE); | 132 | addressView->setMultiSelection(TRUE); |
133 | addressView->hide(); | 133 | addressView->hide(); |
134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
135 | QWhatsThis::add(recipientsBox,QWidget::tr("Chose the recipients from this list")); | 135 | QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); |
136 | 136 | ||
137 | okButton = new QToolButton(bar, "ok"); | 137 | okButton = new QToolButton(bar, "ok"); |
138 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 138 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
139 | okButton->hide(); | 139 | okButton->hide(); |
140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); | 141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); |
142 | 142 | ||
143 | setCentralWidget(widget); | 143 | setCentralWidget(widget); |
144 | } | 144 | } |
145 | 145 | ||
146 | void WriteMail::reject() | 146 | void WriteMail::reject() |
147 | { | 147 | { |
148 | emit cancelMail(); | 148 | emit cancelMail(); |
149 | } | 149 | } |
150 | 150 | ||
151 | // need to insert date | ||
152 | void WriteMail::accept() | 151 | void WriteMail::accept() |
153 | { | 152 | { |
154 | QStringList attachedFiles, attachmentsType; | 153 | QStringList attachedFiles, attachmentsType; |
155 | int idCount = 0; | 154 | int idCount = 0; |
156 | 155 | ||
157 | if (toInput->text() == "") | 156 | if (toInput->text() == "") |
158 | { | 157 | { |
159 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | 158 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); |
160 | return; | 159 | return; |
161 | } | 160 | } |
162 | 161 | ||
163 | if (! getRecipients(false) ) | 162 | if (! getRecipients(false) ) |
164 | { | 163 | { |
165 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | 164 | QMessageBox::warning(this,tr("Incorrect recipient separator"), |
166 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 165 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
167 | return; | 166 | return; |
168 | } | 167 | } |
169 | 168 | ||
170 | if ((ccInput->text()!="") && (! getRecipients(true) )) | 169 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
171 | { | 170 | { |
172 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | 171 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), |
173 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 172 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
174 | return; | 173 | return; |
175 | } | 174 | } |
@@ -231,55 +230,66 @@ void WriteMail::accept() | |||
231 | void WriteMail::getAddress() | 230 | void WriteMail::getAddress() |
232 | { | 231 | { |
233 | showingAddressList = !showingAddressList; | 232 | showingAddressList = !showingAddressList; |
234 | 233 | ||
235 | if (showingAddressList) { | 234 | if (showingAddressList) { |
236 | emailInput->hide(); | 235 | emailInput->hide(); |
237 | addressView->show(); | 236 | addressView->show(); |
238 | okButton->show(); | 237 | okButton->show(); |
239 | 238 | ||
240 | } else { | 239 | } else { |
241 | addressView->hide(); | 240 | addressView->hide(); |
242 | okButton->hide(); | 241 | okButton->hide(); |
243 | emailInput->show(); | 242 | emailInput->show(); |
244 | } | 243 | } |
245 | } | 244 | } |
246 | 245 | ||
247 | void WriteMail::attachFile() | 246 | void WriteMail::attachFile() |
248 | { | 247 | { |
249 | addAtt->showMaximized(); | 248 | addAtt->showMaximized(); |
250 | } | 249 | } |
251 | 250 | ||
252 | void WriteMail::reply(Email replyMail, bool replyAll) | 251 | void WriteMail::reply(Email replyMail, bool replyAll) |
253 | { | 252 | { |
254 | int pos; | 253 | int pos; |
254 | QString ccRecipients; | ||
255 | 255 | ||
256 | mail = replyMail; | 256 | mail = replyMail; |
257 | mail.files.clear(); | 257 | mail.files.clear(); |
258 | 258 | ||
259 | toInput->setText(mail.fromMail); | 259 | toInput->setText(mail.fromMail); |
260 | //replyAll ? ccInput->setText(mail.c) | ||
261 | 260 | ||
261 | if (replyAll) | ||
262 | { | ||
263 | for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) | ||
264 | { | ||
265 | ccRecipients.append(*it); | ||
266 | ccRecipients.append(";"); | ||
267 | } | ||
268 | ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end | ||
269 | ccInput->setText(ccRecipients); | ||
270 | } | ||
271 | |||
262 | addRecipients(replyAll); | 272 | addRecipients(replyAll); |
263 | 273 | ||
264 | subjectInput->setText(tr("Re: ") + mail.subject); | 274 | subjectInput->setText(tr("Re: ") + mail.subject); |
265 | 275 | ||
266 | pos = 0; | 276 | pos = 0; |
267 | mail.body.insert(pos, ">"); | 277 | mail.body.insert(pos, ">"); |
268 | while (pos != -1) { | 278 | while (pos != -1) { |
269 | pos = mail.body.find('\n', pos); | 279 | pos = mail.body.find('\n', pos); |
270 | if (pos != -1) | 280 | if (pos != -1) |
271 | mail.body.insert(++pos, ">>"); | 281 | mail.body.insert(++pos, ">>"); |
272 | } | 282 | } |
273 | 283 | ||
274 | emailInput->setText(mail.body); | 284 | emailInput->setText(mail.body); |
275 | } | 285 | } |
276 | 286 | ||
277 | void WriteMail::forward(Email forwMail) | 287 | void WriteMail::forward(Email forwMail) |
278 | { | 288 | { |
279 | int pos=0; | 289 | int pos=0; |
280 | 290 | ||
281 | QString fwdBody=tr("======forwarded message from "); | 291 | QString fwdBody=tr("======forwarded message from "); |
282 | fwdBody.append(forwMail.fromMail); | 292 | fwdBody.append(forwMail.fromMail); |
283 | fwdBody.append(tr(" starts======\n\n")); | 293 | fwdBody.append(tr(" starts======\n\n")); |
284 | 294 | ||
285 | mail=forwMail; | 295 | mail=forwMail; |
@@ -300,82 +310,80 @@ bool WriteMail::getRecipients(bool ccField) | |||
300 | 310 | ||
301 | mail.recipients.clear(); | 311 | mail.recipients.clear(); |
302 | 312 | ||
303 | ccField ? temp = ccInput->text() : temp=toInput->text() ; | 313 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
304 | 314 | ||
305 | while ( (pos = temp.find(';')) != -1) { | 315 | while ( (pos = temp.find(';')) != -1) { |
306 | str = temp.left(pos).stripWhiteSpace(); | 316 | str = temp.left(pos).stripWhiteSpace(); |
307 | temp = temp.right(temp.length() - (pos + 1)); | 317 | temp = temp.right(temp.length() - (pos + 1)); |
308 | if ( str.find('@') == -1) | 318 | if ( str.find('@') == -1) |
309 | return false; | 319 | return false; |
310 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); | 320 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
311 | addressList->addContact(str, ""); | 321 | addressList->addContact(str, ""); |
312 | } | 322 | } |
313 | temp = temp.stripWhiteSpace(); | 323 | temp = temp.stripWhiteSpace(); |
314 | if ( temp.find('@') == -1) | 324 | if ( temp.find('@') == -1) |
315 | return false; | 325 | return false; |
316 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); | 326 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
317 | addressList->addContact(temp, ""); | 327 | addressList->addContact(temp, ""); |
318 | 328 | ||
319 | return TRUE; | 329 | return TRUE; |
320 | } | 330 | } |
321 | 331 | ||
322 | void WriteMail::addRecipients() | 332 | void WriteMail::addRecipients() |
323 | { | 333 | { |
324 | 334 | toInput->isVisible() ? addRecipients(false) : addRecipients(true); | |
325 | addRecipients(false); | ||
326 | } | 335 | } |
327 | 336 | ||
328 | void WriteMail::addRecipients(bool ccField) | 337 | void WriteMail::addRecipients(bool ccField) |
329 | { | 338 | { |
330 | QString recipients = ""; | 339 | QString recipients = ""; |
331 | 340 | ||
332 | mail.recipients.clear(); | 341 | mail.recipients.clear(); |
333 | 342 | ||
334 | QListViewItem *item = addressView->firstChild(); | 343 | QListViewItem *item = addressView->firstChild(); |
335 | while (item != NULL) { | 344 | while (item != NULL) { |
336 | if ( item->isSelected() ) { | 345 | if ( item->isSelected() ) { |
337 | if (recipients == "") { | 346 | if (recipients == "") { |
338 | recipients = item->text(0); | 347 | recipients = item->text(1); |
339 | } else { | 348 | } else { |
340 | recipients += "; " + item->text(0); | 349 | recipients += "; " + item->text(1); |
341 | } | 350 | } |
342 | } | 351 | } |
343 | item = item->nextSibling(); | 352 | item = item->nextSibling(); |
344 | } | 353 | } |
345 | 354 | ||
346 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | 355 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); |
347 | 356 | ||
348 | addressView->hide(); | 357 | addressView->hide(); |
349 | okButton->hide(); | 358 | okButton->hide(); |
350 | emailInput->show(); | 359 | emailInput->show(); |
351 | addressButton->setOn(FALSE); | 360 | addressButton->setOn(FALSE); |
352 | showingAddressList = !showingAddressList; | 361 | showingAddressList = !showingAddressList; |
353 | } | 362 | } |
354 | 363 | ||
355 | void WriteMail::changeRecipients(int selection) | 364 | void WriteMail::changeRecipients(int selection) |
356 | { | 365 | { |
357 | if (selection==0) | 366 | if (selection==0) |
358 | { | 367 | { |
359 | toInput->show(); | 368 | toInput->show(); |
360 | ccInput->hide(); | 369 | ccInput->hide(); |
361 | } | 370 | } |
362 | else if (selection==1) | 371 | else if (selection==1) |
363 | { | 372 | { |
364 | toInput->hide(); | 373 | toInput->hide(); |
365 | ccInput->show(); | 374 | ccInput->show(); |
366 | } | 375 | } |
367 | } | 376 | } |
368 | 377 | ||
369 | void WriteMail::setRecipient(const QString &recipient) | 378 | void WriteMail::setRecipient(const QString &recipient) |
370 | { | 379 | { |
371 | toInput->setText(recipient); | 380 | toInput->setText(recipient); |
372 | } | 381 | } |
373 | 382 | ||
374 | void WriteMail::newMail() | 383 | void WriteMail::newMail() |
375 | { | 384 | { |
376 | toInput->clear(); | 385 | toInput->clear(); |
377 | subjectInput->clear(); | 386 | subjectInput->clear(); |
378 | emailInput->clear(); | 387 | emailInput->clear(); |
379 | //to clear selected | ||
380 | setAddressList(addressList); | 388 | setAddressList(addressList); |
381 | } | 389 | } |