Diffstat (limited to 'noncore/net/mailit/emailclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 140 |
1 files changed, 102 insertions, 38 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index dff1888..2cedc51 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -18,15 +18,17 @@ | |||
18 | ** | 18 | ** |
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> |
25 | #include <qaction.h> | 26 | #include <qaction.h> |
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 | ||
30 | QCollection::Item AccountList::newItem(QCollection::Item d) | 32 | QCollection::Item AccountList::newItem(QCollection::Item d) |
31 | { | 33 | { |
32 | return dupl( (MailAccount *) d); | 34 | return dupl( (MailAccount *) d); |
@@ -39,9 +41,9 @@ MailAccount* AccountList::dupl(MailAccount *in) | |||
39 | } | 41 | } |
40 | 42 | ||
41 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 43 | EmailClient::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 | ||
47 | sending = FALSE; | 49 | sending = FALSE; |
@@ -52,8 +54,10 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | |||
52 | allAccounts = FALSE; | 54 | allAccounts = FALSE; |
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, |
59 | SLOT(smtpError(int)) ); | 63 | SLOT(smtpError(int)) ); |
@@ -64,10 +68,9 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | |||
64 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 68 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
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, |
73 | SLOT(allMailArrived(int)) ); | 76 | SLOT(allMailArrived(int)) ); |
@@ -83,8 +86,13 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | |||
83 | readMail(); | 86 | readMail(); |
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 | ||
90 | EmailClient::~EmailClient() | 98 | EmailClient::~EmailClient() |
@@ -103,31 +111,10 @@ EmailClient::~EmailClient() | |||
103 | } | 111 | } |
104 | 112 | ||
105 | void EmailClient::init() | 113 | void 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); |
133 | QWhatsThis::add(bar,tr("Main operation toolbar")); | 120 | QWhatsThis::add(bar,tr("Main operation toolbar")); |
@@ -193,10 +180,13 @@ void EmailClient::init() | |||
193 | inboxView->addColumn( tr( "Subject" ) ); | 180 | inboxView->addColumn( tr( "Subject" ) ); |
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" ) ); |
202 | 192 | ||
@@ -209,16 +199,45 @@ void EmailClient::init() | |||
209 | outboxView->addColumn( tr( "To" ) ); | 199 | outboxView->addColumn( tr( "To" ) ); |
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 | ||
217 | setCentralWidget(mailboxView); | 209 | setCentralWidget(mailboxView); |
218 | 210 | ||
219 | } | 211 | } |
220 | 212 | ||
213 | void 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 | |||
221 | void EmailClient::compose() | 240 | void EmailClient::compose() |
222 | { | 241 | { |
223 | emit composeRequested(); | 242 | emit composeRequested(); |
224 | } | 243 | } |
@@ -318,18 +337,18 @@ void EmailClient::getNewMail() { | |||
318 | status1Label->setText(currentAccount->accountName + " headers"); | 337 | status1Label->setText(currentAccount->accountName + " headers"); |
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) { |
326 | mailPtr = item->getMail(); | 345 | mailPtr = item->getMail(); |
327 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 346 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
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 | ||
335 | } | 354 | } |
@@ -337,9 +356,9 @@ void EmailClient::getNewMail() { | |||
337 | void EmailClient::getAllNewMail() | 356 | 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 | ||
344 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 363 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
345 | { | 364 | { |
@@ -347,18 +366,20 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
347 | Email newMail; | 366 | Email newMail; |
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"); |
357 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 377 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
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; |
364 | 385 | ||
@@ -917,9 +938,9 @@ void EmailClient::inboxItemReleased() | |||
917 | { | 938 | { |
918 | //killTimer(timerID); | 939 | //killTimer(timerID); |
919 | } | 940 | } |
920 | 941 | ||
921 | void EmailClient::timerEvent(QTimerEvent *e) | 942 | /*void EmailClient::timerEvent(QTimerEvent *e) |
922 | { | 943 | { |
923 | /*killTimer(timerID); | 944 | /*killTimer(timerID); |
924 | 945 | ||
925 | 946 | ||
@@ -934,10 +955,10 @@ void EmailClient::timerEvent(QTimerEvent *e) | |||
934 | 955 | ||
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 | ||
941 | Email* EmailClient::getCurrentMail() | 962 | Email* EmailClient::getCurrentMail() |
942 | { | 963 | { |
943 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 964 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
@@ -952,10 +973,8 @@ void EmailClient::download(Email* mail) | |||
952 | MailAccount* acc=0; | 973 | MailAccount* acc=0; |
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) |
961 | { | 980 | { |
@@ -965,4 +984,49 @@ void EmailClient::download(Email* mail) | |||
965 | else | 984 | else |
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 | |||
989 | void 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 | } | ||