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 | |||
@@ -26,136 +26,136 @@ | |||
26 | 26 | ||
27 | AddressList::AddressList() | 27 | AddressList::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 | ||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void 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 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(const QString &email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(const QString &name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString 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 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString 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 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int 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 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int 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 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void 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 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString 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 | |||
@@ -25,34 +25,34 @@ | |||
25 | 25 | ||
26 | struct Contact | 26 | struct Contact |
27 | { | 27 | { |
28 | QString email; | 28 | QString email; |
29 | QString name; | 29 | QString name; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | class AddressList : public QObject | 32 | class AddressList : public QObject |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | public: | 36 | public: |
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 | ||
46 | private: | 46 | private: |
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 | ||
52 | private: | 52 | private: |
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 | |||
@@ -365,7 +365,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
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) |
@@ -461,17 +461,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
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 | ||
@@ -642,7 +643,7 @@ void EmailClient::readMail() | |||
642 | } | 643 | } |
643 | } | 644 | } |
644 | 645 | ||
645 | void EmailClient::saveMail(QString fileName, QListView *view) | 646 | void EmailClient::saveMail(const QString &fileName, QListView *view) |
646 | { | 647 | { |
647 | QFile f(fileName); | 648 | QFile f(fileName); |
648 | Email *mail; | 649 | Email *mail; |
@@ -712,7 +713,7 @@ void EmailClient::readSettings() | |||
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); |
@@ -915,32 +916,32 @@ void EmailClient::setDownloadedSize(int size) | |||
915 | 916 | ||
916 | void EmailClient::deleteItem() | 917 | void 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 | ||
936 | void EmailClient::inboxItemPressed() | 937 | void EmailClient::inboxItemPressed() |
937 | { | 938 | { |
938 | //timerID=startTimer(500); | 939 | // timerID=startTimer(500); |
939 | } | 940 | } |
940 | 941 | ||
941 | void EmailClient::inboxItemReleased() | 942 | void 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) |
@@ -965,72 +966,72 @@ void EmailClient::inboxItemReleased() | |||
965 | 966 | ||
966 | Email* EmailClient::getCurrentMail() | 967 | Email* 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 | ||
975 | void EmailClient::download(Email* mail) | 976 | void 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 | ||
993 | void EmailClient::receive(const QCString& msg, const QByteArray& data) | 994 | void 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 | |||
@@ -106,7 +106,7 @@ public slots: | |||
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(); |
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 | |||
@@ -39,7 +39,7 @@ Enclosure* EnclosureList::dupl(Enclosure *in) | |||
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::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(); |
@@ -148,7 +148,7 @@ void EmailHandler::messageArrived(const QString &message, int id, uint size, boo | |||
148 | emit mailArrived(mail, FALSE); | 148 | emit mailArrived(mail, FALSE); |
149 | } | 149 | } |
150 | 150 | ||
151 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 151 | bool 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; |
@@ -204,21 +204,21 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
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) { |
@@ -440,8 +440,8 @@ int EmailHandler::encodeMime(Email *mail) | |||
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: "; |
@@ -510,7 +510,7 @@ int EmailHandler::encodeMime(Email *mail) | |||
510 | return 0; | 510 | return 0; |
511 | } | 511 | } |
512 | 512 | ||
513 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 513 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) |
514 | { | 514 | { |
515 | char *fileData; | 515 | char *fileData; |
516 | char *dataPtr; | 516 | char *dataPtr; |
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 | |||
@@ -37,114 +37,114 @@ | |||
37 | 37 | ||
38 | struct Enclosure | 38 | struct 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 | ||
51 | class EnclosureList : public QList<Enclosure> | 51 | class EnclosureList : public QList<Enclosure> |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Item newItem(Item d); | 54 | Item newItem(Item d); |
55 | private: | 55 | private: |
56 | Enclosure* dupl(Enclosure *in); | 56 | Enclosure* dupl(Enclosure *in); |
57 | Enclosure *ac; | 57 | Enclosure *ac; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | struct Email | 60 | struct 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 | ||
88 | struct MailAccount | 88 | struct 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 | ||
108 | class EmailHandler : public QObject | 108 | class EmailHandler : public QObject |
109 | { | 109 | { |
110 | Q_OBJECT | 110 | Q_OBJECT |
111 | 111 | ||
112 | public: | 112 | public: |
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 | ||
128 | signals: | 128 | signals: |
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 | ||
140 | public slots: | 140 | public 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 | ||
143 | private: | 143 | private: |
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 | |||
@@ -22,77 +22,77 @@ | |||
22 | #include "emaillistitem.h" | 22 | #include "emaillistitem.h" |
23 | 23 | ||
24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | 24 | EmailListItem::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 | ||
51 | Email* EmailListItem::getMail() | 51 | Email* EmailListItem::getMail() |
52 | { | 52 | { |
53 | return &mail; | 53 | return &mail; |
54 | } | 54 | } |
55 | 55 | ||
56 | void EmailListItem::setMail(Email newMail) | 56 | void EmailListItem::setMail(Email newMail) |
57 | { | 57 | { |
58 | mail = newMail; | 58 | mail = newMail; |
59 | repaint(); | 59 | repaint(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void EmailListItem::setItemSelected(bool enable) | 62 | void 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 | ||
69 | bool EmailListItem::isItemSelected() | 69 | bool EmailListItem::isItemSelected() |
70 | { | 70 | { |
71 | return selected; | 71 | return selected; |
72 | } | 72 | } |
73 | 73 | ||
74 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | 74 | void 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 ); |
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 | |||
@@ -50,7 +50,7 @@ PopClient::~PopClient() | |||
50 | delete stream; | 50 | delete stream; |
51 | } | 51 | } |
52 | 52 | ||
53 | void PopClient::newConnection(QString target, int port) | 53 | void 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"); |
@@ -66,7 +66,7 @@ void PopClient::newConnection(QString target, int port) | |||
66 | emit updateStatus("DNS lookup"); | 66 | emit updateStatus("DNS lookup"); |
67 | } | 67 | } |
68 | 68 | ||
69 | void PopClient::setAccount(QString popUser, QString popPasswd) | 69 | void PopClient::setAccount(const QString &popUser, const QString &popPasswd) |
70 | { | 70 | { |
71 | popUserName = popUser; | 71 | popUserName = popUser; |
72 | popPassword = popPasswd; | 72 | popPassword = popPasswd; |
@@ -158,15 +158,15 @@ void PopClient::incomingData() | |||
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 | } |
@@ -182,18 +182,18 @@ void PopClient::incomingData() | |||
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 | } |
@@ -242,10 +242,10 @@ void PopClient::incomingData() | |||
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; |
@@ -276,23 +276,23 @@ void PopClient::incomingData() | |||
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); |
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 | |||
@@ -35,8 +35,8 @@ class PopClient: public QObject | |||
35 | public: | 35 | public: |
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); |
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 | |||
@@ -39,7 +39,7 @@ SmtpClient::~SmtpClient() | |||
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void 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"); |
@@ -53,7 +53,7 @@ void SmtpClient::newConnection(QString target, int port) | |||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void 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 | ||
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 | |||
@@ -30,46 +30,46 @@ | |||
30 | 30 | ||
31 | struct RawEmail | 31 | struct 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 | ||
39 | class SmtpClient: public QObject | 39 | class SmtpClient: public QObject |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
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 | ||
49 | signals: | 49 | signals: |
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 | ||
54 | public slots: | 54 | public slots: |
55 | void errorHandling(int); | 55 | void errorHandling(int); |
56 | 56 | ||
57 | protected slots: | 57 | protected slots: |
58 | void connectionEstablished(); | 58 | void connectionEstablished(); |
59 | void incomingData(); | 59 | void incomingData(); |
60 | 60 | ||
61 | private: | 61 | private: |
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 | |||
@@ -19,286 +19,286 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "textparser.h" | 20 | #include "textparser.h" |
21 | 21 | ||
22 | TextParser::TextParser(QString in, QString lineBreak) | 22 | TextParser::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 | ||
32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) | 32 | TextParser::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 | ||
42 | void TextParser::init() | 42 | void 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 | ||
57 | void TextParser::createSeparators() | 57 | void 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 */ |
63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) | 63 | int 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 | ||
99 | int TextParser::elmCount() | 99 | int TextParser::elmCount() |
100 | { | 100 | { |
101 | return totalElmCount; | 101 | return totalElmCount; |
102 | } | 102 | } |
103 | 103 | ||
104 | QChar TextParser::separatorAt(int pos) | 104 | QChar 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 | ||
113 | QChar TextParser::nextSeparator() | 113 | QChar 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 | ||
125 | bool TextParser::hasNextSeparator() | 125 | bool TextParser::hasNextSeparator() |
126 | { | 126 | { |
127 | return ((separatorPos+1) < totalElmCount); | 127 | return ((separatorPos+1) < totalElmCount); |
128 | } | 128 | } |
129 | 129 | ||
130 | QString TextParser::wordAt(int pos) | 130 | QString 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 | ||
139 | QString TextParser::nextWord() | 139 | QString 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 | ||
151 | bool TextParser::hasNextWord() | 151 | bool TextParser::hasNextWord() |
152 | { | 152 | { |
153 | return ((wordPos + 1) < totalElmCount); | 153 | return ((wordPos + 1) < totalElmCount); |
154 | } | 154 | } |
155 | 155 | ||
156 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) | 156 | QString 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 | ||
192 | QString TextParser::getNextLine() | 192 | QString 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 | ||
201 | bool TextParser::hasNextLine() | 201 | bool 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 | ||
208 | int TextParser::endLinePos(int pos) | 208 | int 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 | ||
216 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) | 216 | int 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 | ||
231 | void TextParser::split() | 231 | void 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 | ||
243 | t_splitLine TextParser::splitLine(t_splitLine line) | 243 | t_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 | ||
272 | bool TextParser::isSeparator(QChar chr) | 272 | bool 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 | ||
281 | t_splitLine TextParser::nextLine() | 281 | t_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 | |||
@@ -49,9 +49,9 @@ class TextParser: public QObject | |||
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
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(); |
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 | |||
@@ -26,136 +26,136 @@ | |||
26 | 26 | ||
27 | AddressList::AddressList() | 27 | AddressList::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 | ||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void 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 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(const QString &email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(const QString &name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString 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 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString 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 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int 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 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int 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 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void 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 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString 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 | |||
@@ -25,34 +25,34 @@ | |||
25 | 25 | ||
26 | struct Contact | 26 | struct Contact |
27 | { | 27 | { |
28 | QString email; | 28 | QString email; |
29 | QString name; | 29 | QString name; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | class AddressList : public QObject | 32 | class AddressList : public QObject |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | public: | 36 | public: |
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 | ||
46 | private: | 46 | private: |
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 | ||
52 | private: | 52 | private: |
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 | |||
@@ -365,7 +365,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
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) |
@@ -461,17 +461,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) | |||
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 | ||
@@ -642,7 +643,7 @@ void EmailClient::readMail() | |||
642 | } | 643 | } |
643 | } | 644 | } |
644 | 645 | ||
645 | void EmailClient::saveMail(QString fileName, QListView *view) | 646 | void EmailClient::saveMail(const QString &fileName, QListView *view) |
646 | { | 647 | { |
647 | QFile f(fileName); | 648 | QFile f(fileName); |
648 | Email *mail; | 649 | Email *mail; |
@@ -712,7 +713,7 @@ void EmailClient::readSettings() | |||
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); |
@@ -915,32 +916,32 @@ void EmailClient::setDownloadedSize(int size) | |||
915 | 916 | ||
916 | void EmailClient::deleteItem() | 917 | void 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 | ||
936 | void EmailClient::inboxItemPressed() | 937 | void EmailClient::inboxItemPressed() |
937 | { | 938 | { |
938 | //timerID=startTimer(500); | 939 | // timerID=startTimer(500); |
939 | } | 940 | } |
940 | 941 | ||
941 | void EmailClient::inboxItemReleased() | 942 | void 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) |
@@ -965,72 +966,72 @@ void EmailClient::inboxItemReleased() | |||
965 | 966 | ||
966 | Email* EmailClient::getCurrentMail() | 967 | Email* 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 | ||
975 | void EmailClient::download(Email* mail) | 976 | void 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 | ||
993 | void EmailClient::receive(const QCString& msg, const QByteArray& data) | 994 | void 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 | |||
@@ -106,7 +106,7 @@ public slots: | |||
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(); |
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 | |||
@@ -39,7 +39,7 @@ Enclosure* EnclosureList::dupl(Enclosure *in) | |||
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::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(); |
@@ -148,7 +148,7 @@ void EmailHandler::messageArrived(const QString &message, int id, uint size, boo | |||
148 | emit mailArrived(mail, FALSE); | 148 | emit mailArrived(mail, FALSE); |
149 | } | 149 | } |
150 | 150 | ||
151 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 151 | bool 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; |
@@ -204,21 +204,21 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
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) { |
@@ -440,8 +440,8 @@ int EmailHandler::encodeMime(Email *mail) | |||
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: "; |
@@ -510,7 +510,7 @@ int EmailHandler::encodeMime(Email *mail) | |||
510 | return 0; | 510 | return 0; |
511 | } | 511 | } |
512 | 512 | ||
513 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 513 | int EmailHandler::encodeFile(const QString &fileName, QString *toBody) |
514 | { | 514 | { |
515 | char *fileData; | 515 | char *fileData; |
516 | char *dataPtr; | 516 | char *dataPtr; |
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 | |||
@@ -37,114 +37,114 @@ | |||
37 | 37 | ||
38 | struct Enclosure | 38 | struct 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 | ||
51 | class EnclosureList : public QList<Enclosure> | 51 | class EnclosureList : public QList<Enclosure> |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Item newItem(Item d); | 54 | Item newItem(Item d); |
55 | private: | 55 | private: |
56 | Enclosure* dupl(Enclosure *in); | 56 | Enclosure* dupl(Enclosure *in); |
57 | Enclosure *ac; | 57 | Enclosure *ac; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | struct Email | 60 | struct 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 | ||
88 | struct MailAccount | 88 | struct 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 | ||
108 | class EmailHandler : public QObject | 108 | class EmailHandler : public QObject |
109 | { | 109 | { |
110 | Q_OBJECT | 110 | Q_OBJECT |
111 | 111 | ||
112 | public: | 112 | public: |
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 | ||
128 | signals: | 128 | signals: |
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 | ||
140 | public slots: | 140 | public 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 | ||
143 | private: | 143 | private: |
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 | |||
@@ -22,77 +22,77 @@ | |||
22 | #include "emaillistitem.h" | 22 | #include "emaillistitem.h" |
23 | 23 | ||
24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | 24 | EmailListItem::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 | ||
51 | Email* EmailListItem::getMail() | 51 | Email* EmailListItem::getMail() |
52 | { | 52 | { |
53 | return &mail; | 53 | return &mail; |
54 | } | 54 | } |
55 | 55 | ||
56 | void EmailListItem::setMail(Email newMail) | 56 | void EmailListItem::setMail(Email newMail) |
57 | { | 57 | { |
58 | mail = newMail; | 58 | mail = newMail; |
59 | repaint(); | 59 | repaint(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void EmailListItem::setItemSelected(bool enable) | 62 | void 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 | ||
69 | bool EmailListItem::isItemSelected() | 69 | bool EmailListItem::isItemSelected() |
70 | { | 70 | { |
71 | return selected; | 71 | return selected; |
72 | } | 72 | } |
73 | 73 | ||
74 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | 74 | void 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 ); |
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 | |||
@@ -50,7 +50,7 @@ PopClient::~PopClient() | |||
50 | delete stream; | 50 | delete stream; |
51 | } | 51 | } |
52 | 52 | ||
53 | void PopClient::newConnection(QString target, int port) | 53 | void 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"); |
@@ -66,7 +66,7 @@ void PopClient::newConnection(QString target, int port) | |||
66 | emit updateStatus("DNS lookup"); | 66 | emit updateStatus("DNS lookup"); |
67 | } | 67 | } |
68 | 68 | ||
69 | void PopClient::setAccount(QString popUser, QString popPasswd) | 69 | void PopClient::setAccount(const QString &popUser, const QString &popPasswd) |
70 | { | 70 | { |
71 | popUserName = popUser; | 71 | popUserName = popUser; |
72 | popPassword = popPasswd; | 72 | popPassword = popPasswd; |
@@ -158,15 +158,15 @@ void PopClient::incomingData() | |||
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 | } |
@@ -182,18 +182,18 @@ void PopClient::incomingData() | |||
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 | } |
@@ -242,10 +242,10 @@ void PopClient::incomingData() | |||
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; |
@@ -276,23 +276,23 @@ void PopClient::incomingData() | |||
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); |
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 | |||
@@ -35,8 +35,8 @@ class PopClient: public QObject | |||
35 | public: | 35 | public: |
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); |
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 | |||
@@ -39,7 +39,7 @@ SmtpClient::~SmtpClient() | |||
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void 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"); |
@@ -53,7 +53,7 @@ void SmtpClient::newConnection(QString target, int port) | |||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void 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 | ||
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 | |||
@@ -30,46 +30,46 @@ | |||
30 | 30 | ||
31 | struct RawEmail | 31 | struct 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 | ||
39 | class SmtpClient: public QObject | 39 | class SmtpClient: public QObject |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
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 | ||
49 | signals: | 49 | signals: |
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 | ||
54 | public slots: | 54 | public slots: |
55 | void errorHandling(int); | 55 | void errorHandling(int); |
56 | 56 | ||
57 | protected slots: | 57 | protected slots: |
58 | void connectionEstablished(); | 58 | void connectionEstablished(); |
59 | void incomingData(); | 59 | void incomingData(); |
60 | 60 | ||
61 | private: | 61 | private: |
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 | |||
@@ -19,286 +19,286 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "textparser.h" | 20 | #include "textparser.h" |
21 | 21 | ||
22 | TextParser::TextParser(QString in, QString lineBreak) | 22 | TextParser::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 | ||
32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) | 32 | TextParser::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 | ||
42 | void TextParser::init() | 42 | void 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 | ||
57 | void TextParser::createSeparators() | 57 | void 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 */ |
63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) | 63 | int 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 | ||
99 | int TextParser::elmCount() | 99 | int TextParser::elmCount() |
100 | { | 100 | { |
101 | return totalElmCount; | 101 | return totalElmCount; |
102 | } | 102 | } |
103 | 103 | ||
104 | QChar TextParser::separatorAt(int pos) | 104 | QChar 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 | ||
113 | QChar TextParser::nextSeparator() | 113 | QChar 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 | ||
125 | bool TextParser::hasNextSeparator() | 125 | bool TextParser::hasNextSeparator() |
126 | { | 126 | { |
127 | return ((separatorPos+1) < totalElmCount); | 127 | return ((separatorPos+1) < totalElmCount); |
128 | } | 128 | } |
129 | 129 | ||
130 | QString TextParser::wordAt(int pos) | 130 | QString 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 | ||
139 | QString TextParser::nextWord() | 139 | QString 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 | ||
151 | bool TextParser::hasNextWord() | 151 | bool TextParser::hasNextWord() |
152 | { | 152 | { |
153 | return ((wordPos + 1) < totalElmCount); | 153 | return ((wordPos + 1) < totalElmCount); |
154 | } | 154 | } |
155 | 155 | ||
156 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) | 156 | QString 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 | ||
192 | QString TextParser::getNextLine() | 192 | QString 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 | ||
201 | bool TextParser::hasNextLine() | 201 | bool 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 | ||
208 | int TextParser::endLinePos(int pos) | 208 | int 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 | ||
216 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) | 216 | int 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 | ||
231 | void TextParser::split() | 231 | void 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 | ||
243 | t_splitLine TextParser::splitLine(t_splitLine line) | 243 | t_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 | ||
272 | bool TextParser::isSeparator(QChar chr) | 272 | bool 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 | ||
281 | t_splitLine TextParser::nextLine() | 281 | t_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 | |||
@@ -49,9 +49,9 @@ class TextParser: public QObject | |||
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
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(); |