summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/emailclient.cpp75
-rw-r--r--noncore/net/mailit/emailclient.h3
-rw-r--r--noncore/net/mailit/emailhandler.cpp16
-rw-r--r--noncore/net/mailit/emailhandler.h1
-rw-r--r--noncore/net/mailit/mailitwindow.cpp26
-rw-r--r--noncore/net/mailit/popclient.cpp80
-rw-r--r--noncore/net/mailit/writemail.cpp28
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp75
-rw-r--r--noncore/unsupported/mailit/emailclient.h3
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp16
-rw-r--r--noncore/unsupported/mailit/emailhandler.h1
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp26
-rw-r--r--noncore/unsupported/mailit/popclient.cpp80
-rw-r--r--noncore/unsupported/mailit/writemail.cpp28
14 files changed, 208 insertions, 250 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
@@ -362,7 +362,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
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
@@ -480,11 +480,11 @@ void EmailClient::allMailArrived(int count)
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
488void EmailClient::moveMailFront(Email *mailPtr) 488void EmailClient::moveMailFront(Email *mailPtr)
489{ 489{
490 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 490 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
@@ -664,7 +664,7 @@ QString EmailClient::getPath(bool enclosurePath)
664 664
665void EmailClient::readSettings() 665void 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);
@@ -891,13 +891,21 @@ void EmailClient::setDownloadedSize(int size)
891void EmailClient::deleteItem() 891void 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
903void EmailClient::inboxItemPressed() 911void EmailClient::inboxItemPressed()
@@ -939,43 +947,22 @@ Email* EmailClient::getCurrentMail()
939 return NULL; 947 return NULL;
940} 948}
941 949
942/* 950void EmailClient::download(Email* mail)
943void EmailClient::reply()
944{
945 Email* mail=getCurrentMail();
946
947 if (mail!=NULL)
948 {
949 emit reply(*mail);
950 }
951}
952
953void EmailClient::replyAll()
954{
955 Email* mail=getCurrentMail();
956
957 if (mail!=NULL)
958 {
959 emit replyAll(*mail);
960 }
961}
962
963void 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
973void 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
@@ -70,6 +70,7 @@ 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
74protected: 75protected:
75 void timerEvent(QTimerEvent*); 76 void timerEvent(QTimerEvent*);
@@ -139,6 +140,8 @@ private:
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;
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
@@ -127,18 +127,20 @@ void EmailHandler::getMailByList(MailList *mailList)
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
134void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete) 136void 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}
@@ -182,13 +184,11 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
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);
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
@@ -111,6 +111,7 @@ class EmailHandler : public QObject
111public: 111public:
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();
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
@@ -18,6 +18,7 @@
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
23MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
@@ -60,8 +61,7 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
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
67MailItWindow::~MailItWindow() 67MailItWindow::~MailItWindow()
@@ -84,6 +84,7 @@ void MailItWindow::compose()
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
@@ -113,6 +114,27 @@ 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" ) );
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
@@ -60,7 +60,7 @@ void PopClient::newConnection(QString target, int port)
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}
@@ -184,13 +184,14 @@ void PopClient::incomingData()
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
@@ -204,12 +205,12 @@ void PopClient::incomingData()
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 {
@@ -237,7 +238,7 @@ void PopClient::incomingData()
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
@@ -272,37 +273,24 @@ void PopClient::incomingData()
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);
@@ -310,12 +298,11 @@ void PopClient::incomingData()
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";
@@ -336,32 +323,3 @@ void PopClient::incomingData()
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
@@ -123,7 +123,7 @@ void WriteMail::init()
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");
@@ -132,7 +132,7 @@ void WriteMail::init()
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") );
@@ -148,7 +148,6 @@ void WriteMail::reject()
148 emit cancelMail(); 148 emit cancelMail();
149} 149}
150 150
151// need to insert date
152void WriteMail::accept() 151void WriteMail::accept()
153{ 152{
154 QStringList attachedFiles, attachmentsType; 153 QStringList attachedFiles, attachmentsType;
@@ -252,13 +251,24 @@ void WriteMail::attachFile()
252void WriteMail::reply(Email replyMail, bool replyAll) 251void 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);
@@ -321,10 +331,9 @@ bool WriteMail::getRecipients(bool ccField)
321 331
322void WriteMail::addRecipients() 332void WriteMail::addRecipients()
323{ 333{
324 334 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
325 addRecipients(false);
326 } 335 }
327 336
328void WriteMail::addRecipients(bool ccField) 337void WriteMail::addRecipients(bool ccField)
329{ 338{
330 QString recipients = ""; 339 QString recipients = "";
@@ -335,9 +344,9 @@ void WriteMail::addRecipients(bool ccField)
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();
@@ -376,6 +385,5 @@ void WriteMail::newMail()
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}
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index 23059cf..dff1888 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -362,7 +362,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
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
@@ -480,11 +480,11 @@ void EmailClient::allMailArrived(int count)
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
488void EmailClient::moveMailFront(Email *mailPtr) 488void EmailClient::moveMailFront(Email *mailPtr)
489{ 489{
490 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 490 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
@@ -664,7 +664,7 @@ QString EmailClient::getPath(bool enclosurePath)
664 664
665void EmailClient::readSettings() 665void 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);
@@ -891,13 +891,21 @@ void EmailClient::setDownloadedSize(int size)
891void EmailClient::deleteItem() 891void 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
903void EmailClient::inboxItemPressed() 911void EmailClient::inboxItemPressed()
@@ -939,43 +947,22 @@ Email* EmailClient::getCurrentMail()
939 return NULL; 947 return NULL;
940} 948}
941 949
942/* 950void EmailClient::download(Email* mail)
943void EmailClient::reply()
944{
945 Email* mail=getCurrentMail();
946
947 if (mail!=NULL)
948 {
949 emit reply(*mail);
950 }
951}
952
953void EmailClient::replyAll()
954{
955 Email* mail=getCurrentMail();
956
957 if (mail!=NULL)
958 {
959 emit replyAll(*mail);
960 }
961}
962
963void 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
973void EmailClient::remove()
974{
975 Email* mail=getCurrentMail();
976
977 if (mail!=NULL)
978 {
979 emit remove(*mail);
980 }
981}*/
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h
index 0890dcf..549683b 100644
--- a/noncore/unsupported/mailit/emailclient.h
+++ b/noncore/unsupported/mailit/emailclient.h
@@ -70,6 +70,7 @@ 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
74protected: 75protected:
75 void timerEvent(QTimerEvent*); 76 void timerEvent(QTimerEvent*);
@@ -139,6 +140,8 @@ private:
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;
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index b180051..fbbada7 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -127,18 +127,20 @@ void EmailHandler::getMailByList(MailList *mailList)
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
134void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete) 136void 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}
@@ -182,13 +184,11 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
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);
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
index e47fd9a..b645868 100644
--- a/noncore/unsupported/mailit/emailhandler.h
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -111,6 +111,7 @@ class EmailHandler : public QObject
111public: 111public:
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();
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp
index 7181adf..ffee67e 100644
--- a/noncore/unsupported/mailit/mailitwindow.cpp
+++ b/noncore/unsupported/mailit/mailitwindow.cpp
@@ -18,6 +18,7 @@
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
23MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
@@ -60,8 +61,7 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
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
67MailItWindow::~MailItWindow() 67MailItWindow::~MailItWindow()
@@ -84,6 +84,7 @@ void MailItWindow::compose()
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
@@ -113,6 +114,27 @@ 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" ) );
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 67306be..6105d09 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -60,7 +60,7 @@ void PopClient::newConnection(QString target, int port)
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}
@@ -184,13 +184,14 @@ void PopClient::incomingData()
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
@@ -204,12 +205,12 @@ void PopClient::incomingData()
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 {
@@ -237,7 +238,7 @@ void PopClient::incomingData()
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
@@ -272,37 +273,24 @@ void PopClient::incomingData()
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);
@@ -310,12 +298,11 @@ void PopClient::incomingData()
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";
@@ -336,32 +323,3 @@ void PopClient::incomingData()
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/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp
index 0336c83..dcf0c6e 100644
--- a/noncore/unsupported/mailit/writemail.cpp
+++ b/noncore/unsupported/mailit/writemail.cpp
@@ -123,7 +123,7 @@ void WriteMail::init()
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");
@@ -132,7 +132,7 @@ void WriteMail::init()
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") );
@@ -148,7 +148,6 @@ void WriteMail::reject()
148 emit cancelMail(); 148 emit cancelMail();
149} 149}
150 150
151// need to insert date
152void WriteMail::accept() 151void WriteMail::accept()
153{ 152{
154 QStringList attachedFiles, attachmentsType; 153 QStringList attachedFiles, attachmentsType;
@@ -252,13 +251,24 @@ void WriteMail::attachFile()
252void WriteMail::reply(Email replyMail, bool replyAll) 251void 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);
@@ -321,10 +331,9 @@ bool WriteMail::getRecipients(bool ccField)
321 331
322void WriteMail::addRecipients() 332void WriteMail::addRecipients()
323{ 333{
324 334 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
325 addRecipients(false);
326 } 335 }
327 336
328void WriteMail::addRecipients(bool ccField) 337void WriteMail::addRecipients(bool ccField)
329{ 338{
330 QString recipients = ""; 339 QString recipients = "";
@@ -335,9 +344,9 @@ void WriteMail::addRecipients(bool ccField)
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();
@@ -376,6 +385,5 @@ void WriteMail::newMail()
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}