summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/emailclient.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mailit/emailclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp73
1 files changed, 39 insertions, 34 deletions
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index da1226c..749a4e9 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -50,28 +50,28 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
50 receiving = FALSE; 50 receiving = FALSE;
51 previewingMail = FALSE; 51 previewingMail = FALSE;
52 mailIdCount = 1; 52 mailIdCount = 1;
53 accountIdCount = 1; 53 accountIdCount = 1;
54 allAccounts = FALSE; 54 allAccounts = FALSE;
55 55
56 init(); 56 init();
57 57
58 58
59 59
60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
61 61
62 connect(emailHandler, SIGNAL(smtpError(int)), this, 62 connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this,
63 SLOT(smtpError(int)) ); 63 SLOT(smtpError(int,const QString &)) );
64 connect(emailHandler, SIGNAL(popError(int)), this, 64 connect(emailHandler, SIGNAL(popError(int,const QString &)), this,
65 SLOT(popError(int)) ); 65 SLOT(popError(int,const QString &)) );
66 66
67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); 67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); 68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
69 69
70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); 70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) );
71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); 71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) );
72 72
73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
74 SLOT(mailArrived(const Email &, bool)) ); 74 SLOT(mailArrived(const Email &, bool)) );
75 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 75 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
76 SLOT(allMailArrived(int)) ); 76 SLOT(allMailArrived(int)) );
77 77
@@ -471,25 +471,25 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
471 } 471 }
472// if (item->getMail()->files.count()>0) 472// if (item->getMail()->files.count()>0)
473// { 473// {
474// item->setPixmap(0, Resource::loadPixmap("mailit/attach")); 474// item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475// } 475// }
476 /*if (!newMail.downloaded) 476 /*if (!newMail.downloaded)
477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ 477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
478 478
479 mailboxView->setCurrentTab(0); 479 mailboxView->setCurrentTab(0);
480 480
481} 481}
482 482
483void EmailClient::allMailArrived(int count) 483void EmailClient::allMailArrived(int /*count*/)
484{ 484{
485 // not previewing means all mailtransfer has been done 485 // not previewing means all mailtransfer has been done
486 /*if (!previewingMail) {*/ 486 /*if (!previewingMail) {*/
487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
488 emit newCaption("Mailit - " + currentAccount->accountName); 488 emit newCaption("Mailit - " + currentAccount->accountName);
489 getNewMail(); 489 getNewMail();
490 return; 490 return;
491 } else { 491 } else {
492 allAccounts = FALSE; 492 allAccounts = FALSE;
493 receiving = FALSE; 493 receiving = FALSE;
494 getMailButton->setEnabled(TRUE); 494 getMailButton->setEnabled(TRUE);
495 cancelButton->setEnabled(FALSE); 495 cancelButton->setEnabled(FALSE);
@@ -509,68 +509,73 @@ void EmailClient::allMailArrived(int count)
509 509
510 mailboxView->setCurrentTab(0); 510 mailboxView->setCurrentTab(0);
511} 511}
512 512
513 513
514void EmailClient::moveMailFront(Email *mailPtr) 514void EmailClient::moveMailFront(Email *mailPtr)
515{ 515{
516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); 517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
518 } 518 }
519} 519}
520 520
521void EmailClient::smtpError(int code) 521void EmailClient::smtpError(int code, const QString & Msg)
522{ 522{
523 QString temp; 523 QString temp;
524 524
525 if (code == ErrUnknownResponse) 525 if (code == ErrUnknownResponse) {
526 temp = "Unknown response from server"; 526 temp = tr("<qt>Unknown response from server</qt>");
527 527 if( ! Msg.isEmpty() )
528 if (code == QSocket::ErrHostNotFound) 528 temp += Msg;
529 temp = "host not found"; 529 } else if (code == QSocket::ErrHostNotFound) {
530 if (code == QSocket::ErrConnectionRefused) 530 temp = tr("<qt>host not found</qt>");
531 temp = "connection refused"; 531 } else if (code == QSocket::ErrConnectionRefused) {
532 if (code == QSocket::ErrSocketRead) 532 temp = tr("<qt>connection refused</qt>");
533 temp = "socket packet error"; 533 } else if (code == QSocket::ErrSocketRead) {
534 temp = tr("<qt>socket packet error</qt>");
535 }
534 536
535 if (code != ErrCancel) { 537 if (code != ErrCancel) {
536 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); 538 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
537 } else { 539 } else {
538 status2Label->setText("Aborted by user"); 540 status2Label->setText("Aborted by user");
539 } 541 }
540 542
541 sending = FALSE; 543 sending = FALSE;
542 sendMailButton->setEnabled(TRUE); 544 sendMailButton->setEnabled(TRUE);
543 cancelButton->setEnabled(FALSE); 545 cancelButton->setEnabled(FALSE);
544 quedMessages.clear(); 546 quedMessages.clear();
545} 547}
546 548
547void EmailClient::popError(int code) 549void EmailClient::popError(int code, const QString & Msg)
548{ 550{
549 QString temp; 551 QString temp;
550 552
551 if (code == ErrUnknownResponse) 553 if (code == ErrUnknownResponse) {
552 temp = "Unknown response from server"; 554 temp = tr("<qt>Unknown response from server</qt>");
553 if (code == ErrLoginFailed) 555 if( ! Msg.isEmpty() )
554 temp = "Login failed\nCheck user name and password"; 556 temp += Msg;
555 557 } else if (code == ErrLoginFailed) {
556 if (code == QSocket::ErrHostNotFound) 558 temp = tr("<qt>Login failed\nCheck user name and password</qt>");
557 temp = "host not found"; 559 } else if (code == QSocket::ErrHostNotFound) {
558 if (code == QSocket::ErrConnectionRefused) 560 temp = tr("<qt>host not found</qt>");
559 temp = "connection refused"; 561 } else if (code == QSocket::ErrConnectionRefused) {
560 if (code == QSocket::ErrSocketRead) 562 temp = tr("<qt>connection refused</qt>");
561 temp = "socket packet error"; 563 } else if (code == QSocket::ErrSocketRead) {
562 564 temp = tr("<qt>socket packet error</qt>");
565 }
566
563 if (code != ErrCancel) { 567 if (code != ErrCancel) {
564 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); 568 QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n"));
569
565 } else { 570 } else {
566 status2Label->setText("Aborted by user"); 571 status2Label->setText("Aborted by user");
567 } 572 }
568 573
569 receiving = FALSE; 574 receiving = FALSE;
570 getMailButton->setEnabled(TRUE); 575 getMailButton->setEnabled(TRUE);
571 cancelButton->setEnabled(FALSE); 576 cancelButton->setEnabled(FALSE);
572 selectAccountMenu->setEnabled(TRUE); 577 selectAccountMenu->setEnabled(TRUE);
573} 578}
574 579
575void EmailClient::inboxItemSelected() 580void EmailClient::inboxItemSelected()
576{ 581{
@@ -889,47 +894,47 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
889 else 894 else
890 { 895 {
891 outboxView->takeItem(mailItem); 896 outboxView->takeItem(mailItem);
892 } 897 }
893} 898}
894 899
895void EmailClient::setMailSize(int size) 900void EmailClient::setMailSize(int size)
896{ 901{
897 progressBar->reset(); 902 progressBar->reset();
898 progressBar->setTotalSteps(size); 903 progressBar->setTotalSteps(size);
899} 904}
900 905
901void EmailClient::setTotalSize(int size) 906void EmailClient::setTotalSize(int /*size*/)
902{ 907{
903 908
904} 909}
905 910
906void EmailClient::setDownloadedSize(int size) 911void EmailClient::setDownloadedSize(int size)
907{ 912{
908 int total = progressBar->totalSteps(); 913 int total = progressBar->totalSteps();
909 914
910 if (size < total) { 915 if (size < total) {
911 progressBar->setProgress(size); 916 progressBar->setProgress(size);
912 } else { 917 } else {
913 progressBar->setProgress(total); 918 progressBar->setProgress(total);
914 } 919 }
915} 920}
916 921
917void EmailClient::deleteItem() 922void EmailClient::deleteItem()
918{ 923{
919 bool inbox=mailboxView->currentTab()==0; 924 bool inbox=mailboxView->currentTab()==0;
920 QListView* box; 925 QListView* box;
921 926
922 EmailListItem* eli; 927 EmailListItem* eli;
923 int pos; 928 // int pos;
924 929
925 inbox ? box=inboxView : box=outboxView; 930 inbox ? box=inboxView : box=outboxView;
926 931
927 eli=(EmailListItem*)box->selectedItem(); 932 eli=(EmailListItem*)box->selectedItem();
928 933
929 if (eli) 934 if (eli)
930 { 935 {
931 box->setSelected(eli->itemBelow(),true); //select the previous item 936 box->setSelected(eli->itemBelow(),true); //select the previous item
932 937
933 deleteMail(eli,(bool&)inbox); //remove mail entry 938 deleteMail(eli,(bool&)inbox); //remove mail entry
934 } 939 }
935} 940}
@@ -937,25 +942,25 @@ void EmailClient::deleteItem()
937void EmailClient::inboxItemPressed() 942void EmailClient::inboxItemPressed()
938{ 943{
939// timerID=startTimer(500); 944// timerID=startTimer(500);
940} 945}
941 946
942void EmailClient::inboxItemReleased() 947void EmailClient::inboxItemReleased()
943{ 948{
944 // killTimer(timerID); 949 // killTimer(timerID);
945} 950}
946 951
947/*void EmailClient::timerEvent(QTimerEvent *e) 952/*void EmailClient::timerEvent(QTimerEvent *e)
948{ 953{
949 /*killTimer(timerID); 954 //killTimer(timerID);
950 955
951 956
952 QPopupMenu *action = new QPopupMenu(this); 957 QPopupMenu *action = new QPopupMenu(this);
953 958
954 int reply=0; 959 int reply=0;
955 960
956 action->insertItem(tr( "Reply To" ),this,SLOT(reply())); 961 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
957 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); 962 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
958 action->insertItem( tr( "Forward" ), this,SLOT(forward())); 963 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
959 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); 964 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
960 965
961 action->exec(QCursor::pos()); 966 action->exec(QCursor::pos());
@@ -982,29 +987,29 @@ void EmailClient::download(Email* mail)
982 987
983 acc=accountList.at(mail->fromAccountId-1); 988 acc=accountList.at(mail->fromAccountId-1);
984 if (acc) 989 if (acc)
985 { 990 {
986 emailHandler->setAccount(*acc); 991 emailHandler->setAccount(*acc);
987 emailHandler->getMailByList(&tempMailDownloadList); 992 emailHandler->getMailByList(&tempMailDownloadList);
988 } 993 }
989 else 994 else
990 QMessageBox::warning(qApp->activeWindow(), 995 QMessageBox::warning(qApp->activeWindow(),
991 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); 996 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
992} 997}
993 998
994void EmailClient::receive(const QCString& msg, const QByteArray& data) 999void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/)
995{ 1000{
996 /*if (msg=="getMail()") 1001 /*if (msg=="getMail()")
997 { 1002 {
998 /*QDialog qd(qApp->activeWindow(),"Getting mail",true); 1003 //QDialog qd(qApp->activeWindow(),"Getting mail",true);
999 QVBoxLayout *vbProg = new QVBoxLayout( &qd ); 1004 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
1000 1005
1001 initStatusBar(&qd); 1006 initStatusBar(&qd);
1002 1007
1003 if (statusBar==0) 1008 if (statusBar==0)
1004 { 1009 {
1005 qDebug("No Bar ..."); 1010 qDebug("No Bar ...");
1006 //statusBar=new ProgressBar(&qd); 1011 //statusBar=new ProgressBar(&qd);
1007 } 1012 }
1008 statusBar->show(); 1013 statusBar->show();
1009 vbProg->addWidget(statusBar); 1014 vbProg->addWidget(statusBar);
1010 qd.showMaximized(); 1015 qd.showMaximized();