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.cpp140
1 files changed, 102 insertions, 38 deletions
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index dff1888..2cedc51 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -19,6 +19,7 @@
19**********************************************************************/ 19**********************************************************************/
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qvbox.h>
22#include <qfile.h> 23#include <qfile.h>
23#include <qcheckbox.h> 24#include <qcheckbox.h>
24#include <qmenubar.h> 25#include <qmenubar.h>
@@ -26,6 +27,7 @@
26#include <qwhatsthis.h> 27#include <qwhatsthis.h>
27#include <qpe/resource.h> 28#include <qpe/resource.h>
28#include "emailclient.h" 29#include "emailclient.h"
30#include "writemail.h"
29 31
30QCollection::Item AccountList::newItem(QCollection::Item d) 32QCollection::Item AccountList::newItem(QCollection::Item d)
31{ 33{
@@ -40,7 +42,7 @@ MailAccount* AccountList::dupl(MailAccount *in)
40 42
41EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) 43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
42 : QMainWindow( parent, name, fl ) 44 : QMainWindow( parent, name, fl )
43{ 45{
44 emailHandler = new EmailHandler(); 46 emailHandler = new EmailHandler();
45 addressList = new AddressList(); 47 addressList = new AddressList();
46 48
@@ -53,6 +55,8 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
53 55
54 init(); 56 init();
55 57
58
59
56 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
57 61
58 connect(emailHandler, SIGNAL(smtpError(int)), this, 62 connect(emailHandler, SIGNAL(smtpError(int)), this,
@@ -65,8 +69,7 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
65 69
66 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); 70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) );
67 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); 71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) );
68 72
69
70 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
71 SLOT(mailArrived(const Email &, bool)) ); 74 SLOT(mailArrived(const Email &, bool)) );
72 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 75 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
@@ -84,6 +87,11 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
84 lineShift = "\r\n"; 87 lineShift = "\r\n";
85 88
86 mailboxView->setCurrentTab(0); //ensure that inbox has focus 89 mailboxView->setCurrentTab(0); //ensure that inbox has focus
90
91 /*channel = new QCopChannel( "QPE/Application/mailit", this );
92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/
94
87} 95}
88 96
89 97
@@ -104,29 +112,8 @@ EmailClient::~EmailClient()
104 112
105void EmailClient::init() 113void EmailClient::init()
106{ 114{
107 statusBar = new QStatusBar(this); 115 initStatusBar(this);
108 statusBar->setSizeGripEnabled(FALSE); 116
109
110 status1Label = new QLabel( tr("Idle"), statusBar);
111 status2Label = new QLabel("", statusBar);
112 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
113 status2Label, SLOT(setText(const QString &)) );
114 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
115 status2Label, SLOT(setText(const QString &)) );
116
117 progressBar = new QProgressBar(statusBar);
118
119 connect(emailHandler, SIGNAL(mailboxSize(int)),
120 this, SLOT(setTotalSize(int)) );
121 connect(emailHandler, SIGNAL(currentMailSize(int)),
122 this, SLOT(setMailSize(int)) );
123 connect(emailHandler, SIGNAL(downloadedSize(int)),
124 this, SLOT(setDownloadedSize(int)) );
125
126 statusBar->addWidget(status1Label);
127 statusBar->addWidget(progressBar);
128 statusBar->addWidget(status2Label);
129
130 setToolBarsMovable(FALSE); 117 setToolBarsMovable(FALSE);
131 118
132 bar = new QToolBar(this); 119 bar = new QToolBar(this);
@@ -194,8 +181,11 @@ void EmailClient::init()
194 inboxView->addColumn( tr( "Date" ) ); 181 inboxView->addColumn( tr( "Date" ) );
195 inboxView->setMinimumSize( QSize( 0, 0 ) ); 182 inboxView->setMinimumSize( QSize( 0, 0 ) );
196 inboxView->setAllColumnsShowFocus(TRUE); 183 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" 184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n"
198 " A blue attachment icon shows whether this mail has attachments.")); 185 "It keeps the fetched mail which can be \n"
186 "viewed by double clicking the entry.\n"
187 "blue attachment icon shows whether this \n"
188 "mailhas attachments.\n"));
199 189
200 grid_2->addWidget( inboxView, 2, 0 ); 190 grid_2->addWidget( inboxView, 2, 0 );
201 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); 191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
@@ -210,7 +200,9 @@ void EmailClient::init()
210 outboxView->addColumn( tr( "Subject" ) ); 200 outboxView->addColumn( tr( "Subject" ) );
211 outboxView->setAllColumnsShowFocus(TRUE); 201 outboxView->setAllColumnsShowFocus(TRUE);
212 202
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.")); 203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n"
204 "It keeps the queued mails to send which can be \n"
205 "reviewed by double clicking the entry."));
214 grid_3->addWidget( outboxView, 0, 0 ); 206 grid_3->addWidget( outboxView, 0, 0 );
215 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); 207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
216 208
@@ -218,6 +210,33 @@ void EmailClient::init()
218 210
219} 211}
220 212
213void EmailClient::initStatusBar(QWidget* parent)
214{
215 statusBar = new QStatusBar(parent);
216 statusBar->setSizeGripEnabled(FALSE);
217
218 status1Label = new QLabel( tr("Idle"), statusBar);
219 status2Label = new QLabel("", statusBar);
220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
221 status2Label, SLOT(setText(const QString &)) );
222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
223 status2Label, SLOT(setText(const QString &)) );
224
225 progressBar = new QProgressBar(statusBar);
226
227 connect(emailHandler, SIGNAL(mailboxSize(int)),
228 this, SLOT(setTotalSize(int)) );
229 connect(emailHandler, SIGNAL(currentMailSize(int)),
230 this, SLOT(setMailSize(int)) );
231 connect(emailHandler, SIGNAL(downloadedSize(int)),
232 this, SLOT(setDownloadedSize(int)) );
233
234 statusBar->addWidget(status1Label);
235 statusBar->addWidget(progressBar);
236 statusBar->addWidget(status2Label);
237
238}
239
221void EmailClient::compose() 240void EmailClient::compose()
222{ 241{
223 emit composeRequested(); 242 emit composeRequested();
@@ -319,7 +338,7 @@ void EmailClient::getNewMail() {
319 progressBar->reset(); 338 progressBar->reset();
320 339
321 //get any previous mails not downloaded and add to queue 340 //get any previous mails not downloaded and add to queue
322 mailDownloadList.clear(); 341 /*mailDownloadList.clear();
323 Email *mailPtr; 342 Email *mailPtr;
324 item = (EmailListItem *) inboxView->firstChild(); 343 item = (EmailListItem *) inboxView->firstChild();
325 while (item != NULL) { 344 while (item != NULL) {
@@ -328,7 +347,7 @@ void EmailClient::getNewMail() {
328 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); 347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
329 } 348 }
330 item = (EmailListItem *) item->nextSibling(); 349 item = (EmailListItem *) item->nextSibling();
331 } 350 }*/
332 351
333 emailHandler->getMailHeaders(); 352 emailHandler->getMailHeaders();
334 353
@@ -338,7 +357,7 @@ void EmailClient::getAllNewMail()
338{ 357{
339 allAccounts = TRUE; 358 allAccounts = TRUE;
340 currentAccount = accountList.first(); 359 currentAccount = accountList.first();
341 getNewMail(); 360 getNewMail();
342} 361}
343 362
344void EmailClient::mailArrived(const Email &mail, bool fromDisk) 363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
@@ -348,9 +367,10 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
348 int thisMailId; 367 int thisMailId;
349 emailHandler->parse(mail.rawMail, lineShift, &newMail); 368 emailHandler->parse(mail.rawMail, lineShift, &newMail);
350 mailconf->setGroup(newMail.id); 369 mailconf->setGroup(newMail.id);
351 370
352 if (fromDisk) 371 if (fromDisk)
353 { 372 {
373
354 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
355 newMail.size = mailconf->readNumEntry("size"); 375 newMail.size = mailconf->readNumEntry("size");
356 newMail.serverId = mailconf->readNumEntry("serverid"); 376 newMail.serverId = mailconf->readNumEntry("serverid");
@@ -358,6 +378,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
358 } 378 }
359 else 379 else
360 { //mail arrived from server 380 { //mail arrived from server
381
361 newMail.serverId = mail.serverId; 382 newMail.serverId = mail.serverId;
362 newMail.size = mail.size; 383 newMail.size = mail.size;
363 newMail.downloaded = mail.downloaded; 384 newMail.downloaded = mail.downloaded;
@@ -918,7 +939,7 @@ void EmailClient::inboxItemReleased()
918 //killTimer(timerID); 939 //killTimer(timerID);
919} 940}
920 941
921void EmailClient::timerEvent(QTimerEvent *e) 942/*void EmailClient::timerEvent(QTimerEvent *e)
922{ 943{
923 /*killTimer(timerID); 944 /*killTimer(timerID);
924 945
@@ -935,8 +956,8 @@ void EmailClient::timerEvent(QTimerEvent *e)
935 action->exec(QCursor::pos()); 956 action->exec(QCursor::pos());
936 957
937 if (action) delete action; 958 if (action) delete action;
938 */ 959
939} 960}*/
940 961
941Email* EmailClient::getCurrentMail() 962Email* EmailClient::getCurrentMail()
942{ 963{
@@ -953,8 +974,6 @@ void EmailClient::download(Email* mail)
953 974
954 tempMailDownloadList.clear(); 975 tempMailDownloadList.clear();
955 tempMailDownloadList.sizeInsert(mail->serverId, mail->size); 976 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
956 if (accountList.count()>0)
957 qDebug("Accounts present");
958 977
959 acc=accountList.at(mail->fromAccountId-1); 978 acc=accountList.at(mail->fromAccountId-1);
960 if (acc) 979 if (acc)
@@ -966,3 +985,48 @@ void EmailClient::download(Email* mail)
966 QMessageBox::warning(qApp->activeWindow(), 985 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"); 986 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
968} 987}
988
989void EmailClient::receive(const QCString& msg, const QByteArray& data)
990{
991 /*if (msg=="getMail()")
992 {
993 /*QDialog qd(qApp->activeWindow(),"Getting mail",true);
994 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
995
996 initStatusBar(&qd);
997
998 if (statusBar==0)
999 {
1000 qDebug("No Bar ...");
1001 //statusBar=new ProgressBar(&qd);
1002 }
1003 statusBar->show();
1004 vbProg->addWidget(statusBar);
1005 qd.showMaximized();
1006 qd.show();
1007 emit getAllNewMail();
1008 //qd.exec();
1009 }
1010 else if (msg=="compose()")
1011 {
1012 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1013
1014 WriteMail wm(&qd,"write new mail");
1015 QVBoxLayout vbProg( &qd );
1016
1017 wm.showMaximized();
1018 vbProg.addWidget(&wm);
1019
1020 qd.showMaximized();
1021
1022 emit composeRequested();
1023 qd.exec();
1024
1025 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1026 }
1027
1028 else if (msg=="dialog()")
1029 {
1030 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1031 }*/
1032}