summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/addresslist.cpp190
-rw-r--r--noncore/net/mailit/addresslist.h36
-rw-r--r--noncore/net/mailit/emailclient.cpp177
-rw-r--r--noncore/net/mailit/emailclient.h2
-rw-r--r--noncore/net/mailit/emailhandler.cpp28
-rw-r--r--noncore/net/mailit/emailhandler.h166
-rw-r--r--noncore/net/mailit/emaillistitem.cpp96
-rw-r--r--noncore/net/mailit/popclient.cpp38
-rw-r--r--noncore/net/mailit/popclient.h4
-rw-r--r--noncore/net/mailit/smtpclient.cpp4
-rw-r--r--noncore/net/mailit/smtpclient.h58
-rw-r--r--noncore/net/mailit/textparser.cpp404
-rw-r--r--noncore/net/mailit/textparser.h6
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp190
-rw-r--r--noncore/unsupported/mailit/addresslist.h36
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp177
-rw-r--r--noncore/unsupported/mailit/emailclient.h2
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp28
-rw-r--r--noncore/unsupported/mailit/emailhandler.h166
-rw-r--r--noncore/unsupported/mailit/emaillistitem.cpp96
-rw-r--r--noncore/unsupported/mailit/popclient.cpp38
-rw-r--r--noncore/unsupported/mailit/popclient.h4
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp4
-rw-r--r--noncore/unsupported/mailit/smtpclient.h58
-rw-r--r--noncore/unsupported/mailit/textparser.cpp404
-rw-r--r--noncore/unsupported/mailit/textparser.h6
26 files changed, 1210 insertions, 1208 deletions
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
index 7d60ebf..18d14bc 100644
--- a/noncore/net/mailit/addresslist.cpp
+++ b/noncore/net/mailit/addresslist.cpp
@@ -17,145 +17,145 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <opie/ocontactaccess.h> 22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h> 23#include <opie/ocontact.h>
24 24
25#include "addresslist.h" 25#include "addresslist.h"
26 26
27AddressList::AddressList() 27AddressList::AddressList()
28{ 28{
29 addresses.setAutoDelete(TRUE); 29 addresses.setAutoDelete(TRUE);
30 read(); 30 read();
31 dirty = FALSE; 31 dirty = FALSE;
32} 32}
33 33
34AddressList::~AddressList() 34AddressList::~AddressList()
35{ 35{
36 addresses.clear(); 36 addresses.clear();
37} 37}
38 38
39void AddressList::addContact(QString email, QString name) 39void AddressList::addContact(const QString &email, const QString &name)
40{ 40{
41 //skip if not a valid email address, 41 //skip if not a valid email address,
42 if (email.find( '@') == -1) 42 if (email.find( '@') == -1)
43 return; 43 return;
44 44
45 if ( ! containsEmail(email) ) { 45 if ( ! containsEmail(email) ) {
46 Contact *in = new Contact; 46 Contact *in = new Contact;
47 in->email = email; 47 in->email = email;
48 in->name = name; 48 in->name = name;
49 addresses.append(in); 49 addresses.append(in);
50 dirty = TRUE; 50 dirty = TRUE;
51 } 51 }
52} 52}
53 53
54bool AddressList::containsEmail(QString email) 54bool AddressList::containsEmail(const QString &email)
55{ 55{
56 return ( getEmailRef(email) != -1 ); 56 return ( getEmailRef(email) != -1 );
57} 57}
58 58
59bool AddressList::containsName(QString name) 59bool AddressList::containsName(const QString &name)
60{ 60{
61 return ( getNameRef(name) != -1 ); 61 return ( getNameRef(name) != -1 );
62} 62}
63 63
64QString AddressList::getNameByEmail(QString email) 64QString AddressList::getNameByEmail(const QString &email)
65{ 65{
66 int pos = getEmailRef(email); 66 int pos = getEmailRef(email);
67 if (pos != -1) { 67 if (pos != -1) {
68 Contact *ptr = addresses.at(pos); 68 Contact *ptr = addresses.at(pos);
69 return ptr->name; 69 return ptr->name;
70 } 70 }
71 71
72 return NULL; 72 return NULL;
73} 73}
74 74
75QString AddressList::getEmailByName(QString name) 75QString AddressList::getEmailByName(const QString &name)
76{ 76{
77 int pos = getNameRef(name); 77 int pos = getNameRef(name);
78 if (pos != -1) { 78 if (pos != -1) {
79 Contact *ptr = addresses.at(pos); 79 Contact *ptr = addresses.at(pos);
80 return ptr->email; 80 return ptr->email;
81 } 81 }
82 82
83 return NULL; 83 return NULL;
84} 84}
85 85
86int AddressList::getEmailRef(QString email) 86int AddressList::getEmailRef(const QString &email)
87{ 87{
88 int pos = 0; 88 int pos = 0;
89 Contact *ptr; 89 Contact *ptr;
90 90
91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
92 if (ptr->email == email) 92 if (ptr->email == email)
93 return pos; 93 return pos;
94 pos++; 94 pos++;
95 } 95 }
96 return -1; 96 return -1;
97} 97}
98 98
99int AddressList::getNameRef(QString name) 99int AddressList::getNameRef(const QString &name)
100{ 100{
101 int pos = 0; 101 int pos = 0;
102 Contact *ptr; 102 Contact *ptr;
103 103
104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
105 if (ptr->name == name) 105 if (ptr->name == 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;(*it).defaultEmail() 124 //OContact* oc;(*it).defaultEmail()
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).fileAs()); 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(const QString &in)
152{ 152{
153 QString out = ""; 153 QString out = "";
154 154
155 int pos = in.find('='); 155 int pos = in.find('=');
156 if (pos != -1) { 156 if (pos != -1) {
157 out = in.mid(pos+1).stripWhiteSpace(); 157 out = in.mid(pos+1).stripWhiteSpace();
158 } 158 }
159 return out; 159 return out;
160} 160}
161 161
diff --git a/noncore/net/mailit/addresslist.h b/noncore/net/mailit/addresslist.h
index 99cef9a..b46d467 100644
--- a/noncore/net/mailit/addresslist.h
+++ b/noncore/net/mailit/addresslist.h
@@ -16,43 +16,43 @@
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#ifndef ADDRESSLIST_H 20#ifndef ADDRESSLIST_H
21#define ADDRESSLIST_H 21#define ADDRESSLIST_H
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qlist.h> 24#include <qlist.h>
25 25
26struct Contact 26struct Contact
27{ 27{
28 QString email; 28 QString email;
29 QString name; 29 QString name;
30}; 30};
31 31
32class AddressList : public QObject 32class AddressList : public QObject
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 AddressList(); 37 AddressList();
38 ~AddressList(); 38 ~AddressList();
39 void addContact(QString email, QString name); 39 void addContact(const QString &email, const QString &name);
40 bool containsEmail(QString email); 40 bool containsEmail(const QString &email);
41 bool containsName(QString name); 41 bool containsName(const QString &name);
42 QString getNameByEmail(QString email); 42 QString getNameByEmail(const QString &email);
43 QString getEmailByName(QString name); 43 QString getEmailByName(const QString &name);
44 QList<Contact>* getContactList(); 44 QList<Contact>* getContactList();
45 45
46private: 46private:
47 int getEmailRef(QString email); 47 int getEmailRef(const QString &email);
48 int getNameRef(QString name); 48 int getNameRef(const QString &name);
49 QString getRightString(QString in); 49 QString getRightString(const QString &in);
50 void read(); 50 void read();
51 51
52private: 52private:
53 QList<Contact> addresses; 53 QList<Contact> addresses;
54 QString filename; 54 QString filename;
55 bool dirty; 55 bool dirty;
56}; 56};
57 57
58#endif 58#endif
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index b039cc4..2102ba7 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -356,25 +356,25 @@ void EmailClient::getNewMail() {
356void EmailClient::getAllNewMail() 356void EmailClient::getAllNewMail()
357{ 357{
358 allAccounts = TRUE; 358 allAccounts = TRUE;
359 currentAccount = accountList.first(); 359 currentAccount = accountList.first();
360 getNewMail(); 360 getNewMail();
361} 361}
362 362
363void EmailClient::mailArrived(const Email &mail, bool fromDisk) 363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
364{ 364{
365 Enclosure *ePtr; 365 Enclosure *ePtr;
366 Email newMail; 366 Email newMail;
367 int thisMailId; 367 int thisMailId;
368 emailHandler->parse(mail.rawMail, lineShift, &newMail); 368 emailHandler->parse( mail.rawMail, lineShift, &newMail);
369 mailconf->setGroup(newMail.id); 369 mailconf->setGroup(newMail.id);
370 370
371 if (fromDisk) 371 if (fromDisk)
372 { 372 {
373 373
374 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
375 newMail.size = mailconf->readNumEntry("size"); 375 newMail.size = mailconf->readNumEntry("size");
376 newMail.serverId = mailconf->readNumEntry("serverid"); 376 newMail.serverId = mailconf->readNumEntry("serverid");
377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
378 } 378 }
379 else 379 else
380 { //mail arrived from server 380 { //mail arrived from server
@@ -452,35 +452,36 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
452 452
453 if (!fromDisk) 453 if (!fromDisk)
454 { 454 {
455 455
456 Email *mailPtr; 456 Email *mailPtr;
457 item = (EmailListItem *) inboxView->firstChild(); 457 item = (EmailListItem *) inboxView->firstChild();
458 while ((item != NULL)&&(!found)) 458 while ((item != NULL)&&(!found))
459 { 459 {
460 mailPtr = item->getMail(); 460 mailPtr = item->getMail();
461 if (mailPtr->id == newMail.id) { 461 if (mailPtr->id == newMail.id) {
462 item->setMail(newMail); 462 item->setMail(newMail);
463 emit mailUpdated(item->getMail()); 463 emit mailUpdated(item->getMail());
464 found = true; 464 found = true;
465 } 465 }
466 item = (EmailListItem *) item->nextSibling(); 466 item = (EmailListItem *) item->nextSibling();
467 } 467 }
468 } 468 }
469 if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); 469 if ((!found)||(fromDisk)) {
470 470 item = new EmailListItem(inboxView, newMail, TRUE);
471 if (item->getMail()->files.count()>0) 471 }
472 { 472 if (item->getMail()->files.count()>0)
473 item->setPixmap(0, Resource::loadPixmap("mailit/attach")); 473 {
474 } 474 item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475 }
475 /*if (!newMail.downloaded) 476 /*if (!newMail.downloaded)
476 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ 477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
477 478
478 mailboxView->setCurrentTab(0); 479 mailboxView->setCurrentTab(0);
479 480
480} 481}
481 482
482void EmailClient::allMailArrived(int count) 483void EmailClient::allMailArrived(int count)
483{ 484{
484 // not previewing means all mailtransfer has been done 485 // not previewing means all mailtransfer has been done
485 /*if (!previewingMail) {*/ 486 /*if (!previewingMail) {*/
486 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
@@ -633,25 +634,25 @@ void EmailClient::readMail()
633 634
634 mail.rawMail = s.mid(start, stop + del.length() - start ); 635 mail.rawMail = s.mid(start, stop + del.length() - start );
635 start = stop + del.length(); 636 start = stop + del.length();
636 emailHandler->parse(mail.rawMail, lineShift, &mail); 637 emailHandler->parse(mail.rawMail, lineShift, &mail);
637 mail.sent = false; 638 mail.sent = false;
638 mail.received = false; 639 mail.received = false;
639 enqueMail(mail); 640 enqueMail(mail);
640 641
641 } 642 }
642 } 643 }
643} 644}
644 645
645void EmailClient::saveMail(QString fileName, QListView *view) 646void EmailClient::saveMail(const QString &fileName, QListView *view)
646{ 647{
647 QFile f(fileName); 648 QFile f(fileName);
648 Email *mail; 649 Email *mail;
649 650
650 if (! f.open(IO_WriteOnly) ) { 651 if (! f.open(IO_WriteOnly) ) {
651 qWarning("could not open file"); 652 qWarning("could not open file");
652 return; 653 return;
653 } 654 }
654 item = (EmailListItem *) view->firstChild(); 655 item = (EmailListItem *) view->firstChild();
655 QTextStream t(&f); 656 QTextStream t(&f);
656 while (item != NULL) { 657 while (item != NULL) {
657 mail = item->getMail(); 658 mail = item->getMail();
@@ -703,25 +704,25 @@ void EmailClient::readSettings()
703 account.popUserName = mailconf->readEntry("POPUser",""); 704 account.popUserName = mailconf->readEntry("POPUser","");
704 account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); 705 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
705 account.popServer = mailconf->readEntry("POPServer",""); 706 account.popServer = mailconf->readEntry("POPServer","");
706 account.smtpServer = mailconf->readEntry("SMTPServer",""); 707 account.smtpServer = mailconf->readEntry("SMTPServer","");
707 account.id = mailconf->readNumEntry("AccountId",0); 708 account.id = mailconf->readNumEntry("AccountId",0);
708 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); 709 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
709 account.lastServerMailCount = 0; 710 account.lastServerMailCount = 0;
710 account.synchronize = FALSE; 711 account.synchronize = FALSE;
711 712
712 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); 713 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
713 if (account.synchronize) 714 if (account.synchronize)
714 { 715 {
715 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); 716 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
716 } 717 }
717 718
718 accountList.append(&account); 719 accountList.append(&account);
719 } 720 }
720 721
721 mailconf->setGroup("mailitglobal"); 722 mailconf->setGroup("mailitglobal");
722 723
723 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) 724 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
724 { 725 {
725 mailIdCount = y; 726 mailIdCount = y;
726 } 727 }
727 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) 728 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
@@ -906,131 +907,131 @@ void EmailClient::setDownloadedSize(int size)
906{ 907{
907 int total = progressBar->totalSteps(); 908 int total = progressBar->totalSteps();
908 909
909 if (size < total) { 910 if (size < total) {
910 progressBar->setProgress(size); 911 progressBar->setProgress(size);
911 } else { 912 } else {
912 progressBar->setProgress(total); 913 progressBar->setProgress(total);
913 } 914 }
914} 915}
915 916
916void EmailClient::deleteItem() 917void EmailClient::deleteItem()
917{ 918{
918 bool inbox=mailboxView->currentTab()==0; 919 bool inbox=mailboxView->currentTab()==0;
919 QListView* box; 920 QListView* box;
920 921
921 EmailListItem* eli; 922 EmailListItem* eli;
922 int pos; 923 int pos;
923 924
924 inbox ? box=inboxView : box=outboxView; 925 inbox ? box=inboxView : box=outboxView;
925 926
926 eli=(EmailListItem*)box->selectedItem(); 927 eli=(EmailListItem*)box->selectedItem();
927 928
928 if (eli) 929 if (eli)
929 { 930 {
930 box->setSelected(eli->itemBelow(),true);//select the previous item 931 box->setSelected(eli->itemBelow(),true); //select the previous item
931 932
932 deleteMail(eli,(bool&)inbox); //remove mail entry 933 deleteMail(eli,(bool&)inbox); //remove mail entry
933 } 934 }
934} 935}
935 936
936void EmailClient::inboxItemPressed() 937void EmailClient::inboxItemPressed()
937{ 938{
938 //timerID=startTimer(500); 939// timerID=startTimer(500);
939} 940}
940 941
941void EmailClient::inboxItemReleased() 942void EmailClient::inboxItemReleased()
942{ 943{
943 //killTimer(timerID); 944 // killTimer(timerID);
944} 945}
945 946
946/*void EmailClient::timerEvent(QTimerEvent *e) 947/*void EmailClient::timerEvent(QTimerEvent *e)
947{ 948{
948 /*killTimer(timerID); 949 /*killTimer(timerID);
949 950
950 951
951 QPopupMenu *action = new QPopupMenu(this); 952 QPopupMenu *action = new QPopupMenu(this);
952 953
953 int reply=0; 954 int reply=0;
954 955
955 action->insertItem(tr( "Reply To" ),this,SLOT(reply())); 956 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
956 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); 957 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
957 action->insertItem( tr( "Forward" ), this,SLOT(forward())); 958 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
958 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); 959 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
959 960
960 action->exec(QCursor::pos()); 961 action->exec(QCursor::pos());
961 962
962 if (action) delete action; 963 if (action) delete action;
963 964
964}*/ 965}*/
965 966
966Email* EmailClient::getCurrentMail() 967Email* EmailClient::getCurrentMail()
967{ 968{
968 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); 969 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
969 if (eli!=NULL) 970 if (eli!=NULL)
970 return eli->getMail(); 971 return eli->getMail();
971 else 972 else
972 return NULL; 973 return NULL;
973} 974}
974 975
975void EmailClient::download(Email* mail) 976void EmailClient::download(Email* mail)
976{ 977{
977 MailAccount* acc=0; 978 MailAccount* acc=0;
978 979
979 tempMailDownloadList.clear(); 980 tempMailDownloadList.clear();
980 tempMailDownloadList.sizeInsert(mail->serverId, mail->size); 981 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
981 982
982 acc=accountList.at(mail->fromAccountId-1); 983 acc=accountList.at(mail->fromAccountId-1);
983 if (acc) 984 if (acc)
984 { 985 {
985 emailHandler->setAccount(*acc); 986 emailHandler->setAccount(*acc);
986 emailHandler->getMailByList(&tempMailDownloadList); 987 emailHandler->getMailByList(&tempMailDownloadList);
987 } 988 }
988 else 989 else
989 QMessageBox::warning(qApp->activeWindow(), 990 QMessageBox::warning(qApp->activeWindow(),
990 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); 991 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
991} 992}
992 993
993void EmailClient::receive(const QCString& msg, const QByteArray& data) 994void EmailClient::receive(const QCString& msg, const QByteArray& data)
994{ 995{
995 /*if (msg=="getMail()") 996 /*if (msg=="getMail()")
996 { 997 {
997 /*QDialog qd(qApp->activeWindow(),"Getting mail",true); 998 /*QDialog qd(qApp->activeWindow(),"Getting mail",true);
998 QVBoxLayout *vbProg = new QVBoxLayout( &qd ); 999 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
999 1000
1000 initStatusBar(&qd); 1001 initStatusBar(&qd);
1001 1002
1002 if (statusBar==0) 1003 if (statusBar==0)
1003 { 1004 {
1004 qDebug("No Bar ..."); 1005 qDebug("No Bar ...");
1005 //statusBar=new ProgressBar(&qd); 1006 //statusBar=new ProgressBar(&qd);
1006 } 1007 }
1007 statusBar->show(); 1008 statusBar->show();
1008 vbProg->addWidget(statusBar); 1009 vbProg->addWidget(statusBar);
1009 qd.showMaximized(); 1010 qd.showMaximized();
1010 qd.show(); 1011 qd.show();
1011 emit getAllNewMail(); 1012 emit getAllNewMail();
1012 //qd.exec(); 1013 //qd.exec();
1013 } 1014 }
1014 else if (msg=="compose()") 1015 else if (msg=="compose()")
1015 { 1016 {
1016 QDialog qd(qApp->activeWindow(),"Getting mail",true); 1017 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1017 1018
1018 WriteMail wm(&qd,"write new mail"); 1019 WriteMail wm(&qd,"write new mail");
1019 QVBoxLayout vbProg( &qd ); 1020 QVBoxLayout vbProg( &qd );
1020 1021
1021 wm.showMaximized(); 1022 wm.showMaximized();
1022 vbProg.addWidget(&wm); 1023 vbProg.addWidget(&wm);
1023 1024
1024 qd.showMaximized(); 1025 qd.showMaximized();
1025 1026
1026 emit composeRequested(); 1027 emit composeRequested();
1027 qd.exec(); 1028 qd.exec();
1028 1029
1029 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1030 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1030 } 1031 }
1031 1032
1032 else if (msg=="dialog()") 1033 else if (msg=="dialog()")
1033 { 1034 {
1034 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1035 }*/ 1036 }*/
1036} 1037}
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h
index 994fec5..c98cfce 100644
--- a/noncore/net/mailit/emailclient.h
+++ b/noncore/net/mailit/emailclient.h
@@ -97,25 +97,25 @@ public slots:
97 void mailSent(); 97 void mailSent();
98 void deleteItem(); 98 void deleteItem();
99 void getNewMail(); 99 void getNewMail();
100 void getAllNewMail(); 100 void getAllNewMail();
101 void smtpError(int code); 101 void smtpError(int code);
102 void popError(int code); 102 void popError(int code);
103 void inboxItemSelected(); 103 void inboxItemSelected();
104 void outboxItemSelected(); 104 void outboxItemSelected();
105 void inboxItemPressed(); 105 void inboxItemPressed();
106 void inboxItemReleased(); 106 void inboxItemReleased();
107 void mailArrived(const Email &mail, bool fromDisk); 107 void mailArrived(const Email &mail, bool fromDisk);
108 void allMailArrived(int); 108 void allMailArrived(int);
109 void saveMail(QString fileName, QListView *view); 109 void saveMail(const QString &fileName, QListView *view);
110 void selectAccount(int); 110 void selectAccount(int);
111 void editAccount(int); 111 void editAccount(int);
112 void updateAccounts(); 112 void updateAccounts();
113 void deleteAccount(int); 113 void deleteAccount(int);
114 void deleteMail(EmailListItem *mailItem, bool &inbox); 114 void deleteMail(EmailListItem *mailItem, bool &inbox);
115 void setTotalSize(int); 115 void setTotalSize(int);
116 void setMailSize(int); 116 void setMailSize(int);
117 void setDownloadedSize(int); 117 void setDownloadedSize(int);
118 void moveMailFront(Email *mailPtr); 118 void moveMailFront(Email *mailPtr);
119 void download(Email*); 119 void download(Email*);
120/* void reply(); 120/* void reply();
121 void replyAll(); 121 void replyAll();
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 62fa64f..59ccd90 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -30,25 +30,25 @@ QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (Enclosure *) d); 31 return dupl( (Enclosure *) d);
32} 32}
33 33
34Enclosure* EnclosureList::dupl(Enclosure *in) 34Enclosure* EnclosureList::dupl(Enclosure *in)
35{ 35{
36 ac = new Enclosure(*in); 36 ac = new Enclosure(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailHandler::EmailHandler() 40EmailHandler::EmailHandler()
41{ 41{
42 qDebug("EMailHandler::EmailHandler"); 42 qDebug("EMailHandler::EmailHandler");
43 43
44 smtpClient = new SmtpClient(); 44 smtpClient = new SmtpClient();
45 popClient = new PopClient(); 45 popClient = new PopClient();
46 46
47 connect(smtpClient, SIGNAL(errorOccurred(int)), this, 47 connect(smtpClient, SIGNAL(errorOccurred(int)), this,
48 SIGNAL(smtpError(int)) ); 48 SIGNAL(smtpError(int)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); 49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, 50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) ); 51 SIGNAL(updateSmtpStatus(const QString &)) );
52 52
53 connect(popClient, SIGNAL(errorOccurred(int)), this, 53 connect(popClient, SIGNAL(errorOccurred(int)), this,
54 SIGNAL(popError(int)) ); 54 SIGNAL(popError(int)) );
@@ -139,25 +139,25 @@ void EmailHandler::getMailByList(MailList *mailList)
139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
140{ 140{
141 Email mail; 141 Email mail;
142 142
143 mail.rawMail = message; 143 mail.rawMail = message;
144 mail.serverId = id; 144 mail.serverId = id;
145 mail.size = size; 145 mail.size = size;
146 mail.downloaded = complete; 146 mail.downloaded = complete;
147 147
148 emit mailArrived(mail, FALSE); 148 emit mailArrived(mail, FALSE);
149} 149}
150 150
151bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
152{ 152{
153 QString temp, boundary; 153 QString temp, boundary;
154 int pos; 154 int pos;
155 QString delimiter, header, body, mimeHeader, mimeBody; 155 QString delimiter, header, body, mimeHeader, mimeBody;
156 QString content, contentType, contentAttribute, id, encoding; 156 QString content, contentType, contentAttribute, id, encoding;
157 QString fileName, storedName; 157 QString fileName, storedName;
158 int enclosureId = 0; 158 int enclosureId = 0;
159 159
160 mail->rawMail = in; 160 mail->rawMail = in;
161 mail->received = TRUE; 161 mail->received = TRUE;
162 mail->files.setAutoDelete(TRUE); 162 mail->files.setAutoDelete(TRUE);
163 163
@@ -195,39 +195,39 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
195 mail->fromMail = p.getString(&pos, 'z', TRUE); 195 mail->fromMail = p.getString(&pos, 'z', TRUE);
196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
197 mail->fromMail.truncate(mail->fromMail.length() - 1); 197 mail->fromMail.truncate(mail->fromMail.length() - 1);
198 mail->from=mail->fromMail; 198 mail->from=mail->fromMail;
199 } 199 }
200 } 200 }
201 201
202 pos=0; 202 pos=0;
203 203
204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: 204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1) 205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
206 { 206 {
207 QString rec; 207 QString rec;
208 208
209 if (p.separatorAt(pos-1)!='-')//The - separator means that this is a Delivered-To: or Reply-To: 209 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
210 { 210 {
211 pos++; 211 pos++;
212 mail->recipients.append(p.getString(&pos, '\r', TRUE)); 212 mail->recipients.append(p.getString(&pos, '\r', TRUE));
213 } 213 }
214 } 214 }
215 // 215 //
216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); 216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
217 217
218 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 218 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
219 { 219 {
220 pos++; 220 pos++;
221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
222 } 222 }
223 223
224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
225 pos++; 225 pos++;
226 mail->subject = p.getString(&pos, 'z', TRUE); 226 mail->subject = p.getString(&pos, 'z', TRUE);
227 } 227 }
228 228
229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
230 pos++; 230 pos++;
231 mail->date = p.getString(&pos, 'z', TRUE); 231 mail->date = p.getString(&pos, 'z', TRUE);
232 } 232 }
233 233
@@ -431,26 +431,26 @@ int EmailHandler::parse64base(char *src, char *bufOut) {
431 } 431 }
432 } 432 }
433 return processed; 433 return processed;
434} 434}
435 435
436int EmailHandler::encodeMime(Email *mail) 436int EmailHandler::encodeMime(Email *mail)
437{ 437{
438 438
439 QString fileName, fileType, contentType, newBody, boundary; 439 QString fileName, fileType, contentType, newBody, boundary;
440 Enclosure *ePtr; 440 Enclosure *ePtr;
441 441
442 QString userName = mailAccount.name; 442 QString userName = mailAccount.name;
443 if (userName.length()>0)//only embrace it if there is a user name 443 if (userName.length()>0) //only embrace it if there is a user name
444 userName += " <" + mailAccount.emailAddress + ">"; 444 userName += " <" + mailAccount.emailAddress + ">";
445 445
446 //add standard headers 446 //add standard headers
447 newBody = "From: " + userName + "\r\nTo: "; 447 newBody = "From: " + userName + "\r\nTo: ";
448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { 448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) {
449 newBody += *it + " "; 449 newBody += *it + " ";
450 } 450 }
451 451
452 newBody += "\r\nCC: "; 452 newBody += "\r\nCC: ";
453 453
454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { 454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) {
455 newBody += *it + " "; 455 newBody += *it + " ";
456 } 456 }
@@ -501,25 +501,25 @@ int EmailHandler::encodeMime(Email *mail)
501 fi.fileName() + "\"\r\n\r\n"; 501 fi.fileName() + "\"\r\n\r\n";
502 502
503 if (encodeFile(fileName, &newBody) == -1) //file not found? 503 if (encodeFile(fileName, &newBody) == -1) //file not found?
504 return -1; 504 return -1;
505 } 505 }
506 506
507 newBody += "\r\n\r\n--" + boundary + "--"; 507 newBody += "\r\n\r\n--" + boundary + "--";
508 mail->rawMail = newBody; 508 mail->rawMail = newBody;
509 509
510 return 0; 510 return 0;
511} 511}
512 512
513int EmailHandler::encodeFile(QString fileName, QString *toBody) 513int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
514{ 514{
515 char *fileData; 515 char *fileData;
516 char *dataPtr; 516 char *dataPtr;
517 QString temp; 517 QString temp;
518 uint dataSize, count; 518 uint dataSize, count;
519 QFile f(fileName); 519 QFile f(fileName);
520 520
521 if (! f.open(IO_ReadOnly) ) { 521 if (! f.open(IO_ReadOnly) ) {
522 qWarning("could not open file: " + fileName); 522 qWarning("could not open file: " + fileName);
523 return -1; 523 return -1;
524 } 524 }
525 QTextStream s(&f); 525 QTextStream s(&f);
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h
index 5b59f65..e4e7f46 100644
--- a/noncore/net/mailit/emailhandler.h
+++ b/noncore/net/mailit/emailhandler.h
@@ -28,123 +28,123 @@
28#include <qfile.h> 28#include <qfile.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qcollection.h> 30#include <qcollection.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include "smtpclient.h" 33#include "smtpclient.h"
34#include "popclient.h" 34#include "popclient.h"
35#include "textparser.h" 35#include "textparser.h"
36#include "maillist.h" 36#include "maillist.h"
37 37
38struct Enclosure 38struct Enclosure
39{ 39{
40 int id; 40 int id;
41 QString originalName; 41 QString originalName;
42 QString name; 42 QString name;
43 QString path; 43 QString path;
44 QString contentType; 44 QString contentType;
45 QString contentAttribute; 45 QString contentAttribute;
46 QString encoding; 46 QString encoding;
47 QString body; //might use to much mem. check!! 47 QString body; //might use to much mem. check!!
48 bool saved, installed; 48 bool saved, installed;
49}; 49};
50 50
51class EnclosureList : public QList<Enclosure> 51class EnclosureList : public QList<Enclosure>
52{ 52{
53public: 53public:
54 Item newItem(Item d); 54 Item newItem(Item d);
55private: 55private:
56 Enclosure* dupl(Enclosure *in); 56 Enclosure* dupl(Enclosure *in);
57 Enclosure *ac; 57 Enclosure *ac;
58}; 58};
59 59
60struct Email 60struct Email
61{ 61{
62 QString id; 62 QString id;
63 QString from; 63 QString from;
64 QString fromMail; 64 QString fromMail;
65 QStringList recipients; 65 QStringList recipients;
66 QStringList carbonCopies; 66 QStringList carbonCopies;
67 QString date; 67 QString date;
68 QString subject; 68 QString subject;
69 QString body; 69 QString body;
70 QString bodyPlain; 70 QString bodyPlain;
71 bool sent, received, read, downloaded; 71 bool sent, received, read, downloaded;
72 QString rawMail; 72 QString rawMail;
73 int mimeType; //1 = Mime 1.0 73 int mimeType; //1 = Mime 1.0
74 int serverId; 74 int serverId;
75 int internalId; 75 int internalId;
76 int fromAccountId; 76 int fromAccountId;
77 QString contentType; //0 = text 77 QString contentType; //0 = text
78 QString contentAttribute; //0 = plain, 1 = html 78 QString contentAttribute; //0 = plain, 1 = html
79 EnclosureList files; 79 EnclosureList files;
80 uint size; 80 uint size;
81 81
82 void addEnclosure(Enclosure *e) 82 void addEnclosure(Enclosure *e)
83 { 83 {
84 files.append(e); 84 files.append(e);
85 } 85 }
86}; 86};
87 87
88struct MailAccount 88struct MailAccount
89{ 89{
90 QString accountName; 90 QString accountName;
91 QString name; 91 QString name;
92 QString emailAddress; 92 QString emailAddress;
93 QString popUserName; 93 QString popUserName;
94 QString popPasswd; 94 QString popPasswd;
95 QString popServer; 95 QString popServer;
96 QString smtpServer; 96 QString smtpServer;
97 bool synchronize; 97 bool synchronize;
98 int syncLimit; 98 int syncLimit;
99 int lastServerMailCount; 99 int lastServerMailCount;
100 int id; 100 int id;
101}; 101};
102 102
103 const int ErrUnknownResponse = 1001; 103 const int ErrUnknownResponse = 1001;
104 const int ErrLoginFailed = 1002; 104 const int ErrLoginFailed = 1002;
105 const int ErrCancel = 1003; 105 const int ErrCancel = 1003;
106 106
107 107
108class EmailHandler : public QObject 108class EmailHandler : public QObject
109{ 109{
110 Q_OBJECT 110 Q_OBJECT
111 111
112public: 112public:
113 EmailHandler(); 113 EmailHandler();
114 void setAccount(MailAccount account); 114 void setAccount(MailAccount account);
115 MailAccount* getAccount(){return &mailAccount;} 115 MailAccount* getAccount(){return &mailAccount;}
116 void sendMail(QList<Email> *mailList); 116 void sendMail(QList<Email> *mailList);
117 void getMail(); 117 void getMail();
118 void getMailHeaders(); 118 void getMailHeaders();
119 void getMailByList(MailList *mailList); 119 void getMailByList(MailList *mailList);
120 bool parse(QString in, QString lineShift, Email *mail); 120 bool parse(const QString &in, const QString &lineShift, Email *mail);
121 bool getEnclosure(Enclosure *ePtr); 121 bool getEnclosure(Enclosure *ePtr);
122 int parse64base(char *src, char *dest); 122 int parse64base(char *src, char *dest);
123 int encodeMime(Email *mail); 123 int encodeMime(Email *mail);
124 int encodeFile(QString fileName, QString *toBody); 124 int encodeFile(const QString &fileName, QString *toBody);
125 void encode64base(char *src, QString *dest, int len); 125 void encode64base(char *src, QString *dest, int len);
126 void cancel(); 126 void cancel();
127 127
128signals: 128signals:
129 void mailSent(); 129 void mailSent();
130 void smtpError(int); 130 void smtpError(int);
131 void popError(int); 131 void popError(int);
132 void mailArrived(const Email &, bool); 132 void mailArrived(const Email &, bool);
133 void updatePopStatus(const QString &); 133 void updatePopStatus(const QString &);
134 void updateSmtpStatus(const QString &); 134 void updateSmtpStatus(const QString &);
135 void mailTransfered(int); 135 void mailTransfered(int);
136 void mailboxSize(int); 136 void mailboxSize(int);
137 void currentMailSize(int); 137 void currentMailSize(int);
138 void downloadedSize(int); 138 void downloadedSize(int);
139 139
140public slots: 140public slots:
141 void messageArrived(const QString &, int id, uint size, bool complete); 141 void messageArrived(const QString &, int id, uint size, bool complete);
142 142
143private: 143private:
144 MailAccount mailAccount; 144 MailAccount mailAccount;
145 SmtpClient *smtpClient; 145 SmtpClient *smtpClient;
146 PopClient *popClient; 146 PopClient *popClient;
147 bool headers; 147 bool headers;
148}; 148};
149 149
150#endif 150#endif
diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp
index b925a1c..fc9f766 100644
--- a/noncore/net/mailit/emaillistitem.cpp
+++ b/noncore/net/mailit/emaillistitem.cpp
@@ -13,87 +13,87 @@
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 <qstring.h> 20#include <qstring.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include "emaillistitem.h" 22#include "emaillistitem.h"
23 23
24EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) 24EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox)
25 : QListViewItem(parent) 25 : QListViewItem(parent)
26{ 26{
27 QString temp; 27 QString temp;
28 28
29 mail = mailIn; 29 mail = mailIn;
30 30
31 if (inbox) { 31 if (inbox) {
32 setText(0, mail.from); 32 setText(0, mail.from);
33 } else { 33 } else {
34 QStringList::Iterator it = mail.recipients.begin(); 34 QStringList::Iterator it = mail.recipients.begin();
35 temp = *it; 35 temp = *it;
36 if (mail.recipients.count() > 1) 36 if (mail.recipients.count() > 1)
37 temp += "..."; 37 temp += "...";
38 setText(0, temp); 38 setText(0, temp);
39 } 39 }
40 setText(1, mail.subject); 40 setText(1, mail.subject);
41 setText(2,mail.date); 41 setText(2,mail.date);
42 42
43 if (mailIn.files.count()>0) 43 if (mailIn.files.count()>0)
44 { 44 {
45 setPixmap(0, Resource::loadPixmap("mailit/attach")); 45 setPixmap(0, Resource::loadPixmap("mailit/attach"));
46 } 46 }
47 47
48 selected = FALSE; 48 selected = FALSE;
49} 49}
50 50
51Email* EmailListItem::getMail() 51Email* EmailListItem::getMail()
52{ 52{
53 return &mail; 53 return &mail;
54} 54}
55 55
56void EmailListItem::setMail(Email newMail) 56void EmailListItem::setMail(Email newMail)
57{ 57{
58 mail = newMail; 58 mail = newMail;
59 repaint(); 59 repaint();
60} 60}
61 61
62void EmailListItem::setItemSelected(bool enable) 62void EmailListItem::setItemSelected(bool enable)
63{ 63{
64 selected = enable; 64 selected = enable;
65 setSelected(enable); 65 setSelected(enable);
66 repaint(); 66 repaint();
67} 67}
68 68
69bool EmailListItem::isItemSelected() 69bool EmailListItem::isItemSelected()
70{ 70{
71 return selected; 71 return selected;
72} 72}
73 73
74void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, 74void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg,
75 int column, int width, int alignment ) 75 int column, int width, int alignment )
76{ 76{
77 77
78 QColorGroup _cg( cg ); 78 QColorGroup _cg( cg );
79 QColor c = _cg.text(); 79 QColor c = _cg.text();
80 80
81 if ( (! mail.read) && (mail.received) ) 81 if ( (! mail.read) && (mail.received) )
82 _cg.setColor( QColorGroup::Text, Qt::blue); 82 _cg.setColor( QColorGroup::Text, Qt::blue);
83 if (!mail.downloaded) 83 if (!mail.downloaded)
84 _cg.setColor( QColorGroup::Text, Qt::red); 84 _cg.setColor( QColorGroup::Text, Qt::red);
85 85
86 /*if (selected) { 86/* if (selected) {
87 _cg.setColor(QColorGroup::Base, Qt::blue); 87 _cg.setColor(QColorGroup::Base, Qt::blue);
88 _cg.setColor(QColorGroup::Text, Qt::yellow); 88 _cg.setColor(QColorGroup::Text, Qt::yellow);
89 if (isSelected()) { 89 if (isSelected()) {
90 _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); 90 _cg.setColor(QColorGroup::HighlightedText, Qt::yellow);
91 } else { 91 } else {
92 _cg.setColor(QColorGroup::Highlight, Qt::blue); 92 _cg.setColor(QColorGroup::Highlight, Qt::blue);
93 } 93 }
94 } 94 }
95 */ 95*/
96 QListViewItem::paintCell( p, _cg, column, width, alignment ); 96 QListViewItem::paintCell( p, _cg, column, width, alignment );
97 97
98 _cg.setColor( QColorGroup::Text, c ); 98 _cg.setColor( QColorGroup::Text, c );
99} 99}
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index fedc4e2..dc0116d 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -41,41 +41,41 @@ PopClient::PopClient()
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 preview = FALSE; 44 preview = FALSE;
45} 45}
46 46
47PopClient::~PopClient() 47PopClient::~PopClient()
48{ 48{
49 delete socket; 49 delete socket;
50 delete stream; 50 delete stream;
51} 51}
52 52
53void PopClient::newConnection(QString target, int port) 53void PopClient::newConnection(const QString &target, int port)
54{ 54{
55 if (receiving) { 55 if (receiving) {
56 qWarning("socket in use, connection refused"); 56 qWarning("socket in use, connection refused");
57 return; 57 return;
58 } 58 }
59 59
60 status = Init; 60 status = Init;
61 61
62 socket->connectToHost(target, port); 62 socket->connectToHost(target, port);
63 receiving = TRUE; 63 receiving = TRUE;
64 //selected = FALSE; 64 //selected = FALSE;
65 65
66 emit updateStatus("DNS lookup"); 66 emit updateStatus("DNS lookup");
67} 67}
68 68
69void PopClient::setAccount(QString popUser, QString popPasswd) 69void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 70{
71 popUserName = popUser; 71 popUserName = popUser;
72 popPassword = popPasswd; 72 popPassword = popPasswd;
73} 73}
74 74
75void PopClient::setSynchronize(int lastCount) 75void PopClient::setSynchronize(int lastCount)
76{ 76{
77 synchronize = TRUE; 77 synchronize = TRUE;
78 lastSync = lastCount; 78 lastSync = lastCount;
79} 79}
80 80
81void PopClient::removeSynchronize() 81void PopClient::removeSynchronize()
@@ -149,60 +149,60 @@ void PopClient::incomingData()
149#endif 149#endif
150 { 150 {
151 timeStamp = ""; 151 timeStamp = "";
152 *stream << "USER " << popUserName << "\r\n"; 152 *stream << "USER " << popUserName << "\r\n";
153 status = Pass; 153 status = Pass;
154 } 154 }
155 155
156 break; 156 break;
157 } 157 }
158 158
159 case Pass: { 159 case Pass: {
160 *stream << "PASS " << popPassword << "\r\n"; 160 *stream << "PASS " << popPassword << "\r\n";
161 status = Stat; 161 status = Stat;
162 162
163 break; 163 break;
164 } 164 }
165 //ask for number of messages 165 //ask for number of messages
166 case Stat: { 166 case Stat: {
167 if (response[0] == '+') { 167 if (response[0] == '+') {
168 *stream << "STAT" << "\r\n"; 168 *stream << "STAT" << "\r\n";
169 status = Mcnt; 169 status = Mcnt;
170 } else errorHandling(ErrLoginFailed); 170 } else errorHandling(ErrLoginFailed);
171 break; 171 break;
172 } 172 }
173 //get count of messages, eg "+OK 4 900.." -> int 4 173 //get count of messages, eg "+OK 4 900.." -> int 4
174 case Mcnt: { 174 case Mcnt: {
175 if (response[0] == '+') { 175 if (response[0] == '+') {
176 temp = response.replace(0, 4, ""); 176 temp = response.replace(0, 4, "");
177 int x = temp.find(" ", 0); 177 int x = temp.find(" ", 0);
178 temp.truncate((uint) x); 178 temp.truncate((uint) x);
179 newMessages = temp.toInt(); 179 newMessages = temp.toInt();
180 messageCount = 1; 180 messageCount = 1;
181 status = List; 181 status = List;
182 182
183 if (synchronize) { 183 if (synchronize) {
184 //messages deleted from server, reload all 184 //messages deleted from server, reload all
185 if (newMessages < lastSync) 185 if (newMessages < lastSync)
186 lastSync = 0; 186 lastSync = 0;
187 messageCount = 1; 187 messageCount = 1;
188 } 188 }
189 189
190 if (selected) { 190 if (selected) {
191 int *ptr = mailList->first(); 191 int *ptr = mailList->first();
192 if (ptr != 0) { 192 if (ptr != 0) {
193 newMessages++; //to ensure no early jumpout 193 newMessages++; //to ensure no early jumpout
194 messageCount = *ptr; 194 messageCount = *ptr;
195 } else newMessages = 0; 195 } else newMessages = 0;
196 } 196 }
197 197
198 } else errorHandling(ErrUnknownResponse); 198 } else errorHandling(ErrUnknownResponse);
199 } 199 }
200 //Read message number x, count upwards to messageCount 200 //Read message number x, count upwards to messageCount
201 case List: { 201 case List: {
202 if (messageCount <= newMessages) { 202 if (messageCount <= newMessages) {
203 *stream << "LIST " << messageCount << "\r\n"; 203 *stream << "LIST " << messageCount << "\r\n";
204 status = Size; 204 status = Size;
205 temp2.setNum(newMessages - lastSync); 205 temp2.setNum(newMessages - lastSync);
206 temp.setNum(messageCount - lastSync); 206 temp.setNum(messageCount - lastSync);
207 if (!selected) { 207 if (!selected) {
208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
@@ -233,28 +233,28 @@ void PopClient::incomingData()
233 233
234 status = Retr; 234 status = Retr;
235 } else { 235 } else {
236 //qWarning(response); 236 //qWarning(response);
237 errorHandling(ErrUnknownResponse); 237 errorHandling(ErrUnknownResponse);
238 } 238 }
239 } 239 }
240 } 240 }
241 //Read message number x, count upwards to messageCount 241 //Read message number x, count upwards to messageCount
242 case Retr: { 242 case Retr: {
243 if (status != Quit) { 243 if (status != Quit) {
244 if ((selected)||(mailSize <= headerLimit)) 244 if ((selected)||(mailSize <= headerLimit))
245 { 245 {
246 *stream << "RETR " << messageCount << "\r\n"; 246 *stream << "RETR " << messageCount << "\r\n";
247 } else { //only header 247 } else { //only header
248 *stream << "TOP " << messageCount << " 0\r\n"; 248 *stream << "TOP " << messageCount << " 0\r\n";
249 } 249 }
250 messageCount++; 250 messageCount++;
251 status = Ignore; 251 status = Ignore;
252 break; 252 break;
253 } } 253 } }
254 case Ignore: { 254 case Ignore: {
255 if (status != Quit) { //because of idiotic switch 255 if (status != Quit) { //because of idiotic switch
256 if (response[0] == '+') { 256 if (response[0] == '+') {
257 message = ""; 257 message = "";
258 status = Read; 258 status = Read;
259 if (!socket->canReadLine()) //sync. problems 259 if (!socket->canReadLine()) //sync. problems
260 break; 260 break;
@@ -267,41 +267,41 @@ void PopClient::incomingData()
267 case Read: { 267 case Read: {
268 if (status != Quit) { //because of idiotic switch 268 if (status != Quit) { //because of idiotic switch
269 message += response; 269 message += response;
270 while ( socket->canReadLine() ) { 270 while ( socket->canReadLine() ) {
271 response = socket->readLine(); 271 response = socket->readLine();
272 message += response; 272 message += response;
273 } 273 }
274 emit downloadedSize(message.length()); 274 emit downloadedSize(message.length());
275 int x = message.find("\r\n.\r\n",-5); 275 int x = message.find("\r\n.\r\n",-5);
276 if (x == -1) { 276 if (x == -1) {
277 break; 277 break;
278 } else { //message reach entire size 278 } else { //message reach entire size
279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
280 { 280 {
281 emit newMessage(message, messageCount-1, mailSize, TRUE); 281 emit newMessage(message, messageCount-1, mailSize, TRUE);
282 } else { //incomplete mail downloaded 282 } else { //incomplete mail downloaded
283 emit newMessage(message, messageCount-1, mailSize, FALSE); 283 emit newMessage(message, messageCount-1, mailSize, FALSE);
284 } 284 }
285 285
286 if ((messageCount > newMessages)||(selected)) //last message ? 286 if ((messageCount > newMessages)||(selected)) //last message ?
287 { 287 {
288 status = Quit; 288 status = Quit;
289 if (selected) { //grab next from queue 289 if (selected) { //grab next from queue
290 newMessages--; 290 newMessages--;
291 status = Quit; 291 status = Quit;
292 } 292 }
293 } 293 }
294 else 294 else
295 { 295 {
296 *stream << "LIST " << messageCount << "\r\n"; 296 *stream << "LIST " << messageCount << "\r\n";
297 status = Size; 297 status = Size;
298 temp2.setNum(newMessages - lastSync); 298 temp2.setNum(newMessages - lastSync);
299 temp.setNum(messageCount - lastSync); 299 temp.setNum(messageCount - lastSync);
300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
301 301
302 break; 302 break;
303 } 303 }
304 } 304 }
305 } 305 }
306 if (status != Quit) 306 if (status != Quit)
307 break; 307 break;
diff --git a/noncore/net/mailit/popclient.h b/noncore/net/mailit/popclient.h
index 10b71ab..c58bc48 100644
--- a/noncore/net/mailit/popclient.h
+++ b/noncore/net/mailit/popclient.h
@@ -26,26 +26,26 @@
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qlist.h> 28#include <qlist.h>
29#include "maillist.h" 29#include "maillist.h"
30 30
31class PopClient: public QObject 31class PopClient: public QObject
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 PopClient(); 36 PopClient();
37 ~PopClient(); 37 ~PopClient();
38 void newConnection(QString target, int port); 38 void newConnection(const QString &target, int port);
39 void setAccount(QString popUser, QString popPasswd); 39 void setAccount(const QString &popUser, const QString &popPasswd);
40 void setSynchronize(int lastCount); 40 void setSynchronize(int lastCount);
41 void removeSynchronize(); 41 void removeSynchronize();
42 void headersOnly(bool headers, int limit); 42 void headersOnly(bool headers, int limit);
43 void setSelectedMails(MailList *list); 43 void setSelectedMails(MailList *list);
44 44
45signals: 45signals:
46 void newMessage(const QString &, int, uint, bool); 46 void newMessage(const QString &, int, uint, bool);
47 void errorOccurred(int status); 47 void errorOccurred(int status);
48 void updateStatus(const QString &); 48 void updateStatus(const QString &);
49 void mailTransfered(int); 49 void mailTransfered(int);
50 void mailboxSize(int); 50 void mailboxSize(int);
51 void currentMailSize(int); 51 void currentMailSize(int);
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 8a51a5b..2916f45 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -30,39 +30,39 @@ SmtpClient::SmtpClient()
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(QString target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
diff --git a/noncore/net/mailit/smtpclient.h b/noncore/net/mailit/smtpclient.h
index ca65af4..45c0703 100644
--- a/noncore/net/mailit/smtpclient.h
+++ b/noncore/net/mailit/smtpclient.h
@@ -21,55 +21,55 @@
21#define SmtpClient_H 21#define SmtpClient_H
22 22
23//#include <stdio.h> 23//#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlist.h> 29#include <qlist.h>
30 30
31struct RawEmail 31struct RawEmail
32{ 32{
33 QString from; 33 QString from;
34 QString subject; 34 QString subject;
35 QStringList to; 35 QStringList to;
36 QString body; 36 QString body;
37}; 37};
38 38
39class SmtpClient: public QObject 39class SmtpClient: public QObject
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 SmtpClient(); 44 SmtpClient();
45 ~SmtpClient(); 45 ~SmtpClient();
46 void newConnection(QString target, int port); 46 void newConnection(const QString &target, int port);
47 void addMail(QString from, QString subject, QStringList to, QString body); 47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
48 48
49signals: 49signals:
50 void errorOccurred(int); 50 void errorOccurred(int);
51 void updateStatus(const QString &); 51 void updateStatus(const QString &);
52 void mailSent(); 52 void mailSent();
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 56
57protected slots: 57protected slots:
58 void connectionEstablished(); 58 void connectionEstablished();
59 void incomingData(); 59 void incomingData();
60 60
61private: 61private:
62 QSocket *socket; 62 QSocket *socket;
63 QTextStream *stream; 63 QTextStream *stream;
64 enum transferStatus 64 enum transferStatus
65 { 65 {
66 Init, From, Recv, MRcv, Data, Body, Quit, Done 66 Init, From, Recv, MRcv, Data, Body, Quit, Done
67 }; 67 };
68 int status; 68 int status;
69 QList<RawEmail> mailList; 69 QList<RawEmail> mailList;
70 RawEmail *mailPtr; 70 RawEmail *mailPtr;
71 bool sending; 71 bool sending;
72 QStringList::Iterator it; 72 QStringList::Iterator it;
73}; 73};
74 74
75#endif 75#endif
diff --git a/noncore/net/mailit/textparser.cpp b/noncore/net/mailit/textparser.cpp
index 3fa5f6e..e5c9f7c 100644
--- a/noncore/net/mailit/textparser.cpp
+++ b/noncore/net/mailit/textparser.cpp
@@ -10,295 +10,295 @@
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 "textparser.h" 20#include "textparser.h"
21 21
22TextParser::TextParser(QString in, QString lineBreak) 22TextParser::TextParser(const QString &in, const QString &lineBreak)
23{ 23{
24 data = in; 24 data = in;
25 lineSep = lineBreak; 25 lineSep = lineBreak;
26 26
27 init(); 27 init();
28 createSeparators(); 28 createSeparators();
29 split(); 29 split();
30} 30}
31 31
32TextParser::TextParser(QString in, QString lineBreak, QString sep) 32TextParser::TextParser(const QString &in, const QString &lineBreak, const QString &sep)
33{ 33{
34 data = in; 34 data = in;
35 lineSep = lineBreak; 35 lineSep = lineBreak;
36 36
37 init(); 37 init();
38 separators = sep; 38 separators = sep;
39 split(); 39 split();
40} 40}
41 41
42void TextParser::init() 42void TextParser::init()
43{ 43{
44 lineCount = 0; 44 lineCount = 0;
45 linePos = 0; 45 linePos = 0;
46 totalElmCount = 0; 46 totalElmCount = 0;
47 separatorPos = -1; //not initialized 47 separatorPos = -1; //not initialized
48 wordPos = -1; //not initialized 48 wordPos = -1; //not initialized
49 sepAtLine = 0; 49 sepAtLine = 0;
50 sepAtPosElm = -1; //such that nextSep equals 0 50 sepAtPosElm = -1; //such that nextSep equals 0
51 wordAtLine = 0; 51 wordAtLine = 0;
52 wordAtPosElm = -1; //such that nextWord equals 0 52 wordAtPosElm = -1; //such that nextWord equals 0
53 atLine = 0; 53 atLine = 0;
54 atPosElm = 0; 54 atPosElm = 0;
55} 55}
56 56
57void TextParser::createSeparators() 57void TextParser::createSeparators()
58{ 58{
59 separators = " @#,.:;<>*/(){}|'?-+=_"; 59 separators = " @#,.:;<>*/(){}|'?-+=_";
60} 60}
61 61
62 /*Returns pos of given search criteria, -1 if not found */ 62/* Returns pos of given search criteria, -1 if not found */
63int TextParser::find(QString target, QChar sep, int pos, bool upperCase) 63int TextParser::find(const QString &target, QChar sep, int pos, bool upperCase)
64{ 64{
65 65
66 t_splitElm parsstr; 66 t_splitElm parsstr;
67 QString pString; 67 QString pString, pTarget;
68 68 pTarget = target;
69 int atLine = 0, atPosElm = 0; 69 int atLine = 0, atPosElm = 0;
70 70
71 getLineReference(pos,&atLine,&atPosElm); 71 getLineReference(pos,&atLine,&atPosElm);
72 72
73 for (int x = pos; x < totalElmCount; x++) 73 for (int x = pos; x < totalElmCount; x++)
74 { 74 {
75 parsstr=splitDone[atLine].elm[atPosElm++]; 75 parsstr=splitDone[atLine].elm[atPosElm++];
76 76
77 if (upperCase) 77 if (upperCase)
78 { 78 {
79 pString=parsstr.str.upper(); 79 pString=parsstr.str.upper();
80 target=target.upper(); 80 pTarget=pTarget.upper();
81 } 81 }
82 else 82 else
83 { 83 {
84 pString=parsstr.str; 84 pString=parsstr.str;
85 } 85 }
86 if ((pString == target) && (parsstr.separator == sep)) 86 if ((pString == pTarget) && (parsstr.separator == sep))
87 { 87 {
88 return x; 88 return x;
89 } 89 }
90 if (atPosElm >= splitDone[atLine].elmCount) 90 if (atPosElm >= splitDone[atLine].elmCount)
91 { //new Line 91 { //new Line
92 atLine++; 92 atLine++;
93 atPosElm = 0; 93 atPosElm = 0;
94 } 94 }
95 } 95 }
96 return -1; 96 return -1;
97} 97}
98 98
99int TextParser::elmCount() 99int TextParser::elmCount()
100{ 100{
101 return totalElmCount; 101 return totalElmCount;
102} 102}
103 103
104QChar TextParser::separatorAt(int pos) 104QChar TextParser::separatorAt(int pos)
105{ 105{
106 if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) 106 if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1)
107 return QChar::null; 107 return QChar::null;
108 108
109 separatorPos = pos; 109 separatorPos = pos;
110 return splitDone[sepAtLine].elm[sepAtPosElm].separator; 110 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
111} 111}
112 112
113QChar TextParser::nextSeparator() 113QChar TextParser::nextSeparator()
114{ 114{
115 sepAtPosElm++; 115 sepAtPosElm++;
116 if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { 116 if (splitDone[sepAtLine].elmCount <= sepAtPosElm) {
117 sepAtLine++; 117 sepAtLine++;
118 sepAtPosElm = 0; 118 sepAtPosElm = 0;
119 } 119 }
120 120
121 separatorPos++; 121 separatorPos++;
122 return splitDone[sepAtLine].elm[sepAtPosElm].separator; 122 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
123} 123}
124 124
125bool TextParser::hasNextSeparator() 125bool TextParser::hasNextSeparator()
126{ 126{
127 return ((separatorPos+1) < totalElmCount); 127 return ((separatorPos+1) < totalElmCount);
128} 128}
129 129
130QString TextParser::wordAt(int pos) 130QString TextParser::wordAt(int pos)
131{ 131{
132 if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) 132 if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1)
133 return NULL; 133 return NULL;
134 134
135 wordPos = pos; 135 wordPos = pos;
136 return splitDone[wordAtLine].elm[wordAtPosElm].str; 136 return splitDone[wordAtLine].elm[wordAtPosElm].str;
137} 137}
138 138
139QString TextParser::nextWord() 139QString TextParser::nextWord()
140{ 140{
141 wordAtPosElm++; 141 wordAtPosElm++;
142 if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { 142 if (splitDone[wordAtLine].elmCount <= wordAtPosElm) {
143 wordAtLine++; 143 wordAtLine++;
144 wordAtPosElm = 0; 144 wordAtPosElm = 0;
145 } 145 }
146 146
147 wordPos++; 147 wordPos++;
148 return splitDone[wordAtLine].elm[wordAtPosElm].str; 148 return splitDone[wordAtLine].elm[wordAtPosElm].str;
149} 149}
150 150
151bool TextParser::hasNextWord() 151bool TextParser::hasNextWord()
152{ 152{
153 return ((wordPos + 1) < totalElmCount); 153 return ((wordPos + 1) < totalElmCount);
154} 154}
155 155
156QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) 156QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false)
157{ 157{
158 QString returnStr = wordAt(*pos); 158 QString returnStr = wordAt(*pos);
159 QChar chr = separatorAt(*pos); 159 QChar chr = separatorAt(*pos);
160 QString s; 160 QString s;
161 161
162 if (returnStr == "") 162 if (returnStr == "")
163 return ""; 163 return "";
164 if (chr == stop) 164 if (chr == stop)
165 return returnStr; 165 return returnStr;
166 166
167 if (!lineEnd) { 167 if (!lineEnd) {
168 while ((chr != stop) && hasNextWord()) { 168 while ((chr != stop) && hasNextWord()) {
169 returnStr.append(chr); 169 returnStr.append(chr);
170 returnStr += nextWord(); 170 returnStr += nextWord();
171 chr = nextSeparator(); 171 chr = nextSeparator();
172 } 172 }
173 } else { //copy from pos to end of line 173 } else { //copy from pos to end of line
174 getLineReference(*pos, &atLine, &atPosElm); 174 getLineReference(*pos, &atLine, &atPosElm);
175 returnStr = ""; 175 returnStr = "";
176 while (atPosElm < splitDone[atLine].elmCount) { 176 while (atPosElm < splitDone[atLine].elmCount) {
177 if (splitDone[atLine].elm[atPosElm].str != "") { 177 if (splitDone[atLine].elm[atPosElm].str != "") {
178 returnStr += splitDone[atLine].elm[atPosElm].str; 178 returnStr += splitDone[atLine].elm[atPosElm].str;
179 } 179 }
180 chr = splitDone[atLine].elm[atPosElm].separator; 180 chr = splitDone[atLine].elm[atPosElm].separator;
181 if (!chr.isNull() && (int) chr != 0) { 181 if (!chr.isNull() && (int) chr != 0) {
182 returnStr.append(splitDone[atLine].elm[atPosElm].separator); 182 returnStr.append(splitDone[atLine].elm[atPosElm].separator);
183 } 183 }
184 atPosElm++; 184 atPosElm++;
185 } 185 }
186 } 186 }
187 187
188 *pos = wordPos; 188 *pos = wordPos;
189 return returnStr; 189 return returnStr;
190} 190}
191 191
192QString TextParser::getNextLine() 192QString TextParser::getNextLine()
193{ 193{
194 atLine++; 194 atLine++;
195 atPosElm = 0; 195 atPosElm = 0;
196 if (atLine < lineCount) 196 if (atLine < lineCount)
197 return splitDone[atLine].str; 197 return splitDone[atLine].str;
198 return ""; 198 return "";
199} 199}
200 200
201bool TextParser::hasNextLine() 201bool TextParser::hasNextLine()
202{ 202{
203 if (atLine+1 < lineCount) 203 if (atLine+1 < lineCount)
204 return TRUE;; 204 return TRUE;;
205 return FALSE; 205 return FALSE;
206} 206}
207 207
208int TextParser::endLinePos(int pos) 208int TextParser::endLinePos(int pos)
209{ 209{
210 if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) 210 if ( (getLineReference(pos, &atLine, &atPosElm)) == -1)
211 return -1; 211 return -1;
212 212
213 return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); 213 return (pos + (splitDone[atLine].elmCount - atPosElm) + 1);
214} 214}
215 215
216int TextParser::getLineReference(int pos, int *line, int *inLinePos) 216int TextParser::getLineReference(int pos, int *line, int *inLinePos)
217{ 217{
218 int currentPos = 0; 218 int currentPos = 0;
219 219
220 for (int x = 0; x < lineCount; x++) { 220 for (int x = 0; x < lineCount; x++) {
221 if ( currentPos + splitDone[x].elmCount > pos) { 221 if ( currentPos + splitDone[x].elmCount > pos) {
222 *line = x; 222 *line = x;
223 *inLinePos = pos - currentPos; 223 *inLinePos = pos - currentPos;
224 return 0; //pos found okay 224 return 0; //pos found okay
225 } 225 }
226 currentPos += splitDone[x].elmCount; 226 currentPos += splitDone[x].elmCount;
227 } 227 }
228 return -1; //no reference found 228 return -1; //no reference found
229} 229}
230 230
231void TextParser::split() 231void TextParser::split()
232{ 232{
233 t_splitLine newLine; 233 t_splitLine newLine;
234 234
235 while ((uint) linePos < data.length()) { 235 while ((uint) linePos < data.length()) {
236 newLine = nextLine(); 236 newLine = nextLine();
237 splitDone[lineCount] = splitLine(newLine); 237 splitDone[lineCount] = splitLine(newLine);
238 totalElmCount += splitDone[lineCount].elmCount; 238 totalElmCount += splitDone[lineCount].elmCount;
239 lineCount++; 239 lineCount++;
240 } 240 }
241} 241}
242 242
243t_splitLine TextParser::splitLine(t_splitLine line) 243t_splitLine TextParser::splitLine(t_splitLine line)
244{ 244{
245 uint pos = 0; 245 uint pos = 0;
246 uint elmCount = 0; 246 uint elmCount = 0;
247 t_splitLine tempLine = line; 247 t_splitLine tempLine = line;
248 248
249 tempLine.str = line.str.simplifyWhiteSpace(); 249 tempLine.str = line.str.simplifyWhiteSpace();
250 tempLine.elm[0].str = ""; 250 tempLine.elm[0].str = "";
251 while ( pos < line.str.length() ) { 251 while ( pos < line.str.length() ) {
252 if ( isSeparator(tempLine.str[pos]) ) { 252 if ( isSeparator(tempLine.str[pos]) ) {
253 tempLine.elm[elmCount].separator = tempLine.str[pos]; 253 tempLine.elm[elmCount].separator = tempLine.str[pos];
254 elmCount++; 254 elmCount++;
255 pos++; 255 pos++;
256 while (tempLine.str[pos] == ' ') 256 while (tempLine.str[pos] == ' ')
257 pos++; 257 pos++;
258 if (pos > line.str.length()) 258 if (pos > line.str.length())
259 elmCount--; 259 elmCount--;
260 tempLine.elm[elmCount].str = ""; 260 tempLine.elm[elmCount].str = "";
261 } else { 261 } else {
262 if (!tempLine.str[pos].isNull()) 262 if (!tempLine.str[pos].isNull())
263 tempLine.elm[elmCount].str += tempLine.str[pos]; 263 tempLine.elm[elmCount].str += tempLine.str[pos];
264 pos++; 264 pos++;
265 } 265 }
266 } 266 }
267 267
268 tempLine.elmCount = elmCount + 1; 268 tempLine.elmCount = elmCount + 1;
269 return tempLine; 269 return tempLine;
270} 270}
271 271
272bool TextParser::isSeparator(QChar chr) 272bool TextParser::isSeparator(QChar chr)
273{ 273{
274 for (uint x = 0; x < separators.length(); x++) { 274 for (uint x = 0; x < separators.length(); x++) {
275 if (chr == separators[x]) 275 if (chr == separators[x])
276 return true; 276 return true;
277 } 277 }
278 return false; 278 return false;
279} 279}
280 280
281t_splitLine TextParser::nextLine() 281t_splitLine TextParser::nextLine()
282{ 282{
283 int newLinePos; 283 int newLinePos;
284 t_splitLine lineType; 284 t_splitLine lineType;
285 285
286 newLinePos = data.find(lineSep, linePos); 286 newLinePos = data.find(lineSep, linePos);
287 287
288 lineType.lineType = NewLine; 288 lineType.lineType = NewLine;
289 lineType.str = ""; 289 lineType.str = "";
290 290
291 if (newLinePos == -1) { 291 if (newLinePos == -1) {
292 newLinePos = data.length(); 292 newLinePos = data.length();
293 lineType.lineType = LastLine; 293 lineType.lineType = LastLine;
294 } 294 }
295 295
296 for (int x = linePos; x < newLinePos; x++) 296 for (int x = linePos; x < newLinePos; x++)
297 lineType.str += data[x]; 297 lineType.str += data[x];
298 298
299 linePos = newLinePos; 299 linePos = newLinePos;
300 if ((uint) linePos < data.length()) //if not EOF, add length of lineSep 300 if ((uint) linePos < data.length()) //if not EOF, add length of lineSep
301 linePos += lineSep.length(); 301 linePos += lineSep.length();
302 302
303 return lineType; 303 return lineType;
304} 304}
diff --git a/noncore/net/mailit/textparser.h b/noncore/net/mailit/textparser.h
index c5e88a0..03bb6d5 100644
--- a/noncore/net/mailit/textparser.h
+++ b/noncore/net/mailit/textparser.h
@@ -40,27 +40,27 @@ struct t_splitLine
40{ 40{
41 t_lineType lineType; 41 t_lineType lineType;
42 QString str; //a bit redundant... 42 QString str; //a bit redundant...
43 t_splitElm elm[MAX_ELEMENTS]; 43 t_splitElm elm[MAX_ELEMENTS];
44 int elmCount; 44 int elmCount;
45}; 45};
46 46
47class TextParser: public QObject 47class TextParser: public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 TextParser(QString in, QString lineBreak); 52 TextParser(const QString &in, const QString &lineBreak);
53 TextParser(QString in, QString lineBreak, QString sep); 53 TextParser(const QString &in, const QString &lineBreak, const QString &sep);
54 int find(QString target, QChar sep, int pos, bool upperCase); 54 int find(const QString &target, QChar sep, int pos, bool upperCase);
55 int elmCount(); 55 int elmCount();
56 QChar separatorAt(int pos); 56 QChar separatorAt(int pos);
57 QChar nextSeparator(); 57 QChar nextSeparator();
58 bool hasNextSeparator(); 58 bool hasNextSeparator();
59 QString wordAt(int pos); 59 QString wordAt(int pos);
60 QString nextWord(); 60 QString nextWord();
61 bool hasNextWord(); 61 bool hasNextWord();
62 QString getString(int *pos, QChar stop, bool lineEnd); 62 QString getString(int *pos, QChar stop, bool lineEnd);
63 QString getNextLine(); 63 QString getNextLine();
64 bool hasNextLine(); 64 bool hasNextLine();
65 int endLinePos(int pos); 65 int endLinePos(int pos);
66 66
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 7d60ebf..18d14bc 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -17,145 +17,145 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <opie/ocontactaccess.h> 22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h> 23#include <opie/ocontact.h>
24 24
25#include "addresslist.h" 25#include "addresslist.h"
26 26
27AddressList::AddressList() 27AddressList::AddressList()
28{ 28{
29 addresses.setAutoDelete(TRUE); 29 addresses.setAutoDelete(TRUE);
30 read(); 30 read();
31 dirty = FALSE; 31 dirty = FALSE;
32} 32}
33 33
34AddressList::~AddressList() 34AddressList::~AddressList()
35{ 35{
36 addresses.clear(); 36 addresses.clear();
37} 37}
38 38
39void AddressList::addContact(QString email, QString name) 39void AddressList::addContact(const QString &email, const QString &name)
40{ 40{
41 //skip if not a valid email address, 41 //skip if not a valid email address,
42 if (email.find( '@') == -1) 42 if (email.find( '@') == -1)
43 return; 43 return;
44 44
45 if ( ! containsEmail(email) ) { 45 if ( ! containsEmail(email) ) {
46 Contact *in = new Contact; 46 Contact *in = new Contact;
47 in->email = email; 47 in->email = email;
48 in->name = name; 48 in->name = name;
49 addresses.append(in); 49 addresses.append(in);
50 dirty = TRUE; 50 dirty = TRUE;
51 } 51 }
52} 52}
53 53
54bool AddressList::containsEmail(QString email) 54bool AddressList::containsEmail(const QString &email)
55{ 55{
56 return ( getEmailRef(email) != -1 ); 56 return ( getEmailRef(email) != -1 );
57} 57}
58 58
59bool AddressList::containsName(QString name) 59bool AddressList::containsName(const QString &name)
60{ 60{
61 return ( getNameRef(name) != -1 ); 61 return ( getNameRef(name) != -1 );
62} 62}
63 63
64QString AddressList::getNameByEmail(QString email) 64QString AddressList::getNameByEmail(const QString &email)
65{ 65{
66 int pos = getEmailRef(email); 66 int pos = getEmailRef(email);
67 if (pos != -1) { 67 if (pos != -1) {
68 Contact *ptr = addresses.at(pos); 68 Contact *ptr = addresses.at(pos);
69 return ptr->name; 69 return ptr->name;
70 } 70 }
71 71
72 return NULL; 72 return NULL;
73} 73}
74 74
75QString AddressList::getEmailByName(QString name) 75QString AddressList::getEmailByName(const QString &name)
76{ 76{
77 int pos = getNameRef(name); 77 int pos = getNameRef(name);
78 if (pos != -1) { 78 if (pos != -1) {
79 Contact *ptr = addresses.at(pos); 79 Contact *ptr = addresses.at(pos);
80 return ptr->email; 80 return ptr->email;
81 } 81 }
82 82
83 return NULL; 83 return NULL;
84} 84}
85 85
86int AddressList::getEmailRef(QString email) 86int AddressList::getEmailRef(const QString &email)
87{ 87{
88 int pos = 0; 88 int pos = 0;
89 Contact *ptr; 89 Contact *ptr;
90 90
91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
92 if (ptr->email == email) 92 if (ptr->email == email)
93 return pos; 93 return pos;
94 pos++; 94 pos++;
95 } 95 }
96 return -1; 96 return -1;
97} 97}
98 98
99int AddressList::getNameRef(QString name) 99int AddressList::getNameRef(const QString &name)
100{ 100{
101 int pos = 0; 101 int pos = 0;
102 Contact *ptr; 102 Contact *ptr;
103 103
104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
105 if (ptr->name == name) 105 if (ptr->name == 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;(*it).defaultEmail() 124 //OContact* oc;(*it).defaultEmail()
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).fileAs()); 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(const QString &in)
152{ 152{
153 QString out = ""; 153 QString out = "";
154 154
155 int pos = in.find('='); 155 int pos = in.find('=');
156 if (pos != -1) { 156 if (pos != -1) {
157 out = in.mid(pos+1).stripWhiteSpace(); 157 out = in.mid(pos+1).stripWhiteSpace();
158 } 158 }
159 return out; 159 return out;
160} 160}
161 161
diff --git a/noncore/unsupported/mailit/addresslist.h b/noncore/unsupported/mailit/addresslist.h
index 99cef9a..b46d467 100644
--- a/noncore/unsupported/mailit/addresslist.h
+++ b/noncore/unsupported/mailit/addresslist.h
@@ -16,43 +16,43 @@
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#ifndef ADDRESSLIST_H 20#ifndef ADDRESSLIST_H
21#define ADDRESSLIST_H 21#define ADDRESSLIST_H
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qlist.h> 24#include <qlist.h>
25 25
26struct Contact 26struct Contact
27{ 27{
28 QString email; 28 QString email;
29 QString name; 29 QString name;
30}; 30};
31 31
32class AddressList : public QObject 32class AddressList : public QObject
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 AddressList(); 37 AddressList();
38 ~AddressList(); 38 ~AddressList();
39 void addContact(QString email, QString name); 39 void addContact(const QString &email, const QString &name);
40 bool containsEmail(QString email); 40 bool containsEmail(const QString &email);
41 bool containsName(QString name); 41 bool containsName(const QString &name);
42 QString getNameByEmail(QString email); 42 QString getNameByEmail(const QString &email);
43 QString getEmailByName(QString name); 43 QString getEmailByName(const QString &name);
44 QList<Contact>* getContactList(); 44 QList<Contact>* getContactList();
45 45
46private: 46private:
47 int getEmailRef(QString email); 47 int getEmailRef(const QString &email);
48 int getNameRef(QString name); 48 int getNameRef(const QString &name);
49 QString getRightString(QString in); 49 QString getRightString(const QString &in);
50 void read(); 50 void read();
51 51
52private: 52private:
53 QList<Contact> addresses; 53 QList<Contact> addresses;
54 QString filename; 54 QString filename;
55 bool dirty; 55 bool dirty;
56}; 56};
57 57
58#endif 58#endif
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index b039cc4..2102ba7 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -356,25 +356,25 @@ void EmailClient::getNewMail() {
356void EmailClient::getAllNewMail() 356void EmailClient::getAllNewMail()
357{ 357{
358 allAccounts = TRUE; 358 allAccounts = TRUE;
359 currentAccount = accountList.first(); 359 currentAccount = accountList.first();
360 getNewMail(); 360 getNewMail();
361} 361}
362 362
363void EmailClient::mailArrived(const Email &mail, bool fromDisk) 363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
364{ 364{
365 Enclosure *ePtr; 365 Enclosure *ePtr;
366 Email newMail; 366 Email newMail;
367 int thisMailId; 367 int thisMailId;
368 emailHandler->parse(mail.rawMail, lineShift, &newMail); 368 emailHandler->parse( mail.rawMail, lineShift, &newMail);
369 mailconf->setGroup(newMail.id); 369 mailconf->setGroup(newMail.id);
370 370
371 if (fromDisk) 371 if (fromDisk)
372 { 372 {
373 373
374 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
375 newMail.size = mailconf->readNumEntry("size"); 375 newMail.size = mailconf->readNumEntry("size");
376 newMail.serverId = mailconf->readNumEntry("serverid"); 376 newMail.serverId = mailconf->readNumEntry("serverid");
377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
378 } 378 }
379 else 379 else
380 { //mail arrived from server 380 { //mail arrived from server
@@ -452,35 +452,36 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
452 452
453 if (!fromDisk) 453 if (!fromDisk)
454 { 454 {
455 455
456 Email *mailPtr; 456 Email *mailPtr;
457 item = (EmailListItem *) inboxView->firstChild(); 457 item = (EmailListItem *) inboxView->firstChild();
458 while ((item != NULL)&&(!found)) 458 while ((item != NULL)&&(!found))
459 { 459 {
460 mailPtr = item->getMail(); 460 mailPtr = item->getMail();
461 if (mailPtr->id == newMail.id) { 461 if (mailPtr->id == newMail.id) {
462 item->setMail(newMail); 462 item->setMail(newMail);
463 emit mailUpdated(item->getMail()); 463 emit mailUpdated(item->getMail());
464 found = true; 464 found = true;
465 } 465 }
466 item = (EmailListItem *) item->nextSibling(); 466 item = (EmailListItem *) item->nextSibling();
467 } 467 }
468 } 468 }
469 if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); 469 if ((!found)||(fromDisk)) {
470 470 item = new EmailListItem(inboxView, newMail, TRUE);
471 if (item->getMail()->files.count()>0) 471 }
472 { 472 if (item->getMail()->files.count()>0)
473 item->setPixmap(0, Resource::loadPixmap("mailit/attach")); 473 {
474 } 474 item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475 }
475 /*if (!newMail.downloaded) 476 /*if (!newMail.downloaded)
476 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ 477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
477 478
478 mailboxView->setCurrentTab(0); 479 mailboxView->setCurrentTab(0);
479 480
480} 481}
481 482
482void EmailClient::allMailArrived(int count) 483void EmailClient::allMailArrived(int count)
483{ 484{
484 // not previewing means all mailtransfer has been done 485 // not previewing means all mailtransfer has been done
485 /*if (!previewingMail) {*/ 486 /*if (!previewingMail) {*/
486 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
@@ -633,25 +634,25 @@ void EmailClient::readMail()
633 634
634 mail.rawMail = s.mid(start, stop + del.length() - start ); 635 mail.rawMail = s.mid(start, stop + del.length() - start );
635 start = stop + del.length(); 636 start = stop + del.length();
636 emailHandler->parse(mail.rawMail, lineShift, &mail); 637 emailHandler->parse(mail.rawMail, lineShift, &mail);
637 mail.sent = false; 638 mail.sent = false;
638 mail.received = false; 639 mail.received = false;
639 enqueMail(mail); 640 enqueMail(mail);
640 641
641 } 642 }
642 } 643 }
643} 644}
644 645
645void EmailClient::saveMail(QString fileName, QListView *view) 646void EmailClient::saveMail(const QString &fileName, QListView *view)
646{ 647{
647 QFile f(fileName); 648 QFile f(fileName);
648 Email *mail; 649 Email *mail;
649 650
650 if (! f.open(IO_WriteOnly) ) { 651 if (! f.open(IO_WriteOnly) ) {
651 qWarning("could not open file"); 652 qWarning("could not open file");
652 return; 653 return;
653 } 654 }
654 item = (EmailListItem *) view->firstChild(); 655 item = (EmailListItem *) view->firstChild();
655 QTextStream t(&f); 656 QTextStream t(&f);
656 while (item != NULL) { 657 while (item != NULL) {
657 mail = item->getMail(); 658 mail = item->getMail();
@@ -703,25 +704,25 @@ void EmailClient::readSettings()
703 account.popUserName = mailconf->readEntry("POPUser",""); 704 account.popUserName = mailconf->readEntry("POPUser","");
704 account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); 705 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
705 account.popServer = mailconf->readEntry("POPServer",""); 706 account.popServer = mailconf->readEntry("POPServer","");
706 account.smtpServer = mailconf->readEntry("SMTPServer",""); 707 account.smtpServer = mailconf->readEntry("SMTPServer","");
707 account.id = mailconf->readNumEntry("AccountId",0); 708 account.id = mailconf->readNumEntry("AccountId",0);
708 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); 709 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
709 account.lastServerMailCount = 0; 710 account.lastServerMailCount = 0;
710 account.synchronize = FALSE; 711 account.synchronize = FALSE;
711 712
712 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); 713 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
713 if (account.synchronize) 714 if (account.synchronize)
714 { 715 {
715 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); 716 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
716 } 717 }
717 718
718 accountList.append(&account); 719 accountList.append(&account);
719 } 720 }
720 721
721 mailconf->setGroup("mailitglobal"); 722 mailconf->setGroup("mailitglobal");
722 723
723 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) 724 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
724 { 725 {
725 mailIdCount = y; 726 mailIdCount = y;
726 } 727 }
727 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) 728 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
@@ -906,131 +907,131 @@ void EmailClient::setDownloadedSize(int size)
906{ 907{
907 int total = progressBar->totalSteps(); 908 int total = progressBar->totalSteps();
908 909
909 if (size < total) { 910 if (size < total) {
910 progressBar->setProgress(size); 911 progressBar->setProgress(size);
911 } else { 912 } else {
912 progressBar->setProgress(total); 913 progressBar->setProgress(total);
913 } 914 }
914} 915}
915 916
916void EmailClient::deleteItem() 917void EmailClient::deleteItem()
917{ 918{
918 bool inbox=mailboxView->currentTab()==0; 919 bool inbox=mailboxView->currentTab()==0;
919 QListView* box; 920 QListView* box;
920 921
921 EmailListItem* eli; 922 EmailListItem* eli;
922 int pos; 923 int pos;
923 924
924 inbox ? box=inboxView : box=outboxView; 925 inbox ? box=inboxView : box=outboxView;
925 926
926 eli=(EmailListItem*)box->selectedItem(); 927 eli=(EmailListItem*)box->selectedItem();
927 928
928 if (eli) 929 if (eli)
929 { 930 {
930 box->setSelected(eli->itemBelow(),true);//select the previous item 931 box->setSelected(eli->itemBelow(),true); //select the previous item
931 932
932 deleteMail(eli,(bool&)inbox); //remove mail entry 933 deleteMail(eli,(bool&)inbox); //remove mail entry
933 } 934 }
934} 935}
935 936
936void EmailClient::inboxItemPressed() 937void EmailClient::inboxItemPressed()
937{ 938{
938 //timerID=startTimer(500); 939// timerID=startTimer(500);
939} 940}
940 941
941void EmailClient::inboxItemReleased() 942void EmailClient::inboxItemReleased()
942{ 943{
943 //killTimer(timerID); 944 // killTimer(timerID);
944} 945}
945 946
946/*void EmailClient::timerEvent(QTimerEvent *e) 947/*void EmailClient::timerEvent(QTimerEvent *e)
947{ 948{
948 /*killTimer(timerID); 949 /*killTimer(timerID);
949 950
950 951
951 QPopupMenu *action = new QPopupMenu(this); 952 QPopupMenu *action = new QPopupMenu(this);
952 953
953 int reply=0; 954 int reply=0;
954 955
955 action->insertItem(tr( "Reply To" ),this,SLOT(reply())); 956 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
956 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); 957 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
957 action->insertItem( tr( "Forward" ), this,SLOT(forward())); 958 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
958 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); 959 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
959 960
960 action->exec(QCursor::pos()); 961 action->exec(QCursor::pos());
961 962
962 if (action) delete action; 963 if (action) delete action;
963 964
964}*/ 965}*/
965 966
966Email* EmailClient::getCurrentMail() 967Email* EmailClient::getCurrentMail()
967{ 968{
968 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); 969 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
969 if (eli!=NULL) 970 if (eli!=NULL)
970 return eli->getMail(); 971 return eli->getMail();
971 else 972 else
972 return NULL; 973 return NULL;
973} 974}
974 975
975void EmailClient::download(Email* mail) 976void EmailClient::download(Email* mail)
976{ 977{
977 MailAccount* acc=0; 978 MailAccount* acc=0;
978 979
979 tempMailDownloadList.clear(); 980 tempMailDownloadList.clear();
980 tempMailDownloadList.sizeInsert(mail->serverId, mail->size); 981 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
981 982
982 acc=accountList.at(mail->fromAccountId-1); 983 acc=accountList.at(mail->fromAccountId-1);
983 if (acc) 984 if (acc)
984 { 985 {
985 emailHandler->setAccount(*acc); 986 emailHandler->setAccount(*acc);
986 emailHandler->getMailByList(&tempMailDownloadList); 987 emailHandler->getMailByList(&tempMailDownloadList);
987 } 988 }
988 else 989 else
989 QMessageBox::warning(qApp->activeWindow(), 990 QMessageBox::warning(qApp->activeWindow(),
990 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); 991 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
991} 992}
992 993
993void EmailClient::receive(const QCString& msg, const QByteArray& data) 994void EmailClient::receive(const QCString& msg, const QByteArray& data)
994{ 995{
995 /*if (msg=="getMail()") 996 /*if (msg=="getMail()")
996 { 997 {
997 /*QDialog qd(qApp->activeWindow(),"Getting mail",true); 998 /*QDialog qd(qApp->activeWindow(),"Getting mail",true);
998 QVBoxLayout *vbProg = new QVBoxLayout( &qd ); 999 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
999 1000
1000 initStatusBar(&qd); 1001 initStatusBar(&qd);
1001 1002
1002 if (statusBar==0) 1003 if (statusBar==0)
1003 { 1004 {
1004 qDebug("No Bar ..."); 1005 qDebug("No Bar ...");
1005 //statusBar=new ProgressBar(&qd); 1006 //statusBar=new ProgressBar(&qd);
1006 } 1007 }
1007 statusBar->show(); 1008 statusBar->show();
1008 vbProg->addWidget(statusBar); 1009 vbProg->addWidget(statusBar);
1009 qd.showMaximized(); 1010 qd.showMaximized();
1010 qd.show(); 1011 qd.show();
1011 emit getAllNewMail(); 1012 emit getAllNewMail();
1012 //qd.exec(); 1013 //qd.exec();
1013 } 1014 }
1014 else if (msg=="compose()") 1015 else if (msg=="compose()")
1015 { 1016 {
1016 QDialog qd(qApp->activeWindow(),"Getting mail",true); 1017 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1017 1018
1018 WriteMail wm(&qd,"write new mail"); 1019 WriteMail wm(&qd,"write new mail");
1019 QVBoxLayout vbProg( &qd ); 1020 QVBoxLayout vbProg( &qd );
1020 1021
1021 wm.showMaximized(); 1022 wm.showMaximized();
1022 vbProg.addWidget(&wm); 1023 vbProg.addWidget(&wm);
1023 1024
1024 qd.showMaximized(); 1025 qd.showMaximized();
1025 1026
1026 emit composeRequested(); 1027 emit composeRequested();
1027 qd.exec(); 1028 qd.exec();
1028 1029
1029 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1030 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1030 } 1031 }
1031 1032
1032 else if (msg=="dialog()") 1033 else if (msg=="dialog()")
1033 { 1034 {
1034 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1035 }*/ 1036 }*/
1036} 1037}
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h
index 994fec5..c98cfce 100644
--- a/noncore/unsupported/mailit/emailclient.h
+++ b/noncore/unsupported/mailit/emailclient.h
@@ -97,25 +97,25 @@ public slots:
97 void mailSent(); 97 void mailSent();
98 void deleteItem(); 98 void deleteItem();
99 void getNewMail(); 99 void getNewMail();
100 void getAllNewMail(); 100 void getAllNewMail();
101 void smtpError(int code); 101 void smtpError(int code);
102 void popError(int code); 102 void popError(int code);
103 void inboxItemSelected(); 103 void inboxItemSelected();
104 void outboxItemSelected(); 104 void outboxItemSelected();
105 void inboxItemPressed(); 105 void inboxItemPressed();
106 void inboxItemReleased(); 106 void inboxItemReleased();
107 void mailArrived(const Email &mail, bool fromDisk); 107 void mailArrived(const Email &mail, bool fromDisk);
108 void allMailArrived(int); 108 void allMailArrived(int);
109 void saveMail(QString fileName, QListView *view); 109 void saveMail(const QString &fileName, QListView *view);
110 void selectAccount(int); 110 void selectAccount(int);
111 void editAccount(int); 111 void editAccount(int);
112 void updateAccounts(); 112 void updateAccounts();
113 void deleteAccount(int); 113 void deleteAccount(int);
114 void deleteMail(EmailListItem *mailItem, bool &inbox); 114 void deleteMail(EmailListItem *mailItem, bool &inbox);
115 void setTotalSize(int); 115 void setTotalSize(int);
116 void setMailSize(int); 116 void setMailSize(int);
117 void setDownloadedSize(int); 117 void setDownloadedSize(int);
118 void moveMailFront(Email *mailPtr); 118 void moveMailFront(Email *mailPtr);
119 void download(Email*); 119 void download(Email*);
120/* void reply(); 120/* void reply();
121 void replyAll(); 121 void replyAll();
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 62fa64f..59ccd90 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -30,25 +30,25 @@ QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (Enclosure *) d); 31 return dupl( (Enclosure *) d);
32} 32}
33 33
34Enclosure* EnclosureList::dupl(Enclosure *in) 34Enclosure* EnclosureList::dupl(Enclosure *in)
35{ 35{
36 ac = new Enclosure(*in); 36 ac = new Enclosure(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailHandler::EmailHandler() 40EmailHandler::EmailHandler()
41{ 41{
42 qDebug("EMailHandler::EmailHandler"); 42 qDebug("EMailHandler::EmailHandler");
43 43
44 smtpClient = new SmtpClient(); 44 smtpClient = new SmtpClient();
45 popClient = new PopClient(); 45 popClient = new PopClient();
46 46
47 connect(smtpClient, SIGNAL(errorOccurred(int)), this, 47 connect(smtpClient, SIGNAL(errorOccurred(int)), this,
48 SIGNAL(smtpError(int)) ); 48 SIGNAL(smtpError(int)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); 49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, 50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) ); 51 SIGNAL(updateSmtpStatus(const QString &)) );
52 52
53 connect(popClient, SIGNAL(errorOccurred(int)), this, 53 connect(popClient, SIGNAL(errorOccurred(int)), this,
54 SIGNAL(popError(int)) ); 54 SIGNAL(popError(int)) );
@@ -139,25 +139,25 @@ void EmailHandler::getMailByList(MailList *mailList)
139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
140{ 140{
141 Email mail; 141 Email mail;
142 142
143 mail.rawMail = message; 143 mail.rawMail = message;
144 mail.serverId = id; 144 mail.serverId = id;
145 mail.size = size; 145 mail.size = size;
146 mail.downloaded = complete; 146 mail.downloaded = complete;
147 147
148 emit mailArrived(mail, FALSE); 148 emit mailArrived(mail, FALSE);
149} 149}
150 150
151bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
152{ 152{
153 QString temp, boundary; 153 QString temp, boundary;
154 int pos; 154 int pos;
155 QString delimiter, header, body, mimeHeader, mimeBody; 155 QString delimiter, header, body, mimeHeader, mimeBody;
156 QString content, contentType, contentAttribute, id, encoding; 156 QString content, contentType, contentAttribute, id, encoding;
157 QString fileName, storedName; 157 QString fileName, storedName;
158 int enclosureId = 0; 158 int enclosureId = 0;
159 159
160 mail->rawMail = in; 160 mail->rawMail = in;
161 mail->received = TRUE; 161 mail->received = TRUE;
162 mail->files.setAutoDelete(TRUE); 162 mail->files.setAutoDelete(TRUE);
163 163
@@ -195,39 +195,39 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
195 mail->fromMail = p.getString(&pos, 'z', TRUE); 195 mail->fromMail = p.getString(&pos, 'z', TRUE);
196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
197 mail->fromMail.truncate(mail->fromMail.length() - 1); 197 mail->fromMail.truncate(mail->fromMail.length() - 1);
198 mail->from=mail->fromMail; 198 mail->from=mail->fromMail;
199 } 199 }
200 } 200 }
201 201
202 pos=0; 202 pos=0;
203 203
204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: 204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1) 205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
206 { 206 {
207 QString rec; 207 QString rec;
208 208
209 if (p.separatorAt(pos-1)!='-')//The - separator means that this is a Delivered-To: or Reply-To: 209 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
210 { 210 {
211 pos++; 211 pos++;
212 mail->recipients.append(p.getString(&pos, '\r', TRUE)); 212 mail->recipients.append(p.getString(&pos, '\r', TRUE));
213 } 213 }
214 } 214 }
215 // 215 //
216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); 216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
217 217
218 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 218 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
219 { 219 {
220 pos++; 220 pos++;
221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
222 } 222 }
223 223
224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
225 pos++; 225 pos++;
226 mail->subject = p.getString(&pos, 'z', TRUE); 226 mail->subject = p.getString(&pos, 'z', TRUE);
227 } 227 }
228 228
229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
230 pos++; 230 pos++;
231 mail->date = p.getString(&pos, 'z', TRUE); 231 mail->date = p.getString(&pos, 'z', TRUE);
232 } 232 }
233 233
@@ -431,26 +431,26 @@ int EmailHandler::parse64base(char *src, char *bufOut) {
431 } 431 }
432 } 432 }
433 return processed; 433 return processed;
434} 434}
435 435
436int EmailHandler::encodeMime(Email *mail) 436int EmailHandler::encodeMime(Email *mail)
437{ 437{
438 438
439 QString fileName, fileType, contentType, newBody, boundary; 439 QString fileName, fileType, contentType, newBody, boundary;
440 Enclosure *ePtr; 440 Enclosure *ePtr;
441 441
442 QString userName = mailAccount.name; 442 QString userName = mailAccount.name;
443 if (userName.length()>0)//only embrace it if there is a user name 443 if (userName.length()>0) //only embrace it if there is a user name
444 userName += " <" + mailAccount.emailAddress + ">"; 444 userName += " <" + mailAccount.emailAddress + ">";
445 445
446 //add standard headers 446 //add standard headers
447 newBody = "From: " + userName + "\r\nTo: "; 447 newBody = "From: " + userName + "\r\nTo: ";
448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { 448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) {
449 newBody += *it + " "; 449 newBody += *it + " ";
450 } 450 }
451 451
452 newBody += "\r\nCC: "; 452 newBody += "\r\nCC: ";
453 453
454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { 454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) {
455 newBody += *it + " "; 455 newBody += *it + " ";
456 } 456 }
@@ -501,25 +501,25 @@ int EmailHandler::encodeMime(Email *mail)
501 fi.fileName() + "\"\r\n\r\n"; 501 fi.fileName() + "\"\r\n\r\n";
502 502
503 if (encodeFile(fileName, &newBody) == -1) //file not found? 503 if (encodeFile(fileName, &newBody) == -1) //file not found?
504 return -1; 504 return -1;
505 } 505 }
506 506
507 newBody += "\r\n\r\n--" + boundary + "--"; 507 newBody += "\r\n\r\n--" + boundary + "--";
508 mail->rawMail = newBody; 508 mail->rawMail = newBody;
509 509
510 return 0; 510 return 0;
511} 511}
512 512
513int EmailHandler::encodeFile(QString fileName, QString *toBody) 513int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
514{ 514{
515 char *fileData; 515 char *fileData;
516 char *dataPtr; 516 char *dataPtr;
517 QString temp; 517 QString temp;
518 uint dataSize, count; 518 uint dataSize, count;
519 QFile f(fileName); 519 QFile f(fileName);
520 520
521 if (! f.open(IO_ReadOnly) ) { 521 if (! f.open(IO_ReadOnly) ) {
522 qWarning("could not open file: " + fileName); 522 qWarning("could not open file: " + fileName);
523 return -1; 523 return -1;
524 } 524 }
525 QTextStream s(&f); 525 QTextStream s(&f);
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
index 5b59f65..e4e7f46 100644
--- a/noncore/unsupported/mailit/emailhandler.h
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -28,123 +28,123 @@
28#include <qfile.h> 28#include <qfile.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qcollection.h> 30#include <qcollection.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include "smtpclient.h" 33#include "smtpclient.h"
34#include "popclient.h" 34#include "popclient.h"
35#include "textparser.h" 35#include "textparser.h"
36#include "maillist.h" 36#include "maillist.h"
37 37
38struct Enclosure 38struct Enclosure
39{ 39{
40 int id; 40 int id;
41 QString originalName; 41 QString originalName;
42 QString name; 42 QString name;
43 QString path; 43 QString path;
44 QString contentType; 44 QString contentType;
45 QString contentAttribute; 45 QString contentAttribute;
46 QString encoding; 46 QString encoding;
47 QString body; //might use to much mem. check!! 47 QString body; //might use to much mem. check!!
48 bool saved, installed; 48 bool saved, installed;
49}; 49};
50 50
51class EnclosureList : public QList<Enclosure> 51class EnclosureList : public QList<Enclosure>
52{ 52{
53public: 53public:
54 Item newItem(Item d); 54 Item newItem(Item d);
55private: 55private:
56 Enclosure* dupl(Enclosure *in); 56 Enclosure* dupl(Enclosure *in);
57 Enclosure *ac; 57 Enclosure *ac;
58}; 58};
59 59
60struct Email 60struct Email
61{ 61{
62 QString id; 62 QString id;
63 QString from; 63 QString from;
64 QString fromMail; 64 QString fromMail;
65 QStringList recipients; 65 QStringList recipients;
66 QStringList carbonCopies; 66 QStringList carbonCopies;
67 QString date; 67 QString date;
68 QString subject; 68 QString subject;
69 QString body; 69 QString body;
70 QString bodyPlain; 70 QString bodyPlain;
71 bool sent, received, read, downloaded; 71 bool sent, received, read, downloaded;
72 QString rawMail; 72 QString rawMail;
73 int mimeType; //1 = Mime 1.0 73 int mimeType; //1 = Mime 1.0
74 int serverId; 74 int serverId;
75 int internalId; 75 int internalId;
76 int fromAccountId; 76 int fromAccountId;
77 QString contentType; //0 = text 77 QString contentType; //0 = text
78 QString contentAttribute; //0 = plain, 1 = html 78 QString contentAttribute; //0 = plain, 1 = html
79 EnclosureList files; 79 EnclosureList files;
80 uint size; 80 uint size;
81 81
82 void addEnclosure(Enclosure *e) 82 void addEnclosure(Enclosure *e)
83 { 83 {
84 files.append(e); 84 files.append(e);
85 } 85 }
86}; 86};
87 87
88struct MailAccount 88struct MailAccount
89{ 89{
90 QString accountName; 90 QString accountName;
91 QString name; 91 QString name;
92 QString emailAddress; 92 QString emailAddress;
93 QString popUserName; 93 QString popUserName;
94 QString popPasswd; 94 QString popPasswd;
95 QString popServer; 95 QString popServer;
96 QString smtpServer; 96 QString smtpServer;
97 bool synchronize; 97 bool synchronize;
98 int syncLimit; 98 int syncLimit;
99 int lastServerMailCount; 99 int lastServerMailCount;
100 int id; 100 int id;
101}; 101};
102 102
103 const int ErrUnknownResponse = 1001; 103 const int ErrUnknownResponse = 1001;
104 const int ErrLoginFailed = 1002; 104 const int ErrLoginFailed = 1002;
105 const int ErrCancel = 1003; 105 const int ErrCancel = 1003;
106 106
107 107
108class EmailHandler : public QObject 108class EmailHandler : public QObject
109{ 109{
110 Q_OBJECT 110 Q_OBJECT
111 111
112public: 112public:
113 EmailHandler(); 113 EmailHandler();
114 void setAccount(MailAccount account); 114 void setAccount(MailAccount account);
115 MailAccount* getAccount(){return &mailAccount;} 115 MailAccount* getAccount(){return &mailAccount;}
116 void sendMail(QList<Email> *mailList); 116 void sendMail(QList<Email> *mailList);
117 void getMail(); 117 void getMail();
118 void getMailHeaders(); 118 void getMailHeaders();
119 void getMailByList(MailList *mailList); 119 void getMailByList(MailList *mailList);
120 bool parse(QString in, QString lineShift, Email *mail); 120 bool parse(const QString &in, const QString &lineShift, Email *mail);
121 bool getEnclosure(Enclosure *ePtr); 121 bool getEnclosure(Enclosure *ePtr);
122 int parse64base(char *src, char *dest); 122 int parse64base(char *src, char *dest);
123 int encodeMime(Email *mail); 123 int encodeMime(Email *mail);
124 int encodeFile(QString fileName, QString *toBody); 124 int encodeFile(const QString &fileName, QString *toBody);
125 void encode64base(char *src, QString *dest, int len); 125 void encode64base(char *src, QString *dest, int len);
126 void cancel(); 126 void cancel();
127 127
128signals: 128signals:
129 void mailSent(); 129 void mailSent();
130 void smtpError(int); 130 void smtpError(int);
131 void popError(int); 131 void popError(int);
132 void mailArrived(const Email &, bool); 132 void mailArrived(const Email &, bool);
133 void updatePopStatus(const QString &); 133 void updatePopStatus(const QString &);
134 void updateSmtpStatus(const QString &); 134 void updateSmtpStatus(const QString &);
135 void mailTransfered(int); 135 void mailTransfered(int);
136 void mailboxSize(int); 136 void mailboxSize(int);
137 void currentMailSize(int); 137 void currentMailSize(int);
138 void downloadedSize(int); 138 void downloadedSize(int);
139 139
140public slots: 140public slots:
141 void messageArrived(const QString &, int id, uint size, bool complete); 141 void messageArrived(const QString &, int id, uint size, bool complete);
142 142
143private: 143private:
144 MailAccount mailAccount; 144 MailAccount mailAccount;
145 SmtpClient *smtpClient; 145 SmtpClient *smtpClient;
146 PopClient *popClient; 146 PopClient *popClient;
147 bool headers; 147 bool headers;
148}; 148};
149 149
150#endif 150#endif
diff --git a/noncore/unsupported/mailit/emaillistitem.cpp b/noncore/unsupported/mailit/emaillistitem.cpp
index b925a1c..fc9f766 100644
--- a/noncore/unsupported/mailit/emaillistitem.cpp
+++ b/noncore/unsupported/mailit/emaillistitem.cpp
@@ -13,87 +13,87 @@
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 <qstring.h> 20#include <qstring.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include "emaillistitem.h" 22#include "emaillistitem.h"
23 23
24EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) 24EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox)
25 : QListViewItem(parent) 25 : QListViewItem(parent)
26{ 26{
27 QString temp; 27 QString temp;
28 28
29 mail = mailIn; 29 mail = mailIn;
30 30
31 if (inbox) { 31 if (inbox) {
32 setText(0, mail.from); 32 setText(0, mail.from);
33 } else { 33 } else {
34 QStringList::Iterator it = mail.recipients.begin(); 34 QStringList::Iterator it = mail.recipients.begin();
35 temp = *it; 35 temp = *it;
36 if (mail.recipients.count() > 1) 36 if (mail.recipients.count() > 1)
37 temp += "..."; 37 temp += "...";
38 setText(0, temp); 38 setText(0, temp);
39 } 39 }
40 setText(1, mail.subject); 40 setText(1, mail.subject);
41 setText(2,mail.date); 41 setText(2,mail.date);
42 42
43 if (mailIn.files.count()>0) 43 if (mailIn.files.count()>0)
44 { 44 {
45 setPixmap(0, Resource::loadPixmap("mailit/attach")); 45 setPixmap(0, Resource::loadPixmap("mailit/attach"));
46 } 46 }
47 47
48 selected = FALSE; 48 selected = FALSE;
49} 49}
50 50
51Email* EmailListItem::getMail() 51Email* EmailListItem::getMail()
52{ 52{
53 return &mail; 53 return &mail;
54} 54}
55 55
56void EmailListItem::setMail(Email newMail) 56void EmailListItem::setMail(Email newMail)
57{ 57{
58 mail = newMail; 58 mail = newMail;
59 repaint(); 59 repaint();
60} 60}
61 61
62void EmailListItem::setItemSelected(bool enable) 62void EmailListItem::setItemSelected(bool enable)
63{ 63{
64 selected = enable; 64 selected = enable;
65 setSelected(enable); 65 setSelected(enable);
66 repaint(); 66 repaint();
67} 67}
68 68
69bool EmailListItem::isItemSelected() 69bool EmailListItem::isItemSelected()
70{ 70{
71 return selected; 71 return selected;
72} 72}
73 73
74void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, 74void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg,
75 int column, int width, int alignment ) 75 int column, int width, int alignment )
76{ 76{
77 77
78 QColorGroup _cg( cg ); 78 QColorGroup _cg( cg );
79 QColor c = _cg.text(); 79 QColor c = _cg.text();
80 80
81 if ( (! mail.read) && (mail.received) ) 81 if ( (! mail.read) && (mail.received) )
82 _cg.setColor( QColorGroup::Text, Qt::blue); 82 _cg.setColor( QColorGroup::Text, Qt::blue);
83 if (!mail.downloaded) 83 if (!mail.downloaded)
84 _cg.setColor( QColorGroup::Text, Qt::red); 84 _cg.setColor( QColorGroup::Text, Qt::red);
85 85
86 /*if (selected) { 86/* if (selected) {
87 _cg.setColor(QColorGroup::Base, Qt::blue); 87 _cg.setColor(QColorGroup::Base, Qt::blue);
88 _cg.setColor(QColorGroup::Text, Qt::yellow); 88 _cg.setColor(QColorGroup::Text, Qt::yellow);
89 if (isSelected()) { 89 if (isSelected()) {
90 _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); 90 _cg.setColor(QColorGroup::HighlightedText, Qt::yellow);
91 } else { 91 } else {
92 _cg.setColor(QColorGroup::Highlight, Qt::blue); 92 _cg.setColor(QColorGroup::Highlight, Qt::blue);
93 } 93 }
94 } 94 }
95 */ 95*/
96 QListViewItem::paintCell( p, _cg, column, width, alignment ); 96 QListViewItem::paintCell( p, _cg, column, width, alignment );
97 97
98 _cg.setColor( QColorGroup::Text, c ); 98 _cg.setColor( QColorGroup::Text, c );
99} 99}
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index fedc4e2..dc0116d 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -41,41 +41,41 @@ PopClient::PopClient()
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 preview = FALSE; 44 preview = FALSE;
45} 45}
46 46
47PopClient::~PopClient() 47PopClient::~PopClient()
48{ 48{
49 delete socket; 49 delete socket;
50 delete stream; 50 delete stream;
51} 51}
52 52
53void PopClient::newConnection(QString target, int port) 53void PopClient::newConnection(const QString &target, int port)
54{ 54{
55 if (receiving) { 55 if (receiving) {
56 qWarning("socket in use, connection refused"); 56 qWarning("socket in use, connection refused");
57 return; 57 return;
58 } 58 }
59 59
60 status = Init; 60 status = Init;
61 61
62 socket->connectToHost(target, port); 62 socket->connectToHost(target, port);
63 receiving = TRUE; 63 receiving = TRUE;
64 //selected = FALSE; 64 //selected = FALSE;
65 65
66 emit updateStatus("DNS lookup"); 66 emit updateStatus("DNS lookup");
67} 67}
68 68
69void PopClient::setAccount(QString popUser, QString popPasswd) 69void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 70{
71 popUserName = popUser; 71 popUserName = popUser;
72 popPassword = popPasswd; 72 popPassword = popPasswd;
73} 73}
74 74
75void PopClient::setSynchronize(int lastCount) 75void PopClient::setSynchronize(int lastCount)
76{ 76{
77 synchronize = TRUE; 77 synchronize = TRUE;
78 lastSync = lastCount; 78 lastSync = lastCount;
79} 79}
80 80
81void PopClient::removeSynchronize() 81void PopClient::removeSynchronize()
@@ -149,60 +149,60 @@ void PopClient::incomingData()
149#endif 149#endif
150 { 150 {
151 timeStamp = ""; 151 timeStamp = "";
152 *stream << "USER " << popUserName << "\r\n"; 152 *stream << "USER " << popUserName << "\r\n";
153 status = Pass; 153 status = Pass;
154 } 154 }
155 155
156 break; 156 break;
157 } 157 }
158 158
159 case Pass: { 159 case Pass: {
160 *stream << "PASS " << popPassword << "\r\n"; 160 *stream << "PASS " << popPassword << "\r\n";
161 status = Stat; 161 status = Stat;
162 162
163 break; 163 break;
164 } 164 }
165 //ask for number of messages 165 //ask for number of messages
166 case Stat: { 166 case Stat: {
167 if (response[0] == '+') { 167 if (response[0] == '+') {
168 *stream << "STAT" << "\r\n"; 168 *stream << "STAT" << "\r\n";
169 status = Mcnt; 169 status = Mcnt;
170 } else errorHandling(ErrLoginFailed); 170 } else errorHandling(ErrLoginFailed);
171 break; 171 break;
172 } 172 }
173 //get count of messages, eg "+OK 4 900.." -> int 4 173 //get count of messages, eg "+OK 4 900.." -> int 4
174 case Mcnt: { 174 case Mcnt: {
175 if (response[0] == '+') { 175 if (response[0] == '+') {
176 temp = response.replace(0, 4, ""); 176 temp = response.replace(0, 4, "");
177 int x = temp.find(" ", 0); 177 int x = temp.find(" ", 0);
178 temp.truncate((uint) x); 178 temp.truncate((uint) x);
179 newMessages = temp.toInt(); 179 newMessages = temp.toInt();
180 messageCount = 1; 180 messageCount = 1;
181 status = List; 181 status = List;
182 182
183 if (synchronize) { 183 if (synchronize) {
184 //messages deleted from server, reload all 184 //messages deleted from server, reload all
185 if (newMessages < lastSync) 185 if (newMessages < lastSync)
186 lastSync = 0; 186 lastSync = 0;
187 messageCount = 1; 187 messageCount = 1;
188 } 188 }
189 189
190 if (selected) { 190 if (selected) {
191 int *ptr = mailList->first(); 191 int *ptr = mailList->first();
192 if (ptr != 0) { 192 if (ptr != 0) {
193 newMessages++; //to ensure no early jumpout 193 newMessages++; //to ensure no early jumpout
194 messageCount = *ptr; 194 messageCount = *ptr;
195 } else newMessages = 0; 195 } else newMessages = 0;
196 } 196 }
197 197
198 } else errorHandling(ErrUnknownResponse); 198 } else errorHandling(ErrUnknownResponse);
199 } 199 }
200 //Read message number x, count upwards to messageCount 200 //Read message number x, count upwards to messageCount
201 case List: { 201 case List: {
202 if (messageCount <= newMessages) { 202 if (messageCount <= newMessages) {
203 *stream << "LIST " << messageCount << "\r\n"; 203 *stream << "LIST " << messageCount << "\r\n";
204 status = Size; 204 status = Size;
205 temp2.setNum(newMessages - lastSync); 205 temp2.setNum(newMessages - lastSync);
206 temp.setNum(messageCount - lastSync); 206 temp.setNum(messageCount - lastSync);
207 if (!selected) { 207 if (!selected) {
208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
@@ -233,28 +233,28 @@ void PopClient::incomingData()
233 233
234 status = Retr; 234 status = Retr;
235 } else { 235 } else {
236 //qWarning(response); 236 //qWarning(response);
237 errorHandling(ErrUnknownResponse); 237 errorHandling(ErrUnknownResponse);
238 } 238 }
239 } 239 }
240 } 240 }
241 //Read message number x, count upwards to messageCount 241 //Read message number x, count upwards to messageCount
242 case Retr: { 242 case Retr: {
243 if (status != Quit) { 243 if (status != Quit) {
244 if ((selected)||(mailSize <= headerLimit)) 244 if ((selected)||(mailSize <= headerLimit))
245 { 245 {
246 *stream << "RETR " << messageCount << "\r\n"; 246 *stream << "RETR " << messageCount << "\r\n";
247 } else { //only header 247 } else { //only header
248 *stream << "TOP " << messageCount << " 0\r\n"; 248 *stream << "TOP " << messageCount << " 0\r\n";
249 } 249 }
250 messageCount++; 250 messageCount++;
251 status = Ignore; 251 status = Ignore;
252 break; 252 break;
253 } } 253 } }
254 case Ignore: { 254 case Ignore: {
255 if (status != Quit) { //because of idiotic switch 255 if (status != Quit) { //because of idiotic switch
256 if (response[0] == '+') { 256 if (response[0] == '+') {
257 message = ""; 257 message = "";
258 status = Read; 258 status = Read;
259 if (!socket->canReadLine()) //sync. problems 259 if (!socket->canReadLine()) //sync. problems
260 break; 260 break;
@@ -267,41 +267,41 @@ void PopClient::incomingData()
267 case Read: { 267 case Read: {
268 if (status != Quit) { //because of idiotic switch 268 if (status != Quit) { //because of idiotic switch
269 message += response; 269 message += response;
270 while ( socket->canReadLine() ) { 270 while ( socket->canReadLine() ) {
271 response = socket->readLine(); 271 response = socket->readLine();
272 message += response; 272 message += response;
273 } 273 }
274 emit downloadedSize(message.length()); 274 emit downloadedSize(message.length());
275 int x = message.find("\r\n.\r\n",-5); 275 int x = message.find("\r\n.\r\n",-5);
276 if (x == -1) { 276 if (x == -1) {
277 break; 277 break;
278 } else { //message reach entire size 278 } else { //message reach entire size
279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
280 { 280 {
281 emit newMessage(message, messageCount-1, mailSize, TRUE); 281 emit newMessage(message, messageCount-1, mailSize, TRUE);
282 } else { //incomplete mail downloaded 282 } else { //incomplete mail downloaded
283 emit newMessage(message, messageCount-1, mailSize, FALSE); 283 emit newMessage(message, messageCount-1, mailSize, FALSE);
284 } 284 }
285 285
286 if ((messageCount > newMessages)||(selected)) //last message ? 286 if ((messageCount > newMessages)||(selected)) //last message ?
287 { 287 {
288 status = Quit; 288 status = Quit;
289 if (selected) { //grab next from queue 289 if (selected) { //grab next from queue
290 newMessages--; 290 newMessages--;
291 status = Quit; 291 status = Quit;
292 } 292 }
293 } 293 }
294 else 294 else
295 { 295 {
296 *stream << "LIST " << messageCount << "\r\n"; 296 *stream << "LIST " << messageCount << "\r\n";
297 status = Size; 297 status = Size;
298 temp2.setNum(newMessages - lastSync); 298 temp2.setNum(newMessages - lastSync);
299 temp.setNum(messageCount - lastSync); 299 temp.setNum(messageCount - lastSync);
300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
301 301
302 break; 302 break;
303 } 303 }
304 } 304 }
305 } 305 }
306 if (status != Quit) 306 if (status != Quit)
307 break; 307 break;
diff --git a/noncore/unsupported/mailit/popclient.h b/noncore/unsupported/mailit/popclient.h
index 10b71ab..c58bc48 100644
--- a/noncore/unsupported/mailit/popclient.h
+++ b/noncore/unsupported/mailit/popclient.h
@@ -26,26 +26,26 @@
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qlist.h> 28#include <qlist.h>
29#include "maillist.h" 29#include "maillist.h"
30 30
31class PopClient: public QObject 31class PopClient: public QObject
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 PopClient(); 36 PopClient();
37 ~PopClient(); 37 ~PopClient();
38 void newConnection(QString target, int port); 38 void newConnection(const QString &target, int port);
39 void setAccount(QString popUser, QString popPasswd); 39 void setAccount(const QString &popUser, const QString &popPasswd);
40 void setSynchronize(int lastCount); 40 void setSynchronize(int lastCount);
41 void removeSynchronize(); 41 void removeSynchronize();
42 void headersOnly(bool headers, int limit); 42 void headersOnly(bool headers, int limit);
43 void setSelectedMails(MailList *list); 43 void setSelectedMails(MailList *list);
44 44
45signals: 45signals:
46 void newMessage(const QString &, int, uint, bool); 46 void newMessage(const QString &, int, uint, bool);
47 void errorOccurred(int status); 47 void errorOccurred(int status);
48 void updateStatus(const QString &); 48 void updateStatus(const QString &);
49 void mailTransfered(int); 49 void mailTransfered(int);
50 void mailboxSize(int); 50 void mailboxSize(int);
51 void currentMailSize(int); 51 void currentMailSize(int);
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 8a51a5b..2916f45 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -30,39 +30,39 @@ SmtpClient::SmtpClient()
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(QString target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
diff --git a/noncore/unsupported/mailit/smtpclient.h b/noncore/unsupported/mailit/smtpclient.h
index ca65af4..45c0703 100644
--- a/noncore/unsupported/mailit/smtpclient.h
+++ b/noncore/unsupported/mailit/smtpclient.h
@@ -21,55 +21,55 @@
21#define SmtpClient_H 21#define SmtpClient_H
22 22
23//#include <stdio.h> 23//#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlist.h> 29#include <qlist.h>
30 30
31struct RawEmail 31struct RawEmail
32{ 32{
33 QString from; 33 QString from;
34 QString subject; 34 QString subject;
35 QStringList to; 35 QStringList to;
36 QString body; 36 QString body;
37}; 37};
38 38
39class SmtpClient: public QObject 39class SmtpClient: public QObject
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 SmtpClient(); 44 SmtpClient();
45 ~SmtpClient(); 45 ~SmtpClient();
46 void newConnection(QString target, int port); 46 void newConnection(const QString &target, int port);
47 void addMail(QString from, QString subject, QStringList to, QString body); 47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
48 48
49signals: 49signals:
50 void errorOccurred(int); 50 void errorOccurred(int);
51 void updateStatus(const QString &); 51 void updateStatus(const QString &);
52 void mailSent(); 52 void mailSent();
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 56
57protected slots: 57protected slots:
58 void connectionEstablished(); 58 void connectionEstablished();
59 void incomingData(); 59 void incomingData();
60 60
61private: 61private:
62 QSocket *socket; 62 QSocket *socket;
63 QTextStream *stream; 63 QTextStream *stream;
64 enum transferStatus 64 enum transferStatus
65 { 65 {
66 Init, From, Recv, MRcv, Data, Body, Quit, Done 66 Init, From, Recv, MRcv, Data, Body, Quit, Done
67 }; 67 };
68 int status; 68 int status;
69 QList<RawEmail> mailList; 69 QList<RawEmail> mailList;
70 RawEmail *mailPtr; 70 RawEmail *mailPtr;
71 bool sending; 71 bool sending;
72 QStringList::Iterator it; 72 QStringList::Iterator it;
73}; 73};
74 74
75#endif 75#endif
diff --git a/noncore/unsupported/mailit/textparser.cpp b/noncore/unsupported/mailit/textparser.cpp
index 3fa5f6e..e5c9f7c 100644
--- a/noncore/unsupported/mailit/textparser.cpp
+++ b/noncore/unsupported/mailit/textparser.cpp
@@ -10,295 +10,295 @@
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 "textparser.h" 20#include "textparser.h"
21 21
22TextParser::TextParser(QString in, QString lineBreak) 22TextParser::TextParser(const QString &in, const QString &lineBreak)
23{ 23{
24 data = in; 24 data = in;
25 lineSep = lineBreak; 25 lineSep = lineBreak;
26 26
27 init(); 27 init();
28 createSeparators(); 28 createSeparators();
29 split(); 29 split();
30} 30}
31 31
32TextParser::TextParser(QString in, QString lineBreak, QString sep) 32TextParser::TextParser(const QString &in, const QString &lineBreak, const QString &sep)
33{ 33{
34 data = in; 34 data = in;
35 lineSep = lineBreak; 35 lineSep = lineBreak;
36 36
37 init(); 37 init();
38 separators = sep; 38 separators = sep;
39 split(); 39 split();
40} 40}
41 41
42void TextParser::init() 42void TextParser::init()
43{ 43{
44 lineCount = 0; 44 lineCount = 0;
45 linePos = 0; 45 linePos = 0;
46 totalElmCount = 0; 46 totalElmCount = 0;
47 separatorPos = -1; //not initialized 47 separatorPos = -1; //not initialized
48 wordPos = -1; //not initialized 48 wordPos = -1; //not initialized
49 sepAtLine = 0; 49 sepAtLine = 0;
50 sepAtPosElm = -1; //such that nextSep equals 0 50 sepAtPosElm = -1; //such that nextSep equals 0
51 wordAtLine = 0; 51 wordAtLine = 0;
52 wordAtPosElm = -1; //such that nextWord equals 0 52 wordAtPosElm = -1; //such that nextWord equals 0
53 atLine = 0; 53 atLine = 0;
54 atPosElm = 0; 54 atPosElm = 0;
55} 55}
56 56
57void TextParser::createSeparators() 57void TextParser::createSeparators()
58{ 58{
59 separators = " @#,.:;<>*/(){}|'?-+=_"; 59 separators = " @#,.:;<>*/(){}|'?-+=_";
60} 60}
61 61
62 /*Returns pos of given search criteria, -1 if not found */ 62/* Returns pos of given search criteria, -1 if not found */
63int TextParser::find(QString target, QChar sep, int pos, bool upperCase) 63int TextParser::find(const QString &target, QChar sep, int pos, bool upperCase)
64{ 64{
65 65
66 t_splitElm parsstr; 66 t_splitElm parsstr;
67 QString pString; 67 QString pString, pTarget;
68 68 pTarget = target;
69 int atLine = 0, atPosElm = 0; 69 int atLine = 0, atPosElm = 0;
70 70
71 getLineReference(pos,&atLine,&atPosElm); 71 getLineReference(pos,&atLine,&atPosElm);
72 72
73 for (int x = pos; x < totalElmCount; x++) 73 for (int x = pos; x < totalElmCount; x++)
74 { 74 {
75 parsstr=splitDone[atLine].elm[atPosElm++]; 75 parsstr=splitDone[atLine].elm[atPosElm++];
76 76
77 if (upperCase) 77 if (upperCase)
78 { 78 {
79 pString=parsstr.str.upper(); 79 pString=parsstr.str.upper();
80 target=target.upper(); 80 pTarget=pTarget.upper();
81 } 81 }
82 else 82 else
83 { 83 {
84 pString=parsstr.str; 84 pString=parsstr.str;
85 } 85 }
86 if ((pString == target) && (parsstr.separator == sep)) 86 if ((pString == pTarget) && (parsstr.separator == sep))
87 { 87 {
88 return x; 88 return x;
89 } 89 }
90 if (atPosElm >= splitDone[atLine].elmCount) 90 if (atPosElm >= splitDone[atLine].elmCount)
91 { //new Line 91 { //new Line
92 atLine++; 92 atLine++;
93 atPosElm = 0; 93 atPosElm = 0;
94 } 94 }
95 } 95 }
96 return -1; 96 return -1;
97} 97}
98 98
99int TextParser::elmCount() 99int TextParser::elmCount()
100{ 100{
101 return totalElmCount; 101 return totalElmCount;
102} 102}
103 103
104QChar TextParser::separatorAt(int pos) 104QChar TextParser::separatorAt(int pos)
105{ 105{
106 if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) 106 if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1)
107 return QChar::null; 107 return QChar::null;
108 108
109 separatorPos = pos; 109 separatorPos = pos;
110 return splitDone[sepAtLine].elm[sepAtPosElm].separator; 110 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
111} 111}
112 112
113QChar TextParser::nextSeparator() 113QChar TextParser::nextSeparator()
114{ 114{
115 sepAtPosElm++; 115 sepAtPosElm++;
116 if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { 116 if (splitDone[sepAtLine].elmCount <= sepAtPosElm) {
117 sepAtLine++; 117 sepAtLine++;
118 sepAtPosElm = 0; 118 sepAtPosElm = 0;
119 } 119 }
120 120
121 separatorPos++; 121 separatorPos++;
122 return splitDone[sepAtLine].elm[sepAtPosElm].separator; 122 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
123} 123}
124 124
125bool TextParser::hasNextSeparator() 125bool TextParser::hasNextSeparator()
126{ 126{
127 return ((separatorPos+1) < totalElmCount); 127 return ((separatorPos+1) < totalElmCount);
128} 128}
129 129
130QString TextParser::wordAt(int pos) 130QString TextParser::wordAt(int pos)
131{ 131{
132 if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) 132 if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1)
133 return NULL; 133 return NULL;
134 134
135 wordPos = pos; 135 wordPos = pos;
136 return splitDone[wordAtLine].elm[wordAtPosElm].str; 136 return splitDone[wordAtLine].elm[wordAtPosElm].str;
137} 137}
138 138
139QString TextParser::nextWord() 139QString TextParser::nextWord()
140{ 140{
141 wordAtPosElm++; 141 wordAtPosElm++;
142 if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { 142 if (splitDone[wordAtLine].elmCount <= wordAtPosElm) {
143 wordAtLine++; 143 wordAtLine++;
144 wordAtPosElm = 0; 144 wordAtPosElm = 0;
145 } 145 }
146 146
147 wordPos++; 147 wordPos++;
148 return splitDone[wordAtLine].elm[wordAtPosElm].str; 148 return splitDone[wordAtLine].elm[wordAtPosElm].str;
149} 149}
150 150
151bool TextParser::hasNextWord() 151bool TextParser::hasNextWord()
152{ 152{
153 return ((wordPos + 1) < totalElmCount); 153 return ((wordPos + 1) < totalElmCount);
154} 154}
155 155
156QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) 156QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false)
157{ 157{
158 QString returnStr = wordAt(*pos); 158 QString returnStr = wordAt(*pos);
159 QChar chr = separatorAt(*pos); 159 QChar chr = separatorAt(*pos);
160 QString s; 160 QString s;
161 161
162 if (returnStr == "") 162 if (returnStr == "")
163 return ""; 163 return "";
164 if (chr == stop) 164 if (chr == stop)
165 return returnStr; 165 return returnStr;
166 166
167 if (!lineEnd) { 167 if (!lineEnd) {
168 while ((chr != stop) && hasNextWord()) { 168 while ((chr != stop) && hasNextWord()) {
169 returnStr.append(chr); 169 returnStr.append(chr);
170 returnStr += nextWord(); 170 returnStr += nextWord();
171 chr = nextSeparator(); 171 chr = nextSeparator();
172 } 172 }
173 } else { //copy from pos to end of line 173 } else { //copy from pos to end of line
174 getLineReference(*pos, &atLine, &atPosElm); 174 getLineReference(*pos, &atLine, &atPosElm);
175 returnStr = ""; 175 returnStr = "";
176 while (atPosElm < splitDone[atLine].elmCount) { 176 while (atPosElm < splitDone[atLine].elmCount) {
177 if (splitDone[atLine].elm[atPosElm].str != "") { 177 if (splitDone[atLine].elm[atPosElm].str != "") {
178 returnStr += splitDone[atLine].elm[atPosElm].str; 178 returnStr += splitDone[atLine].elm[atPosElm].str;
179 } 179 }
180 chr = splitDone[atLine].elm[atPosElm].separator; 180 chr = splitDone[atLine].elm[atPosElm].separator;
181 if (!chr.isNull() && (int) chr != 0) { 181 if (!chr.isNull() && (int) chr != 0) {
182 returnStr.append(splitDone[atLine].elm[atPosElm].separator); 182 returnStr.append(splitDone[atLine].elm[atPosElm].separator);
183 } 183 }
184 atPosElm++; 184 atPosElm++;
185 } 185 }
186 } 186 }
187 187
188 *pos = wordPos; 188 *pos = wordPos;
189 return returnStr; 189 return returnStr;
190} 190}
191 191
192QString TextParser::getNextLine() 192QString TextParser::getNextLine()
193{ 193{
194 atLine++; 194 atLine++;
195 atPosElm = 0; 195 atPosElm = 0;
196 if (atLine < lineCount) 196 if (atLine < lineCount)
197 return splitDone[atLine].str; 197 return splitDone[atLine].str;
198 return ""; 198 return "";
199} 199}
200 200
201bool TextParser::hasNextLine() 201bool TextParser::hasNextLine()
202{ 202{
203 if (atLine+1 < lineCount) 203 if (atLine+1 < lineCount)
204 return TRUE;; 204 return TRUE;;
205 return FALSE; 205 return FALSE;
206} 206}
207 207
208int TextParser::endLinePos(int pos) 208int TextParser::endLinePos(int pos)
209{ 209{
210 if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) 210 if ( (getLineReference(pos, &atLine, &atPosElm)) == -1)
211 return -1; 211 return -1;
212 212
213 return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); 213 return (pos + (splitDone[atLine].elmCount - atPosElm) + 1);
214} 214}
215 215
216int TextParser::getLineReference(int pos, int *line, int *inLinePos) 216int TextParser::getLineReference(int pos, int *line, int *inLinePos)
217{ 217{
218 int currentPos = 0; 218 int currentPos = 0;
219 219
220 for (int x = 0; x < lineCount; x++) { 220 for (int x = 0; x < lineCount; x++) {
221 if ( currentPos + splitDone[x].elmCount > pos) { 221 if ( currentPos + splitDone[x].elmCount > pos) {
222 *line = x; 222 *line = x;
223 *inLinePos = pos - currentPos; 223 *inLinePos = pos - currentPos;
224 return 0; //pos found okay 224 return 0; //pos found okay
225 } 225 }
226 currentPos += splitDone[x].elmCount; 226 currentPos += splitDone[x].elmCount;
227 } 227 }
228 return -1; //no reference found 228 return -1; //no reference found
229} 229}
230 230
231void TextParser::split() 231void TextParser::split()
232{ 232{
233 t_splitLine newLine; 233 t_splitLine newLine;
234 234
235 while ((uint) linePos < data.length()) { 235 while ((uint) linePos < data.length()) {
236 newLine = nextLine(); 236 newLine = nextLine();
237 splitDone[lineCount] = splitLine(newLine); 237 splitDone[lineCount] = splitLine(newLine);
238 totalElmCount += splitDone[lineCount].elmCount; 238 totalElmCount += splitDone[lineCount].elmCount;
239 lineCount++; 239 lineCount++;
240 } 240 }
241} 241}
242 242
243t_splitLine TextParser::splitLine(t_splitLine line) 243t_splitLine TextParser::splitLine(t_splitLine line)
244{ 244{
245 uint pos = 0; 245 uint pos = 0;
246 uint elmCount = 0; 246 uint elmCount = 0;
247 t_splitLine tempLine = line; 247 t_splitLine tempLine = line;
248 248
249 tempLine.str = line.str.simplifyWhiteSpace(); 249 tempLine.str = line.str.simplifyWhiteSpace();
250 tempLine.elm[0].str = ""; 250 tempLine.elm[0].str = "";
251 while ( pos < line.str.length() ) { 251 while ( pos < line.str.length() ) {
252 if ( isSeparator(tempLine.str[pos]) ) { 252 if ( isSeparator(tempLine.str[pos]) ) {
253 tempLine.elm[elmCount].separator = tempLine.str[pos]; 253 tempLine.elm[elmCount].separator = tempLine.str[pos];
254 elmCount++; 254 elmCount++;
255 pos++; 255 pos++;
256 while (tempLine.str[pos] == ' ') 256 while (tempLine.str[pos] == ' ')
257 pos++; 257 pos++;
258 if (pos > line.str.length()) 258 if (pos > line.str.length())
259 elmCount--; 259 elmCount--;
260 tempLine.elm[elmCount].str = ""; 260 tempLine.elm[elmCount].str = "";
261 } else { 261 } else {
262 if (!tempLine.str[pos].isNull()) 262 if (!tempLine.str[pos].isNull())
263 tempLine.elm[elmCount].str += tempLine.str[pos]; 263 tempLine.elm[elmCount].str += tempLine.str[pos];
264 pos++; 264 pos++;
265 } 265 }
266 } 266 }
267 267
268 tempLine.elmCount = elmCount + 1; 268 tempLine.elmCount = elmCount + 1;
269 return tempLine; 269 return tempLine;
270} 270}
271 271
272bool TextParser::isSeparator(QChar chr) 272bool TextParser::isSeparator(QChar chr)
273{ 273{
274 for (uint x = 0; x < separators.length(); x++) { 274 for (uint x = 0; x < separators.length(); x++) {
275 if (chr == separators[x]) 275 if (chr == separators[x])
276 return true; 276 return true;
277 } 277 }
278 return false; 278 return false;
279} 279}
280 280
281t_splitLine TextParser::nextLine() 281t_splitLine TextParser::nextLine()
282{ 282{
283 int newLinePos; 283 int newLinePos;
284 t_splitLine lineType; 284 t_splitLine lineType;
285 285
286 newLinePos = data.find(lineSep, linePos); 286 newLinePos = data.find(lineSep, linePos);
287 287
288 lineType.lineType = NewLine; 288 lineType.lineType = NewLine;
289 lineType.str = ""; 289 lineType.str = "";
290 290
291 if (newLinePos == -1) { 291 if (newLinePos == -1) {
292 newLinePos = data.length(); 292 newLinePos = data.length();
293 lineType.lineType = LastLine; 293 lineType.lineType = LastLine;
294 } 294 }
295 295
296 for (int x = linePos; x < newLinePos; x++) 296 for (int x = linePos; x < newLinePos; x++)
297 lineType.str += data[x]; 297 lineType.str += data[x];
298 298
299 linePos = newLinePos; 299 linePos = newLinePos;
300 if ((uint) linePos < data.length()) //if not EOF, add length of lineSep 300 if ((uint) linePos < data.length()) //if not EOF, add length of lineSep
301 linePos += lineSep.length(); 301 linePos += lineSep.length();
302 302
303 return lineType; 303 return lineType;
304} 304}
diff --git a/noncore/unsupported/mailit/textparser.h b/noncore/unsupported/mailit/textparser.h
index c5e88a0..03bb6d5 100644
--- a/noncore/unsupported/mailit/textparser.h
+++ b/noncore/unsupported/mailit/textparser.h
@@ -40,27 +40,27 @@ struct t_splitLine
40{ 40{
41 t_lineType lineType; 41 t_lineType lineType;
42 QString str; //a bit redundant... 42 QString str; //a bit redundant...
43 t_splitElm elm[MAX_ELEMENTS]; 43 t_splitElm elm[MAX_ELEMENTS];
44 int elmCount; 44 int elmCount;
45}; 45};
46 46
47class TextParser: public QObject 47class TextParser: public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 TextParser(QString in, QString lineBreak); 52 TextParser(const QString &in, const QString &lineBreak);
53 TextParser(QString in, QString lineBreak, QString sep); 53 TextParser(const QString &in, const QString &lineBreak, const QString &sep);
54 int find(QString target, QChar sep, int pos, bool upperCase); 54 int find(const QString &target, QChar sep, int pos, bool upperCase);
55 int elmCount(); 55 int elmCount();
56 QChar separatorAt(int pos); 56 QChar separatorAt(int pos);
57 QChar nextSeparator(); 57 QChar nextSeparator();
58 bool hasNextSeparator(); 58 bool hasNextSeparator();
59 QString wordAt(int pos); 59 QString wordAt(int pos);
60 QString nextWord(); 60 QString nextWord();
61 bool hasNextWord(); 61 bool hasNextWord();
62 QString getString(int *pos, QChar stop, bool lineEnd); 62 QString getString(int *pos, QChar stop, bool lineEnd);
63 QString getNextLine(); 63 QString getNextLine();
64 bool hasNextLine(); 64 bool hasNextLine();
65 int endLinePos(int pos); 65 int endLinePos(int pos);
66 66