summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/addresslist.cpp2
-rw-r--r--noncore/net/mailit/emailclient.cpp8
-rw-r--r--noncore/net/mailit/emailhandler.cpp2
-rw-r--r--noncore/net/mailit/mailitwindow.cpp3
-rw-r--r--noncore/net/mailit/popclient.cpp10
-rw-r--r--noncore/net/mailit/readmail.cpp1
-rw-r--r--noncore/net/mailit/smtpclient.cpp20
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp2
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp8
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp2
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp3
-rw-r--r--noncore/unsupported/mailit/popclient.cpp10
-rw-r--r--noncore/unsupported/mailit/readmail.cpp1
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp20
14 files changed, 42 insertions, 50 deletions
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
index 9fe558a..8d9ab91 100644
--- a/noncore/net/mailit/addresslist.cpp
+++ b/noncore/net/mailit/addresslist.cpp
@@ -106,49 +106,49 @@ int AddressList::getNameRef(QString name)
106 return pos; 106 return pos;
107 pos++; 107 pos++;
108 } 108 }
109 return -1; 109 return -1;
110} 110}
111 111
112QList<Contact>* AddressList::getContactList() 112QList<Contact>* AddressList::getContactList()
113{ 113{
114 return &addresses; 114 return &addresses;
115} 115}
116 116
117void AddressList::read() 117void AddressList::read()
118{ 118{
119 OContactAccess::List::Iterator it; 119 OContactAccess::List::Iterator it;
120 120
121 QString lineEmail, lineName, email, name; 121 QString lineEmail, lineName, email, name;
122 OContactAccess m_contactdb("mailit"); 122 OContactAccess m_contactdb("mailit");
123 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 123 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
124 //OContact* oc; 124 //OContact* oc;
125 125
126 for ( it = m_list.begin(); it != m_list.end(); ++it ) 126 for ( it = m_list.begin(); it != m_list.end(); ++it )
127 { 127 {
128 //oc=(OContact*) it; 128 //oc=(OContact*) it;
129 if ((*it).defaultEmail().length()!=0) 129 if ((*it).defaultEmail().length()!=0)
130 addContact((*it).defaultEmail(),(*it).fullName()); 130 addContact((*it).defaultEmail(),(*it).fileAs());
131 } 131 }
132 132
133 /*if (! f.open(IO_ReadOnly) ) 133 /*if (! f.open(IO_ReadOnly) )
134 return; 134 return;
135 135
136 QTextStream stream(&f); 136 QTextStream stream(&f);
137 137
138 while (! stream.atEnd() ) { 138 while (! stream.atEnd() ) {
139 lineEmail = stream.readLine(); 139 lineEmail = stream.readLine();
140 if (! stream.atEnd() ) 140 if (! stream.atEnd() )
141 lineName = stream.readLine(); 141 lineName = stream.readLine();
142 else return; 142 else return;
143 143
144 email = getRightString(lineEmail); 144 email = getRightString(lineEmail);
145 name = getRightString(lineName); 145 name = getRightString(lineName);
146 addContact(email, name); 146 addContact(email, name);
147 } 147 }
148 f.close();*/ 148 f.close();*/
149} 149}
150 150
151QString AddressList::getRightString(QString in) 151QString AddressList::getRightString(QString in)
152{ 152{
153 QString out = ""; 153 QString out = "";
154 154
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index 6612541..0d82a9a 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -511,49 +511,49 @@ void EmailClient::inboxItemSelected()
511{ 511{
512 item = (EmailListItem*) inboxView->selectedItem(); 512 item = (EmailListItem*) inboxView->selectedItem();
513 if (item != NULL) { 513 if (item != NULL) {
514 emit viewEmail(inboxView, item->getMail()); 514 emit viewEmail(inboxView, item->getMail());
515 } 515 }
516} 516}
517 517
518void EmailClient::outboxItemSelected() 518void EmailClient::outboxItemSelected()
519{ 519{
520 item = (EmailListItem*) outboxView->selectedItem(); 520 item = (EmailListItem*) outboxView->selectedItem();
521 if (item != NULL) { 521 if (item != NULL) {
522 emit viewEmail(outboxView, item->getMail()); 522 emit viewEmail(outboxView, item->getMail());
523 } 523 }
524 524
525} 525}
526 526
527void EmailClient::readMail() 527void EmailClient::readMail()
528{ 528{
529 Email mail; 529 Email mail;
530 int start, stop; 530 int start, stop;
531 QString s, del; 531 QString s, del;
532 532
533 QFile f(getPath(FALSE) + "inbox.txt"); 533 QFile f(getPath(FALSE) + "inbox.txt");
534// QFileInfo fi(f); 534// QFileInfo fi(f);
535 qDebug( f.name()); 535 //qDebug( f.name());
536 536
537 if ( f.open(IO_ReadOnly) ) { // file opened successfully 537 if ( f.open(IO_ReadOnly) ) { // file opened successfully
538 QTextStream t( &f ); // use a text stream 538 QTextStream t( &f ); // use a text stream
539 s = t.read(); 539 s = t.read();
540 f.close(); 540 f.close();
541 541
542 start = 0; 542 start = 0;
543 del = "\n.\n"; 543 del = "\n.\n";
544 while ((uint) start < s.length()) { 544 while ((uint) start < s.length()) {
545 stop = s.find(del, start); 545 stop = s.find(del, start);
546 if (stop == -1) 546 if (stop == -1)
547 stop = s.length() - del.length(); 547 stop = s.length() - del.length();
548 548
549 mail.rawMail = s.mid(start, stop + del.length() - start ); 549 mail.rawMail = s.mid(start, stop + del.length() - start );
550 start = stop + del.length(); 550 start = stop + del.length();
551 mailArrived(mail, TRUE); 551 mailArrived(mail, TRUE);
552 } 552 }
553 } 553 }
554 554
555 QFile fo(getPath(FALSE) + "outbox.txt"); 555 QFile fo(getPath(FALSE) + "outbox.txt");
556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
557 QTextStream t( &fo ); // use a text stream 557 QTextStream t( &fo ); // use a text stream
558 s = t.read(); 558 s = t.read();
559 fo.close(); 559 fo.close();
@@ -565,54 +565,54 @@ void EmailClient::readMail()
565 if (stop == -1) 565 if (stop == -1)
566 stop = s.length() - del.length(); 566 stop = s.length() - del.length();
567 567
568 mail.rawMail = s.mid(start, stop + del.length() - start ); 568 mail.rawMail = s.mid(start, stop + del.length() - start );
569 start = stop + del.length(); 569 start = stop + del.length();
570 emailHandler->parse(mail.rawMail, lineShift, &mail); 570 emailHandler->parse(mail.rawMail, lineShift, &mail);
571 mail.sent = false; 571 mail.sent = false;
572 mail.received = false; 572 mail.received = false;
573 enqueMail(mail); 573 enqueMail(mail);
574 574
575 } 575 }
576 } 576 }
577} 577}
578 578
579void EmailClient::saveMail(QString fileName, QListView *view) 579void EmailClient::saveMail(QString fileName, QListView *view)
580{ 580{
581 QFile f(fileName); 581 QFile f(fileName);
582 Email *mail; 582 Email *mail;
583 583
584 if (! f.open(IO_WriteOnly) ) { 584 if (! f.open(IO_WriteOnly) ) {
585 qWarning("could not open file"); 585 qWarning("could not open file");
586 return; 586 return;
587 } 587 }
588 item = (EmailListItem *) view->firstChild(); 588 item = (EmailListItem *) view->firstChild();
589 qDebug (QString("Write : ") ); 589 //qDebug (QString("Write : ") );
590 QTextStream t(&f); 590 QTextStream t(&f);
591 while (item != NULL) { 591 while (item != NULL) {
592 mail = item->getMail(); 592 mail = item->getMail();
593 qDebug(mail->rawMail); 593 //qDebug(mail->rawMail);
594 qDebug(mail->recipients.first()); 594 //qDebug(mail->recipients.first());
595 t << mail->rawMail; 595 t << mail->rawMail;
596 596
597 mailconf->setGroup(mail->id); 597 mailconf->setGroup(mail->id);
598 mailconf->writeEntry("mailread", mail->read); 598 mailconf->writeEntry("mailread", mail->read);
599 599
600 item = (EmailListItem *) item->nextSibling(); 600 item = (EmailListItem *) item->nextSibling();
601 } 601 }
602 f.close(); 602 f.close();
603} 603}
604 604
605//paths for mailit, is settings, inbox, enclosures 605//paths for mailit, is settings, inbox, enclosures
606QString EmailClient::getPath(bool enclosurePath) 606QString EmailClient::getPath(bool enclosurePath)
607{ 607{
608 QString basePath = "qtmail"; 608 QString basePath = "qtmail";
609 QString enclosures = "enclosures"; 609 QString enclosures = "enclosures";
610 610
611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
612 if ( !dir.exists() ) 612 if ( !dir.exists() )
613 dir.mkdir( dir.path() ); 613 dir.mkdir( dir.path() );
614 614
615 if (enclosurePath) { 615 if (enclosurePath) {
616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
617 617
618 if ( !dir.exists() ) 618 if ( !dir.exists() )
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 9c1c814..03f8a28 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -142,50 +142,48 @@ void EmailHandler::messageArrived(const QString &message, int id, uint size, boo
142 mail.rawMail = message; 142 mail.rawMail = message;
143 mail.serverId = id; 143 mail.serverId = id;
144 mail.size = size; 144 mail.size = size;
145 mail.downloaded = complete; 145 mail.downloaded = complete;
146 146
147 emit mailArrived(mail, FALSE); 147 emit mailArrived(mail, FALSE);
148} 148}
149 149
150bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 150bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
151{ 151{
152 QString temp, boundary; 152 QString temp, boundary;
153 int pos; 153 int pos;
154 QString delimiter, header, body, mimeHeader, mimeBody; 154 QString delimiter, header, body, mimeHeader, mimeBody;
155 QString content, contentType, contentAttribute, id, encoding; 155 QString content, contentType, contentAttribute, id, encoding;
156 QString fileName, storedName; 156 QString fileName, storedName;
157 int enclosureId = 0; 157 int enclosureId = 0;
158 158
159 mail->rawMail = in; 159 mail->rawMail = in;
160 mail->received = TRUE; 160 mail->received = TRUE;
161 mail->files.setAutoDelete(TRUE); 161 mail->files.setAutoDelete(TRUE);
162 162
163 temp = lineShift + "." + lineShift; 163 temp = lineShift + "." + lineShift;
164 164
165 if (in.right(temp.length()) != temp) { 165 if (in.right(temp.length()) != temp) {
166 qWarning(in.right(temp.length()));
167 qWarning(" . added at end of email as separator");
168 mail->rawMail += temp; 166 mail->rawMail += temp;
169 } 167 }
170 168
171 169
172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 170 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
173 pos = in.find(delimiter, 0, FALSE); 171 pos = in.find(delimiter, 0, FALSE);
174 header = in.left(pos); 172 header = in.left(pos);
175 body = in.right(in.length() - pos - delimiter.length()); 173 body = in.right(in.length() - pos - delimiter.length());
176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 174 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
177 body.truncate(body.length()-2); 175 body.truncate(body.length()-2);
178 176
179 TextParser p(header, lineShift); 177 TextParser p(header, lineShift);
180 178
181 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { 179 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
182 pos++; 180 pos++;
183 if (p.separatorAt(pos) == ' ') { 181 if (p.separatorAt(pos) == ' ') {
184 mail->from = p.getString(&pos, '<', false); 182 mail->from = p.getString(&pos, '<', false);
185 mail->from = mail->from.stripWhiteSpace(); 183 mail->from = mail->from.stripWhiteSpace();
186 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 184 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
187 mail->from = mail->from.left(mail->from.length() - 1); 185 mail->from = mail->from.left(mail->from.length() - 1);
188 mail->from = mail->from.right(mail->from.length() - 1); 186 mail->from = mail->from.right(mail->from.length() - 1);
189 } 187 }
190 pos++; 188 pos++;
191 mail->fromMail = p.getString(&pos, '>', false); 189 mail->fromMail = p.getString(&pos, '>', false);
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp
index fd49c1f..2bf1dcb 100644
--- a/noncore/net/mailit/mailitwindow.cpp
+++ b/noncore/net/mailit/mailitwindow.cpp
@@ -6,82 +6,79 @@
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 "mailitwindow.h" 20#include "mailitwindow.h"
21 21
22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
23 : QMainWindow(parent, name, fl) 23 : QMainWindow(parent, name, fl)
24{ 24{
25 currentCaption = "Mailit"; 25 currentCaption = "Mailit";
26 setCaption(tr(currentCaption)); 26 setCaption(tr(currentCaption));
27 views = new QWidgetStack(this); 27 views = new QWidgetStack(this);
28 setCentralWidget(views); 28 setCentralWidget(views);
29 29
30 qWarning("***Starting writeMail");
31 emailClient = new EmailClient(views, "client"); 30 emailClient = new EmailClient(views, "client");
32 writeMail = new WriteMail(views, "writing"); 31 writeMail = new WriteMail(views, "writing");
33 readMail = new ReadMail(views, "reading"); 32 readMail = new ReadMail(views, "reading");
34 qWarning("***Finished readMail");
35 33
36 views->raiseWidget(emailClient); 34 views->raiseWidget(emailClient);
37 35
38 connect(emailClient, SIGNAL(composeRequested()), 36 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) ); 37 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 38 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) ); 39 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 40 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) ); 41 SLOT(updateMailView(Email *)) );
44 42
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 43 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 44 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) ); 45 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) ); 47 SLOT(enqueMail(const Email &)) );
50 48
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 49 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &)), this, 50 connect(readMail, SIGNAL(replyRequested(Email &)), this,
53 SLOT(composeReply(Email &)) ); 51 SLOT(composeReply(Email &)) );
54 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 52 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
55 SLOT(deleteMail(EmailListItem *, bool &)) ); 53 SLOT(deleteMail(EmailListItem *, bool &)) );
56 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 54 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
57 SLOT(moveMailFront(Email *)) ); 55 SLOT(moveMailFront(Email *)) );
58 56
59 connect(emailClient, SIGNAL(newCaption(const QString &)), 57 connect(emailClient, SIGNAL(newCaption(const QString &)),
60 this, SLOT(updateCaption(const QString &)) ); 58 this, SLOT(updateCaption(const QString &)) );
61 viewingMail = FALSE; 59 viewingMail = FALSE;
62 60
63 qWarning("***Finished MailitWindow");
64} 61}
65 62
66MailItWindow::~MailItWindow() 63MailItWindow::~MailItWindow()
67{ 64{
68} 65}
69 66
70void MailItWindow::closeEvent(QCloseEvent *e) 67void MailItWindow::closeEvent(QCloseEvent *e)
71{ 68{
72 if (views->visibleWidget() == emailClient) { 69 if (views->visibleWidget() == emailClient) {
73 e->accept(); 70 e->accept();
74 } else { 71 } else {
75 showEmailClient(); 72 showEmailClient();
76 } 73 }
77} 74}
78 75
79void MailItWindow::compose() 76void MailItWindow::compose()
80{ 77{
81 viewingMail = FALSE; 78 viewingMail = FALSE;
82 emailClient->hide(); 79 emailClient->hide();
83 readMail->hide(); 80 readMail->hide();
84 views->raiseWidget(writeMail); 81 views->raiseWidget(writeMail);
85 writeMail->setAddressList(emailClient->getAdrListRef()); 82 writeMail->setAddressList(emailClient->getAdrListRef());
86 setCaption( tr( "Write mail" ) ); 83 setCaption( tr( "Write mail" ) );
87} 84}
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index 2f14ed2..f9cc337 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -98,61 +98,61 @@ void PopClient::setSelectedMails(MailList *list)
98void PopClient::connectionEstablished() 98void PopClient::connectionEstablished()
99{ 99{
100 emit updateStatus(tr("Connection established")); 100 emit updateStatus(tr("Connection established"));
101} 101}
102 102
103void PopClient::errorHandling(int status) 103void PopClient::errorHandling(int status)
104{ 104{
105 emit updateStatus(tr("Error Occured")); 105 emit updateStatus(tr("Error Occured"));
106 emit errorOccurred(status); 106 emit errorOccurred(status);
107 socket->close(); 107 socket->close();
108 receiving = FALSE; 108 receiving = FALSE;
109} 109}
110 110
111void PopClient::incomingData() 111void PopClient::incomingData()
112{ 112{
113 QString response, temp, temp2, timeStamp; 113 QString response, temp, temp2, timeStamp;
114 QString md5Source; 114 QString md5Source;
115 int start, end; 115 int start, end;
116// char *md5Digest; 116// char *md5Digest;
117 char md5Digest[16]; 117 char md5Digest[16];
118// if ( !socket->canReadLine() ) 118// if ( !socket->canReadLine() )
119// return; 119// return;
120 120
121 response = socket->readLine(); 121 response = socket->readLine();
122 qDebug(response +" %d", status); 122 //qDebug(response +" %d", status);
123 123
124 switch(status) { 124 switch(status) {
125 //logging in 125 //logging in
126 case Init: { 126 case Init: {
127#ifdef APOP_TEST 127#ifdef APOP_TEST
128 start = response.find('<',0); 128 start = response.find('<',0);
129 end = response.find('>', start); 129 end = response.find('>', start);
130 if( start >= 0 && end > start ) 130 if( start >= 0 && end > start )
131 { 131 {
132 timeStamp = response.mid( start , end - start + 1); 132 timeStamp = response.mid( start , end - start + 1);
133 md5Source = timeStamp + popPassword; 133 md5Source = timeStamp + popPassword;
134 qDebug( md5Source); 134 //qDebug( md5Source);
135// for( int i = 0; i < md5Source.length(); i++) { 135// for( int i = 0; i < md5Source.length(); i++) {
136// buff[i] = (QChar)md5Source[i]; 136// buff[i] = (QChar)md5Source[i];
137// } 137// }
138 138
139 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 139 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
140// md5_buffer(char const *buffer, unsigned int len, char *digest); 140// md5_buffer(char const *buffer, unsigned int len, char *digest);
141 141
142// MD5_Init( &ctx); 142// MD5_Init( &ctx);
143// MD5_Update( &ctx, buff, sizeof( buff) ); 143// MD5_Update( &ctx, buff, sizeof( buff) );
144// MD5_Final( md5Digest, &ctx); 144// MD5_Final( md5Digest, &ctx);
145// MD5( buff, md5Source.length(), md5Digest); 145// MD5( buff, md5Source.length(), md5Digest);
146 146
147 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 147 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
148 { 148 {
149 printf("%x", md5Digest[j]); 149 printf("%x", md5Digest[j]);
150 } 150 }
151 printf("\n"); 151 printf("\n");
152// qDebug(md5Digest); 152// qDebug(md5Digest);
153 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 153 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
154 // qDebug("%s", stream); 154 // qDebug("%s", stream);
155 status = Stat; 155 status = Stat;
156 } 156 }
157 else 157 else
158#endif 158#endif
@@ -171,143 +171,143 @@ void PopClient::incomingData()
171 break; 171 break;
172 } 172 }
173 //ask for number of messages 173 //ask for number of messages
174 case Stat: { 174 case Stat: {
175 if (response[0] == '+') { 175 if (response[0] == '+') {
176 *stream << "STAT" << "\r\n"; 176 *stream << "STAT" << "\r\n";
177 status = Mcnt; 177 status = Mcnt;
178 } else errorHandling(ErrLoginFailed); 178 } else errorHandling(ErrLoginFailed);
179 break; 179 break;
180 } 180 }
181 //get count of messages, eg "+OK 4 900.." -> int 4 181 //get count of messages, eg "+OK 4 900.." -> int 4
182 case Mcnt: { 182 case Mcnt: {
183 if (response[0] == '+') { 183 if (response[0] == '+') {
184 temp = response.replace(0, 4, ""); 184 temp = response.replace(0, 4, "");
185 int x = temp.find(" ", 0); 185 int x = temp.find(" ", 0);
186 temp.truncate((uint) x); 186 temp.truncate((uint) x);
187 newMessages = temp.toInt(); 187 newMessages = temp.toInt();
188 messageCount = 1; 188 messageCount = 1;
189 status = List; 189 status = List;
190 190
191 if (synchronize) { 191 if (synchronize) {
192 //messages deleted from server, reload all 192 //messages deleted from server, reload all
193 if (newMessages < lastSync) 193 if (newMessages < lastSync)
194 lastSync = 0; 194 lastSync = 0;
195 messageCount = lastSync + 1; 195 messageCount = 1;
196 } 196 }
197 197
198 if (selected) { 198 if (selected) {
199 int *ptr = mailList->first(); 199 int *ptr = mailList->first();
200 if (ptr != 0) { 200 if (ptr != 0) {
201 newMessages++; //to ensure no early jumpout 201 newMessages++; //to ensure no early jumpout
202 messageCount = *(mailList->first()); 202 messageCount = *(mailList->first());
203 } else newMessages = 0; 203 } else newMessages = 0;
204 } 204 }
205 } else errorHandling(ErrUnknownResponse); 205 } else errorHandling(ErrUnknownResponse);
206 } 206 }
207 //Read message number x, count upwards to messageCount 207 //Read message number x, count upwards to messageCount
208 case List: { 208 case List: {
209 if (messageCount <= newMessages) { 209 if (messageCount <= newMessages) {
210 *stream << "LIST " << messageCount << "\r\n"; 210 *stream << "LIST " << messageCount << "\r\n";
211 status = Size; 211 status = Size;
212 temp2.setNum(newMessages - lastSync); 212 temp2.setNum(newMessages - lastSync);
213 temp.setNum(messageCount - lastSync); 213 temp.setNum(messageCount - lastSync);
214 if (!selected) { 214 if (!selected) {
215 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 215 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
216 } else { 216 } else {
217 //completing a previously closed transfer 217 //completing a previously closed transfer
218 if ( (messageCount - lastSync) <= 0) { 218 if ( (messageCount - lastSync) <= 0) {
219 temp.setNum(messageCount); 219 temp.setNum(messageCount);
220 emit updateStatus(tr("Previous message ") + temp); 220 emit updateStatus(tr("Previous message ") + temp);
221 } else { 221 } else {
222 emit updateStatus(tr("Completing message ") + temp); 222 emit updateStatus(tr("Completing message ") + temp);
223 } 223 }
224 } 224 }
225 break; 225 break;
226 } else { 226 } else {
227 emit updateStatus(tr("No new Messages")); 227 emit updateStatus(tr("No new Messages"));
228 status = Quit; 228 status = Quit;
229 } 229 }
230 } 230 }
231 //get size of message, eg "500 characters in message.." -> int 500 231 //get size of message, eg "500 characters in message.." -> int 500
232 case Size: { 232 case Size: {
233 if (status != Quit) { //because of idiotic switch 233 if (status != Quit) { //because of idiotic switch
234 if (response[0] == '+') { 234 if (response[0] == '+') {
235 temp = response.replace(0, 4, ""); 235 temp = response.replace(0, 4, "");
236 int x = temp.find(" ", 0); 236 int x = temp.find(" ", 0);
237 temp = temp.right(temp.length() - ((uint) x + 1) ); 237 temp = temp.right(temp.length() - ((uint) x + 1) );
238 mailSize = temp.toInt(); 238 mailSize = temp.toInt();
239 emit currentMailSize(mailSize); 239 emit currentMailSize(mailSize);
240 240
241 status = Retr; 241 status = Retr;
242 } else { 242 } else {
243 qWarning(response); 243 //qWarning(response);
244 errorHandling(ErrUnknownResponse); 244 errorHandling(ErrUnknownResponse);
245 } 245 }
246 } 246 }
247 } 247 }
248 //Read message number x, count upwards to messageCount 248 //Read message number x, count upwards to messageCount
249 case Retr: { 249 case Retr: {
250 if (status != Quit) { 250 if (status != Quit) {
251 if (!preview || mailSize <= headerLimit) { 251 if (!preview || mailSize <= headerLimit) {
252 *stream << "RETR " << messageCount << "\r\n"; 252 *stream << "RETR " << messageCount << "\r\n";
253 } else { //only header 253 } else { //only header
254 *stream << "TOP " << messageCount << " 0\r\n"; 254 *stream << "TOP " << messageCount << " 0\r\n";
255 } 255 }
256 messageCount++; 256 messageCount++;
257 status = Ignore; 257 status = Ignore;
258 break; 258 break;
259 } } 259 } }
260 case Ignore: { 260 case Ignore: {
261 if (status != Quit) { //because of idiotic switch 261 if (status != Quit) { //because of idiotic switch
262 if (response[0] == '+') { 262 if (response[0] == '+') {
263 message = ""; 263 message = "";
264 status = Read; 264 status = Read;
265 if (!socket->canReadLine()) //sync. problems 265 if (!socket->canReadLine()) //sync. problems
266 break; 266 break;
267 response = socket->readLine(); 267 response = socket->readLine();
268 } else errorHandling(ErrUnknownResponse); 268 } else errorHandling(ErrUnknownResponse);
269 } 269 }
270 } 270 }
271 //add all incoming lines to body. When size is reached, send 271 //add all incoming lines to body. When size is reached, send
272 //message, and go back to read new message 272 //message, and go back to read new message
273 case Read: { 273 case Read: {
274 if (status != Quit) { //because of idiotic switch 274 if (status != Quit) { //because of idiotic switch
275 message += response; 275 message += response;
276 while ( socket->canReadLine() ) { 276 while ( socket->canReadLine() ) {
277 response = socket->readLine(); 277 response = socket->readLine();
278 message += response; 278 message += response;
279 } 279 }
280 emit downloadedSize(message.length()); 280 emit downloadedSize(message.length());
281 int x = message.find("\r\n.\r\n",-5); 281 int x = message.find("\r\n.\r\n",-5);
282 if (x == -1) { 282 if (x == -1) {
283 break; 283 break;
284 } else { //message reach entire size 284 } else { //message reach entire size
285 //complete mail downloaded 285 //complete mail downloaded
286 if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ 286 if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){
287 emit newMessage(message, messageCount-1, mailSize, TRUE); 287 emit newMessage(message, messageCount-1, mailSize, TRUE);
288 } else { //incomplete mail downloaded 288 } else { //incomplete mail downloaded
289 emit newMessage(message, messageCount-1, mailSize, FALSE); 289 emit newMessage(message, messageCount-1, mailSize, FALSE);
290 } 290 }
291 if (messageCount > newMessages) //that was the last message 291 if (messageCount > newMessages) //that was the last message
292 status = Quit; 292 status = Quit;
293 else { //ask for new message 293 else { //ask for new message
294 if (selected) { //grab next from queue 294 if (selected) { //grab next from queue
295 int *ptr = mailList->next(); 295 int *ptr = mailList->next();
296 if (ptr != 0) { 296 if (ptr != 0) {
297 messageCount = *ptr; 297 messageCount = *ptr;
298 *stream << "LIST " << messageCount << "\r\n"; 298 *stream << "LIST " << messageCount << "\r\n";
299 status = Size; 299 status = Size;
300 //completing a previously closed transfer 300 //completing a previously closed transfer
301 if ( (messageCount - lastSync) <= 0) { 301 if ( (messageCount - lastSync) <= 0) {
302 temp.setNum(messageCount); 302 temp.setNum(messageCount);
303 emit updateStatus(tr("Previous message ") + temp); 303 emit updateStatus(tr("Previous message ") + temp);
304 } else { 304 } else {
305 temp.setNum(messageCount - lastSync); 305 temp.setNum(messageCount - lastSync);
306 emit updateStatus(tr("Completing message ") + temp); 306 emit updateStatus(tr("Completing message ") + temp);
307 } 307 }
308 break; 308 break;
309 } else { 309 } else {
310 newMessages--; 310 newMessages--;
311 status = Quit; 311 status = Quit;
312 } 312 }
313 } else { 313 } else {
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp
index a5e7147..7cd3e09 100644
--- a/noncore/net/mailit/readmail.cpp
+++ b/noncore/net/mailit/readmail.cpp
@@ -68,48 +68,49 @@ void ReadMail::init()
68 nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); 68 nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
69 connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); 69 connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) );
70 nextButton->addTo(bar); 70 nextButton->addTo(bar);
71 nextButton->addTo(viewMenu); 71 nextButton->addTo(viewMenu);
72 72
73 attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); 73 attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 );
74 connect( attatchmentsButton, SIGNAL( activated() ), this, 74 connect( attatchmentsButton, SIGNAL( activated() ), this,
75 SLOT( viewAttatchments() ) ); 75 SLOT( viewAttatchments() ) );
76 attatchmentsButton->addTo(bar); 76 attatchmentsButton->addTo(bar);
77 attatchmentsButton->addTo(viewMenu); 77 attatchmentsButton->addTo(viewMenu);
78 78
79 plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); 79 plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE);
80 connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); 80 connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) );
81 plainTextButton->addTo(bar); 81 plainTextButton->addTo(bar);
82 plainTextButton->addTo(viewMenu); 82 plainTextButton->addTo(viewMenu);
83 83
84 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); 84 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
85 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); 85 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
86 deleteButton->addTo(bar); 86 deleteButton->addTo(bar);
87 deleteButton->addTo(mailMenu); 87 deleteButton->addTo(mailMenu);
88 88
89 viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); 89 viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close()));
90 90
91 emailView = new QTextView( this, "emailView" ); 91 emailView = new QTextView( this, "emailView" );
92
92 setCentralWidget(emailView); 93 setCentralWidget(emailView);
93 94
94 mime = new QMimeSourceFactory(); 95 mime = new QMimeSourceFactory();
95 emailView->setMimeSourceFactory(mime); 96 emailView->setMimeSourceFactory(mime);
96} 97}
97 98
98void ReadMail::updateView() 99void ReadMail::updateView()
99{ 100{
100 Enclosure *ePtr; 101 Enclosure *ePtr;
101 QString mailStringSize; 102 QString mailStringSize;
102 QString text, temp; 103 QString text, temp;
103 104
104 mail->read = TRUE; //mark as read 105 mail->read = TRUE; //mark as read
105 inbox = mail->received; 106 inbox = mail->received;
106 107
107 replyButton->removeFrom(mailMenu); 108 replyButton->removeFrom(mailMenu);
108 replyButton->removeFrom(bar); 109 replyButton->removeFrom(bar);
109 110
110 if (inbox == TRUE) { 111 if (inbox == TRUE) {
111 replyButton->addTo(bar); 112 replyButton->addTo(bar);
112 replyButton->addTo(mailMenu); 113 replyButton->addTo(mailMenu);
113 114
114 if (!mail->downloaded) { 115 if (!mail->downloaded) {
115 //report currently viewed mail so that it will be 116 //report currently viewed mail so that it will be
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 6699a90..b2e38e5 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -66,106 +66,106 @@ void SmtpClient::addMail(QString from, QString subject, QStringList to, QString
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 emit errorOccurred(status); 76 emit errorOccurred(status);
77 socket->close(); 77 socket->close();
78 mailList.clear(); 78 mailList.clear();
79 sending = FALSE; 79 sending = FALSE;
80} 80}
81 81
82void SmtpClient::incomingData() 82void SmtpClient::incomingData()
83{ 83{
84 QString response; 84 QString response;
85 85
86 if (!socket->canReadLine()) 86 if (!socket->canReadLine())
87 return; 87 return;
88 88
89 response = socket->readLine(); 89 response = socket->readLine();
90 qDebug(response); 90 //qDebug(response);
91 91
92 switch(status) { 92 switch(status) {
93 case Init: { 93 case Init: {
94 if (response[0] == '2') { 94 if (response[0] == '2') {
95 status = From; 95 status = From;
96 mailPtr = mailList.first(); 96 mailPtr = mailList.first();
97 *stream << "HELO there\r\n"; 97 *stream << "HELO there\r\n";
98 qDebug("HELO"); 98 //qDebug("HELO");
99 } else errorHandling(ErrUnknownResponse); 99 } else errorHandling(ErrUnknownResponse);
100 break; 100 break;
101 } 101 }
102 case From: { 102 case From: {
103 if (response[0] == '2') { 103 if (response[0] == '2') {
104 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; 104 *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
105 status = Recv; 105 status = Recv;
106 qDebug("MAIL FROM: "+mailPtr->from); 106 //qDebug("MAIL FROM: "+mailPtr->from);
107 } else errorHandling(ErrUnknownResponse); 107 } else errorHandling(ErrUnknownResponse);
108 break; 108 break;
109 } 109 }
110 case Recv: { 110 case Recv: {
111 if (response[0] == '2') { 111 if (response[0] == '2') {
112 it = mailPtr->to.begin(); 112 it = mailPtr->to.begin();
113 if (it == NULL) 113 if (it == NULL)
114 errorHandling(ErrUnknownResponse); 114 errorHandling(ErrUnknownResponse);
115 *stream << "RCPT TO: <" << *it << ">\r\n"; 115 *stream << "RCPT TO: " << *it << ">\r\n";
116 qDebug("RCPT TO: "+ *it); 116 //qDebug("RCPT TO: "+ *it);
117 status = MRcv; 117 status = MRcv;
118 } else errorHandling(ErrUnknownResponse); 118 } else errorHandling(ErrUnknownResponse);
119 break; 119 break;
120 } 120 }
121 case MRcv: { 121 case MRcv: {
122 if (response[0] == '2') { 122 if (response[0] == '2') {
123 it++; 123 it++;
124 if ( it != mailPtr->to.end() ) { 124 if ( it != mailPtr->to.end() ) {
125 *stream << "RCPT TO: <" << *it << ">\r\n"; 125 *stream << "RCPT TO: <" << *it << ">\r\n";
126 qDebug("RCPT TO: "+ *it); 126 //qDebug("RCPT TO: "+ *it);
127 break; 127 break;
128 } else { 128 } else {
129 status = Data; 129 status = Data;
130 } 130 }
131 } else errorHandling(ErrUnknownResponse); 131 } else errorHandling(ErrUnknownResponse);
132 } 132 }
133 case Data: { 133 case Data: {
134 if (response[0] == '2') { 134 if (response[0] == '2') {
135 *stream << "DATA\r\n"; 135 *stream << "DATA\r\n";
136 status = Body; 136 status = Body;
137 qDebug("DATA"); 137 //qDebug("DATA");
138 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
139 } else errorHandling(ErrUnknownResponse); 139 } else errorHandling(ErrUnknownResponse);
140 break; 140 break;
141 } 141 }
142 case Body: { 142 case Body: {
143 if (response[0] == '3') { 143 if (response[0] == '3') {
144 *stream << mailPtr->body << "\r\n.\r\n"; 144 *stream << mailPtr->body << "\r\n.\r\n";
145 mailPtr = mailList.next(); 145 mailPtr = mailList.next();
146 if (mailPtr != NULL) { 146 if (mailPtr != NULL) {
147 status = From; 147 status = From;
148 } else { 148 } else {
149 status = Quit; 149 status = Quit;
150 } 150 }
151 qDebug("BODY"); 151 //qDebug("BODY");
152 } else errorHandling(ErrUnknownResponse); 152 } else errorHandling(ErrUnknownResponse);
153 break; 153 break;
154 } 154 }
155 case Quit: { 155 case Quit: {
156 if (response[0] == '2') { 156 if (response[0] == '2') {
157 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
158 status = Done; 158 status = Done;
159 QString temp; 159 QString temp;
160 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
161 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
162 emit mailSent(); 162 emit mailSent();
163 mailList.clear(); 163 mailList.clear();
164 sending = FALSE; 164 sending = FALSE;
165 socket->close(); 165 socket->close();
166 qDebug("QUIT"); 166 //qDebug("QUIT");
167 } else errorHandling(ErrUnknownResponse); 167 } else errorHandling(ErrUnknownResponse);
168 break; 168 break;
169 } 169 }
170 } 170 }
171} 171}
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 9fe558a..8d9ab91 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -106,49 +106,49 @@ int AddressList::getNameRef(QString name)
106 return pos; 106 return pos;
107 pos++; 107 pos++;
108 } 108 }
109 return -1; 109 return -1;
110} 110}
111 111
112QList<Contact>* AddressList::getContactList() 112QList<Contact>* AddressList::getContactList()
113{ 113{
114 return &addresses; 114 return &addresses;
115} 115}
116 116
117void AddressList::read() 117void AddressList::read()
118{ 118{
119 OContactAccess::List::Iterator it; 119 OContactAccess::List::Iterator it;
120 120
121 QString lineEmail, lineName, email, name; 121 QString lineEmail, lineName, email, name;
122 OContactAccess m_contactdb("mailit"); 122 OContactAccess m_contactdb("mailit");
123 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 123 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
124 //OContact* oc; 124 //OContact* oc;
125 125
126 for ( it = m_list.begin(); it != m_list.end(); ++it ) 126 for ( it = m_list.begin(); it != m_list.end(); ++it )
127 { 127 {
128 //oc=(OContact*) it; 128 //oc=(OContact*) it;
129 if ((*it).defaultEmail().length()!=0) 129 if ((*it).defaultEmail().length()!=0)
130 addContact((*it).defaultEmail(),(*it).fullName()); 130 addContact((*it).defaultEmail(),(*it).fileAs());
131 } 131 }
132 132
133 /*if (! f.open(IO_ReadOnly) ) 133 /*if (! f.open(IO_ReadOnly) )
134 return; 134 return;
135 135
136 QTextStream stream(&f); 136 QTextStream stream(&f);
137 137
138 while (! stream.atEnd() ) { 138 while (! stream.atEnd() ) {
139 lineEmail = stream.readLine(); 139 lineEmail = stream.readLine();
140 if (! stream.atEnd() ) 140 if (! stream.atEnd() )
141 lineName = stream.readLine(); 141 lineName = stream.readLine();
142 else return; 142 else return;
143 143
144 email = getRightString(lineEmail); 144 email = getRightString(lineEmail);
145 name = getRightString(lineName); 145 name = getRightString(lineName);
146 addContact(email, name); 146 addContact(email, name);
147 } 147 }
148 f.close();*/ 148 f.close();*/
149} 149}
150 150
151QString AddressList::getRightString(QString in) 151QString AddressList::getRightString(QString in)
152{ 152{
153 QString out = ""; 153 QString out = "";
154 154
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index 6612541..0d82a9a 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -511,49 +511,49 @@ void EmailClient::inboxItemSelected()
511{ 511{
512 item = (EmailListItem*) inboxView->selectedItem(); 512 item = (EmailListItem*) inboxView->selectedItem();
513 if (item != NULL) { 513 if (item != NULL) {
514 emit viewEmail(inboxView, item->getMail()); 514 emit viewEmail(inboxView, item->getMail());
515 } 515 }
516} 516}
517 517
518void EmailClient::outboxItemSelected() 518void EmailClient::outboxItemSelected()
519{ 519{
520 item = (EmailListItem*) outboxView->selectedItem(); 520 item = (EmailListItem*) outboxView->selectedItem();
521 if (item != NULL) { 521 if (item != NULL) {
522 emit viewEmail(outboxView, item->getMail()); 522 emit viewEmail(outboxView, item->getMail());
523 } 523 }
524 524
525} 525}
526 526
527void EmailClient::readMail() 527void EmailClient::readMail()
528{ 528{
529 Email mail; 529 Email mail;
530 int start, stop; 530 int start, stop;
531 QString s, del; 531 QString s, del;
532 532
533 QFile f(getPath(FALSE) + "inbox.txt"); 533 QFile f(getPath(FALSE) + "inbox.txt");
534// QFileInfo fi(f); 534// QFileInfo fi(f);
535 qDebug( f.name()); 535 //qDebug( f.name());
536 536
537 if ( f.open(IO_ReadOnly) ) { // file opened successfully 537 if ( f.open(IO_ReadOnly) ) { // file opened successfully
538 QTextStream t( &f ); // use a text stream 538 QTextStream t( &f ); // use a text stream
539 s = t.read(); 539 s = t.read();
540 f.close(); 540 f.close();
541 541
542 start = 0; 542 start = 0;
543 del = "\n.\n"; 543 del = "\n.\n";
544 while ((uint) start < s.length()) { 544 while ((uint) start < s.length()) {
545 stop = s.find(del, start); 545 stop = s.find(del, start);
546 if (stop == -1) 546 if (stop == -1)
547 stop = s.length() - del.length(); 547 stop = s.length() - del.length();
548 548
549 mail.rawMail = s.mid(start, stop + del.length() - start ); 549 mail.rawMail = s.mid(start, stop + del.length() - start );
550 start = stop + del.length(); 550 start = stop + del.length();
551 mailArrived(mail, TRUE); 551 mailArrived(mail, TRUE);
552 } 552 }
553 } 553 }
554 554
555 QFile fo(getPath(FALSE) + "outbox.txt"); 555 QFile fo(getPath(FALSE) + "outbox.txt");
556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
557 QTextStream t( &fo ); // use a text stream 557 QTextStream t( &fo ); // use a text stream
558 s = t.read(); 558 s = t.read();
559 fo.close(); 559 fo.close();
@@ -565,54 +565,54 @@ void EmailClient::readMail()
565 if (stop == -1) 565 if (stop == -1)
566 stop = s.length() - del.length(); 566 stop = s.length() - del.length();
567 567
568 mail.rawMail = s.mid(start, stop + del.length() - start ); 568 mail.rawMail = s.mid(start, stop + del.length() - start );
569 start = stop + del.length(); 569 start = stop + del.length();
570 emailHandler->parse(mail.rawMail, lineShift, &mail); 570 emailHandler->parse(mail.rawMail, lineShift, &mail);
571 mail.sent = false; 571 mail.sent = false;
572 mail.received = false; 572 mail.received = false;
573 enqueMail(mail); 573 enqueMail(mail);
574 574
575 } 575 }
576 } 576 }
577} 577}
578 578
579void EmailClient::saveMail(QString fileName, QListView *view) 579void EmailClient::saveMail(QString fileName, QListView *view)
580{ 580{
581 QFile f(fileName); 581 QFile f(fileName);
582 Email *mail; 582 Email *mail;
583 583
584 if (! f.open(IO_WriteOnly) ) { 584 if (! f.open(IO_WriteOnly) ) {
585 qWarning("could not open file"); 585 qWarning("could not open file");
586 return; 586 return;
587 } 587 }
588 item = (EmailListItem *) view->firstChild(); 588 item = (EmailListItem *) view->firstChild();
589 qDebug (QString("Write : ") ); 589 //qDebug (QString("Write : ") );
590 QTextStream t(&f); 590 QTextStream t(&f);
591 while (item != NULL) { 591 while (item != NULL) {
592 mail = item->getMail(); 592 mail = item->getMail();
593 qDebug(mail->rawMail); 593 //qDebug(mail->rawMail);
594 qDebug(mail->recipients.first()); 594 //qDebug(mail->recipients.first());
595 t << mail->rawMail; 595 t << mail->rawMail;
596 596
597 mailconf->setGroup(mail->id); 597 mailconf->setGroup(mail->id);
598 mailconf->writeEntry("mailread", mail->read); 598 mailconf->writeEntry("mailread", mail->read);
599 599
600 item = (EmailListItem *) item->nextSibling(); 600 item = (EmailListItem *) item->nextSibling();
601 } 601 }
602 f.close(); 602 f.close();
603} 603}
604 604
605//paths for mailit, is settings, inbox, enclosures 605//paths for mailit, is settings, inbox, enclosures
606QString EmailClient::getPath(bool enclosurePath) 606QString EmailClient::getPath(bool enclosurePath)
607{ 607{
608 QString basePath = "qtmail"; 608 QString basePath = "qtmail";
609 QString enclosures = "enclosures"; 609 QString enclosures = "enclosures";
610 610
611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
612 if ( !dir.exists() ) 612 if ( !dir.exists() )
613 dir.mkdir( dir.path() ); 613 dir.mkdir( dir.path() );
614 614
615 if (enclosurePath) { 615 if (enclosurePath) {
616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
617 617
618 if ( !dir.exists() ) 618 if ( !dir.exists() )
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 9c1c814..03f8a28 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -142,50 +142,48 @@ void EmailHandler::messageArrived(const QString &message, int id, uint size, boo
142 mail.rawMail = message; 142 mail.rawMail = message;
143 mail.serverId = id; 143 mail.serverId = id;
144 mail.size = size; 144 mail.size = size;
145 mail.downloaded = complete; 145 mail.downloaded = complete;
146 146
147 emit mailArrived(mail, FALSE); 147 emit mailArrived(mail, FALSE);
148} 148}
149 149
150bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 150bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
151{ 151{
152 QString temp, boundary; 152 QString temp, boundary;
153 int pos; 153 int pos;
154 QString delimiter, header, body, mimeHeader, mimeBody; 154 QString delimiter, header, body, mimeHeader, mimeBody;
155 QString content, contentType, contentAttribute, id, encoding; 155 QString content, contentType, contentAttribute, id, encoding;
156 QString fileName, storedName; 156 QString fileName, storedName;
157 int enclosureId = 0; 157 int enclosureId = 0;
158 158
159 mail->rawMail = in; 159 mail->rawMail = in;
160 mail->received = TRUE; 160 mail->received = TRUE;
161 mail->files.setAutoDelete(TRUE); 161 mail->files.setAutoDelete(TRUE);
162 162
163 temp = lineShift + "." + lineShift; 163 temp = lineShift + "." + lineShift;
164 164
165 if (in.right(temp.length()) != temp) { 165 if (in.right(temp.length()) != temp) {
166 qWarning(in.right(temp.length()));
167 qWarning(" . added at end of email as separator");
168 mail->rawMail += temp; 166 mail->rawMail += temp;
169 } 167 }
170 168
171 169
172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 170 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
173 pos = in.find(delimiter, 0, FALSE); 171 pos = in.find(delimiter, 0, FALSE);
174 header = in.left(pos); 172 header = in.left(pos);
175 body = in.right(in.length() - pos - delimiter.length()); 173 body = in.right(in.length() - pos - delimiter.length());
176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 174 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
177 body.truncate(body.length()-2); 175 body.truncate(body.length()-2);
178 176
179 TextParser p(header, lineShift); 177 TextParser p(header, lineShift);
180 178
181 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { 179 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
182 pos++; 180 pos++;
183 if (p.separatorAt(pos) == ' ') { 181 if (p.separatorAt(pos) == ' ') {
184 mail->from = p.getString(&pos, '<', false); 182 mail->from = p.getString(&pos, '<', false);
185 mail->from = mail->from.stripWhiteSpace(); 183 mail->from = mail->from.stripWhiteSpace();
186 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 184 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
187 mail->from = mail->from.left(mail->from.length() - 1); 185 mail->from = mail->from.left(mail->from.length() - 1);
188 mail->from = mail->from.right(mail->from.length() - 1); 186 mail->from = mail->from.right(mail->from.length() - 1);
189 } 187 }
190 pos++; 188 pos++;
191 mail->fromMail = p.getString(&pos, '>', false); 189 mail->fromMail = p.getString(&pos, '>', false);
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp
index fd49c1f..2bf1dcb 100644
--- a/noncore/unsupported/mailit/mailitwindow.cpp
+++ b/noncore/unsupported/mailit/mailitwindow.cpp
@@ -6,82 +6,79 @@
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 "mailitwindow.h" 20#include "mailitwindow.h"
21 21
22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
23 : QMainWindow(parent, name, fl) 23 : QMainWindow(parent, name, fl)
24{ 24{
25 currentCaption = "Mailit"; 25 currentCaption = "Mailit";
26 setCaption(tr(currentCaption)); 26 setCaption(tr(currentCaption));
27 views = new QWidgetStack(this); 27 views = new QWidgetStack(this);
28 setCentralWidget(views); 28 setCentralWidget(views);
29 29
30 qWarning("***Starting writeMail");
31 emailClient = new EmailClient(views, "client"); 30 emailClient = new EmailClient(views, "client");
32 writeMail = new WriteMail(views, "writing"); 31 writeMail = new WriteMail(views, "writing");
33 readMail = new ReadMail(views, "reading"); 32 readMail = new ReadMail(views, "reading");
34 qWarning("***Finished readMail");
35 33
36 views->raiseWidget(emailClient); 34 views->raiseWidget(emailClient);
37 35
38 connect(emailClient, SIGNAL(composeRequested()), 36 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) ); 37 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 38 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) ); 39 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 40 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) ); 41 SLOT(updateMailView(Email *)) );
44 42
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 43 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 44 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) ); 45 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) ); 47 SLOT(enqueMail(const Email &)) );
50 48
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 49 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &)), this, 50 connect(readMail, SIGNAL(replyRequested(Email &)), this,
53 SLOT(composeReply(Email &)) ); 51 SLOT(composeReply(Email &)) );
54 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 52 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
55 SLOT(deleteMail(EmailListItem *, bool &)) ); 53 SLOT(deleteMail(EmailListItem *, bool &)) );
56 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 54 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
57 SLOT(moveMailFront(Email *)) ); 55 SLOT(moveMailFront(Email *)) );
58 56
59 connect(emailClient, SIGNAL(newCaption(const QString &)), 57 connect(emailClient, SIGNAL(newCaption(const QString &)),
60 this, SLOT(updateCaption(const QString &)) ); 58 this, SLOT(updateCaption(const QString &)) );
61 viewingMail = FALSE; 59 viewingMail = FALSE;
62 60
63 qWarning("***Finished MailitWindow");
64} 61}
65 62
66MailItWindow::~MailItWindow() 63MailItWindow::~MailItWindow()
67{ 64{
68} 65}
69 66
70void MailItWindow::closeEvent(QCloseEvent *e) 67void MailItWindow::closeEvent(QCloseEvent *e)
71{ 68{
72 if (views->visibleWidget() == emailClient) { 69 if (views->visibleWidget() == emailClient) {
73 e->accept(); 70 e->accept();
74 } else { 71 } else {
75 showEmailClient(); 72 showEmailClient();
76 } 73 }
77} 74}
78 75
79void MailItWindow::compose() 76void MailItWindow::compose()
80{ 77{
81 viewingMail = FALSE; 78 viewingMail = FALSE;
82 emailClient->hide(); 79 emailClient->hide();
83 readMail->hide(); 80 readMail->hide();
84 views->raiseWidget(writeMail); 81 views->raiseWidget(writeMail);
85 writeMail->setAddressList(emailClient->getAdrListRef()); 82 writeMail->setAddressList(emailClient->getAdrListRef());
86 setCaption( tr( "Write mail" ) ); 83 setCaption( tr( "Write mail" ) );
87} 84}
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 2f14ed2..f9cc337 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -98,61 +98,61 @@ void PopClient::setSelectedMails(MailList *list)
98void PopClient::connectionEstablished() 98void PopClient::connectionEstablished()
99{ 99{
100 emit updateStatus(tr("Connection established")); 100 emit updateStatus(tr("Connection established"));
101} 101}
102 102
103void PopClient::errorHandling(int status) 103void PopClient::errorHandling(int status)
104{ 104{
105 emit updateStatus(tr("Error Occured")); 105 emit updateStatus(tr("Error Occured"));
106 emit errorOccurred(status); 106 emit errorOccurred(status);
107 socket->close(); 107 socket->close();
108 receiving = FALSE; 108 receiving = FALSE;
109} 109}
110 110
111void PopClient::incomingData() 111void PopClient::incomingData()
112{ 112{
113 QString response, temp, temp2, timeStamp; 113 QString response, temp, temp2, timeStamp;
114 QString md5Source; 114 QString md5Source;
115 int start, end; 115 int start, end;
116// char *md5Digest; 116// char *md5Digest;
117 char md5Digest[16]; 117 char md5Digest[16];
118// if ( !socket->canReadLine() ) 118// if ( !socket->canReadLine() )
119// return; 119// return;
120 120
121 response = socket->readLine(); 121 response = socket->readLine();
122 qDebug(response +" %d", status); 122 //qDebug(response +" %d", status);
123 123
124 switch(status) { 124 switch(status) {
125 //logging in 125 //logging in
126 case Init: { 126 case Init: {
127#ifdef APOP_TEST 127#ifdef APOP_TEST
128 start = response.find('<',0); 128 start = response.find('<',0);
129 end = response.find('>', start); 129 end = response.find('>', start);
130 if( start >= 0 && end > start ) 130 if( start >= 0 && end > start )
131 { 131 {
132 timeStamp = response.mid( start , end - start + 1); 132 timeStamp = response.mid( start , end - start + 1);
133 md5Source = timeStamp + popPassword; 133 md5Source = timeStamp + popPassword;
134 qDebug( md5Source); 134 //qDebug( md5Source);
135// for( int i = 0; i < md5Source.length(); i++) { 135// for( int i = 0; i < md5Source.length(); i++) {
136// buff[i] = (QChar)md5Source[i]; 136// buff[i] = (QChar)md5Source[i];
137// } 137// }
138 138
139 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 139 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
140// md5_buffer(char const *buffer, unsigned int len, char *digest); 140// md5_buffer(char const *buffer, unsigned int len, char *digest);
141 141
142// MD5_Init( &ctx); 142// MD5_Init( &ctx);
143// MD5_Update( &ctx, buff, sizeof( buff) ); 143// MD5_Update( &ctx, buff, sizeof( buff) );
144// MD5_Final( md5Digest, &ctx); 144// MD5_Final( md5Digest, &ctx);
145// MD5( buff, md5Source.length(), md5Digest); 145// MD5( buff, md5Source.length(), md5Digest);
146 146
147 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 147 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
148 { 148 {
149 printf("%x", md5Digest[j]); 149 printf("%x", md5Digest[j]);
150 } 150 }
151 printf("\n"); 151 printf("\n");
152// qDebug(md5Digest); 152// qDebug(md5Digest);
153 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 153 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
154 // qDebug("%s", stream); 154 // qDebug("%s", stream);
155 status = Stat; 155 status = Stat;
156 } 156 }
157 else 157 else
158#endif 158#endif
@@ -171,143 +171,143 @@ void PopClient::incomingData()
171 break; 171 break;
172 } 172 }
173 //ask for number of messages 173 //ask for number of messages
174 case Stat: { 174 case Stat: {
175 if (response[0] == '+') { 175 if (response[0] == '+') {
176 *stream << "STAT" << "\r\n"; 176 *stream << "STAT" << "\r\n";
177 status = Mcnt; 177 status = Mcnt;
178 } else errorHandling(ErrLoginFailed); 178 } else errorHandling(ErrLoginFailed);
179 break; 179 break;
180 } 180 }
181 //get count of messages, eg "+OK 4 900.." -> int 4 181 //get count of messages, eg "+OK 4 900.." -> int 4
182 case Mcnt: { 182 case Mcnt: {
183 if (response[0] == '+') { 183 if (response[0] == '+') {
184 temp = response.replace(0, 4, ""); 184 temp = response.replace(0, 4, "");
185 int x = temp.find(" ", 0); 185 int x = temp.find(" ", 0);
186 temp.truncate((uint) x); 186 temp.truncate((uint) x);
187 newMessages = temp.toInt(); 187 newMessages = temp.toInt();
188 messageCount = 1; 188 messageCount = 1;
189 status = List; 189 status = List;
190 190
191 if (synchronize) { 191 if (synchronize) {
192 //messages deleted from server, reload all 192 //messages deleted from server, reload all
193 if (newMessages < lastSync) 193 if (newMessages < lastSync)
194 lastSync = 0; 194 lastSync = 0;
195 messageCount = lastSync + 1; 195 messageCount = 1;
196 } 196 }
197 197
198 if (selected) { 198 if (selected) {
199 int *ptr = mailList->first(); 199 int *ptr = mailList->first();
200 if (ptr != 0) { 200 if (ptr != 0) {
201 newMessages++; //to ensure no early jumpout 201 newMessages++; //to ensure no early jumpout
202 messageCount = *(mailList->first()); 202 messageCount = *(mailList->first());
203 } else newMessages = 0; 203 } else newMessages = 0;
204 } 204 }
205 } else errorHandling(ErrUnknownResponse); 205 } else errorHandling(ErrUnknownResponse);
206 } 206 }
207 //Read message number x, count upwards to messageCount 207 //Read message number x, count upwards to messageCount
208 case List: { 208 case List: {
209 if (messageCount <= newMessages) { 209 if (messageCount <= newMessages) {
210 *stream << "LIST " << messageCount << "\r\n"; 210 *stream << "LIST " << messageCount << "\r\n";
211 status = Size; 211 status = Size;
212 temp2.setNum(newMessages - lastSync); 212 temp2.setNum(newMessages - lastSync);
213 temp.setNum(messageCount - lastSync); 213 temp.setNum(messageCount - lastSync);
214 if (!selected) { 214 if (!selected) {
215 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 215 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
216 } else { 216 } else {
217 //completing a previously closed transfer 217 //completing a previously closed transfer
218 if ( (messageCount - lastSync) <= 0) { 218 if ( (messageCount - lastSync) <= 0) {
219 temp.setNum(messageCount); 219 temp.setNum(messageCount);
220 emit updateStatus(tr("Previous message ") + temp); 220 emit updateStatus(tr("Previous message ") + temp);
221 } else { 221 } else {
222 emit updateStatus(tr("Completing message ") + temp); 222 emit updateStatus(tr("Completing message ") + temp);
223 } 223 }
224 } 224 }
225 break; 225 break;
226 } else { 226 } else {
227 emit updateStatus(tr("No new Messages")); 227 emit updateStatus(tr("No new Messages"));
228 status = Quit; 228 status = Quit;
229 } 229 }
230 } 230 }
231 //get size of message, eg "500 characters in message.." -> int 500 231 //get size of message, eg "500 characters in message.." -> int 500
232 case Size: { 232 case Size: {
233 if (status != Quit) { //because of idiotic switch 233 if (status != Quit) { //because of idiotic switch
234 if (response[0] == '+') { 234 if (response[0] == '+') {
235 temp = response.replace(0, 4, ""); 235 temp = response.replace(0, 4, "");
236 int x = temp.find(" ", 0); 236 int x = temp.find(" ", 0);
237 temp = temp.right(temp.length() - ((uint) x + 1) ); 237 temp = temp.right(temp.length() - ((uint) x + 1) );
238 mailSize = temp.toInt(); 238 mailSize = temp.toInt();
239 emit currentMailSize(mailSize); 239 emit currentMailSize(mailSize);
240 240
241 status = Retr; 241 status = Retr;
242 } else { 242 } else {
243 qWarning(response); 243 //qWarning(response);
244 errorHandling(ErrUnknownResponse); 244 errorHandling(ErrUnknownResponse);
245 } 245 }
246 } 246 }
247 } 247 }
248 //Read message number x, count upwards to messageCount 248 //Read message number x, count upwards to messageCount
249 case Retr: { 249 case Retr: {
250 if (status != Quit) { 250 if (status != Quit) {
251 if (!preview || mailSize <= headerLimit) { 251 if (!preview || mailSize <= headerLimit) {
252 *stream << "RETR " << messageCount << "\r\n"; 252 *stream << "RETR " << messageCount << "\r\n";
253 } else { //only header 253 } else { //only header
254 *stream << "TOP " << messageCount << " 0\r\n"; 254 *stream << "TOP " << messageCount << " 0\r\n";
255 } 255 }
256 messageCount++; 256 messageCount++;
257 status = Ignore; 257 status = Ignore;
258 break; 258 break;
259 } } 259 } }
260 case Ignore: { 260 case Ignore: {
261 if (status != Quit) { //because of idiotic switch 261 if (status != Quit) { //because of idiotic switch
262 if (response[0] == '+') { 262 if (response[0] == '+') {
263 message = ""; 263 message = "";
264 status = Read; 264 status = Read;
265 if (!socket->canReadLine()) //sync. problems 265 if (!socket->canReadLine()) //sync. problems
266 break; 266 break;
267 response = socket->readLine(); 267 response = socket->readLine();
268 } else errorHandling(ErrUnknownResponse); 268 } else errorHandling(ErrUnknownResponse);
269 } 269 }
270 } 270 }
271 //add all incoming lines to body. When size is reached, send 271 //add all incoming lines to body. When size is reached, send
272 //message, and go back to read new message 272 //message, and go back to read new message
273 case Read: { 273 case Read: {
274 if (status != Quit) { //because of idiotic switch 274 if (status != Quit) { //because of idiotic switch
275 message += response; 275 message += response;
276 while ( socket->canReadLine() ) { 276 while ( socket->canReadLine() ) {
277 response = socket->readLine(); 277 response = socket->readLine();
278 message += response; 278 message += response;
279 } 279 }
280 emit downloadedSize(message.length()); 280 emit downloadedSize(message.length());
281 int x = message.find("\r\n.\r\n",-5); 281 int x = message.find("\r\n.\r\n",-5);
282 if (x == -1) { 282 if (x == -1) {
283 break; 283 break;
284 } else { //message reach entire size 284 } else { //message reach entire size
285 //complete mail downloaded 285 //complete mail downloaded
286 if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ 286 if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){
287 emit newMessage(message, messageCount-1, mailSize, TRUE); 287 emit newMessage(message, messageCount-1, mailSize, TRUE);
288 } else { //incomplete mail downloaded 288 } else { //incomplete mail downloaded
289 emit newMessage(message, messageCount-1, mailSize, FALSE); 289 emit newMessage(message, messageCount-1, mailSize, FALSE);
290 } 290 }
291 if (messageCount > newMessages) //that was the last message 291 if (messageCount > newMessages) //that was the last message
292 status = Quit; 292 status = Quit;
293 else { //ask for new message 293 else { //ask for new message
294 if (selected) { //grab next from queue 294 if (selected) { //grab next from queue
295 int *ptr = mailList->next(); 295 int *ptr = mailList->next();
296 if (ptr != 0) { 296 if (ptr != 0) {
297 messageCount = *ptr; 297 messageCount = *ptr;
298 *stream << "LIST " << messageCount << "\r\n"; 298 *stream << "LIST " << messageCount << "\r\n";
299 status = Size; 299 status = Size;
300 //completing a previously closed transfer 300 //completing a previously closed transfer
301 if ( (messageCount - lastSync) <= 0) { 301 if ( (messageCount - lastSync) <= 0) {
302 temp.setNum(messageCount); 302 temp.setNum(messageCount);
303 emit updateStatus(tr("Previous message ") + temp); 303 emit updateStatus(tr("Previous message ") + temp);
304 } else { 304 } else {
305 temp.setNum(messageCount - lastSync); 305 temp.setNum(messageCount - lastSync);
306 emit updateStatus(tr("Completing message ") + temp); 306 emit updateStatus(tr("Completing message ") + temp);
307 } 307 }
308 break; 308 break;
309 } else { 309 } else {
310 newMessages--; 310 newMessages--;
311 status = Quit; 311 status = Quit;
312 } 312 }
313 } else { 313 } else {
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp
index a5e7147..7cd3e09 100644
--- a/noncore/unsupported/mailit/readmail.cpp
+++ b/noncore/unsupported/mailit/readmail.cpp
@@ -68,48 +68,49 @@ void ReadMail::init()
68 nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); 68 nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
69 connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); 69 connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) );
70 nextButton->addTo(bar); 70 nextButton->addTo(bar);
71 nextButton->addTo(viewMenu); 71 nextButton->addTo(viewMenu);
72 72
73 attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); 73 attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 );
74 connect( attatchmentsButton, SIGNAL( activated() ), this, 74 connect( attatchmentsButton, SIGNAL( activated() ), this,
75 SLOT( viewAttatchments() ) ); 75 SLOT( viewAttatchments() ) );
76 attatchmentsButton->addTo(bar); 76 attatchmentsButton->addTo(bar);
77 attatchmentsButton->addTo(viewMenu); 77 attatchmentsButton->addTo(viewMenu);
78 78
79 plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); 79 plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE);
80 connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); 80 connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) );
81 plainTextButton->addTo(bar); 81 plainTextButton->addTo(bar);
82 plainTextButton->addTo(viewMenu); 82 plainTextButton->addTo(viewMenu);
83 83
84 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); 84 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
85 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); 85 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
86 deleteButton->addTo(bar); 86 deleteButton->addTo(bar);
87 deleteButton->addTo(mailMenu); 87 deleteButton->addTo(mailMenu);
88 88
89 viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); 89 viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close()));
90 90
91 emailView = new QTextView( this, "emailView" ); 91 emailView = new QTextView( this, "emailView" );
92
92 setCentralWidget(emailView); 93 setCentralWidget(emailView);
93 94
94 mime = new QMimeSourceFactory(); 95 mime = new QMimeSourceFactory();
95 emailView->setMimeSourceFactory(mime); 96 emailView->setMimeSourceFactory(mime);
96} 97}
97 98
98void ReadMail::updateView() 99void ReadMail::updateView()
99{ 100{
100 Enclosure *ePtr; 101 Enclosure *ePtr;
101 QString mailStringSize; 102 QString mailStringSize;
102 QString text, temp; 103 QString text, temp;
103 104
104 mail->read = TRUE; //mark as read 105 mail->read = TRUE; //mark as read
105 inbox = mail->received; 106 inbox = mail->received;
106 107
107 replyButton->removeFrom(mailMenu); 108 replyButton->removeFrom(mailMenu);
108 replyButton->removeFrom(bar); 109 replyButton->removeFrom(bar);
109 110
110 if (inbox == TRUE) { 111 if (inbox == TRUE) {
111 replyButton->addTo(bar); 112 replyButton->addTo(bar);
112 replyButton->addTo(mailMenu); 113 replyButton->addTo(mailMenu);
113 114
114 if (!mail->downloaded) { 115 if (!mail->downloaded) {
115 //report currently viewed mail so that it will be 116 //report currently viewed mail so that it will be
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 6699a90..b2e38e5 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -66,106 +66,106 @@ void SmtpClient::addMail(QString from, QString subject, QStringList to, QString
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 emit errorOccurred(status); 76 emit errorOccurred(status);
77 socket->close(); 77 socket->close();
78 mailList.clear(); 78 mailList.clear();
79 sending = FALSE; 79 sending = FALSE;
80} 80}
81 81
82void SmtpClient::incomingData() 82void SmtpClient::incomingData()
83{ 83{
84 QString response; 84 QString response;
85 85
86 if (!socket->canReadLine()) 86 if (!socket->canReadLine())
87 return; 87 return;
88 88
89 response = socket->readLine(); 89 response = socket->readLine();
90 qDebug(response); 90 //qDebug(response);
91 91
92 switch(status) { 92 switch(status) {
93 case Init: { 93 case Init: {
94 if (response[0] == '2') { 94 if (response[0] == '2') {
95 status = From; 95 status = From;
96 mailPtr = mailList.first(); 96 mailPtr = mailList.first();
97 *stream << "HELO there\r\n"; 97 *stream << "HELO there\r\n";
98 qDebug("HELO"); 98 //qDebug("HELO");
99 } else errorHandling(ErrUnknownResponse); 99 } else errorHandling(ErrUnknownResponse);
100 break; 100 break;
101 } 101 }
102 case From: { 102 case From: {
103 if (response[0] == '2') { 103 if (response[0] == '2') {
104 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; 104 *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
105 status = Recv; 105 status = Recv;
106 qDebug("MAIL FROM: "+mailPtr->from); 106 //qDebug("MAIL FROM: "+mailPtr->from);
107 } else errorHandling(ErrUnknownResponse); 107 } else errorHandling(ErrUnknownResponse);
108 break; 108 break;
109 } 109 }
110 case Recv: { 110 case Recv: {
111 if (response[0] == '2') { 111 if (response[0] == '2') {
112 it = mailPtr->to.begin(); 112 it = mailPtr->to.begin();
113 if (it == NULL) 113 if (it == NULL)
114 errorHandling(ErrUnknownResponse); 114 errorHandling(ErrUnknownResponse);
115 *stream << "RCPT TO: <" << *it << ">\r\n"; 115 *stream << "RCPT TO: " << *it << ">\r\n";
116 qDebug("RCPT TO: "+ *it); 116 //qDebug("RCPT TO: "+ *it);
117 status = MRcv; 117 status = MRcv;
118 } else errorHandling(ErrUnknownResponse); 118 } else errorHandling(ErrUnknownResponse);
119 break; 119 break;
120 } 120 }
121 case MRcv: { 121 case MRcv: {
122 if (response[0] == '2') { 122 if (response[0] == '2') {
123 it++; 123 it++;
124 if ( it != mailPtr->to.end() ) { 124 if ( it != mailPtr->to.end() ) {
125 *stream << "RCPT TO: <" << *it << ">\r\n"; 125 *stream << "RCPT TO: <" << *it << ">\r\n";
126 qDebug("RCPT TO: "+ *it); 126 //qDebug("RCPT TO: "+ *it);
127 break; 127 break;
128 } else { 128 } else {
129 status = Data; 129 status = Data;
130 } 130 }
131 } else errorHandling(ErrUnknownResponse); 131 } else errorHandling(ErrUnknownResponse);
132 } 132 }
133 case Data: { 133 case Data: {
134 if (response[0] == '2') { 134 if (response[0] == '2') {
135 *stream << "DATA\r\n"; 135 *stream << "DATA\r\n";
136 status = Body; 136 status = Body;
137 qDebug("DATA"); 137 //qDebug("DATA");
138 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
139 } else errorHandling(ErrUnknownResponse); 139 } else errorHandling(ErrUnknownResponse);
140 break; 140 break;
141 } 141 }
142 case Body: { 142 case Body: {
143 if (response[0] == '3') { 143 if (response[0] == '3') {
144 *stream << mailPtr->body << "\r\n.\r\n"; 144 *stream << mailPtr->body << "\r\n.\r\n";
145 mailPtr = mailList.next(); 145 mailPtr = mailList.next();
146 if (mailPtr != NULL) { 146 if (mailPtr != NULL) {
147 status = From; 147 status = From;
148 } else { 148 } else {
149 status = Quit; 149 status = Quit;
150 } 150 }
151 qDebug("BODY"); 151 //qDebug("BODY");
152 } else errorHandling(ErrUnknownResponse); 152 } else errorHandling(ErrUnknownResponse);
153 break; 153 break;
154 } 154 }
155 case Quit: { 155 case Quit: {
156 if (response[0] == '2') { 156 if (response[0] == '2') {
157 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
158 status = Done; 158 status = Done;
159 QString temp; 159 QString temp;
160 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
161 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
162 emit mailSent(); 162 emit mailSent();
163 mailList.clear(); 163 mailList.clear();
164 sending = FALSE; 164 sending = FALSE;
165 socket->close(); 165 socket->close();
166 qDebug("QUIT"); 166 //qDebug("QUIT");
167 } else errorHandling(ErrUnknownResponse); 167 } else errorHandling(ErrUnknownResponse);
168 break; 168 break;
169 } 169 }
170 } 170 }
171} 171}