summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/addatt.cpp4
-rw-r--r--noncore/net/mailit/emailclient.cpp73
-rw-r--r--noncore/net/mailit/emailclient.h4
-rw-r--r--noncore/net/mailit/emailhandler.cpp10
-rw-r--r--noncore/net/mailit/emailhandler.h4
-rw-r--r--noncore/net/mailit/mailit.pro1
-rw-r--r--noncore/net/mailit/mailitwindow.cpp4
-rw-r--r--noncore/net/mailit/maillist.cpp160
-rw-r--r--noncore/net/mailit/popclient.cpp16
-rw-r--r--noncore/net/mailit/popclient.h3
-rw-r--r--noncore/net/mailit/smtpclient.cpp35
-rw-r--r--noncore/net/mailit/smtpclient.h3
-rw-r--r--noncore/net/mailit/viewatt.cpp14
-rw-r--r--noncore/net/mailit/writemail.cpp598
-rw-r--r--noncore/unsupported/mailit/addatt.cpp4
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp73
-rw-r--r--noncore/unsupported/mailit/emailclient.h4
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp10
-rw-r--r--noncore/unsupported/mailit/emailhandler.h4
-rw-r--r--noncore/unsupported/mailit/mailit.pro1
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp4
-rw-r--r--noncore/unsupported/mailit/maillist.cpp160
-rw-r--r--noncore/unsupported/mailit/popclient.cpp16
-rw-r--r--noncore/unsupported/mailit/popclient.h3
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp35
-rw-r--r--noncore/unsupported/mailit/smtpclient.h3
-rw-r--r--noncore/unsupported/mailit/viewatt.cpp14
-rw-r--r--noncore/unsupported/mailit/writemail.cpp598
28 files changed, 948 insertions, 910 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp
index daefac6..19ac58f 100644
--- a/noncore/net/mailit/addatt.cpp
+++ b/noncore/net/mailit/addatt.cpp
@@ -1,224 +1,224 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qhbox.h> 21#include <qhbox.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include "addatt.h" 25#include "addatt.h"
26 26
27FileItem::FileItem(QListView *parent, DocLnk* dl) 27FileItem::FileItem(QListView *parent, DocLnk* dl)
28 : QListViewItem(parent) 28 : QListViewItem(parent)
29{ 29{
30 /*file = fileInfo; 30 /*file = fileInfo;
31 type = fileType;*/ 31 type = fileType;*/
32 32
33 doclnk=dl; 33 doclnk=dl;
34 34
35 setText(0, doclnk->name()); 35 setText(0, doclnk->name());
36 36
37 /*if (fileType == "Picture") { 37 /*if (fileType == "Picture") {
38 setPixmap(0, Resource::loadPixmap("pixmap")); 38 setPixmap(0, Resource::loadPixmap("pixmap"));
39 } else if (fileType == "Document") { 39 } else if (fileType == "Document") {
40 setPixmap(0, Resource::loadPixmap("txt")); 40 setPixmap(0, Resource::loadPixmap("txt"));
41 } else if (fileType == "Sound") { 41 } else if (fileType == "Sound") {
42 setPixmap(0, Resource::loadPixmap("play")); 42 setPixmap(0, Resource::loadPixmap("play"));
43 } else if (fileType == "Movie") { 43 } else if (fileType == "Movie") {
44 setPixmap(0, Resource::loadPixmap("MPEGPlayer")); 44 setPixmap(0, Resource::loadPixmap("MPEGPlayer"));
45 } else if (fileType == "File") { 45 } else if (fileType == "File") {
46 setPixmap(0, Resource::loadPixmap("exec")); 46 setPixmap(0, Resource::loadPixmap("exec"));
47 }*/ 47 }*/
48} 48}
49 49
50FileItem::~FileItem() 50FileItem::~FileItem()
51{ 51{
52 if (doclnk!=NULL) delete doclnk; 52 if (doclnk!=NULL) delete doclnk;
53 doclnk=NULL; 53 doclnk=NULL;
54} 54}
55 55
56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) 56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
57 : QDialog(parent, name, f) 57 : QDialog(parent, name, f)
58{ 58{
59 setCaption("Adding attachments"); 59 setCaption(tr("Adding attachments") );
60 60
61 QGridLayout *top = new QGridLayout(this, 1,1 ); 61 QGridLayout *top = new QGridLayout(this, 1,1 );
62 62
63 QHBox *buttons=new QHBox(this); 63 QHBox *buttons=new QHBox(this);
64 /*fileCategoryButton = new QPushButton(this);*/ 64 /*fileCategoryButton = new QPushButton(this);*/
65 attachButton = new QPushButton(tr("attach..."), buttons); 65 attachButton = new QPushButton(tr("attach..."), buttons);
66 removeButton = new QPushButton(tr("Remove"), buttons); 66 removeButton = new QPushButton(tr("Remove"), buttons);
67 67
68 /*fileCategories = new QPopupMenu(fileCategoryButton); 68 /*fileCategories = new QPopupMenu(fileCategoryButton);
69 fileCategoryButton->setPopup(fileCategories); 69 fileCategoryButton->setPopup(fileCategories);
70 fileCategories->insertItem("Document"); 70 fileCategories->insertItem("Document");
71 fileCategories->insertItem("Picture"); 71 fileCategories->insertItem("Picture");
72 fileCategories->insertItem("Sound"); 72 fileCategories->insertItem("Sound");
73 fileCategories->insertItem("Movie"); 73 fileCategories->insertItem("Movie");
74 fileCategories->insertItem("File"); 74 fileCategories->insertItem("File");
75 75
76 fileCategoryButton->setText("Document"); 76 fileCategoryButton->setText("Document");
77 top->addWidget(fileCategoryButton, 0, 0);*/ 77 top->addWidget(fileCategoryButton, 0, 0);*/
78 78
79 79
80 top->addWidget(buttons,1,0); 80 top->addWidget(buttons,1,0);
81 //buttons->addWidget(attachButton,0,0); 81 //buttons->addWidget(attachButton,0,0);
82 //buttons->addWidget(removeButton,0,1); 82 //buttons->addWidget(removeButton,0,1);
83 83
84 //connect(fileCategories, SIGNAL(activated(int)), this, 84 //connect(fileCategories, SIGNAL(activated(int)), this,
85 //SLOT(fileCategorySelected(int)) );*/ 85 //SLOT(fileCategorySelected(int)) );*/
86 connect(attachButton, SIGNAL(clicked()), this, 86 connect(attachButton, SIGNAL(clicked()), this,
87 SLOT(addattachment()) ); 87 SLOT(addattachment()) );
88 connect(removeButton, SIGNAL(clicked()), this, 88 connect(removeButton, SIGNAL(clicked()), this,
89 SLOT(removeattachment()) ); 89 SLOT(removeattachment()) );
90 90
91 /*listView = new QListView(this, "AttView"); 91 /*listView = new QListView(this, "AttView");
92 listView->addColumn("Documents");* 92 listView->addColumn("Documents");*
93 connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, 93 connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this,
94 SLOT(addattachment()) );*/ 94 SLOT(addattachment()) );*/
95 95
96 96
97 attView = new QListView(this, "Selected"); 97 attView = new QListView(this, "Selected");
98 attView->addColumn(tr("Attached")); 98 attView->addColumn(tr("Attached"));
99 attView->addColumn(tr("File type")); 99 attView->addColumn(tr("File type"));
100 connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, 100 connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this,
101 SLOT(removeattachment()) ); 101 SLOT(removeattachment()) );
102 102
103 //top->addWidget(ofs, 0,0); 103 //top->addWidget(ofs, 0,0);
104 top->addWidget(attView, 0,0); 104 top->addWidget(attView, 0,0);
105 105
106 clear(); 106 clear();
107 107
108 108
109} 109}
110 110
111void AddAtt::clear() 111void AddAtt::clear()
112{ 112{
113 attView->clear(); 113 attView->clear();
114 //getFiles(); 114 //getFiles();
115 modified = FALSE; 115 modified = FALSE;
116} 116}
117 117
118/*void AddAtt::fileCategorySelected(int id) 118/*void AddAtt::fileCategorySelected(int id)
119{ 119{
120 fileCategoryButton->setText(fileCategories->text(id)); 120 fileCategoryButton->setText(fileCategories->text(id));
121 getFiles(); 121 getFiles();
122}*/ 122}*/
123 123
124void AddAtt::addattachment() 124void AddAtt::addattachment()
125 { 125 {// ### FIXME wrong use -zecke
126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); 126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
127 127
128 ofs.showMaximized(); 128 ofs.showMaximized();
129 129
130 if (ofs.exec()==QDialog::Accepted) 130 if (ofs.exec()==QDialog::Accepted)
131 { 131 {
132 DocLnk* dl=new DocLnk(ofs.selectedDocument()); 132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
133 FileItem* fi=new FileItem(attView,dl); 133 FileItem* fi=new FileItem(attView,dl);
134 fi->setPixmap(0,dl->pixmap()); 134 fi->setPixmap(0,dl->pixmap());
135 fi->setText(1,dl->type()); 135 fi->setText(1,dl->type());
136 attView->insertItem(fi); 136 attView->insertItem(fi);
137 modified = TRUE; 137 modified = TRUE;
138 } 138 }
139} 139}
140 140
141void AddAtt::removeattachment() 141void AddAtt::removeattachment()
142{ 142{
143 if (attView->selectedItem() != NULL) 143 if (attView->selectedItem() != NULL)
144 { 144 {
145 attView->takeItem(attView->selectedItem()); 145 attView->takeItem(attView->selectedItem());
146 } 146 }
147 modified = TRUE; 147 modified = TRUE;
148} 148}
149 149
150void AddAtt::reject() 150void AddAtt::reject()
151{ 151{
152 if (modified) { 152 if (modified) {
153 attView->clear(); 153 attView->clear();
154 modified = FALSE; 154 modified = FALSE;
155 } 155 }
156} 156}
157 157
158void AddAtt::accept() 158void AddAtt::accept()
159{ 159{
160 modified = FALSE; 160 modified = FALSE;
161 hide(); 161 hide();
162} 162}
163 163
164void AddAtt::getFiles() 164void AddAtt::getFiles()
165{ 165{
166 QString path, selected; 166 QString path, selected;
167 167
168 /*listView->clear(); 168 /*listView->clear();
169 169
170 selected = fileCategoryButton->text(); 170 selected = fileCategoryButton->text();
171 if (selected == "Picture") { 171 if (selected == "Picture") {
172 path = "../pics/"; 172 path = "../pics/";
173 } else if (selected == "Document") { 173 } else if (selected == "Document") {
174 path = "" ; //sub-dirs not decided 174 path = "" ; //sub-dirs not decided
175 } else if (selected == "Sound") { 175 } else if (selected == "Sound") {
176 path = "../sounds/"; //sub-dirs not decided 176 path = "../sounds/"; //sub-dirs not decided
177 } else if (selected == "Movie") { 177 } else if (selected == "Movie") {
178 path = ""; //sub-dirs not decided 178 path = ""; //sub-dirs not decided
179 } else if (selected == "File") { 179 } else if (selected == "File") {
180 path = ""; //sub-dirs not decided 180 path = ""; //sub-dirs not decided
181 } 181 }
182 182
183 dir = new QDir(path); 183 dir = new QDir(path);
184 dir->setFilter(QDir::Files); 184 dir->setFilter(QDir::Files);
185 const QFileInfoList *dirInfoList = dir->entryInfoList(); 185 const QFileInfoList *dirInfoList = dir->entryInfoList();
186 186
187 QFileInfoListIterator it(*dirInfoList); // create list iterator 187 QFileInfoListIterator it(*dirInfoList); // create list iterator
188 188
189 while ( (fi=it.current()) ) { // for each file... 189 while ( (fi=it.current()) ) { // for each file...
190 item = new FileItem(lis+ütView, *fi, selected); 190 item = new FileItem(lis+ütView, *fi, selected);
191 ++it; // goto next list element 191 ++it; // goto next list element
192 }*/ 192 }*/
193} 193}
194 194
195QStringList AddAtt::returnattachedFiles() 195QStringList AddAtt::returnattachedFiles()
196{ 196{
197 QFileInfo info; 197 QFileInfo info;
198 QStringList list; 198 QStringList list;
199 199
200 item = (FileItem *) attView->firstChild(); 200 item = (FileItem *) attView->firstChild();
201 201
202 202
203 while (item != NULL) { 203 while (item != NULL) {
204 DocLnk* dl=item->getDocLnk(); 204 DocLnk* dl=item->getDocLnk();
205 list+=dl->file(); 205 list+=dl->file();
206 /*info = item->getFileInfo(); 206 /*info = item->getFileInfo();
207 list += info.filePath();*/ 207 list += info.filePath();*/
208 item = (FileItem *) item->nextSibling(); 208 item = (FileItem *) item->nextSibling();
209 } 209 }
210 return list; 210 return list;
211} 211}
212 212
213QStringList AddAtt::returnFileTypes() 213QStringList AddAtt::returnFileTypes()
214{ 214{
215 QStringList list; 215 QStringList list;
216 216
217 item = (FileItem *) attView->firstChild(); 217 item = (FileItem *) attView->firstChild();
218 218
219 while (item != NULL) { 219 while (item != NULL) {
220 list += item->getDocLnk()->type(); 220 list += item->getDocLnk()->type();
221 item = (FileItem *) item->nextSibling(); 221 item = (FileItem *) item->nextSibling();
222 } 222 }
223 return list; 223 return list;
224} 224}
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index da1226c..749a4e9 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -1,257 +1,257 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qfile.h> 23#include <qfile.h>
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qmenubar.h> 25#include <qmenubar.h>
26#include <qaction.h> 26#include <qaction.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include "emailclient.h" 29#include "emailclient.h"
30#include "writemail.h" 30#include "writemail.h"
31 31
32QCollection::Item AccountList::newItem(QCollection::Item d) 32QCollection::Item AccountList::newItem(QCollection::Item d)
33{ 33{
34 return dupl( (MailAccount *) d); 34 return dupl( (MailAccount *) d);
35} 35}
36 36
37MailAccount* AccountList::dupl(MailAccount *in) 37MailAccount* AccountList::dupl(MailAccount *in)
38{ 38{
39 ac = new MailAccount(*in); 39 ac = new MailAccount(*in);
40 return ac; 40 return ac;
41} 41}
42 42
43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) 43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
44 : QMainWindow( parent, name, fl ) 44 : QMainWindow( parent, name, fl )
45{ 45{
46 emailHandler = new EmailHandler(); 46 emailHandler = new EmailHandler();
47 addressList = new AddressList(); 47 addressList = new AddressList();
48 48
49 sending = FALSE; 49 sending = FALSE;
50 receiving = FALSE; 50 receiving = FALSE;
51 previewingMail = FALSE; 51 previewingMail = FALSE;
52 mailIdCount = 1; 52 mailIdCount = 1;
53 accountIdCount = 1; 53 accountIdCount = 1;
54 allAccounts = FALSE; 54 allAccounts = FALSE;
55 55
56 init(); 56 init();
57 57
58 58
59 59
60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
61 61
62 connect(emailHandler, SIGNAL(smtpError(int)), this, 62 connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this,
63 SLOT(smtpError(int)) ); 63 SLOT(smtpError(int,const QString &)) );
64 connect(emailHandler, SIGNAL(popError(int)), this, 64 connect(emailHandler, SIGNAL(popError(int,const QString &)), this,
65 SLOT(popError(int)) ); 65 SLOT(popError(int,const QString &)) );
66 66
67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); 67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); 68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
69 69
70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); 70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) );
71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); 71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) );
72 72
73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
74 SLOT(mailArrived(const Email &, bool)) ); 74 SLOT(mailArrived(const Email &, bool)) );
75 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 75 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
76 SLOT(allMailArrived(int)) ); 76 SLOT(allMailArrived(int)) );
77 77
78 mailconf = new Config("mailit"); 78 mailconf = new Config("mailit");
79 //In case Synchronize is not defined in settings.txt 79 //In case Synchronize is not defined in settings.txt
80 80
81 readSettings(); 81 readSettings();
82 82
83 updateAccounts(); 83 updateAccounts();
84 84
85 lineShift = "\n"; 85 lineShift = "\n";
86 readMail(); 86 readMail();
87 lineShift = "\r\n"; 87 lineShift = "\r\n";
88 88
89 mailboxView->setCurrentTab(0); //ensure that inbox has focus 89 mailboxView->setCurrentTab(0); //ensure that inbox has focus
90 90
91 /*channel = new QCopChannel( "QPE/Application/mailit", this ); 91 /*channel = new QCopChannel( "QPE/Application/mailit", this );
92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/ 93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/
94 94
95} 95}
96 96
97 97
98EmailClient::~EmailClient() 98EmailClient::~EmailClient()
99{ 99{
100 //needs to be moved from destructor to closewindow event 100 //needs to be moved from destructor to closewindow event
101 saveMail(getPath(FALSE) + "inbox.txt", inboxView); 101 saveMail(getPath(FALSE) + "inbox.txt", inboxView);
102 //does not currently work. Defining outbox in the same 102 //does not currently work. Defining outbox in the same
103 //format as inbox is not a good solution as they have 103 //format as inbox is not a good solution as they have
104 //different properties 104 //different properties
105 saveMail(getPath(FALSE) + "outbox.txt", outboxView); 105 saveMail(getPath(FALSE) + "outbox.txt", outboxView);
106 saveSettings(); 106 saveSettings();
107 107
108 mailconf->write(); 108 mailconf->write();
109 delete mailconf; 109 delete mailconf;
110 110
111} 111}
112 112
113void EmailClient::init() 113void EmailClient::init()
114{ 114{
115 initStatusBar(this); 115 initStatusBar(this);
116 116
117 setToolBarsMovable(FALSE); 117 setToolBarsMovable(FALSE);
118 118
119 bar = new QToolBar(this); 119 bar = new QToolBar(this);
120 QWhatsThis::add(bar,tr("Main operation toolbar")); 120 QWhatsThis::add(bar,tr("Main operation toolbar"));
121 bar->setHorizontalStretchable( TRUE ); 121 bar->setHorizontalStretchable( TRUE );
122 122
123 mb = new QMenuBar( bar ); 123 mb = new QMenuBar( bar );
124 124
125 QPopupMenu *mail = new QPopupMenu(mb); 125 QPopupMenu *mail = new QPopupMenu(mb);
126 mb->insertItem( tr( "&Mail" ), mail); 126 mb->insertItem( tr( "&Mail" ), mail);
127 127
128 QPopupMenu *configure = new QPopupMenu(mb); 128 QPopupMenu *configure = new QPopupMenu(mb);
129 mb->insertItem( tr( "Accounts" ), configure); 129 mb->insertItem( tr( "Accounts" ), configure);
130 130
131 selectAccountMenu = new QPopupMenu(mb); 131 selectAccountMenu = new QPopupMenu(mb);
132 editAccountMenu = new QPopupMenu(mb); 132 editAccountMenu = new QPopupMenu(mb);
133 deleteAccountMenu = new QPopupMenu(mb); 133 deleteAccountMenu = new QPopupMenu(mb);
134 134
135 mail->insertItem(tr("Get Mail in"), selectAccountMenu); 135 mail->insertItem(tr("Get Mail in"), selectAccountMenu);
136 configure->insertItem(tr("Edit account"), editAccountMenu); 136 configure->insertItem(tr("Edit account"), editAccountMenu);
137 configure->insertItem(tr("Delete account"), deleteAccountMenu); 137 configure->insertItem(tr("Delete account"), deleteAccountMenu);
138 138
139 bar = new QToolBar(this); 139 bar = new QToolBar(this);
140 140
141 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); 141 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar);
142 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); 142 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account."));
143 143
144 getMailButton->setPopup(selectAccountMenu); 144 getMailButton->setPopup(selectAccountMenu);
145 145
146 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); 146 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
147 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); 147 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) );
148 sendMailButton->addTo(bar); 148 sendMailButton->addTo(bar);
149 sendMailButton->addTo(mail); 149 sendMailButton->addTo(mail);
150 sendMailButton->setWhatsThis("Send mail queued in the outbox"); 150 sendMailButton->setWhatsThis("Send mail queued in the outbox");
151 151
152 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 152 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
153 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); 153 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
154 composeButton->addTo(bar); 154 composeButton->addTo(bar);
155 composeButton->addTo(mail); 155 composeButton->addTo(mail);
156 composeButton->setWhatsThis("Compose a new mail"); 156 composeButton->setWhatsThis("Compose a new mail");
157 157
158 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); 158 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
159 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); 159 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
160 cancelButton->addTo(mail); 160 cancelButton->addTo(mail);
161 cancelButton->addTo(bar); 161 cancelButton->addTo(bar);
162 cancelButton->setEnabled(FALSE); 162 cancelButton->setEnabled(FALSE);
163 cancelButton->setWhatsThis("Stop the currently active mail transfer"); 163 cancelButton->setWhatsThis("Stop the currently active mail transfer");
164 164
165 165
166 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); 166 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
167 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); 167 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
168 deleteButton->addTo(bar); 168 deleteButton->addTo(bar);
169 deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); 169 deleteButton->setWhatsThis("Remove the currently selected eMail(s)");
170 170
171 mailboxView = new OTabWidget( this, "mailboxView" ); 171 mailboxView = new OTabWidget( this, "mailboxView" );
172 172
173 QWidget* widget = new QWidget( mailboxView, "widget" ); 173 QWidget* widget = new QWidget( mailboxView, "widget" );
174 grid_2 = new QGridLayout( widget ); 174 grid_2 = new QGridLayout( widget );
175// grid_2->setSpacing(6); 175// grid_2->setSpacing(6);
176// grid_2->setMargin( 11 ); 176// grid_2->setMargin( 11 );
177 177
178 inboxView = new QListView( widget, "inboxView" ); 178 inboxView = new QListView( widget, "inboxView" );
179 inboxView->addColumn( tr( "From" ) ); 179 inboxView->addColumn( tr( "From" ) );
180 inboxView->addColumn( tr( "Subject" ) ); 180 inboxView->addColumn( tr( "Subject" ) );
181 inboxView->addColumn( tr( "Date" ) ); 181 inboxView->addColumn( tr( "Date" ) );
182 inboxView->setMinimumSize( QSize( 0, 0 ) ); 182 inboxView->setMinimumSize( QSize( 0, 0 ) );
183 inboxView->setAllColumnsShowFocus(TRUE); 183 inboxView->setAllColumnsShowFocus(TRUE);
184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" 184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n"
185 "It keeps the fetched mail which can be \n" 185 "It keeps the fetched mail which can be \n"
186 "viewed by double clicking the entry.\n" 186 "viewed by double clicking the entry.\n"
187 "blue attachment icon shows whether this \n" 187 "blue attachment icon shows whether this \n"
188 "mailhas attachments.\n")); 188 "mailhas attachments.\n"));
189 189
190 grid_2->addWidget( inboxView, 2, 0 ); 190 grid_2->addWidget( inboxView, 2, 0 );
191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); 191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
192 192
193 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); 193 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" );
194 grid_3 = new QGridLayout( widget_2 ); 194 grid_3 = new QGridLayout( widget_2 );
195// grid_3->setSpacing(6); 195// grid_3->setSpacing(6);
196// grid_3->setMargin( 11 ); 196// grid_3->setMargin( 11 );
197 197
198 outboxView = new QListView( widget_2, "outboxView" ); 198 outboxView = new QListView( widget_2, "outboxView" );
199 outboxView->addColumn( tr( "To" ) ); 199 outboxView->addColumn( tr( "To" ) );
200 outboxView->addColumn( tr( "Subject" ) ); 200 outboxView->addColumn( tr( "Subject" ) );
201 outboxView->setAllColumnsShowFocus(TRUE); 201 outboxView->setAllColumnsShowFocus(TRUE);
202 202
203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" 203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n"
204 "It keeps the queued mails to send which can be \n" 204 "It keeps the queued mails to send which can be \n"
205 "reviewed by double clicking the entry.")); 205 "reviewed by double clicking the entry."));
206 grid_3->addWidget( outboxView, 0, 0 ); 206 grid_3->addWidget( outboxView, 0, 0 );
207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); 207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
208 208
209 setCentralWidget(mailboxView); 209 setCentralWidget(mailboxView);
210 210
211} 211}
212 212
213void EmailClient::initStatusBar(QWidget* parent) 213void EmailClient::initStatusBar(QWidget* parent)
214{ 214{
215 statusBar = new QStatusBar(parent); 215 statusBar = new QStatusBar(parent);
216 statusBar->setSizeGripEnabled(FALSE); 216 statusBar->setSizeGripEnabled(FALSE);
217 217
218 status1Label = new QLabel( tr("Idle"), statusBar); 218 status1Label = new QLabel( tr("Idle"), statusBar);
219 status2Label = new QLabel("", statusBar); 219 status2Label = new QLabel("", statusBar);
220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), 220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
221 status2Label, SLOT(setText(const QString &)) ); 221 status2Label, SLOT(setText(const QString &)) );
222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), 222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
223 status2Label, SLOT(setText(const QString &)) ); 223 status2Label, SLOT(setText(const QString &)) );
224 224
225 progressBar = new QProgressBar(statusBar); 225 progressBar = new QProgressBar(statusBar);
226 226
227 connect(emailHandler, SIGNAL(mailboxSize(int)), 227 connect(emailHandler, SIGNAL(mailboxSize(int)),
228 this, SLOT(setTotalSize(int)) ); 228 this, SLOT(setTotalSize(int)) );
229 connect(emailHandler, SIGNAL(currentMailSize(int)), 229 connect(emailHandler, SIGNAL(currentMailSize(int)),
230 this, SLOT(setMailSize(int)) ); 230 this, SLOT(setMailSize(int)) );
231 connect(emailHandler, SIGNAL(downloadedSize(int)), 231 connect(emailHandler, SIGNAL(downloadedSize(int)),
232 this, SLOT(setDownloadedSize(int)) ); 232 this, SLOT(setDownloadedSize(int)) );
233 233
234 statusBar->addWidget(status1Label); 234 statusBar->addWidget(status1Label);
235 statusBar->addWidget(progressBar); 235 statusBar->addWidget(progressBar);
236 statusBar->addWidget(status2Label); 236 statusBar->addWidget(status2Label);
237 237
238} 238}
239 239
240void EmailClient::compose() 240void EmailClient::compose()
241{ 241{
242 emit composeRequested(); 242 emit composeRequested();
243} 243}
244 244
245void EmailClient::cancel() 245void EmailClient::cancel()
246{ 246{
247 emailHandler->cancel(); 247 emailHandler->cancel();
248} 248}
249 249
250AddressList* EmailClient::getAdrListRef() 250AddressList* EmailClient::getAdrListRef()
251{ 251{
252 return addressList; 252 return addressList;
253} 253}
254 254
255//this needs to be rewritten to syncronize with outboxView 255//this needs to be rewritten to syncronize with outboxView
256void EmailClient::enqueMail(const Email &mail) 256void EmailClient::enqueMail(const Email &mail)
257{ 257{
@@ -291,747 +291,752 @@ void EmailClient::sendQuedMail()
291 while (item != NULL) { 291 while (item != NULL) {
292 quedMessages.append(item->getMail()); 292 quedMessages.append(item->getMail());
293 item = (EmailListItem *) item->nextSibling(); 293 item = (EmailListItem *) item->nextSibling();
294 count++; 294 count++;
295 } 295 }
296 setMailAccount(); 296 setMailAccount();
297 emailHandler->sendMail(&quedMessages); 297 emailHandler->sendMail(&quedMessages);
298 sending = TRUE; 298 sending = TRUE;
299 sendMailButton->setEnabled(FALSE); 299 sendMailButton->setEnabled(FALSE);
300 cancelButton->setEnabled(TRUE); 300 cancelButton->setEnabled(TRUE);
301 } else { 301 } else {
302 qWarning("sendQuedMail(): no messages to send"); 302 qWarning("sendQuedMail(): no messages to send");
303 } 303 }
304 } 304 }
305} 305}
306 306
307void EmailClient::setMailAccount() 307void EmailClient::setMailAccount()
308{ 308{
309 emailHandler->setAccount(*currentAccount); 309 emailHandler->setAccount(*currentAccount);
310} 310}
311 311
312void EmailClient::mailSent() 312void EmailClient::mailSent()
313{ 313{
314 sending = FALSE; 314 sending = FALSE;
315 sendMailButton->setEnabled(TRUE); 315 sendMailButton->setEnabled(TRUE);
316 316
317 quedMessages.clear(); 317 quedMessages.clear();
318 outboxView->clear(); //should be moved to an sentBox 318 outboxView->clear(); //should be moved to an sentBox
319} 319}
320 320
321void EmailClient::getNewMail() { 321void EmailClient::getNewMail() {
322 322
323 if (accountList.count() == 0) { 323 if (accountList.count() == 0) {
324 QMessageBox::warning(qApp->activeWindow(),"No account selected", 324 QMessageBox::warning(qApp->activeWindow(),"No account selected",
325 "You must create an account", "OK\n"); 325 "You must create an account", "OK\n");
326 return; 326 return;
327 } 327 }
328 328
329 setMailAccount(); 329 setMailAccount();
330 330
331 receiving = TRUE; 331 receiving = TRUE;
332 previewingMail = TRUE; 332 previewingMail = TRUE;
333 getMailButton->setEnabled(FALSE); 333 getMailButton->setEnabled(FALSE);
334 cancelButton->setEnabled(TRUE); 334 cancelButton->setEnabled(TRUE);
335 selectAccountMenu->setEnabled(FALSE); 335 selectAccountMenu->setEnabled(FALSE);
336 336
337 status1Label->setText(currentAccount->accountName + " headers"); 337 status1Label->setText(currentAccount->accountName + " headers");
338 progressBar->reset(); 338 progressBar->reset();
339 339
340 //get any previous mails not downloaded and add to queue 340 //get any previous mails not downloaded and add to queue
341 /*mailDownloadList.clear(); 341 /*mailDownloadList.clear();
342 Email *mailPtr; 342 Email *mailPtr;
343 item = (EmailListItem *) inboxView->firstChild(); 343 item = (EmailListItem *) inboxView->firstChild();
344 while (item != NULL) { 344 while (item != NULL) {
345 mailPtr = item->getMail(); 345 mailPtr = item->getMail();
346 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { 346 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) {
347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); 347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
348 } 348 }
349 item = (EmailListItem *) item->nextSibling(); 349 item = (EmailListItem *) item->nextSibling();
350 }*/ 350 }*/
351 351
352 emailHandler->getMailHeaders(); 352 emailHandler->getMailHeaders();
353 353
354} 354}
355 355
356void EmailClient::getAllNewMail() 356void EmailClient::getAllNewMail()
357{ 357{
358 allAccounts = TRUE; 358 allAccounts = TRUE;
359 currentAccount = accountList.first(); 359 currentAccount = accountList.first();
360 getNewMail(); 360 getNewMail();
361} 361}
362 362
363void EmailClient::mailArrived(const Email &mail, bool fromDisk) 363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
364{ 364{
365 Enclosure *ePtr; 365 Enclosure *ePtr;
366 Email newMail; 366 Email newMail;
367 int thisMailId; 367 int thisMailId;
368 emailHandler->parse( mail.rawMail, lineShift, &newMail); 368 emailHandler->parse( mail.rawMail, lineShift, &newMail);
369 mailconf->setGroup(newMail.id); 369 mailconf->setGroup(newMail.id);
370 370
371 if (fromDisk) 371 if (fromDisk)
372 { 372 {
373 373
374 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
375 newMail.size = mailconf->readNumEntry("size"); 375 newMail.size = mailconf->readNumEntry("size");
376 newMail.serverId = mailconf->readNumEntry("serverid"); 376 newMail.serverId = mailconf->readNumEntry("serverid");
377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
378 } 378 }
379 else 379 else
380 { //mail arrived from server 380 { //mail arrived from server
381 381
382 newMail.serverId = mail.serverId; 382 newMail.serverId = mail.serverId;
383 newMail.size = mail.size; 383 newMail.size = mail.size;
384 newMail.downloaded = mail.downloaded; 384 newMail.downloaded = mail.downloaded;
385 385
386 newMail.fromAccountId = emailHandler->getAccount()->id; 386 newMail.fromAccountId = emailHandler->getAccount()->id;
387 mailconf->writeEntry("fromaccountid", newMail.fromAccountId); 387 mailconf->writeEntry("fromaccountid", newMail.fromAccountId);
388 } 388 }
389 389
390 //add if read or not 390 //add if read or not
391 newMail.read = mailconf->readBoolEntry("mailread"); 391 newMail.read = mailconf->readBoolEntry("mailread");
392 392
393 //check if new mail 393 //check if new mail
394 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { 394 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) {
395 thisMailId = mailIdCount; 395 thisMailId = mailIdCount;
396 mailIdCount++; 396 mailIdCount++;
397 397
398 //set server count, so that if the user aborts, the new 398 //set server count, so that if the user aborts, the new
399 //header is not reloaded 399 //header is not reloaded
400 if ((currentAccount)&&(currentAccount->synchronize)) 400 if ((currentAccount)&&(currentAccount->synchronize))
401 currentAccount->lastServerMailCount++; 401 currentAccount->lastServerMailCount++;
402 402
403 mailconf->writeEntry("internalmailid", thisMailId); 403 mailconf->writeEntry("internalmailid", thisMailId);
404 mailconf->writeEntry("downloaded", newMail.downloaded); 404 mailconf->writeEntry("downloaded", newMail.downloaded);
405 mailconf->writeEntry("size", (int) newMail.size); 405 mailconf->writeEntry("size", (int) newMail.size);
406 mailconf->writeEntry("serverid", newMail.serverId); 406 mailconf->writeEntry("serverid", newMail.serverId);
407 407
408 //addressList->addContact(newMail.fromMail, newMail.from); 408 //addressList->addContact(newMail.fromMail, newMail.from);
409 } 409 }
410 410
411 mailconf->writeEntry("downloaded", newMail.downloaded); 411 mailconf->writeEntry("downloaded", newMail.downloaded);
412 412
413 QString stringMailId; 413 QString stringMailId;
414 stringMailId.setNum(thisMailId); 414 stringMailId.setNum(thisMailId);
415 //see if any attatchments needs to be stored 415 //see if any attatchments needs to be stored
416 416
417 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { 417 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
418 QString stringId; 418 QString stringId;
419 stringId.setNum(ePtr->id); 419 stringId.setNum(ePtr->id);
420 420
421 int id = mailconf->readNumEntry("enclosureid_" + stringId); 421 int id = mailconf->readNumEntry("enclosureid_" + stringId);
422 if (id != ePtr->id) { //new entry 422 if (id != ePtr->id) { //new entry
423 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); 423 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id);
424 mailconf->writeEntry("name_" + stringId, ePtr->originalName); 424 mailconf->writeEntry("name_" + stringId, ePtr->originalName);
425 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); 425 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType);
426 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); 426 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute);
427 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 427 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
428 mailconf->writeEntry("installed_" + stringId, FALSE); 428 mailconf->writeEntry("installed_" + stringId, FALSE);
429 429
430 ePtr->name = stringMailId + "_" + stringId; 430 ePtr->name = stringMailId + "_" + stringId;
431 ePtr->path = getPath(TRUE); 431 ePtr->path = getPath(TRUE);
432 if (emailHandler->getEnclosure(ePtr)) { //file saved 432 if (emailHandler->getEnclosure(ePtr)) { //file saved
433 ePtr->saved = TRUE; 433 ePtr->saved = TRUE;
434 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 434 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
435 mailconf->writeEntry("filename_" + stringId, ePtr->name); 435 mailconf->writeEntry("filename_" + stringId, ePtr->name);
436 mailconf->writeEntry("path_" + stringId, ePtr->path); 436 mailconf->writeEntry("path_" + stringId, ePtr->path);
437 } else { 437 } else {
438 ePtr->saved = FALSE; 438 ePtr->saved = FALSE;
439 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 439 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
440 } 440 }
441 } else { 441 } else {
442 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); 442 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
443 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); 443 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
444 if (ePtr->saved) { 444 if (ePtr->saved) {
445 ePtr->name = mailconf->readEntry("filename_" + stringId); 445 ePtr->name = mailconf->readEntry("filename_" + stringId);
446 ePtr->path = mailconf->readEntry("path_" + stringId); 446 ePtr->path = mailconf->readEntry("path_" + stringId);
447 } 447 }
448 } 448 }
449 } 449 }
450 450
451 bool found=false; 451 bool found=false;
452 452
453 if (!fromDisk) 453 if (!fromDisk)
454 { 454 {
455 455
456 Email *mailPtr; 456 Email *mailPtr;
457 item = (EmailListItem *) inboxView->firstChild(); 457 item = (EmailListItem *) inboxView->firstChild();
458 while ((item != NULL)&&(!found)) 458 while ((item != NULL)&&(!found))
459 { 459 {
460 mailPtr = item->getMail(); 460 mailPtr = item->getMail();
461 if (mailPtr->id == newMail.id) { 461 if (mailPtr->id == newMail.id) {
462 item->setMail(newMail); 462 item->setMail(newMail);
463 emit mailUpdated(item->getMail()); 463 emit mailUpdated(item->getMail());
464 found = true; 464 found = true;
465 } 465 }
466 item = (EmailListItem *) item->nextSibling(); 466 item = (EmailListItem *) item->nextSibling();
467 } 467 }
468 } 468 }
469 if ((!found)||(fromDisk)) { 469 if ((!found)||(fromDisk)) {
470 item = new EmailListItem(inboxView, newMail, TRUE); 470 item = new EmailListItem(inboxView, newMail, TRUE);
471 } 471 }
472// if (item->getMail()->files.count()>0) 472// if (item->getMail()->files.count()>0)
473// { 473// {
474// item->setPixmap(0, Resource::loadPixmap("mailit/attach")); 474// item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475// } 475// }
476 /*if (!newMail.downloaded) 476 /*if (!newMail.downloaded)
477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ 477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
478 478
479 mailboxView->setCurrentTab(0); 479 mailboxView->setCurrentTab(0);
480 480
481} 481}
482 482
483void EmailClient::allMailArrived(int count) 483void EmailClient::allMailArrived(int /*count*/)
484{ 484{
485 // not previewing means all mailtransfer has been done 485 // not previewing means all mailtransfer has been done
486 /*if (!previewingMail) {*/ 486 /*if (!previewingMail) {*/
487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
488 emit newCaption("Mailit - " + currentAccount->accountName); 488 emit newCaption("Mailit - " + currentAccount->accountName);
489 getNewMail(); 489 getNewMail();
490 return; 490 return;
491 } else { 491 } else {
492 allAccounts = FALSE; 492 allAccounts = FALSE;
493 receiving = FALSE; 493 receiving = FALSE;
494 getMailButton->setEnabled(TRUE); 494 getMailButton->setEnabled(TRUE);
495 cancelButton->setEnabled(FALSE); 495 cancelButton->setEnabled(FALSE);
496 selectAccountMenu->setEnabled(TRUE); 496 selectAccountMenu->setEnabled(TRUE);
497 status1Label->setText("Idle"); 497 status1Label->setText("Idle");
498 498
499 progressBar->reset(); 499 progressBar->reset();
500 return; 500 return;
501 } 501 }
502 //} 502 //}
503 503
504 // all headers downloaded from server, start downloading remaining mails 504 // all headers downloaded from server, start downloading remaining mails
505 previewingMail = FALSE; 505 previewingMail = FALSE;
506 status1Label->setText(currentAccount->accountName); 506 status1Label->setText(currentAccount->accountName);
507 progressBar->reset(); 507 progressBar->reset();
508 508
509 509
510 mailboxView->setCurrentTab(0); 510 mailboxView->setCurrentTab(0);
511} 511}
512 512
513 513
514void EmailClient::moveMailFront(Email *mailPtr) 514void EmailClient::moveMailFront(Email *mailPtr)
515{ 515{
516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); 517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
518 } 518 }
519} 519}
520 520
521void EmailClient::smtpError(int code) 521void EmailClient::smtpError(int code, const QString & Msg)
522{ 522{
523 QString temp; 523 QString temp;
524 524
525 if (code == ErrUnknownResponse) 525 if (code == ErrUnknownResponse) {
526 temp = "Unknown response from server"; 526 temp = tr("<qt>Unknown response from server</qt>");
527 527 if( ! Msg.isEmpty() )
528 if (code == QSocket::ErrHostNotFound) 528 temp += Msg;
529 temp = "host not found"; 529 } else if (code == QSocket::ErrHostNotFound) {
530 if (code == QSocket::ErrConnectionRefused) 530 temp = tr("<qt>host not found</qt>");
531 temp = "connection refused"; 531 } else if (code == QSocket::ErrConnectionRefused) {
532 if (code == QSocket::ErrSocketRead) 532 temp = tr("<qt>connection refused</qt>");
533 temp = "socket packet error"; 533 } else if (code == QSocket::ErrSocketRead) {
534 temp = tr("<qt>socket packet error</qt>");
535 }
534 536
535 if (code != ErrCancel) { 537 if (code != ErrCancel) {
536 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); 538 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
537 } else { 539 } else {
538 status2Label->setText("Aborted by user"); 540 status2Label->setText("Aborted by user");
539 } 541 }
540 542
541 sending = FALSE; 543 sending = FALSE;
542 sendMailButton->setEnabled(TRUE); 544 sendMailButton->setEnabled(TRUE);
543 cancelButton->setEnabled(FALSE); 545 cancelButton->setEnabled(FALSE);
544 quedMessages.clear(); 546 quedMessages.clear();
545} 547}
546 548
547void EmailClient::popError(int code) 549void EmailClient::popError(int code, const QString & Msg)
548{ 550{
549 QString temp; 551 QString temp;
550 552
551 if (code == ErrUnknownResponse) 553 if (code == ErrUnknownResponse) {
552 temp = "Unknown response from server"; 554 temp = tr("<qt>Unknown response from server</qt>");
553 if (code == ErrLoginFailed) 555 if( ! Msg.isEmpty() )
554 temp = "Login failed\nCheck user name and password"; 556 temp += Msg;
555 557 } else if (code == ErrLoginFailed) {
556 if (code == QSocket::ErrHostNotFound) 558 temp = tr("<qt>Login failed\nCheck user name and password</qt>");
557 temp = "host not found"; 559 } else if (code == QSocket::ErrHostNotFound) {
558 if (code == QSocket::ErrConnectionRefused) 560 temp = tr("<qt>host not found</qt>");
559 temp = "connection refused"; 561 } else if (code == QSocket::ErrConnectionRefused) {
560 if (code == QSocket::ErrSocketRead) 562 temp = tr("<qt>connection refused</qt>");
561 temp = "socket packet error"; 563 } else if (code == QSocket::ErrSocketRead) {
562 564 temp = tr("<qt>socket packet error</qt>");
565 }
566
563 if (code != ErrCancel) { 567 if (code != ErrCancel) {
564 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); 568 QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n"));
569
565 } else { 570 } else {
566 status2Label->setText("Aborted by user"); 571 status2Label->setText("Aborted by user");
567 } 572 }
568 573
569 receiving = FALSE; 574 receiving = FALSE;
570 getMailButton->setEnabled(TRUE); 575 getMailButton->setEnabled(TRUE);
571 cancelButton->setEnabled(FALSE); 576 cancelButton->setEnabled(FALSE);
572 selectAccountMenu->setEnabled(TRUE); 577 selectAccountMenu->setEnabled(TRUE);
573} 578}
574 579
575void EmailClient::inboxItemSelected() 580void EmailClient::inboxItemSelected()
576{ 581{
577 //killTimer(timerID); 582 //killTimer(timerID);
578 583
579 item = (EmailListItem*) inboxView->selectedItem(); 584 item = (EmailListItem*) inboxView->selectedItem();
580 if (item != NULL) { 585 if (item != NULL) {
581 emit viewEmail(inboxView, item->getMail()); 586 emit viewEmail(inboxView, item->getMail());
582 } 587 }
583} 588}
584 589
585void EmailClient::outboxItemSelected() 590void EmailClient::outboxItemSelected()
586{ 591{
587 //killTimer(timerID); 592 //killTimer(timerID);
588 593
589 item = (EmailListItem*) outboxView->selectedItem(); 594 item = (EmailListItem*) outboxView->selectedItem();
590 if (item != NULL) { 595 if (item != NULL) {
591 emit viewEmail(outboxView, item->getMail()); 596 emit viewEmail(outboxView, item->getMail());
592 } 597 }
593 598
594} 599}
595 600
596void EmailClient::readMail() 601void EmailClient::readMail()
597{ 602{
598 Email mail; 603 Email mail;
599 int start, stop; 604 int start, stop;
600 QString s, del; 605 QString s, del;
601 606
602 QFile f(getPath(FALSE) + "inbox.txt"); 607 QFile f(getPath(FALSE) + "inbox.txt");
603 608
604 if ( f.open(IO_ReadOnly) ) { // file opened successfully 609 if ( f.open(IO_ReadOnly) ) { // file opened successfully
605 QTextStream t( &f ); // use a text stream 610 QTextStream t( &f ); // use a text stream
606 s = t.read(); 611 s = t.read();
607 f.close(); 612 f.close();
608 613
609 start = 0; 614 start = 0;
610 del = "\n.\n"; 615 del = "\n.\n";
611 while ((uint) start < s.length()) { 616 while ((uint) start < s.length()) {
612 stop = s.find(del, start); 617 stop = s.find(del, start);
613 if (stop == -1) 618 if (stop == -1)
614 stop = s.length() - del.length(); 619 stop = s.length() - del.length();
615 620
616 mail.rawMail = s.mid(start, stop + del.length() - start ); 621 mail.rawMail = s.mid(start, stop + del.length() - start );
617 start = stop + del.length(); 622 start = stop + del.length();
618 mailArrived(mail, TRUE); 623 mailArrived(mail, TRUE);
619 } 624 }
620 } 625 }
621 626
622 QFile fo(getPath(FALSE) + "outbox.txt"); 627 QFile fo(getPath(FALSE) + "outbox.txt");
623 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 628 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
624 QTextStream t( &fo ); // use a text stream 629 QTextStream t( &fo ); // use a text stream
625 s = t.read(); 630 s = t.read();
626 fo.close(); 631 fo.close();
627 632
628 start = 0; 633 start = 0;
629 del = "\n.\n"; 634 del = "\n.\n";
630 while ((uint) start < s.length()) { 635 while ((uint) start < s.length()) {
631 stop = s.find(del, start); 636 stop = s.find(del, start);
632 if (stop == -1) 637 if (stop == -1)
633 stop = s.length() - del.length(); 638 stop = s.length() - del.length();
634 639
635 mail.rawMail = s.mid(start, stop + del.length() - start ); 640 mail.rawMail = s.mid(start, stop + del.length() - start );
636 start = stop + del.length(); 641 start = stop + del.length();
637 emailHandler->parse(mail.rawMail, lineShift, &mail); 642 emailHandler->parse(mail.rawMail, lineShift, &mail);
638 mail.sent = false; 643 mail.sent = false;
639 mail.received = false; 644 mail.received = false;
640 enqueMail(mail); 645 enqueMail(mail);
641 646
642 } 647 }
643 } 648 }
644} 649}
645 650
646void EmailClient::saveMail(const QString &fileName, QListView *view) 651void EmailClient::saveMail(const QString &fileName, QListView *view)
647{ 652{
648 QFile f(fileName); 653 QFile f(fileName);
649 Email *mail; 654 Email *mail;
650 655
651 if (! f.open(IO_WriteOnly) ) { 656 if (! f.open(IO_WriteOnly) ) {
652 qWarning("could not open file"); 657 qWarning("could not open file");
653 return; 658 return;
654 } 659 }
655 item = (EmailListItem *) view->firstChild(); 660 item = (EmailListItem *) view->firstChild();
656 QTextStream t(&f); 661 QTextStream t(&f);
657 while (item != NULL) { 662 while (item != NULL) {
658 mail = item->getMail(); 663 mail = item->getMail();
659 t << mail->rawMail; 664 t << mail->rawMail;
660 665
661 mailconf->setGroup(mail->id); 666 mailconf->setGroup(mail->id);
662 mailconf->writeEntry("mailread", mail->read); 667 mailconf->writeEntry("mailread", mail->read);
663 668
664 item = (EmailListItem *) item->nextSibling(); 669 item = (EmailListItem *) item->nextSibling();
665 } 670 }
666 f.close(); 671 f.close();
667} 672}
668 673
669//paths for mailit, is settings, inbox, enclosures 674//paths for mailit, is settings, inbox, enclosures
670QString EmailClient::getPath(bool enclosurePath) 675QString EmailClient::getPath(bool enclosurePath)
671{ 676{
672 QString basePath = "qtmail"; 677 QString basePath = "qtmail";
673 QString enclosures = "enclosures"; 678 QString enclosures = "enclosures";
674 679
675 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 680 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
676 if ( !dir.exists() ) 681 if ( !dir.exists() )
677 dir.mkdir( dir.path() ); 682 dir.mkdir( dir.path() );
678 683
679 if (enclosurePath) { 684 if (enclosurePath) {
680 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 685 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
681 686
682 if ( !dir.exists() ) 687 if ( !dir.exists() )
683 dir.mkdir( dir.path() ); 688 dir.mkdir( dir.path() );
684 689
685 return (dir.path() + "/"); 690 return (dir.path() + "/");
686 691
687 } 692 }
688 return (dir.path() + "/"); 693 return (dir.path() + "/");
689} 694}
690 695
691void EmailClient::readSettings() 696void EmailClient::readSettings()
692{ 697{
693 int y,acc_count; 698 int y,acc_count;
694 699
695 mailconf->setGroup("mailitglobal"); 700 mailconf->setGroup("mailitglobal");
696 acc_count=mailconf->readNumEntry("Accounts",0); 701 acc_count=mailconf->readNumEntry("Accounts",0);
697 702
698 for (int accountPos = 0;accountPos<acc_count ; accountPos++) 703 for (int accountPos = 0;accountPos<acc_count ; accountPos++)
699 { 704 {
700 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... 705 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ...
701 account.accountName = mailconf->readEntry("AccName",""); 706 account.accountName = mailconf->readEntry("AccName","");
702 account.name = mailconf->readEntry("UserName",""); 707 account.name = mailconf->readEntry("UserName","");
703 account.emailAddress = mailconf->readEntry("Email",""); 708 account.emailAddress = mailconf->readEntry("Email","");
704 account.popUserName = mailconf->readEntry("POPUser",""); 709 account.popUserName = mailconf->readEntry("POPUser","");
705 account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); 710 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
706 account.popServer = mailconf->readEntry("POPServer",""); 711 account.popServer = mailconf->readEntry("POPServer","");
707 account.smtpServer = mailconf->readEntry("SMTPServer",""); 712 account.smtpServer = mailconf->readEntry("SMTPServer","");
708 account.id = mailconf->readNumEntry("AccountId",0); 713 account.id = mailconf->readNumEntry("AccountId",0);
709 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); 714 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
710 account.lastServerMailCount = 0; 715 account.lastServerMailCount = 0;
711 account.synchronize = FALSE; 716 account.synchronize = FALSE;
712 717
713 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); 718 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
714 if (account.synchronize) 719 if (account.synchronize)
715 { 720 {
716 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); 721 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
717 } 722 }
718 723
719 accountList.append(&account); 724 accountList.append(&account);
720 } 725 }
721 726
722 mailconf->setGroup("mailitglobal"); 727 mailconf->setGroup("mailitglobal");
723 728
724 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) 729 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
725 { 730 {
726 mailIdCount = y; 731 mailIdCount = y;
727 } 732 }
728 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) 733 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
729 { 734 {
730 accountIdCount = y; 735 accountIdCount = y;
731 } 736 }
732} 737}
733 738
734void EmailClient::saveSettings() 739void EmailClient::saveSettings()
735{ 740{
736 int acc_count=0; 741 int acc_count=0;
737 MailAccount *accountPtr; 742 MailAccount *accountPtr;
738 743
739 744
740 if (!mailconf) 745 if (!mailconf)
741 { 746 {
742 qWarning("could not save settings"); 747 qWarning("could not save settings");
743 return; 748 return;
744 } 749 }
745 750
746 for (accountPtr = accountList.first(); accountPtr != 0; 751 for (accountPtr = accountList.first(); accountPtr != 0;
747 accountPtr = accountList.next()) 752 accountPtr = accountList.next())
748 { 753 {
749 mailconf->setGroup("Account_"+QString::number(++acc_count)); 754 mailconf->setGroup("Account_"+QString::number(++acc_count));
750 mailconf->writeEntry("AccName",accountPtr->accountName ); 755 mailconf->writeEntry("AccName",accountPtr->accountName );
751 mailconf->writeEntry("UserName",accountPtr->name); 756 mailconf->writeEntry("UserName",accountPtr->name);
752 mailconf->writeEntry("Email",accountPtr->emailAddress); 757 mailconf->writeEntry("Email",accountPtr->emailAddress);
753 mailconf->writeEntry("POPUser",accountPtr->popUserName); 758 mailconf->writeEntry("POPUser",accountPtr->popUserName);
754 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); 759 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd);
755 mailconf->writeEntry("POPServer",accountPtr->popServer); 760 mailconf->writeEntry("POPServer",accountPtr->popServer);
756 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); 761 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer);
757 mailconf->writeEntry("AccountId",accountPtr->id); 762 mailconf->writeEntry("AccountId",accountPtr->id);
758 if (accountPtr->synchronize) 763 if (accountPtr->synchronize)
759 { 764 {
760 mailconf->writeEntry("Synchronize","Yes"); 765 mailconf->writeEntry("Synchronize","Yes");
761 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); 766 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit);
762 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); 767 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount);
763 } 768 }
764 else 769 else
765 { 770 {
766 mailconf->writeEntry("Synchronize", "No"); 771 mailconf->writeEntry("Synchronize", "No");
767 } 772 }
768 } 773 }
769 774
770 mailconf->setGroup("mailitglobal"); 775 mailconf->setGroup("mailitglobal");
771 mailconf->writeEntry("Accounts",acc_count); 776 mailconf->writeEntry("Accounts",acc_count);
772 mailconf->writeEntry("mailidcount", mailIdCount); 777 mailconf->writeEntry("mailidcount", mailIdCount);
773 mailconf->writeEntry("accountidcount", accountIdCount); 778 mailconf->writeEntry("accountidcount", accountIdCount);
774} 779}
775 780
776void EmailClient::selectAccount(int id) 781void EmailClient::selectAccount(int id)
777{ 782{
778 if (accountList.count() > 0) { 783 if (accountList.count() > 0) {
779 currentAccount = accountList.at(id); 784 currentAccount = accountList.at(id);
780 emit newCaption("Mailit - " + currentAccount->accountName); 785 emit newCaption("Mailit - " + currentAccount->accountName);
781 getNewMail(); 786 getNewMail();
782 } else { 787 } else {
783 emit newCaption("Mailit ! No account defined"); 788 emit newCaption("Mailit ! No account defined");
784 } 789 }
785} 790}
786 791
787void EmailClient::editAccount(int id) 792void EmailClient::editAccount(int id)
788{ 793{
789 MailAccount *newAccount; 794 MailAccount *newAccount;
790 795
791 editAccountView = new EditAccount(this, "account", TRUE); 796 editAccountView = new EditAccount(this, "account", TRUE);
792 if (id == newAccountId) { //new account 797 if (id == newAccountId) { //new account
793 newAccount = new MailAccount; 798 newAccount = new MailAccount;
794 editAccountView->setAccount(newAccount); 799 editAccountView->setAccount(newAccount);
795 } else { 800 } else {
796 newAccount = accountList.at(id); 801 newAccount = accountList.at(id);
797 editAccountView->setAccount(newAccount, FALSE); 802 editAccountView->setAccount(newAccount, FALSE);
798 } 803 }
799 804
800 editAccountView->showMaximized(); 805 editAccountView->showMaximized();
801 editAccountView->exec(); 806 editAccountView->exec();
802 807
803 if (editAccountView->result() == QDialog::Accepted) { 808 if (editAccountView->result() == QDialog::Accepted) {
804 if (id == newAccountId) { 809 if (id == newAccountId) {
805 newAccount->id = accountIdCount; 810 newAccount->id = accountIdCount;
806 accountIdCount++; 811 accountIdCount++;
807 accountList.append(newAccount); 812 accountList.append(newAccount);
808 updateAccounts(); 813 updateAccounts();
809 } else { 814 } else {
810 updateAccounts(); 815 updateAccounts();
811 } 816 }
812 } 817 }
813 818
814 delete editAccountView; 819 delete editAccountView;
815} 820}
816 821
817void EmailClient::deleteAccount(int id) 822void EmailClient::deleteAccount(int id)
818{ 823{
819 MailAccount *newAccount; 824 MailAccount *newAccount;
820 QString message; 825 QString message;
821 826
822 newAccount = accountList.at(id); 827 newAccount = accountList.at(id);
823 message = "Delete account:\n" + newAccount->accountName; 828 message = "Delete account:\n" + newAccount->accountName;
824 switch( QMessageBox::warning( this, "Mailit", message, 829 switch( QMessageBox::warning( this, "Mailit", message,
825 "Yes", "No", 0, 0, 1 ) ) { 830 "Yes", "No", 0, 0, 1 ) ) {
826 831
827 case 0: accountList.remove(id); 832 case 0: accountList.remove(id);
828 updateAccounts(); 833 updateAccounts();
829 break; 834 break;
830 case 1: 835 case 1:
831 break; 836 break;
832 } 837 }
833} 838}
834 839
835void EmailClient::updateAccounts() 840void EmailClient::updateAccounts()
836{ 841{
837 MailAccount *accountPtr; 842 MailAccount *accountPtr;
838 843
839 //rebuild menus, clear all first 844 //rebuild menus, clear all first
840 editAccountMenu->clear(); 845 editAccountMenu->clear();
841 selectAccountMenu->clear(); 846 selectAccountMenu->clear();
842 deleteAccountMenu->clear(); 847 deleteAccountMenu->clear();
843 848
844 newAccountId = editAccountMenu->insertItem("New", this, 849 newAccountId = editAccountMenu->insertItem("New", this,
845 SLOT(editAccount(int)) ); 850 SLOT(editAccount(int)) );
846 editAccountMenu->insertSeparator(); 851 editAccountMenu->insertSeparator();
847 852
848 idCount = 0; 853 idCount = 0;
849 for (accountPtr = accountList.first(); accountPtr != 0; 854 for (accountPtr = accountList.first(); accountPtr != 0;
850 accountPtr = accountList.next()) { 855 accountPtr = accountList.next()) {
851 856
852 editAccountMenu->insertItem(accountPtr->accountName, 857 editAccountMenu->insertItem(accountPtr->accountName,
853 this, SLOT(editAccount(int)), 0, idCount); 858 this, SLOT(editAccount(int)), 0, idCount);
854 selectAccountMenu->insertItem(accountPtr->accountName, 859 selectAccountMenu->insertItem(accountPtr->accountName,
855 this, SLOT(selectAccount(int)), 0, idCount); 860 this, SLOT(selectAccount(int)), 0, idCount);
856 deleteAccountMenu->insertItem(accountPtr->accountName, 861 deleteAccountMenu->insertItem(accountPtr->accountName,
857 this, SLOT(deleteAccount(int)), 0, idCount); 862 this, SLOT(deleteAccount(int)), 0, idCount);
858 idCount++; 863 idCount++;
859 } 864 }
860} 865}
861 866
862void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) 867void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
863{ 868{
864 Email *mPtr; 869 Email *mPtr;
865 Enclosure *ePtr; 870 Enclosure *ePtr;
866 871
867 if (inbox) 872 if (inbox)
868 { 873 {
869 mPtr = mailItem->getMail(); 874 mPtr = mailItem->getMail();
870 875
871 //if mail is in queue for download, remove it from 876 //if mail is in queue for download, remove it from
872 //queue if possible 877 //queue if possible
873 if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { 878 if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) {
874 if ( !mPtr->downloaded ) 879 if ( !mPtr->downloaded )
875 mailDownloadList.remove(mPtr->serverId, mPtr->size); 880 mailDownloadList.remove(mPtr->serverId, mPtr->size);
876 } 881 }
877 882
878 mailconf->setGroup(mPtr->id); 883 mailconf->setGroup(mPtr->id);
879 mailconf->clearGroup(); 884 mailconf->clearGroup();
880 885
881 //delete any temporary attatchemnts storing 886 //delete any temporary attatchemnts storing
882 for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { 887 for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) {
883 if (ePtr->saved) { 888 if (ePtr->saved) {
884 QFile::remove( (ePtr->path + ePtr->name) ); 889 QFile::remove( (ePtr->path + ePtr->name) );
885 } 890 }
886 } 891 }
887 inboxView->takeItem(mailItem); 892 inboxView->takeItem(mailItem);
888 } 893 }
889 else 894 else
890 { 895 {
891 outboxView->takeItem(mailItem); 896 outboxView->takeItem(mailItem);
892 } 897 }
893} 898}
894 899
895void EmailClient::setMailSize(int size) 900void EmailClient::setMailSize(int size)
896{ 901{
897 progressBar->reset(); 902 progressBar->reset();
898 progressBar->setTotalSteps(size); 903 progressBar->setTotalSteps(size);
899} 904}
900 905
901void EmailClient::setTotalSize(int size) 906void EmailClient::setTotalSize(int /*size*/)
902{ 907{
903 908
904} 909}
905 910
906void EmailClient::setDownloadedSize(int size) 911void EmailClient::setDownloadedSize(int size)
907{ 912{
908 int total = progressBar->totalSteps(); 913 int total = progressBar->totalSteps();
909 914
910 if (size < total) { 915 if (size < total) {
911 progressBar->setProgress(size); 916 progressBar->setProgress(size);
912 } else { 917 } else {
913 progressBar->setProgress(total); 918 progressBar->setProgress(total);
914 } 919 }
915} 920}
916 921
917void EmailClient::deleteItem() 922void EmailClient::deleteItem()
918{ 923{
919 bool inbox=mailboxView->currentTab()==0; 924 bool inbox=mailboxView->currentTab()==0;
920 QListView* box; 925 QListView* box;
921 926
922 EmailListItem* eli; 927 EmailListItem* eli;
923 int pos; 928 // int pos;
924 929
925 inbox ? box=inboxView : box=outboxView; 930 inbox ? box=inboxView : box=outboxView;
926 931
927 eli=(EmailListItem*)box->selectedItem(); 932 eli=(EmailListItem*)box->selectedItem();
928 933
929 if (eli) 934 if (eli)
930 { 935 {
931 box->setSelected(eli->itemBelow(),true); //select the previous item 936 box->setSelected(eli->itemBelow(),true); //select the previous item
932 937
933 deleteMail(eli,(bool&)inbox); //remove mail entry 938 deleteMail(eli,(bool&)inbox); //remove mail entry
934 } 939 }
935} 940}
936 941
937void EmailClient::inboxItemPressed() 942void EmailClient::inboxItemPressed()
938{ 943{
939// timerID=startTimer(500); 944// timerID=startTimer(500);
940} 945}
941 946
942void EmailClient::inboxItemReleased() 947void EmailClient::inboxItemReleased()
943{ 948{
944 // killTimer(timerID); 949 // killTimer(timerID);
945} 950}
946 951
947/*void EmailClient::timerEvent(QTimerEvent *e) 952/*void EmailClient::timerEvent(QTimerEvent *e)
948{ 953{
949 /*killTimer(timerID); 954 //killTimer(timerID);
950 955
951 956
952 QPopupMenu *action = new QPopupMenu(this); 957 QPopupMenu *action = new QPopupMenu(this);
953 958
954 int reply=0; 959 int reply=0;
955 960
956 action->insertItem(tr( "Reply To" ),this,SLOT(reply())); 961 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
957 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); 962 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
958 action->insertItem( tr( "Forward" ), this,SLOT(forward())); 963 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
959 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); 964 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
960 965
961 action->exec(QCursor::pos()); 966 action->exec(QCursor::pos());
962 967
963 if (action) delete action; 968 if (action) delete action;
964 969
965}*/ 970}*/
966 971
967Email* EmailClient::getCurrentMail() 972Email* EmailClient::getCurrentMail()
968{ 973{
969 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); 974 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
970 if (eli!=NULL) 975 if (eli!=NULL)
971 return eli->getMail(); 976 return eli->getMail();
972 else 977 else
973 return NULL; 978 return NULL;
974} 979}
975 980
976void EmailClient::download(Email* mail) 981void EmailClient::download(Email* mail)
977{ 982{
978 MailAccount* acc=0; 983 MailAccount* acc=0;
979 984
980 tempMailDownloadList.clear(); 985 tempMailDownloadList.clear();
981 tempMailDownloadList.sizeInsert(mail->serverId, mail->size); 986 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
982 987
983 acc=accountList.at(mail->fromAccountId-1); 988 acc=accountList.at(mail->fromAccountId-1);
984 if (acc) 989 if (acc)
985 { 990 {
986 emailHandler->setAccount(*acc); 991 emailHandler->setAccount(*acc);
987 emailHandler->getMailByList(&tempMailDownloadList); 992 emailHandler->getMailByList(&tempMailDownloadList);
988 } 993 }
989 else 994 else
990 QMessageBox::warning(qApp->activeWindow(), 995 QMessageBox::warning(qApp->activeWindow(),
991 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); 996 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
992} 997}
993 998
994void EmailClient::receive(const QCString& msg, const QByteArray& data) 999void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/)
995{ 1000{
996 /*if (msg=="getMail()") 1001 /*if (msg=="getMail()")
997 { 1002 {
998 /*QDialog qd(qApp->activeWindow(),"Getting mail",true); 1003 //QDialog qd(qApp->activeWindow(),"Getting mail",true);
999 QVBoxLayout *vbProg = new QVBoxLayout( &qd ); 1004 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
1000 1005
1001 initStatusBar(&qd); 1006 initStatusBar(&qd);
1002 1007
1003 if (statusBar==0) 1008 if (statusBar==0)
1004 { 1009 {
1005 qDebug("No Bar ..."); 1010 qDebug("No Bar ...");
1006 //statusBar=new ProgressBar(&qd); 1011 //statusBar=new ProgressBar(&qd);
1007 } 1012 }
1008 statusBar->show(); 1013 statusBar->show();
1009 vbProg->addWidget(statusBar); 1014 vbProg->addWidget(statusBar);
1010 qd.showMaximized(); 1015 qd.showMaximized();
1011 qd.show(); 1016 qd.show();
1012 emit getAllNewMail(); 1017 emit getAllNewMail();
1013 //qd.exec(); 1018 //qd.exec();
1014 } 1019 }
1015 else if (msg=="compose()") 1020 else if (msg=="compose()")
1016 { 1021 {
1017 QDialog qd(qApp->activeWindow(),"Getting mail",true); 1022 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1018 1023
1019 WriteMail wm(&qd,"write new mail"); 1024 WriteMail wm(&qd,"write new mail");
1020 QVBoxLayout vbProg( &qd ); 1025 QVBoxLayout vbProg( &qd );
1021 1026
1022 wm.showMaximized(); 1027 wm.showMaximized();
1023 vbProg.addWidget(&wm); 1028 vbProg.addWidget(&wm);
1024 1029
1025 qd.showMaximized(); 1030 qd.showMaximized();
1026 1031
1027 emit composeRequested(); 1032 emit composeRequested();
1028 qd.exec(); 1033 qd.exec();
1029 1034
1030 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1031 } 1036 }
1032 1037
1033 else if (msg=="dialog()") 1038 else if (msg=="dialog()")
1034 { 1039 {
1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1040 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1036 }*/ 1041 }*/
1037} 1042}
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h
index c98cfce..80c6d31 100644
--- a/noncore/net/mailit/emailclient.h
+++ b/noncore/net/mailit/emailclient.h
@@ -1,181 +1,181 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef EMAILCLIENT_H 20#ifndef EMAILCLIENT_H
21#define EMAILCLIENT_H 21#define EMAILCLIENT_H
22 22
23#include <qlist.h> 23#include <qlist.h>
24#include <qcstring.h> 24#include <qcstring.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qaction.h> 32#include <qaction.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qtooltip.h> 34#include <qtooltip.h>
35#include <qtoolbutton.h> 35#include <qtoolbutton.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39#include <qprogressbar.h> 39#include <qprogressbar.h>
40#include <qstatusbar.h> 40#include <qstatusbar.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <opie/otabwidget.h> 43#include <opie/otabwidget.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45#include <qtimer.h> 45#include <qtimer.h>
46 46
47#include "emailhandler.h" 47#include "emailhandler.h"
48#include "emaillistitem.h" 48#include "emaillistitem.h"
49#include "textparser.h" 49#include "textparser.h"
50#include "editaccount.h" 50#include "editaccount.h"
51#include "maillist.h" 51#include "maillist.h"
52#include "addresslist.h" 52#include "addresslist.h"
53 53
54#include <qpe/config.h> 54#include <qpe/config.h>
55 55
56class AccountList : public QList<MailAccount> 56class AccountList : public QList<MailAccount>
57{ 57{
58public: 58public:
59 Item newItem(Item d); 59 Item newItem(Item d);
60private: 60private:
61 MailAccount* dupl(MailAccount *in); 61 MailAccount* dupl(MailAccount *in);
62 MailAccount *ac; 62 MailAccount *ac;
63}; 63};
64 64
65//class EmailClient : public EmailClientBase 65//class EmailClient : public EmailClientBase
66class EmailClient : public QMainWindow 66class EmailClient : public QMainWindow
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 69
70public: 70public:
71 EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); 71 EmailClient( QWidget* parent, const char* name, WFlags fl = 0 );
72 ~EmailClient(); 72 ~EmailClient();
73 AddressList* getAdrListRef(); 73 AddressList* getAdrListRef();
74 74
75protected: 75protected:
76 //void timerEvent(QTimerEvent*); 76 //void timerEvent(QTimerEvent*);
77 77
78signals: 78signals:
79 void composeRequested(); 79 void composeRequested();
80 void viewEmail(QListView *, Email *); 80 void viewEmail(QListView *, Email *);
81 void mailUpdated(Email *); 81 void mailUpdated(Email *);
82 void newCaption(const QString &); 82 void newCaption(const QString &);
83 void replyRequested(Email&, bool&); 83 void replyRequested(Email&, bool&);
84 void forwardRequested(Email&); 84 void forwardRequested(Email&);
85 void removeItem(EmailListItem*, bool&); 85 void removeItem(EmailListItem*, bool&);
86 /*void reply(Email&); 86 /*void reply(Email&);
87 void replyAll(Email&); 87 void replyAll(Email&);
88 void remove(Email&); 88 void remove(Email&);
89 void forward(Email&);*/ 89 void forward(Email&);*/
90 90
91public slots: 91public slots:
92 void compose(); 92 void compose();
93 void cancel(); 93 void cancel();
94 void enqueMail(const Email &mail); 94 void enqueMail(const Email &mail);
95 void setMailAccount(); 95 void setMailAccount();
96 void sendQuedMail(); 96 void sendQuedMail();
97 void mailSent(); 97 void mailSent();
98 void deleteItem(); 98 void deleteItem();
99 void getNewMail(); 99 void getNewMail();
100 void getAllNewMail(); 100 void getAllNewMail();
101 void smtpError(int code); 101 void smtpError(int code, const QString & Msg );
102 void popError(int code); 102 void popError(int code, const QString & Msg);
103 void inboxItemSelected(); 103 void inboxItemSelected();
104 void outboxItemSelected(); 104 void outboxItemSelected();
105 void inboxItemPressed(); 105 void inboxItemPressed();
106 void inboxItemReleased(); 106 void inboxItemReleased();
107 void mailArrived(const Email &mail, bool fromDisk); 107 void mailArrived(const Email &mail, bool fromDisk);
108 void allMailArrived(int); 108 void allMailArrived(int);
109 void saveMail(const QString &fileName, QListView *view); 109 void saveMail(const QString &fileName, QListView *view);
110 void selectAccount(int); 110 void selectAccount(int);
111 void editAccount(int); 111 void editAccount(int);
112 void updateAccounts(); 112 void updateAccounts();
113 void deleteAccount(int); 113 void deleteAccount(int);
114 void deleteMail(EmailListItem *mailItem, bool &inbox); 114 void deleteMail(EmailListItem *mailItem, bool &inbox);
115 void setTotalSize(int); 115 void setTotalSize(int);
116 void setMailSize(int); 116 void setMailSize(int);
117 void setDownloadedSize(int); 117 void setDownloadedSize(int);
118 void moveMailFront(Email *mailPtr); 118 void moveMailFront(Email *mailPtr);
119 void download(Email*); 119 void download(Email*);
120/* void reply(); 120/* void reply();
121 void replyAll(); 121 void replyAll();
122 void forward(); 122 void forward();
123 void remove();*/ 123 void remove();*/
124 124
125private slots: 125private slots:
126 void receive(const QCString&, const QByteArray&); 126 void receive(const QCString&, const QByteArray&);
127 127
128private: 128private:
129 void init(); 129 void init();
130 void initStatusBar(QWidget*); 130 void initStatusBar(QWidget*);
131 void readMail(); 131 void readMail();
132 QString getPath(bool enclosurePath); 132 QString getPath(bool enclosurePath);
133 void readSettings(); 133 void readSettings();
134 void saveSettings(); 134 void saveSettings();
135 Email* getCurrentMail(); 135 Email* getCurrentMail();
136 int timerID; 136 int timerID;
137 Config *mailconf; 137 Config *mailconf;
138 int newAccountId, idCount, mailIdCount; 138 int newAccountId, idCount, mailIdCount;
139 int accountIdCount; 139 int accountIdCount;
140 AccountList accountList; 140 AccountList accountList;
141 AddressList *addressList; 141 AddressList *addressList;
142 142
143 EditAccount *editAccountView; 143 EditAccount *editAccountView;
144 EmailListItem *item; 144 EmailListItem *item;
145 EmailHandler *emailHandler; 145 EmailHandler *emailHandler;
146 QList<Email> quedMessages; 146 QList<Email> quedMessages;
147 MailList mailDownloadList; 147 MailList mailDownloadList;
148 MailList tempMailDownloadList; 148 MailList tempMailDownloadList;
149 149
150 bool sending, receiving, previewingMail, allAccounts; 150 bool sending, receiving, previewingMail, allAccounts;
151 QString lineShift; 151 QString lineShift;
152 MailAccount account, *currentAccount; 152 MailAccount account, *currentAccount;
153 153
154 QCopChannel* channel; 154 QCopChannel* channel;
155 155
156 QToolBar *bar; 156 QToolBar *bar;
157 QProgressBar *progressBar; 157 QProgressBar *progressBar;
158 QStatusBar *statusBar; 158 QStatusBar *statusBar;
159 QLabel *status1Label, *status2Label; 159 QLabel *status1Label, *status2Label;
160 QToolButton *getMailButton; 160 QToolButton *getMailButton;
161 QAction *sendMailButton; 161 QAction *sendMailButton;
162 QAction *composeButton; 162 QAction *composeButton;
163 QAction *cancelButton; 163 QAction *cancelButton;
164 QAction *deleteButton; 164 QAction *deleteButton;
165 //QToolButton *setAccountButton; 165 //QToolButton *setAccountButton;
166 166
167 QMenuBar *mb; 167 QMenuBar *mb;
168 QPopupMenu *selectAccountMenu; 168 QPopupMenu *selectAccountMenu;
169 QPopupMenu *editAccountMenu; 169 QPopupMenu *editAccountMenu;
170 QPopupMenu *deleteAccountMenu; 170 QPopupMenu *deleteAccountMenu;
171 QPopupMenu *setAccountMenu; 171 QPopupMenu *setAccountMenu;
172 172
173 OTabWidget* mailboxView; 173 OTabWidget* mailboxView;
174 QListView* inboxView; 174 QListView* inboxView;
175 QListView* outboxView; 175 QListView* outboxView;
176 176
177 QGridLayout* grid_2; 177 QGridLayout* grid_2;
178 QGridLayout* grid_3; 178 QGridLayout* grid_3;
179}; 179};
180 180
181#endif // EMAILCLIENT_H 181#endif // EMAILCLIENT_H
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 39f693d..5b8bda1 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -1,357 +1,357 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qfileinfo.h> 20#include <qfileinfo.h>
21#include <stdlib.h> 21#include <stdlib.h>
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qcstring.h> 24#include <qcstring.h>
25#include "emailhandler.h" 25#include "emailhandler.h"
26#include <qpe/applnk.h> 26#include <qpe/applnk.h>
27#include <qpe/filemanager.h> 27#include <qpe/filemanager.h>
28 28
29QCollection::Item EnclosureList::newItem(QCollection::Item d) 29QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (Enclosure *) d); 31 return dupl( (Enclosure *) d);
32} 32}
33 33
34Enclosure* EnclosureList::dupl(Enclosure *in) 34Enclosure* EnclosureList::dupl(Enclosure *in)
35{ 35{
36 ac = new Enclosure(*in); 36 ac = new Enclosure(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailHandler::EmailHandler() 40EmailHandler::EmailHandler()
41{ 41{
42 qDebug("EMailHandler::EmailHandler"); 42 qDebug("EMailHandler::EmailHandler");
43 43
44 smtpClient = new SmtpClient(); 44 smtpClient = new SmtpClient();
45 popClient = new PopClient(); 45 popClient = new PopClient();
46 46
47 connect(smtpClient, SIGNAL(errorOccurred(int)), this, 47 connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this,
48 SIGNAL(smtpError(int)) ); 48 SIGNAL(smtpError(int, const QString &)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); 49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, 50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) ); 51 SIGNAL(updateSmtpStatus(const QString &)) );
52 52
53 connect(popClient, SIGNAL(errorOccurred(int)), this, 53 connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this,
54 SIGNAL(popError(int)) ); 54 SIGNAL(popError(int, const QString &)) );
55 connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), 55 connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)),
56 this, SLOT(messageArrived(const QString &, int, uint, bool)) ); 56 this, SLOT(messageArrived(const QString &, int, uint, bool)) );
57 connect(popClient, SIGNAL(updateStatus(const QString &)), this, 57 connect(popClient, SIGNAL(updateStatus(const QString &)), this,
58 SIGNAL(updatePopStatus(const QString &)) ); 58 SIGNAL(updatePopStatus(const QString &)) );
59 connect(popClient, SIGNAL(mailTransfered(int)), this, 59 connect(popClient, SIGNAL(mailTransfered(int)), this,
60 SIGNAL(mailTransfered(int)) ); 60 SIGNAL(mailTransfered(int)) );
61 61
62 62
63 //relaying size information 63 //relaying size information
64 connect(popClient, SIGNAL(currentMailSize(int)), 64 connect(popClient, SIGNAL(currentMailSize(int)),
65 this, SIGNAL(currentMailSize(int)) ); 65 this, SIGNAL(currentMailSize(int)) );
66 connect(popClient, SIGNAL(downloadedSize(int)), 66 connect(popClient, SIGNAL(downloadedSize(int)),
67 this, SIGNAL(downloadedSize(int)) ); 67 this, SIGNAL(downloadedSize(int)) );
68} 68}
69 69
70void EmailHandler::sendMail(QList<Email> *mailList) 70void EmailHandler::sendMail(QList<Email> *mailList)
71{ 71{
72 Email *currentMail; 72 Email *currentMail;
73 QString temp; 73 QString temp;
74 QString userName = mailAccount.name; 74 QString userName = mailAccount.name;
75 userName += " <" + mailAccount.emailAddress + ">"; 75 userName += " <" + mailAccount.emailAddress + ">";
76 76
77 for (currentMail = mailList->first(); currentMail != 0; 77 for (currentMail = mailList->first(); currentMail != 0;
78 currentMail = mailList->next()) { 78 currentMail = mailList->next()) {
79 79
80 if (encodeMime(currentMail) == 0) { 80 if (encodeMime(currentMail) == 0) {
81 smtpClient->addMail(userName, currentMail->subject, 81 smtpClient->addMail(userName, currentMail->subject,
82 currentMail->recipients, currentMail->rawMail); 82 currentMail->recipients, currentMail->rawMail);
83 } else { //error 83 } else { //error
84 temp = tr("Could not locate all files in \nmail with subject: ") + 84 temp = tr("Could not locate all files in \nmail with subject: ") +
85 currentMail->subject; 85 currentMail->subject;
86 temp += tr("\nMail has NOT been sent"); 86 temp += tr("\nMail has NOT been sent");
87 QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); 87 QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n"));
88 88
89 } 89 }
90 } 90 }
91 smtpClient->newConnection(mailAccount.smtpServer, 25); 91 smtpClient->newConnection(mailAccount.smtpServer, 25);
92} 92}
93 93
94void EmailHandler::setAccount(MailAccount account) 94void EmailHandler::setAccount(MailAccount account)
95{ 95{
96 mailAccount = account; 96 mailAccount = account;
97} 97}
98 98
99void EmailHandler::getMail() 99void EmailHandler::getMail()
100{ 100{
101 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); 101 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
102 if (mailAccount.synchronize) { 102 if (mailAccount.synchronize) {
103 popClient->setSynchronize(mailAccount.lastServerMailCount); 103 popClient->setSynchronize(mailAccount.lastServerMailCount);
104 } else { 104 } else {
105 popClient->removeSynchronize(); 105 popClient->removeSynchronize();
106 } 106 }
107 107
108 headers = FALSE; 108 headers = FALSE;
109 //popClient->headersOnly(headers, 0); 109 //popClient->headersOnly(headers, 0);
110 popClient->newConnection(mailAccount.popServer, 110); 110 popClient->newConnection(mailAccount.popServer, 110);
111} 111}
112 112
113void EmailHandler::getMailHeaders() 113void EmailHandler::getMailHeaders()
114{ 114{
115 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); 115 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
116 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); 116 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize();
117 117
118 headers = TRUE; 118 headers = TRUE;
119 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all 119 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
120 qDebug("Initiating connection"); 120 qDebug("Initiating connection");
121 popClient->newConnection(mailAccount.popServer, 110); 121 popClient->newConnection(mailAccount.popServer, 110);
122} 122}
123 123
124void EmailHandler::getMailByList(MailList *mailList) 124void EmailHandler::getMailByList(MailList *mailList)
125{ 125{
126 if (mailList->count() == 0) { //should not occur though 126 if (mailList->count() == 0) { //should not occur though
127 emit mailTransfered(0); 127 emit mailTransfered(0);
128 return; 128 return;
129 } 129 }
130 130
131 headers = FALSE; 131 headers = FALSE;
132 popClient->headersOnly(FALSE, 0); 132 popClient->headersOnly(FALSE, 0);
133 133
134 popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); 134 popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd);
135 popClient->setSelectedMails(mailList); 135 popClient->setSelectedMails(mailList);
136 popClient->newConnection(mailAccount.popServer, 110); 136 popClient->newConnection(mailAccount.popServer, 110);
137 } 137 }
138 138
139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
140{ 140{
141 Email mail; 141 Email mail;
142 142
143 mail.rawMail = message; 143 mail.rawMail = message;
144 mail.serverId = id; 144 mail.serverId = id;
145 mail.size = size; 145 mail.size = size;
146 mail.downloaded = complete; 146 mail.downloaded = complete;
147 147
148 emit mailArrived(mail, FALSE); 148 emit mailArrived(mail, FALSE);
149} 149}
150 150
151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) 151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
152{ 152{
153 QString temp, boundary; 153 QString temp, boundary;
154 int pos; 154 int pos;
155 QString delimiter, header, body, mimeHeader, mimeBody; 155 QString delimiter, header, body, mimeHeader, mimeBody;
156 QString content, contentType, contentAttribute, id, encoding; 156 QString content, contentType, contentAttribute, id, encoding;
157 QString fileName, storedName; 157 QString fileName, storedName;
158 int enclosureId = 0; 158 int enclosureId = 0;
159 159
160 mail->rawMail = in; 160 mail->rawMail = in;
161 mail->received = TRUE; 161 mail->received = TRUE;
162 mail->files.setAutoDelete(TRUE); 162 mail->files.setAutoDelete(TRUE);
163 163
164 temp = lineShift + "." + lineShift; 164 temp = lineShift + "." + lineShift;
165 165
166 if (in.right(temp.length()) != temp) { 166 if (in.right(temp.length()) != temp) {
167 mail->rawMail += temp; 167 mail->rawMail += temp;
168 } 168 }
169 169
170 170
171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
172 pos = in.find(delimiter, 0, FALSE); 172 pos = in.find(delimiter, 0, FALSE);
173 header = in.left(pos); 173 header = in.left(pos);
174 body = in.right(in.length() - pos - delimiter.length()); 174 body = in.right(in.length() - pos - delimiter.length());
175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
176 body.truncate(body.length()-2); 176 body.truncate(body.length()-2);
177 177
178 // TextParser p(header, lineShift); 178 // TextParser p(header, lineShift);
179 TextParser * lp = new TextParser(header, lineShift); 179 TextParser * lp = new TextParser(header, lineShift);
180#define p (*lp) 180#define p (*lp)
181 181
182 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { 182 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
183 pos++; 183 pos++;
184 if (p.separatorAt(pos) == ' ') { 184 if (p.separatorAt(pos) == ' ') {
185 mail->from = p.getString(&pos, '<', false); 185 mail->from = p.getString(&pos, '<', false);
186 mail->from = mail->from.stripWhiteSpace(); 186 mail->from = mail->from.stripWhiteSpace();
187 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 187 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
188 mail->from = mail->from.left(mail->from.length() - 1); 188 mail->from = mail->from.left(mail->from.length() - 1);
189 mail->from = mail->from.right(mail->from.length() - 1); 189 mail->from = mail->from.right(mail->from.length() - 1);
190 } 190 }
191 pos++; 191 pos++;
192 mail->fromMail = p.getString(&pos, '>', false); 192 mail->fromMail = p.getString(&pos, '>', false);
193 } else { 193 } else {
194 if (p.separatorAt(pos) == '<') //No name.. nasty 194 if (p.separatorAt(pos) == '<') //No name.. nasty
195 pos++; 195 pos++;
196 //pos++; 196 //pos++;
197 mail->fromMail = p.getString(&pos, 'z', TRUE); 197 mail->fromMail = p.getString(&pos, 'z', TRUE);
198 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 198 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
199 mail->fromMail.truncate(mail->fromMail.length() - 1); 199 mail->fromMail.truncate(mail->fromMail.length() - 1);
200 mail->from=mail->fromMail; 200 mail->from=mail->fromMail;
201 } 201 }
202 } 202 }
203 203
204 pos=0; 204 pos=0;
205 205
206 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: 206 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
207 while((pos = p.find("TO",':', pos+1, TRUE))!=-1) 207 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
208 { 208 {
209 QString rec; 209 QString rec;
210 210
211 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To: 211 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
212 { 212 {
213 pos++; 213 pos++;
214 mail->recipients.append(p.getString(&pos, '\r', TRUE)); 214 mail->recipients.append(p.getString(&pos, '\r', TRUE));
215 } 215 }
216 } 216 }
217 // 217 //
218 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); 218 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
219 219
220 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 220 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
221 { 221 {
222 pos++; 222 pos++;
223 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 223 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
224 } 224 }
225 225
226 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 226 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
227 pos++; 227 pos++;
228 mail->subject = p.getString(&pos, 'z', TRUE); 228 mail->subject = p.getString(&pos, 'z', TRUE);
229 } 229 }
230 230
231 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 231 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
232 pos++; 232 pos++;
233 mail->date = p.getString(&pos, 'z', TRUE); 233 mail->date = p.getString(&pos, 'z', TRUE);
234 } 234 }
235 235
236 236
237 237
238 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { 238 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
239 pos++; 239 pos++;
240 if ( (p.wordAt(pos).upper() == "ID") && 240 if ( (p.wordAt(pos).upper() == "ID") &&
241 (p.separatorAt(pos) == ':') ) { 241 (p.separatorAt(pos) == ':') ) {
242 242
243 id = p.getString(&pos, 'z', TRUE); 243 id = p.getString(&pos, 'z', TRUE);
244 mail->id = id; 244 mail->id = id;
245 } 245 }
246 } 246 }
247 247
248 pos = 0; 248 pos = 0;
249 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { 249 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
250 pos++; 250 pos++;
251 if ( (p.wordAt(pos).upper() == "VERSION") && 251 if ( (p.wordAt(pos).upper() == "VERSION") &&
252 (p.separatorAt(pos) == ':') ) { 252 (p.separatorAt(pos) == ':') ) {
253 pos++; 253 pos++;
254 if (p.getString(&pos, 'z', true) == "1.0") { 254 if (p.getString(&pos, 'z', true) == "1.0") {
255 mail->mimeType = 1; 255 mail->mimeType = 1;
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 if (mail->mimeType == 1) { 260 if (mail->mimeType == 1) {
261 boundary = ""; 261 boundary = "";
262 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { 262 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
263 pos++; 263 pos++;
264 boundary = p.getString(&pos, 'z', true); 264 boundary = p.getString(&pos, 'z', true);
265 if (boundary[0] == '"') { 265 if (boundary[0] == '"') {
266 boundary = boundary.left(boundary.length() - 1); //strip " 266 boundary = boundary.left(boundary.length() - 1); //strip "
267 boundary = boundary.right(boundary.length() - 1); //strip " 267 boundary = boundary.right(boundary.length() - 1); //strip "
268 } 268 }
269 boundary = "--" + boundary; //create boundary field 269 boundary = "--" + boundary; //create boundary field
270 } 270 }
271 271
272 if (boundary == "") { //fooled by Mime-Version 272 if (boundary == "") { //fooled by Mime-Version
273 mail->body = body; 273 mail->body = body;
274 mail->bodyPlain = body; 274 mail->bodyPlain = body;
275 delete lp; 275 delete lp;
276 return mail; 276 return mail;
277 } 277 }
278 278
279 while (body.length() > 0) { 279 while (body.length() > 0) {
280 pos = body.find(boundary, 0, FALSE); 280 pos = body.find(boundary, 0, FALSE);
281 pos = body.find(delimiter, pos, FALSE); 281 pos = body.find(delimiter, pos, FALSE);
282 mimeHeader = body.left(pos); 282 mimeHeader = body.left(pos);
283 mimeBody = body.right(body.length() - pos - delimiter.length()); 283 mimeBody = body.right(body.length() - pos - delimiter.length());
284 TextParser bp(mimeHeader, lineShift); 284 TextParser bp(mimeHeader, lineShift);
285 285
286 contentType = ""; 286 contentType = "";
287 contentAttribute = ""; 287 contentAttribute = "";
288 fileName = ""; 288 fileName = "";
289 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { 289 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
290 pos++; 290 pos++;
291 if ( (bp.wordAt(pos).upper() == "TYPE") && 291 if ( (bp.wordAt(pos).upper() == "TYPE") &&
292 (bp.separatorAt(pos) == ':') ) { 292 (bp.separatorAt(pos) == ':') ) {
293 contentType = bp.nextWord().upper(); 293 contentType = bp.nextWord().upper();
294 if (bp.nextSeparator() == '/') 294 if (bp.nextSeparator() == '/')
295 contentAttribute = bp.nextWord().upper(); 295 contentAttribute = bp.nextWord().upper();
296 content = contentType + "/" + contentAttribute; 296 content = contentType + "/" + contentAttribute;
297 } 297 }
298 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { 298 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
299 pos++; 299 pos++;
300 encoding = bp.getString(&pos, 'z', TRUE); 300 encoding = bp.getString(&pos, 'z', TRUE);
301 } 301 }
302 302
303 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { 303 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
304 pos++; 304 pos++;
305 fileName = bp.getString(&pos, 'z', TRUE); 305 fileName = bp.getString(&pos, 'z', TRUE);
306 fileName = fileName.right(fileName.length() - 1); 306 fileName = fileName.right(fileName.length() - 1);
307 fileName = fileName.left(fileName.length() - 1); 307 fileName = fileName.left(fileName.length() - 1);
308 } 308 }
309 309
310 } 310 }
311 pos = mimeBody.find(boundary, 0, FALSE); 311 pos = mimeBody.find(boundary, 0, FALSE);
312 if (pos == -1) //should not occur, malformed mail 312 if (pos == -1) //should not occur, malformed mail
313 pos = mimeBody.length(); 313 pos = mimeBody.length();
314 body = mimeBody.right(mimeBody.length() - pos); 314 body = mimeBody.right(mimeBody.length() - pos);
315 mimeBody = mimeBody.left(pos); 315 mimeBody = mimeBody.left(pos);
316 316
317 if (fileName != "") { //attatchments of some type, audio, image etc. 317 if (fileName != "") { //attatchments of some type, audio, image etc.
318 318
319 Enclosure e; 319 Enclosure e;
320 e.id = enclosureId; 320 e.id = enclosureId;
321 e.originalName = fileName; 321 e.originalName = fileName;
322 e.contentType = contentType; 322 e.contentType = contentType;
323 e.contentAttribute = contentAttribute; 323 e.contentAttribute = contentAttribute;
324 e.encoding = encoding; 324 e.encoding = encoding;
325 e.body = mimeBody; 325 e.body = mimeBody;
326 e.saved = FALSE; 326 e.saved = FALSE;
327 mail->addEnclosure(&e); 327 mail->addEnclosure(&e);
328 enclosureId++; 328 enclosureId++;
329 329
330 } else if (contentType == "TEXT") { 330 } else if (contentType == "TEXT") {
331 if (contentAttribute == "PLAIN") { 331 if (contentAttribute == "PLAIN") {
332 mail->body = mimeBody; 332 mail->body = mimeBody;
333 mail->bodyPlain = mimeBody; 333 mail->bodyPlain = mimeBody;
334 } 334 }
335 if (contentAttribute == "HTML") { 335 if (contentAttribute == "HTML") {
336 mail->body = mimeBody; 336 mail->body = mimeBody;
337 } 337 }
338 } 338 }
339 } 339 }
340 } else { 340 } else {
341 mail->bodyPlain = body; 341 mail->bodyPlain = body;
342 mail->body = body; 342 mail->body = body;
343 } 343 }
344 delete lp; 344 delete lp;
345 return TRUE; 345 return TRUE;
346} 346}
347 347
348bool EmailHandler::getEnclosure(Enclosure *ePtr) 348bool EmailHandler::getEnclosure(Enclosure *ePtr)
349{ 349{
350 QFile f(ePtr->path + ePtr->name); 350 QFile f(ePtr->path + ePtr->name);
351 char src[4]; 351 char src[4];
352 char *destPtr; 352 char *destPtr;
353 QByteArray buffer; 353 QByteArray buffer;
354 uint bufCount, pos, decodedCount, size, x; 354 uint bufCount, pos, decodedCount, size, x;
355 355
356 if (! f.open(IO_WriteOnly) ) { 356 if (! f.open(IO_WriteOnly) ) {
357 qWarning("could not save: " + ePtr->path + ePtr->name); 357 qWarning("could not save: " + ePtr->path + ePtr->name);
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h
index e4e7f46..74a8e4c 100644
--- a/noncore/net/mailit/emailhandler.h
+++ b/noncore/net/mailit/emailhandler.h
@@ -1,150 +1,150 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef EmailHandler_H 20#ifndef EmailHandler_H
21#define EmailHandler_H 21#define EmailHandler_H
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlist.h> 26#include <qlist.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qfile.h> 28#include <qfile.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qcollection.h> 30#include <qcollection.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include "smtpclient.h" 33#include "smtpclient.h"
34#include "popclient.h" 34#include "popclient.h"
35#include "textparser.h" 35#include "textparser.h"
36#include "maillist.h" 36#include "maillist.h"
37 37
38struct Enclosure 38struct Enclosure
39{ 39{
40 int id; 40 int id;
41 QString originalName; 41 QString originalName;
42 QString name; 42 QString name;
43 QString path; 43 QString path;
44 QString contentType; 44 QString contentType;
45 QString contentAttribute; 45 QString contentAttribute;
46 QString encoding; 46 QString encoding;
47 QString body; //might use to much mem. check!! 47 QString body; //might use to much mem. check!!
48 bool saved, installed; 48 bool saved, installed;
49}; 49};
50 50
51class EnclosureList : public QList<Enclosure> 51class EnclosureList : public QList<Enclosure>
52{ 52{
53public: 53public:
54 Item newItem(Item d); 54 Item newItem(Item d);
55private: 55private:
56 Enclosure* dupl(Enclosure *in); 56 Enclosure* dupl(Enclosure *in);
57 Enclosure *ac; 57 Enclosure *ac;
58}; 58};
59 59
60struct Email 60struct Email
61{ 61{
62 QString id; 62 QString id;
63 QString from; 63 QString from;
64 QString fromMail; 64 QString fromMail;
65 QStringList recipients; 65 QStringList recipients;
66 QStringList carbonCopies; 66 QStringList carbonCopies;
67 QString date; 67 QString date;
68 QString subject; 68 QString subject;
69 QString body; 69 QString body;
70 QString bodyPlain; 70 QString bodyPlain;
71 bool sent, received, read, downloaded; 71 bool sent, received, read, downloaded;
72 QString rawMail; 72 QString rawMail;
73 int mimeType; //1 = Mime 1.0 73 int mimeType; //1 = Mime 1.0
74 int serverId; 74 int serverId;
75 int internalId; 75 int internalId;
76 int fromAccountId; 76 int fromAccountId;
77 QString contentType; //0 = text 77 QString contentType; //0 = text
78 QString contentAttribute; //0 = plain, 1 = html 78 QString contentAttribute; //0 = plain, 1 = html
79 EnclosureList files; 79 EnclosureList files;
80 uint size; 80 uint size;
81 81
82 void addEnclosure(Enclosure *e) 82 void addEnclosure(Enclosure *e)
83 { 83 {
84 files.append(e); 84 files.append(e);
85 } 85 }
86}; 86};
87 87
88struct MailAccount 88struct MailAccount
89{ 89{
90 QString accountName; 90 QString accountName;
91 QString name; 91 QString name;
92 QString emailAddress; 92 QString emailAddress;
93 QString popUserName; 93 QString popUserName;
94 QString popPasswd; 94 QString popPasswd;
95 QString popServer; 95 QString popServer;
96 QString smtpServer; 96 QString smtpServer;
97 bool synchronize; 97 bool synchronize;
98 int syncLimit; 98 int syncLimit;
99 int lastServerMailCount; 99 int lastServerMailCount;
100 int id; 100 int id;
101}; 101};
102 102
103 const int ErrUnknownResponse = 1001; 103 const int ErrUnknownResponse = 1001;
104 const int ErrLoginFailed = 1002; 104 const int ErrLoginFailed = 1002;
105 const int ErrCancel = 1003; 105 const int ErrCancel = 1003;
106 106
107 107
108class EmailHandler : public QObject 108class EmailHandler : public QObject
109{ 109{
110 Q_OBJECT 110 Q_OBJECT
111 111
112public: 112public:
113 EmailHandler(); 113 EmailHandler();
114 void setAccount(MailAccount account); 114 void setAccount(MailAccount account);
115 MailAccount* getAccount(){return &mailAccount;} 115 MailAccount* getAccount(){return &mailAccount;}
116 void sendMail(QList<Email> *mailList); 116 void sendMail(QList<Email> *mailList);
117 void getMail(); 117 void getMail();
118 void getMailHeaders(); 118 void getMailHeaders();
119 void getMailByList(MailList *mailList); 119 void getMailByList(MailList *mailList);
120 bool parse(const QString &in, const 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(const QString &fileName, QString *toBody); 124 int encodeFile(const QString &fileName, QString *toBody);
125 void encode64base(char *src, QString *dest, int len); 125 void encode64base(char *src, QString *dest, int len);
126 void cancel(); 126 void cancel();
127 127
128signals: 128signals:
129 void mailSent(); 129 void mailSent();
130 void smtpError(int); 130 void smtpError(int, const QString & Msg );
131 void popError(int); 131 void popError(int, const QString & Msg );
132 void mailArrived(const Email &, bool); 132 void mailArrived(const Email &, bool);
133 void updatePopStatus(const QString &); 133 void updatePopStatus(const QString &);
134 void updateSmtpStatus(const QString &); 134 void updateSmtpStatus(const QString &);
135 void mailTransfered(int); 135 void mailTransfered(int);
136 void mailboxSize(int); 136 void mailboxSize(int);
137 void currentMailSize(int); 137 void currentMailSize(int);
138 void downloadedSize(int); 138 void downloadedSize(int);
139 139
140public slots: 140public slots:
141 void messageArrived(const QString &, int id, uint size, bool complete); 141 void messageArrived(const QString &, int id, uint size, bool complete);
142 142
143private: 143private:
144 MailAccount mailAccount; 144 MailAccount mailAccount;
145 SmtpClient *smtpClient; 145 SmtpClient *smtpClient;
146 PopClient *popClient; 146 PopClient *popClient;
147 bool headers; 147 bool headers;
148}; 148};
149 149
150#endif 150#endif
diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro
index cfbda36..5e9a83a 100644
--- a/noncore/net/mailit/mailit.pro
+++ b/noncore/net/mailit/mailit.pro
@@ -1,62 +1,63 @@
1TEMPLATE = app 1TEMPLATE = app
2TARGET = mailit
2CONFIG = qt warn_on release 3CONFIG = qt warn_on release
3HEADERS = emailclient.h \ 4HEADERS = emailclient.h \
4 emailhandler.h \ 5 emailhandler.h \
5 emaillistitem.h \ 6 emaillistitem.h \
6 mailitwindow.h \ 7 mailitwindow.h \
7 md5.h \ 8 md5.h \
8 popclient.h \ 9 popclient.h \
9 readmail.h \ 10 readmail.h \
10 smtpclient.h \ 11 smtpclient.h \
11 writemail.h \ 12 writemail.h \
12 textparser.h \ 13 textparser.h \
13 viewatt.h \ 14 viewatt.h \
14 addatt.h \ 15 addatt.h \
15 editaccount.h \ 16 editaccount.h \
16 maillist.h \ 17 maillist.h \
17 addresslist.h 18 addresslist.h
18SOURCES = emailclient.cpp \ 19SOURCES = emailclient.cpp \
19 emailhandler.cpp \ 20 emailhandler.cpp \
20 emaillistitem.cpp \ 21 emaillistitem.cpp \
21 mailitwindow.cpp \ 22 mailitwindow.cpp \
22 main.cpp \ 23 main.cpp \
23 md5.c \ 24 md5.c \
24 popclient.cpp \ 25 popclient.cpp \
25 readmail.cpp \ 26 readmail.cpp \
26 smtpclient.cpp \ 27 smtpclient.cpp \
27 writemail.cpp \ 28 writemail.cpp \
28 textparser.cpp \ 29 textparser.cpp \
29 viewatt.cpp \ 30 viewatt.cpp \
30 addatt.cpp \ 31 addatt.cpp \
31 editaccount.cpp \ 32 editaccount.cpp \
32 maillist.cpp \ 33 maillist.cpp \
33 addresslist.cpp 34 addresslist.cpp
34 35
35INCLUDEPATH += $(OPIEDIR)/include 36INCLUDEPATH += $(OPIEDIR)/include
36DEPENDPATH += $(OPIEDIR)/include 37DEPENDPATH += $(OPIEDIR)/include
37LIBS += -lqpe -lopie 38LIBS += -lqpe -lopie
38# -lssl 39# -lssl
39MOC_DIR=qpeobj 40MOC_DIR=qpeobj
40OBJECTS_DIR=qpeobj 41OBJECTS_DIR=qpeobj
41DESTDIR=$(OPIEDIR)/bin 42DESTDIR=$(OPIEDIR)/bin
42 43
43TRANSLATIONS = ../../../i18n/de/mailit.ts \ 44TRANSLATIONS = ../../../i18n/de/mailit.ts \
44 ../../../i18n/nl/mailit.ts \ 45 ../../../i18n/nl/mailit.ts \
45 ../../../i18n/da/mailit.ts \ 46 ../../../i18n/da/mailit.ts \
46 ../../../i18n/xx/mailit.ts \ 47 ../../../i18n/xx/mailit.ts \
47 ../../../i18n/it/mailit.ts \ 48 ../../../i18n/it/mailit.ts \
48 ../../../i18n/en/mailit.ts \ 49 ../../../i18n/en/mailit.ts \
49 ../../../i18n/es/mailit.ts \ 50 ../../../i18n/es/mailit.ts \
50 ../../../i18n/fr/mailit.ts \ 51 ../../../i18n/fr/mailit.ts \
51 ../../../i18n/hu/mailit.ts \ 52 ../../../i18n/hu/mailit.ts \
52 ../../../i18n/ja/mailit.ts \ 53 ../../../i18n/ja/mailit.ts \
53 ../../../i18n/ko/mailit.ts \ 54 ../../../i18n/ko/mailit.ts \
54 ../../../i18n/no/mailit.ts \ 55 ../../../i18n/no/mailit.ts \
55 ../../../i18n/pl/mailit.ts \ 56 ../../../i18n/pl/mailit.ts \
56 ../../../i18n/pt/mailit.ts \ 57 ../../../i18n/pt/mailit.ts \
57 ../../../i18n/pt_BR/mailit.ts \ 58 ../../../i18n/pt_BR/mailit.ts \
58 ../../../i18n/sl/mailit.ts \ 59 ../../../i18n/sl/mailit.ts \
59 ../../../i18n/zh_CN/mailit.ts \ 60 ../../../i18n/zh_CN/mailit.ts \
60 ../../../i18n/zh_TW/mailit.ts 61 ../../../i18n/zh_TW/mailit.ts
61 62
62include ( $(OPIEDIR)/include.pro ) 63include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp
index f945a0f..6e298c7 100644
--- a/noncore/net/mailit/mailitwindow.cpp
+++ b/noncore/net/mailit/mailitwindow.cpp
@@ -1,168 +1,168 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qwhatsthis.h> 20#include <qwhatsthis.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include "mailitwindow.h" 22#include "mailitwindow.h"
23 23
24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/)
25 : QMainWindow(parent, name, WStyle_ContextHelp) 25 : QMainWindow(parent, name, WStyle_ContextHelp)
26{ 26{
27 currentCaption = "Mailit"; 27 currentCaption = tr("Mailit");
28 setCaption(tr(currentCaption)); 28 setCaption(tr(currentCaption));
29 views = new QWidgetStack(this); 29 views = new QWidgetStack(this);
30 setCentralWidget(views); 30 setCentralWidget(views);
31 QWhatsThis::add(views,tr("Central view area")); 31 QWhatsThis::add(views,tr("Central view area"));
32 emailClient = new EmailClient(views, "client"); 32 emailClient = new EmailClient(views, "client");
33 writeMail = new WriteMail(views, "writing"); 33 writeMail = new WriteMail(views, "writing");
34 readMail = new ReadMail(views, "reading"); 34 readMail = new ReadMail(views, "reading");
35 35
36 views->raiseWidget(emailClient); 36 views->raiseWidget(emailClient);
37 37
38 connect(emailClient, SIGNAL(composeRequested()), 38 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) ); 39 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) ); 41 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) ); 43 SLOT(updateMailView(Email *)) );
44 44
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) ); 47 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) ); 49 SLOT(enqueMail(const Email &)) );
50 50
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, 52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this,
53 SLOT(composeReply(Email &, bool&)) ); 53 SLOT(composeReply(Email &, bool&)) );
54 connect(readMail, SIGNAL(forwardRequested(Email &)), this, 54 connect(readMail, SIGNAL(forwardRequested(Email &)), this,
55 SLOT(composeForward(Email &)) ); 55 SLOT(composeForward(Email &)) );
56 56
57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
58 SLOT(deleteMail(EmailListItem *, bool &)) ); 58 SLOT(deleteMail(EmailListItem *, bool &)) );
59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
60 SLOT(moveMailFront(Email *)) ); 60 SLOT(moveMailFront(Email *)) );
61 61
62 connect(emailClient, SIGNAL(newCaption(const QString &)), 62 connect(emailClient, SIGNAL(newCaption(const QString &)),
63 this, SLOT(updateCaption(const QString &)) ); 63 this, SLOT(updateCaption(const QString &)) );
64 64
65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) ); 65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) );
66 66
67 viewingMail = FALSE; 67 viewingMail = FALSE;
68} 68}
69 69
70MailItWindow::~MailItWindow() 70MailItWindow::~MailItWindow()
71{ 71{
72} 72}
73 73
74void MailItWindow::closeEvent(QCloseEvent *e) 74void MailItWindow::closeEvent(QCloseEvent *e)
75{ 75{
76 if (views->visibleWidget() == emailClient) { 76 if (views->visibleWidget() == emailClient) {
77 e->accept(); 77 e->accept();
78 } else { 78 } else {
79 showEmailClient(); 79 showEmailClient();
80 } 80 }
81} 81}
82 82
83void MailItWindow::compose() 83void MailItWindow::compose()
84{ 84{
85 viewingMail = FALSE; 85 viewingMail = FALSE;
86 emailClient->hide(); 86 emailClient->hide();
87 readMail->hide(); 87 readMail->hide();
88 views->raiseWidget(writeMail); 88 views->raiseWidget(writeMail);
89 writeMail->setAddressList(emailClient->getAdrListRef()); 89 writeMail->setAddressList(emailClient->getAdrListRef());
90 writeMail->newMail(); 90 writeMail->newMail();
91 setCaption( tr( "Write mail" ) ); 91 setCaption( tr( "Write mail" ) );
92} 92}
93 93
94void MailItWindow::composeReply(Email &mail, bool& replyAll) 94void MailItWindow::composeReply(Email &mail, bool& replyAll)
95{ 95{
96 compose(); 96 compose();
97 writeMail->reply(mail,replyAll) ; 97 writeMail->reply(mail,replyAll) ;
98} 98}
99 99
100void MailItWindow::composeForward(Email &mail) 100void MailItWindow::composeForward(Email &mail)
101{ 101{
102 compose(); 102 compose();
103 writeMail->forward(mail) ; 103 writeMail->forward(mail) ;
104} 104}
105 105
106 106
107void MailItWindow::showEmailClient() 107void MailItWindow::showEmailClient()
108{ 108{
109 viewingMail = FALSE; 109 viewingMail = FALSE;
110 writeMail->hide(); 110 writeMail->hide();
111 readMail->hide(); 111 readMail->hide();
112 views->raiseWidget(emailClient); 112 views->raiseWidget(emailClient);
113 setCaption( tr(currentCaption) ); 113 setCaption( tr(currentCaption) );
114} 114}
115 115
116void MailItWindow::viewMail(QListView *view, Email *mail) 116void MailItWindow::viewMail(QListView *view, Email *mail)
117{ 117{
118 viewingMail = TRUE; 118 viewingMail = TRUE;
119 emailClient->hide(); 119 emailClient->hide();
120 120
121 int result=0; 121 int result=0;
122 122
123 if ((mail->received)&&(!mail->downloaded)) 123 if ((mail->received)&&(!mail->downloaded))
124 { 124 {
125 QMessageBox mb( tr("Mail not downloaded"), 125 QMessageBox mb( tr("Mail not downloaded"),
126 tr("The mail you have clicked \n" 126 tr("The mail you have clicked \n"
127 "has not been downloaded yet.\n " 127 "has not been downloaded yet.\n "
128 "Would you like to do it now ?"), 128 "Would you like to do it now ?"),
129 QMessageBox::Information, 129 QMessageBox::Information,
130 QMessageBox::Yes | QMessageBox::Default, 130 QMessageBox::Yes | QMessageBox::Default,
131 QMessageBox::No | QMessageBox::Escape,0 ); 131 QMessageBox::No | QMessageBox::Escape,0 );
132 132
133 result=mb.exec(); 133 result=mb.exec();
134 134
135 if (result==QMessageBox::Yes) 135 if (result==QMessageBox::Yes)
136 { 136 {
137 emailClient->download(mail); 137 emailClient->download(mail);
138 } 138 }
139 } 139 }
140 140
141 readMail->update(view, mail); 141 readMail->update(view, mail);
142 views->raiseWidget(readMail); 142 views->raiseWidget(readMail);
143 setCaption( tr( "Read Mail" ) ); 143 setCaption( tr( "Read Mail" ) );
144} 144}
145 145
146void MailItWindow::updateMailView(Email *mail) 146void MailItWindow::updateMailView(Email *mail)
147{ 147{
148 if (viewingMail) { 148 if (viewingMail) {
149 readMail->mailUpdated(mail); 149 readMail->mailUpdated(mail);
150 } 150 }
151} 151}
152 152
153void MailItWindow::updateCaption(const QString &newCaption) 153void MailItWindow::updateCaption(const QString &newCaption)
154{ 154{
155 currentCaption = newCaption; 155 currentCaption = newCaption;
156 setCaption(tr(currentCaption)); 156 setCaption(tr(currentCaption));
157} 157}
158 158
159void MailItWindow::setDocument(const QString &_address) 159void MailItWindow::setDocument(const QString &_address)
160{ 160{
161 // strip leading 'mailto:' 161 // strip leading 'mailto:'
162 QString address = _address; 162 QString address = _address;
163 if (address.startsWith("mailto:")) 163 if (address.startsWith("mailto:"))
164 address = address.mid(6); 164 address = address.mid(6);
165 165
166 compose(); 166 compose();
167 writeMail->setRecipient(address); 167 writeMail->setRecipient(address);
168} 168}
diff --git a/noncore/net/mailit/maillist.cpp b/noncore/net/mailit/maillist.cpp
index b5325a9..8c34295 100644
--- a/noncore/net/mailit/maillist.cpp
+++ b/noncore/net/mailit/maillist.cpp
@@ -1,131 +1,131 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "maillist.h" 20#include "maillist.h"
21 21
22void MailList::clear() 22void MailList::clear()
23{ 23{
24 sortedList.setAutoDelete(TRUE); 24 sortedList.setAutoDelete(TRUE);
25 sortedList.clear(); 25 sortedList.clear();
26 currentPos = 0; 26 currentPos = 0;
27} 27}
28 28
29int MailList::count() 29int MailList::count()
30{ 30{
31 return sortedList.count(); 31 return sortedList.count();
32} 32}
33 33
34int* MailList::first() 34int* MailList::first()
35{ 35{
36 dList *mPtr; 36 dList *mPtr;
37 37
38 if (sortedList.count() == 0) 38 if (sortedList.count() == 0)
39 return NULL; 39 return NULL;
40 40
41 mPtr = sortedList.at(0); 41 mPtr = sortedList.at(0);
42 currentPos = 1; 42 currentPos = 1;
43 return &(mPtr->serverId); 43 return &(mPtr->serverId);
44} 44}
45 45
46int* MailList::next() 46int* MailList::next()
47{ 47{
48 dList *mPtr; 48 dList *mPtr;
49 49
50 if ( (currentPos) >= sortedList.count()) 50 if ( (currentPos) >= sortedList.count())
51 return NULL; 51 return NULL;
52 52
53 mPtr = sortedList.at(currentPos); 53 mPtr = sortedList.at(currentPos);
54 currentPos++; 54 currentPos++;
55 return &(mPtr->serverId); 55 return &(mPtr->serverId);
56} 56}
57 57
58void MailList::sizeInsert(int serverId, uint size) 58void MailList::sizeInsert(int serverId, uint size)
59{ 59{
60 dList *tempPtr; 60 dList *tempPtr;
61 int x; 61 int x;
62 62
63 dList *newEntry = new dList; 63 dList *newEntry = new dList;
64 newEntry->serverId = serverId; 64 newEntry->serverId = serverId;
65 newEntry->size = size; 65 newEntry->size = size;
66 66
67 for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) { 67 for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) {
68 if (newEntry->size < tempPtr->size) { 68 if (newEntry->size < tempPtr->size) {
69 x = sortedList.at(); 69 x = sortedList.at();
70 sortedList.insert(x, newEntry); 70 sortedList.insert(x, newEntry);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 sortedList.append(newEntry); 74 sortedList.append(newEntry);
75} 75}
76 76
77void MailList::moveFront(int serverId, uint size) 77void MailList::moveFront(int serverId, uint/* size*/)
78{ 78{
79 dList *currentPtr; 79 dList *currentPtr;
80 uint tempPos; 80 uint tempPos;
81 QString temp; 81 QString temp;
82 82
83 tempPos = currentPos; 83 tempPos = currentPos;
84 if ( tempPos >= sortedList.count() ) 84 if ( tempPos >= sortedList.count() )
85 return; 85 return;
86 currentPtr = sortedList.at(tempPos); 86 currentPtr = sortedList.at(tempPos);
87 while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) { 87 while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
88 tempPos++; 88 tempPos++;
89 currentPtr = sortedList.at(tempPos); 89 currentPtr = sortedList.at(tempPos);
90 } 90 }
91 91
92 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) { 92 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
93 temp.setNum(currentPtr->serverId); 93 temp.setNum(currentPtr->serverId);
94 qWarning("moved to front, message: " + temp); 94 qWarning("moved to front, message: " + temp);
95 95
96 dList *itemPtr = sortedList.take(tempPos); 96 dList *itemPtr = sortedList.take(tempPos);
97 sortedList.insert(currentPos, itemPtr); 97 sortedList.insert(currentPos, itemPtr);
98 } 98 }
99 99
100} 100}
101 101
102//only works if mail is not already in download 102//only works if mail is not already in download
103bool MailList::remove(int serverId, uint size) 103bool MailList::remove(int serverId, uint /*size*/)
104{ 104{
105 dList *currentPtr; 105 dList *currentPtr;
106 uint tempPos; 106 uint tempPos;
107 QString temp; 107 QString temp;
108 108
109 tempPos = currentPos; 109 tempPos = currentPos;
110 if ( tempPos >=sortedList.count() ) 110 if ( tempPos >=sortedList.count() )
111 return FALSE; 111 return FALSE;
112 currentPtr = sortedList.at(tempPos); 112 currentPtr = sortedList.at(tempPos);
113 while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) { 113 while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
114 tempPos++; 114 tempPos++;
115 currentPtr = sortedList.at(tempPos); 115 currentPtr = sortedList.at(tempPos);
116 } 116 }
117 117
118 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) { 118 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
119 temp.setNum(currentPtr->serverId); 119 temp.setNum(currentPtr->serverId);
120 qWarning("deleted message: " + temp); 120 qWarning("deleted message: " + temp);
121 sortedList.remove(tempPos); 121 sortedList.remove(tempPos);
122 122
123 return TRUE; 123 return TRUE;
124 } 124 }
125 return FALSE; 125 return FALSE;
126} 126}
127 127
128void MailList::insert(int pos, int serverId, uint size) 128void MailList::insert(int /*pos*/, int /*serverId*/, uint/* size*/)
129{ 129{
130 //sortedList.insert(pos, mPtr); 130// sortedList.insert(pos, mPtr);
131} 131}
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index dc0116d..5da3bcb 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -1,327 +1,331 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "popclient.h" 20#include "popclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22//#define APOP_TEST 22//#define APOP_TEST
23 23
24extern "C" { 24extern "C" {
25#include "md5.h" 25#include "md5.h"
26} 26}
27 27
28#include <qcstring.h> 28#include <qcstring.h>
29 29
30PopClient::PopClient() 30PopClient::PopClient()
31{ 31{
32 32
33 socket = new QSocket(this, "popClient"); 33 socket = new QSocket(this, "popClient");
34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
37 37
38 stream = new QTextStream(socket); 38 stream = new QTextStream(socket);
39 39
40 receiving = FALSE; 40 receiving = FALSE;
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 preview = FALSE; 44 preview = FALSE;
45} 45}
46 46
47PopClient::~PopClient() 47PopClient::~PopClient()
48{ 48{
49 delete socket; 49 delete socket;
50 delete stream; 50 delete stream;
51} 51}
52 52
53void PopClient::newConnection(const QString &target, int port) 53void PopClient::newConnection(const QString &target, int port)
54{ 54{
55 if (receiving) { 55 if (receiving) {
56 qWarning("socket in use, connection refused"); 56 qWarning("socket in use, connection refused");
57 return; 57 return;
58 } 58 }
59 59
60 status = Init; 60 status = Init;
61 61
62 socket->connectToHost(target, port); 62 socket->connectToHost(target, port);
63 receiving = TRUE; 63 receiving = TRUE;
64 //selected = FALSE; 64 //selected = FALSE;
65 65
66 emit updateStatus("DNS lookup"); 66 emit updateStatus(tr("DNS lookup"));
67} 67}
68 68
69void PopClient::setAccount(const QString &popUser, const QString &popPasswd) 69void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 70{
71 popUserName = popUser; 71 popUserName = popUser;
72 popPassword = popPasswd; 72 popPassword = popPasswd;
73} 73}
74 74
75void PopClient::setSynchronize(int lastCount) 75void PopClient::setSynchronize(int lastCount)
76{ 76{
77 synchronize = TRUE; 77 synchronize = TRUE;
78 lastSync = lastCount; 78 lastSync = lastCount;
79} 79}
80 80
81void PopClient::removeSynchronize() 81void PopClient::removeSynchronize()
82{ 82{
83 synchronize = FALSE; 83 synchronize = FALSE;
84 lastSync = 0; 84 lastSync = 0;
85} 85}
86 86
87void PopClient::headersOnly(bool headers, int limit) 87void PopClient::headersOnly(bool headers, int limit)
88{ 88{
89 preview = headers; 89 preview = headers;
90 headerLimit = limit; 90 headerLimit = limit;
91} 91}
92 92
93void PopClient::setSelectedMails(MailList *list) 93void PopClient::setSelectedMails(MailList *list)
94{ 94{
95 selected = TRUE; 95 selected = TRUE;
96 mailList = list; 96 mailList = list;
97} 97}
98 98
99void PopClient::connectionEstablished() 99void PopClient::connectionEstablished()
100{ 100{
101 emit updateStatus(tr("Connection established")); 101 emit updateStatus(tr("Connection established"));
102} 102}
103 103
104void PopClient::errorHandling(int status) 104void PopClient::errorHandling(int status)
105{ 105{
106 errorHandlingWithMsg( status, QString::null );
107}
108void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
109{
106 emit updateStatus(tr("Error Occured")); 110 emit updateStatus(tr("Error Occured"));
107 emit errorOccurred(status); 111 emit errorOccurred(status, Msg);
108 socket->close(); 112 socket->close();
109 receiving = FALSE; 113 receiving = FALSE;
110} 114}
111 115
112void PopClient::incomingData() 116void PopClient::incomingData()
113{ 117{
114 QString response, temp, temp2, timeStamp; 118 QString response, temp, temp2, timeStamp;
115 QString md5Source; 119 QString md5Source;
116 int start, end; 120 int start, end;
117// char *md5Digest; 121// char *md5Digest;
118 char md5Digest[16]; 122 char md5Digest[16];
119// if ( !socket->canReadLine() ) 123// if ( !socket->canReadLine() )
120// return; 124// return;
121 125
122 126
123 response = socket->readLine(); 127 response = socket->readLine();
124 128
125 switch(status) { 129 switch(status) {
126 //logging in 130 //logging in
127 case Init: { 131 case Init: {
128#ifdef APOP_TEST 132#ifdef APOP_TEST
129 start = response.find('<',0); 133 start = response.find('<',0);
130 end = response.find('>', start); 134 end = response.find('>', start);
131 if( start >= 0 && end > start ) 135 if( start >= 0 && end > start )
132 { 136 {
133 timeStamp = response.mid( start , end - start + 1); 137 timeStamp = response.mid( start , end - start + 1);
134 md5Source = timeStamp + popPassword; 138 md5Source = timeStamp + popPassword;
135 139
136 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 140 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
137 141
138 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 142 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
139 { 143 {
140 printf("%x", md5Digest[j]); 144 printf("%x", md5Digest[j]);
141 } 145 }
142 printf("\n"); 146 printf("\n");
143// qDebug(md5Digest); 147// qDebug(md5Digest);
144 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 148 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
145 // qDebug("%s", stream); 149 // qDebug("%s", stream);
146 status = Stat; 150 status = Stat;
147 } 151 }
148 else 152 else
149#endif 153#endif
150 { 154 {
151 timeStamp = ""; 155 timeStamp = "";
152 *stream << "USER " << popUserName << "\r\n"; 156 *stream << "USER " << popUserName << "\r\n";
153 status = Pass; 157 status = Pass;
154 } 158 }
155 159
156 break; 160 break;
157 } 161 }
158 162
159 case Pass: { 163 case Pass: {
160 *stream << "PASS " << popPassword << "\r\n"; 164 *stream << "PASS " << popPassword << "\r\n";
161 status = Stat; 165 status = Stat;
162 166
163 break; 167 break;
164 } 168 }
165 //ask for number of messages 169 //ask for number of messages
166 case Stat: { 170 case Stat: {
167 if (response[0] == '+') { 171 if (response[0] == '+') {
168 *stream << "STAT" << "\r\n"; 172 *stream << "STAT" << "\r\n";
169 status = Mcnt; 173 status = Mcnt;
170 } else errorHandling(ErrLoginFailed); 174 } else errorHandlingWithMsg(ErrLoginFailed, response);
171 break; 175 break;
172 } 176 }
173 //get count of messages, eg "+OK 4 900.." -> int 4 177 //get count of messages, eg "+OK 4 900.." -> int 4
174 case Mcnt: { 178 case Mcnt: {
175 if (response[0] == '+') { 179 if (response[0] == '+') {
176 temp = response.replace(0, 4, ""); 180 temp = response.replace(0, 4, "");
177 int x = temp.find(" ", 0); 181 int x = temp.find(" ", 0);
178 temp.truncate((uint) x); 182 temp.truncate((uint) x);
179 newMessages = temp.toInt(); 183 newMessages = temp.toInt();
180 messageCount = 1; 184 messageCount = 1;
181 status = List; 185 status = List;
182 186
183 if (synchronize) { 187 if (synchronize) {
184 //messages deleted from server, reload all 188 //messages deleted from server, reload all
185 if (newMessages < lastSync) 189 if (newMessages < lastSync)
186 lastSync = 0; 190 lastSync = 0;
187 messageCount = 1; 191 messageCount = 1;
188 } 192 }
189 193
190 if (selected) { 194 if (selected) {
191 int *ptr = mailList->first(); 195 int *ptr = mailList->first();
192 if (ptr != 0) { 196 if (ptr != 0) {
193 newMessages++; //to ensure no early jumpout 197 newMessages++; //to ensure no early jumpout
194 messageCount = *ptr; 198 messageCount = *ptr;
195 } else newMessages = 0; 199 } else newMessages = 0;
196 } 200 }
197 201
198 } else errorHandling(ErrUnknownResponse); 202 } else errorHandlingWithMsg(ErrUnknownResponse, response);
199 } 203 }
200 //Read message number x, count upwards to messageCount 204 //Read message number x, count upwards to messageCount
201 case List: { 205 case List: {
202 if (messageCount <= newMessages) { 206 if (messageCount <= newMessages) {
203 *stream << "LIST " << messageCount << "\r\n"; 207 *stream << "LIST " << messageCount << "\r\n";
204 status = Size; 208 status = Size;
205 temp2.setNum(newMessages - lastSync); 209 temp2.setNum(newMessages - lastSync);
206 temp.setNum(messageCount - lastSync); 210 temp.setNum(messageCount - lastSync);
207 if (!selected) { 211 if (!selected) {
208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 212 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
209 } else { 213 } else {
210 //completing a previously closed transfer 214 //completing a previously closed transfer
211 /* if ( (messageCount - lastSync) <= 0) { 215 /* if ( (messageCount - lastSync) <= 0) {
212 temp.setNum(messageCount); 216 temp.setNum(messageCount);
213 emit updateStatus(tr("Previous message ") + temp); 217 emit updateStatus(tr("Previous message ") + temp);
214 } else {*/ 218 } else {*/
215 emit updateStatus(tr("Completing message ") + temp); 219 emit updateStatus(tr("Completing message ") + temp);
216 //} 220 //}
217 } 221 }
218 break; 222 break;
219 } else { 223 } else {
220 emit updateStatus(tr("No new Messages")); 224 emit updateStatus(tr("No new Messages"));
221 status = Quit; 225 status = Quit;
222 } 226 }
223 } 227 }
224 //get size of message, eg "500 characters in message.." -> int 500 228 //get size of message, eg "500 characters in message.." -> int 500
225 case Size: { 229 case Size: {
226 if (status != Quit) { //because of idiotic switch 230 if (status != Quit) { //because of idiotic switch
227 if (response[0] == '+') { 231 if (response[0] == '+') {
228 temp = response.replace(0, 4, ""); 232 temp = response.replace(0, 4, "");
229 int x = temp.find(" ", 0); 233 int x = temp.find(" ", 0);
230 temp = temp.right(temp.length() - ((uint) x + 1) ); 234 temp = temp.right(temp.length() - ((uint) x + 1) );
231 mailSize = temp.toInt(); 235 mailSize = temp.toInt();
232 emit currentMailSize(mailSize); 236 emit currentMailSize(mailSize);
233 237
234 status = Retr; 238 status = Retr;
235 } else { 239 } else {
236 //qWarning(response); 240 //qWarning(response);
237 errorHandling(ErrUnknownResponse); 241 errorHandlingWithMsg(ErrUnknownResponse, response);
238 } 242 }
239 } 243 }
240 } 244 }
241 //Read message number x, count upwards to messageCount 245 //Read message number x, count upwards to messageCount
242 case Retr: { 246 case Retr: {
243 if (status != Quit) { 247 if (status != Quit) {
244 if ((selected)||(mailSize <= headerLimit)) 248 if ((selected)||(mailSize <= headerLimit))
245 { 249 {
246 *stream << "RETR " << messageCount << "\r\n"; 250 *stream << "RETR " << messageCount << "\r\n";
247 } else { //only header 251 } else { //only header
248 *stream << "TOP " << messageCount << " 0\r\n"; 252 *stream << "TOP " << messageCount << " 0\r\n";
249 } 253 }
250 messageCount++; 254 messageCount++;
251 status = Ignore; 255 status = Ignore;
252 break; 256 break;
253 } } 257 } }
254 case Ignore: { 258 case Ignore: {
255 if (status != Quit) { //because of idiotic switch 259 if (status != Quit) { //because of idiotic switch
256 if (response[0] == '+') { 260 if (response[0] == '+') {
257 message = ""; 261 message = "";
258 status = Read; 262 status = Read;
259 if (!socket->canReadLine()) //sync. problems 263 if (!socket->canReadLine()) //sync. problems
260 break; 264 break;
261 response = socket->readLine(); 265 response = socket->readLine();
262 } else errorHandling(ErrUnknownResponse); 266 } else errorHandlingWithMsg(ErrUnknownResponse, response);
263 } 267 }
264 } 268 }
265 //add all incoming lines to body. When size is reached, send 269 //add all incoming lines to body. When size is reached, send
266 //message, and go back to read new message 270 //message, and go back to read new message
267 case Read: { 271 case Read: {
268 if (status != Quit) { //because of idiotic switch 272 if (status != Quit) { //because of idiotic switch
269 message += response; 273 message += response;
270 while ( socket->canReadLine() ) { 274 while ( socket->canReadLine() ) {
271 response = socket->readLine(); 275 response = socket->readLine();
272 message += response; 276 message += response;
273 } 277 }
274 emit downloadedSize(message.length()); 278 emit downloadedSize(message.length());
275 int x = message.find("\r\n.\r\n",-5); 279 int x = message.find("\r\n.\r\n",-5);
276 if (x == -1) { 280 if (x == -1) {
277 break; 281 break;
278 } else { //message reach entire size 282 } else { //message reach entire size
279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 283 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
280 { 284 {
281 emit newMessage(message, messageCount-1, mailSize, TRUE); 285 emit newMessage(message, messageCount-1, mailSize, TRUE);
282 } else { //incomplete mail downloaded 286 } else { //incomplete mail downloaded
283 emit newMessage(message, messageCount-1, mailSize, FALSE); 287 emit newMessage(message, messageCount-1, mailSize, FALSE);
284 } 288 }
285 289
286 if ((messageCount > newMessages)||(selected)) //last message ? 290 if ((messageCount > newMessages)||(selected)) //last message ?
287 { 291 {
288 status = Quit; 292 status = Quit;
289 if (selected) { //grab next from queue 293 if (selected) { //grab next from queue
290 newMessages--; 294 newMessages--;
291 status = Quit; 295 status = Quit;
292 } 296 }
293 } 297 }
294 else 298 else
295 { 299 {
296 *stream << "LIST " << messageCount << "\r\n"; 300 *stream << "LIST " << messageCount << "\r\n";
297 status = Size; 301 status = Size;
298 temp2.setNum(newMessages - lastSync); 302 temp2.setNum(newMessages - lastSync);
299 temp.setNum(messageCount - lastSync); 303 temp.setNum(messageCount - lastSync);
300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 304 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
301 305
302 break; 306 break;
303 } 307 }
304 } 308 }
305 } 309 }
306 if (status != Quit) 310 if (status != Quit)
307 break; 311 break;
308 } 312 }
309 case Quit: { 313 case Quit: {
310 *stream << "Quit\r\n"; 314 *stream << "Quit\r\n";
311 status = Done; 315 status = Done;
312 int newM = newMessages - lastSync; 316 int newM = newMessages - lastSync;
313 if (newM > 0) { 317 if (newM > 0) {
314 temp.setNum(newM); 318 temp.setNum(newM);
315 emit updateStatus(temp + tr(" new messages")); 319 emit updateStatus(temp + tr(" new messages"));
316 } else { 320 } else {
317 emit updateStatus(tr("No new messages")); 321 emit updateStatus(tr("No new messages"));
318 } 322 }
319 323
320 socket->close(); 324 socket->close();
321 receiving = FALSE; 325 receiving = FALSE;
322 emit mailTransfered(newM); 326 emit mailTransfered(newM);
323 break; 327 break;
324 } 328 }
325 } 329 }
326 330
327} 331}
diff --git a/noncore/net/mailit/popclient.h b/noncore/net/mailit/popclient.h
index c58bc48..6774ceb 100644
--- a/noncore/net/mailit/popclient.h
+++ b/noncore/net/mailit/popclient.h
@@ -1,76 +1,77 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PopClient_H 20#ifndef PopClient_H
21#define PopClient_H 21#define PopClient_H
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qlist.h> 28#include <qlist.h>
29#include "maillist.h" 29#include "maillist.h"
30 30
31class PopClient: public QObject 31class PopClient: public QObject
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 PopClient(); 36 PopClient();
37 ~PopClient(); 37 ~PopClient();
38 void newConnection(const QString &target, int port); 38 void newConnection(const QString &target, int port);
39 void setAccount(const QString &popUser, const QString &popPasswd); 39 void setAccount(const QString &popUser, const QString &popPasswd);
40 void setSynchronize(int lastCount); 40 void setSynchronize(int lastCount);
41 void removeSynchronize(); 41 void removeSynchronize();
42 void headersOnly(bool headers, int limit); 42 void headersOnly(bool headers, int limit);
43 void setSelectedMails(MailList *list); 43 void setSelectedMails(MailList *list);
44 44
45signals: 45signals:
46 void newMessage(const QString &, int, uint, bool); 46 void newMessage(const QString &, int, uint, bool);
47 void errorOccurred(int status); 47 void errorOccurred(int status, const QString & Msg );
48 void updateStatus(const QString &); 48 void updateStatus(const QString &);
49 void mailTransfered(int); 49 void mailTransfered(int);
50 void mailboxSize(int); 50 void mailboxSize(int);
51 void currentMailSize(int); 51 void currentMailSize(int);
52 void downloadedSize(int); 52 void downloadedSize(int);
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & );
56 57
57protected slots: 58protected slots:
58 void connectionEstablished(); 59 void connectionEstablished();
59 void incomingData(); 60 void incomingData();
60 61
61private: 62private:
62 QSocket *socket; 63 QSocket *socket;
63 QTextStream *stream; 64 QTextStream *stream;
64 enum transferStatus 65 enum transferStatus
65 { 66 {
66 Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks, 67 Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks,
67 Quit, Done, Ignore 68 Quit, Done, Ignore
68 }; 69 };
69 int status, lastSync; 70 int status, lastSync;
70 int messageCount, newMessages, mailSize, headerLimit; 71 int messageCount, newMessages, mailSize, headerLimit;
71 bool receiving, synchronize, preview, selected; 72 bool receiving, synchronize, preview, selected;
72 QString popUserName, popPassword, message; 73 QString popUserName, popPassword, message;
73 MailList *mailList; 74 MailList *mailList;
74}; 75};
75 76
76#endif 77#endif
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 2916f45..5b5ef52 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -1,163 +1,170 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "smtpclient.h" 20#include "smtpclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22 22
23SmtpClient::SmtpClient() 23SmtpClient::SmtpClient()
24{ 24{
25 socket = new QSocket(this, "smtpClient"); 25 socket = new QSocket(this, "smtpClient");
26 stream = new QTextStream(socket); 26 stream = new QTextStream(socket);
27 mailList.setAutoDelete(TRUE); 27 mailList.setAutoDelete(TRUE);
28 28
29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(const QString &target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 emit errorOccurred(status); 76 errorHandlingWithMsg( status, QString::null );
77}
78
79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
80{
81 emit errorOccurred(status, EMsg );
77 socket->close(); 82 socket->close();
78 mailList.clear(); 83 mailList.clear();
79 sending = FALSE; 84 sending = FALSE;
80} 85}
81 86
82void SmtpClient::incomingData() 87void SmtpClient::incomingData()
83{ 88{
84 QString response; 89 QString response;
85 90
86 if (!socket->canReadLine()) 91 if (!socket->canReadLine())
87 return; 92 return;
88 93
89 response = socket->readLine(); 94 response = socket->readLine();
90
91 switch(status) { 95 switch(status) {
92 case Init: { 96 case Init: {
93 if (response[0] == '2') { 97 if (response[0] == '2') {
94 status = From; 98 status = From;
95 mailPtr = mailList.first(); 99 mailPtr = mailList.first();
96 *stream << "HELO there\r\n"; 100 *stream << "HELO there\r\n";
97 } else errorHandling(ErrUnknownResponse); 101 } else errorHandlingWithMsg(ErrUnknownResponse,response);
98 break; 102 break;
99 } 103 }
100 case From: { 104 case From: {
101 if (response[0] == '2') { 105 if (response[0] == '2') {
102 *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; 106 qDebug(mailPtr->from);
107 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n";
103 status = Recv; 108 status = Recv;
104 } else errorHandling(ErrUnknownResponse); 109 } else errorHandlingWithMsg(ErrUnknownResponse, response );
105 break; 110 break;
106 } 111 }
107 case Recv: { 112 case Recv: {
108 if (response[0] == '2') { 113 if (response[0] == '2') {
109 it = mailPtr->to.begin(); 114 it = mailPtr->to.begin();
110 if (it == NULL) 115 if (it == NULL) {
111 errorHandling(ErrUnknownResponse); 116 errorHandlingWithMsg(ErrUnknownResponse,response);
112 *stream << "RCPT TO: " << *it << ">\r\n"; 117 }
118 *stream << "RCPT TO: <" << *it << ">\r\n";
113 status = MRcv; 119 status = MRcv;
114 } else errorHandling(ErrUnknownResponse); 120 } else errorHandlingWithMsg(ErrUnknownResponse,response);
115 break; 121 break;
116 } 122 }
117 case MRcv: { 123 case MRcv: {
118 if (response[0] == '2') { 124 if (response[0] == '2') {
119 it++; 125 it++;
120 if ( it != mailPtr->to.end() ) { 126 if ( it != mailPtr->to.end() ) {
121 *stream << "RCPT TO: <" << *it << ">\r\n"; 127 *stream << "RCPT TO: <" << *it << ">\r\n";
122 break; 128 break;
123 } else { 129 } else {
124 status = Data; 130 status = Data;
125 } 131 }
126 } else errorHandling(ErrUnknownResponse); 132 } else errorHandlingWithMsg(ErrUnknownResponse,response);
127 } 133 }
128 case Data: { 134 case Data: {
129 if (response[0] == '2') { 135 if (response[0] == '2') {
130 *stream << "DATA\r\n"; 136 *stream << "DATA\r\n";
131 status = Body; 137 status = Body;
132 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
133 } else errorHandling(ErrUnknownResponse); 139
140 } else errorHandlingWithMsg(ErrUnknownResponse,response);
134 break; 141 break;
135 } 142 }
136 case Body: { 143 case Body: {
137 if (response[0] == '3') { 144 if (response[0] == '3') {
138 *stream << mailPtr->body << "\r\n.\r\n"; 145 *stream << mailPtr->body << "\r\n.\r\n";
139 mailPtr = mailList.next(); 146 mailPtr = mailList.next();
140 if (mailPtr != NULL) { 147 if (mailPtr != NULL) {
141 status = From; 148 status = From;
142 } else { 149 } else {
143 status = Quit; 150 status = Quit;
144 } 151 }
145 } else errorHandling(ErrUnknownResponse); 152 } else errorHandlingWithMsg(ErrUnknownResponse,response);
146 break; 153 break;
147 } 154 }
148 case Quit: { 155 case Quit: {
149 if (response[0] == '2') { 156 if (response[0] == '2') {
150 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
151 status = Done; 158 status = Done;
152 QString temp; 159 QString temp;
153 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
154 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
155 emit mailSent(); 162 emit mailSent();
156 mailList.clear(); 163 mailList.clear();
157 sending = FALSE; 164 sending = FALSE;
158 socket->close(); 165 socket->close();
159 } else errorHandling(ErrUnknownResponse); 166 } else errorHandlingWithMsg(ErrUnknownResponse,response);
160 break; 167 break;
161 } 168 }
162 } 169 }
163} 170}
diff --git a/noncore/net/mailit/smtpclient.h b/noncore/net/mailit/smtpclient.h
index 45c0703..554ba3f 100644
--- a/noncore/net/mailit/smtpclient.h
+++ b/noncore/net/mailit/smtpclient.h
@@ -1,75 +1,76 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef SmtpClient_H 20#ifndef SmtpClient_H
21#define SmtpClient_H 21#define SmtpClient_H
22 22
23//#include <stdio.h> 23//#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlist.h> 29#include <qlist.h>
30 30
31struct RawEmail 31struct RawEmail
32{ 32{
33 QString from; 33 QString from;
34 QString subject; 34 QString subject;
35 QStringList to; 35 QStringList to;
36 QString body; 36 QString body;
37}; 37};
38 38
39class SmtpClient: public QObject 39class SmtpClient: public QObject
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 SmtpClient(); 44 SmtpClient();
45 ~SmtpClient(); 45 ~SmtpClient();
46 void newConnection(const QString &target, int port); 46 void newConnection(const QString &target, int port);
47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body); 47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
48 48
49signals: 49signals:
50 void errorOccurred(int); 50 void errorOccurred(int, const QString & LR );
51 void updateStatus(const QString &); 51 void updateStatus(const QString &);
52 void mailSent(); 52 void mailSent();
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & LastResponse );
56 57
57protected slots: 58protected slots:
58 void connectionEstablished(); 59 void connectionEstablished();
59 void incomingData(); 60 void incomingData();
60 61
61private: 62private:
62 QSocket *socket; 63 QSocket *socket;
63 QTextStream *stream; 64 QTextStream *stream;
64 enum transferStatus 65 enum transferStatus
65 { 66 {
66 Init, From, Recv, MRcv, Data, Body, Quit, Done 67 Init, From, Recv, MRcv, Data, Body, Quit, Done
67 }; 68 };
68 int status; 69 int status;
69 QList<RawEmail> mailList; 70 QList<RawEmail> mailList;
70 RawEmail *mailPtr; 71 RawEmail *mailPtr;
71 bool sending; 72 bool sending;
72 QStringList::Iterator it; 73 QStringList::Iterator it;
73}; 74};
74 75
75#endif 76#endif
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp
index 21885c2..293e137 100644
--- a/noncore/net/mailit/viewatt.cpp
+++ b/noncore/net/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "resource.h" 20#include "resource.h"
21#include "viewatt.h" 21#include "viewatt.h"
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
27 : QMainWindow(parent, name, f) 27 : QMainWindow(parent, name, f)
28{ 28{
29 setCaption("Exploring attatchments"); 29 setCaption(tr("Exploring attatchments"));
30 30
31 setToolBarsMovable( FALSE ); 31 setToolBarsMovable( FALSE );
32 bar = new QToolBar(this); 32 bar = new QToolBar(this);
33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); 35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
36 36
37 listView = new QListView(this, "AttView"); 37 listView = new QListView(this, "AttView");
38 listView->addColumn( "Attatchment" ); 38 listView->addColumn( tr("Attatchment") );
39 listView->addColumn( "Type" ); 39 listView->addColumn( tr("Type") );
40 listView->addColumn( "Installed" ); 40 listView->addColumn( tr("Installed") );
41 setCentralWidget(listView); 41 setCentralWidget(listView);
42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); 42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
43} 43}
44 44
45void ViewAtt::update(Email *mailIn, bool inbox) 45void ViewAtt::update(Email *mailIn, bool inbox)
46{ 46{
47 QListViewItem *item; 47 QListViewItem *item;
48 Enclosure *ePtr; 48 Enclosure *ePtr;
49 49
50 50
51 51
52 listView->clear(); 52 listView->clear();
53 if (inbox) { 53 if (inbox) {
54 bar->clear(); 54 bar->clear();
55 installButton->addTo( bar ); 55 installButton->addTo( bar );
56 bar->show(); 56 bar->show();
57 } else { 57 } else {
58 bar->hide(); 58 bar->hide();
59 } 59 }
60 60
61 mail = mailIn; 61 mail = mailIn;
62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
63 63
64 QString isInstalled = "No"; 64 QString isInstalled = tr("No");
65 if (ePtr->installed) 65 if (ePtr->installed)
66 isInstalled = "Yes"; 66 isInstalled = tr("Yes");
67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
68 68
69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; 69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
70 70
71 MimeType mt(mtypeDef); 71 MimeType mt(mtypeDef);
72 72
73 item->setPixmap(0, mt.pixmap()); 73 item->setPixmap(0, mt.pixmap());
74 74
75 /* 75 /*
76 if (ePtr->contentType == "TEXT") { 76 if (ePtr->contentType == "TEXT") {
77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
78 actions->addTo(bar); 78 actions->addTo(bar);
79 } 79 }
80 if (ePtr->contentType == "AUDIO") { 80 if (ePtr->contentType == "AUDIO") {
81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
82 actions->addTo(bar); 82 actions->addTo(bar);
83 item->setPixmap(0, Resource::loadPixmap("play")); 83 item->setPixmap(0, Resource::loadPixmap("play"));
84 } 84 }
85 if (ePtr->contentType == "IMAGE") { 85 if (ePtr->contentType == "IMAGE") {
86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
87 actions->addTo(bar); 87 actions->addTo(bar);
88 item->setPixmap(0, Resource::loadPixmap("pixmap")); 88 item->setPixmap(0, Resource::loadPixmap("pixmap"));
89 }*/ 89 }*/
90 } 90 }
91} 91}
92 92
93void ViewAtt::install() 93void ViewAtt::install()
94{ 94{
95 Enclosure *ePtr, *selPtr; 95 Enclosure *ePtr, *selPtr;
96 QListViewItem *item; 96 QListViewItem *item;
97 QString filename; 97 QString filename;
98 DocLnk d; 98 DocLnk d;
99 99
100 item = listView->selectedItem(); 100 item = listView->selectedItem();
101 if (item != NULL) { 101 if (item != NULL) {
102 filename = item->text(0); 102 filename = item->text(0);
103 selPtr = NULL; 103 selPtr = NULL;
104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
105 if (ePtr->originalName == filename) 105 if (ePtr->originalName == filename)
106 selPtr = ePtr; 106 selPtr = ePtr;
107 } 107 }
108 108
109 if (selPtr == NULL) { 109 if (selPtr == NULL) {
110 qWarning("Internal error, file is not installed to documents"); 110 qWarning("Internal error, file is not installed to documents");
111 return; 111 return;
112 } 112 }
113 113
114 d.setName(selPtr->originalName); 114 d.setName(selPtr->originalName);
115 d.setFile(selPtr->path + selPtr->name); 115 d.setFile(selPtr->path + selPtr->name);
116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
117 d.writeLink(); 117 d.writeLink();
118 selPtr->installed = TRUE; 118 selPtr->installed = TRUE;
119 item->setText(2, "Yes"); 119 item->setText(2, tr("Yes"));
120 } 120 }
121} 121}
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp
index 0298cb3..26b9660 100644
--- a/noncore/net/mailit/writemail.cpp
+++ b/noncore/net/mailit/writemail.cpp
@@ -1,402 +1,402 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include "writemail.h" 22#include "writemail.h"
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl ) 25WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl )
26{ 26{
27 showingAddressList = FALSE; 27 showingAddressList = FALSE;
28 init(); 28 init();
29 29
30 addAtt = new AddAtt(0, "Add Attachments"); 30 addAtt = new AddAtt(0, "Add Attachments");
31} 31}
32 32
33WriteMail::~WriteMail() 33WriteMail::~WriteMail()
34{ 34{
35 delete addAtt; 35 delete addAtt;
36} 36}
37 37
38void WriteMail::setAddressList(AddressList *list) 38void WriteMail::setAddressList(AddressList *list)
39{ 39{
40 AContact *cPtr; 40 AContact *cPtr;
41 41
42 addressList = list; 42 addressList = list;
43 43
44 addressView->clear(); 44 addressView->clear();
45 QList<AContact> *cListPtr = addressList->getContactList(); 45 QList<AContact> *cListPtr = addressList->getContactList();
46 QListViewItem *item; 46 QListViewItem *item;
47 for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { 47 for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) {
48 item = new QListViewItem(addressView, cPtr->name, cPtr->email); 48 item = new QListViewItem(addressView, cPtr->name, cPtr->email);
49 } 49 }
50} 50}
51 51
52void WriteMail::init() 52void WriteMail::init()
53{ 53{
54 setToolBarsMovable(FALSE); 54 setToolBarsMovable(FALSE);
55 55
56 bar = new QToolBar(this); 56 bar = new QToolBar(this);
57 bar->setHorizontalStretchable( TRUE ); 57 bar->setHorizontalStretchable( TRUE );
58 58
59 menu = new QMenuBar( bar ); 59 menu = new QMenuBar( bar );
60 60
61 mailMenu = new QPopupMenu(menu); 61 mailMenu = new QPopupMenu(menu);
62 menu->insertItem( tr( "&Mail" ), mailMenu); 62 menu->insertItem( tr( "&Mail" ), mailMenu);
63 addMenu = new QPopupMenu(menu); 63 addMenu = new QPopupMenu(menu);
64 menu->insertItem( tr( "&Add" ), addMenu); 64 menu->insertItem( tr( "&Add" ), addMenu);
65 65
66 bar = new QToolBar(this); 66 bar = new QToolBar(this);
67 attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); 67 attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0);
68 attachButton->addTo(bar); 68 attachButton->addTo(bar);
69 attachButton->addTo(addMenu); 69 attachButton->addTo(addMenu);
70 connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); 70 connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) );
71 attachButton->setWhatsThis(tr("Click here to attach files to your mail")); 71 attachButton->setWhatsThis(tr("Click here to attach files to your mail"));
72 72
73 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); 73 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0);
74 confirmButton->addTo(bar); 74 confirmButton->addTo(bar);
75 confirmButton->addTo(mailMenu); 75 confirmButton->addTo(mailMenu);
76 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); 76 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) );
77 confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); 77 confirmButton->setWhatsThis(tr("This button puts your mail in the send queue"));
78 78
79 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 79 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
80 newButton->addTo(mailMenu); 80 newButton->addTo(mailMenu);
81 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); 81 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
82 newButton->setWhatsThis(tr("Click here to create a new mail")); 82 newButton->setWhatsThis(tr("Click here to create a new mail"));
83 83
84 widget = new QWidget(this, "widget"); 84 widget = new QWidget(this, "widget");
85 grid = new QGridLayout( widget ); 85 grid = new QGridLayout( widget );
86 86
87 recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); 87 recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
88 recipientsBox->insertItem( tr( "To:" ) ); 88 recipientsBox->insertItem( tr( "To:" ) );
89 recipientsBox->insertItem( tr( "CC:" ) ); 89 recipientsBox->insertItem( tr( "CC:" ) );
90 recipientsBox->setCurrentItem(0); 90 recipientsBox->setCurrentItem(0);
91 grid->addWidget( recipientsBox, 0, 0 ); 91 grid->addWidget( recipientsBox, 0, 0 );
92 connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); 92 connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int)));
93 93
94 subjetLabel = new QLabel( widget, "subjetLabel" ); 94 subjetLabel = new QLabel( widget, "subjetLabel" );
95 subjetLabel->setText( tr( "Subject:" ) ); 95 subjetLabel->setText( tr( "Subject:" ) );
96 96
97 grid->addWidget( subjetLabel, 1, 0 ); 97 grid->addWidget( subjetLabel, 1, 0 );
98 98
99 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); 99 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
100 ToolButton13_2->setText( tr( "..." ) ); 100 ToolButton13_2->setText( tr( "..." ) );
101 grid->addWidget( ToolButton13_2, 1, 2 ); 101 grid->addWidget( ToolButton13_2, 1, 2 );
102 102
103 subjectInput = new QLineEdit( widget, "subjectInput" ); 103 subjectInput = new QLineEdit( widget, "subjectInput" );
104 grid->addWidget( subjectInput, 1, 1 ); 104 grid->addWidget( subjectInput, 1, 1 );
105 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); 105 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here"));
106 106
107 toInput = new QLineEdit( widget, "toInput" ); 107 toInput = new QLineEdit( widget, "toInput" );
108 grid->addWidget( toInput, 0, 1 ); 108 grid->addWidget( toInput, 0, 1 );
109 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); 109 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here"));
110 110
111 ccInput = new QLineEdit( widget, "ccInput" ); 111 ccInput = new QLineEdit( widget, "ccInput" );
112 ccInput->hide(); 112 ccInput->hide();
113 grid->addWidget( ccInput, 0, 1 ); 113 grid->addWidget( ccInput, 0, 1 );
114 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); 114 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here"));
115 115
116 addressButton = new QToolButton( widget, "addressButton" ); 116 addressButton = new QToolButton( widget, "addressButton" );
117 addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); 117 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
118 addressButton->setToggleButton(TRUE); 118 addressButton->setToggleButton(TRUE);
119 grid->addWidget( addressButton, 0, 2 ); 119 grid->addWidget( addressButton, 0, 2 );
120 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); 120 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
121 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); 121 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your Opie addressbook"));
122 122
123 emailInput = new QMultiLineEdit( widget, "emailInput" ); 123 emailInput = new QMultiLineEdit( widget, "emailInput" );
124 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); 124 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
125 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); 125 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here"));
126 126
127 addressView = new QListView( widget, "addressView"); 127 addressView = new QListView( widget, "addressView");
128 addressView->addColumn("Name"); 128 addressView->addColumn(tr("Name"));
129 addressView->addColumn("EMail"); 129 addressView->addColumn(tr("EMail") );
130 addressView->setAllColumnsShowFocus(TRUE); 130 addressView->setAllColumnsShowFocus(TRUE);
131 addressView->setMultiSelection(TRUE); 131 addressView->setMultiSelection(TRUE);
132 addressView->hide(); 132 addressView->hide();
133 grid->addMultiCellWidget( addressView, 3, 3, 0, 2); 133 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
134 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); 134 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list"));
135 135
136 okButton = new QToolButton(bar, "ok"); 136 okButton = new QToolButton(bar, "ok");
137 okButton->setPixmap( Resource::loadPixmap("enter") ); 137 okButton->setPixmap( Resource::loadPixmap("enter") );
138 okButton->hide(); 138 okButton->hide();
139 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); 139 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
140 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); 140 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here"));
141 141
142 setCentralWidget(widget); 142 setCentralWidget(widget);
143} 143}
144 144
145void WriteMail::reject() 145void WriteMail::reject()
146{ 146{
147 emit cancelMail(); 147 emit cancelMail();
148} 148}
149 149
150void WriteMail::accept() 150void WriteMail::accept()
151{ 151{
152 QStringList attachedFiles, attachmentsType; 152 QStringList attachedFiles, attachmentsType;
153 int idCount = 0; 153 int idCount = 0;
154 154
155 if (toInput->text() == "") 155 if (toInput->text() == "")
156 { 156 {
157 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); 157 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n"));
158 return; 158 return;
159 } 159 }
160 160
161 if (! getRecipients(false) ) 161 if (! getRecipients(false) )
162 { 162 {
163 QMessageBox::warning(this,tr("Incorrect recipient separator"), 163 QMessageBox::warning(this,tr("Incorrect recipient separator"),
164 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 164 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
165 return; 165 return;
166 } 166 }
167 167
168 if ((ccInput->text()!="") && (! getRecipients(true) )) 168 if ((ccInput->text()!="") && (! getRecipients(true) ))
169 { 169 {
170 QMessageBox::warning(this,tr("Incorrect carbon copy separator"), 170 QMessageBox::warning(this,tr("Incorrect carbon copy separator"),
171 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 171 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
172 return; 172 return;
173 } 173 }
174 174
175 mail.subject = subjectInput->text(); 175 mail.subject = subjectInput->text();
176 mail.body = emailInput->text(); 176 mail.body = emailInput->text();
177 mail.sent = false; 177 mail.sent = false;
178 mail.received = false; 178 mail.received = false;
179 179
180 mail.rawMail = "To: "; 180 mail.rawMail = "To: ";
181 181
182 for (QStringList::Iterator it = mail.recipients.begin(); 182 for (QStringList::Iterator it = mail.recipients.begin();
183 it != mail.recipients.end(); ++it) { 183 it != mail.recipients.end(); ++it) {
184 184
185 mail.rawMail += (*it); 185 mail.rawMail += (*it);
186 mail.rawMail += ",\n"; 186 mail.rawMail += ",\n";
187 } 187 }
188 188
189 mail.rawMail.truncate(mail.rawMail.length()-2); 189 mail.rawMail.truncate(mail.rawMail.length()-2);
190 190
191 mail.rawMail += "\nCC: "; 191 mail.rawMail += "\nCC: ";
192 192
193 for (QStringList::Iterator it = mail.carbonCopies.begin(); 193 for (QStringList::Iterator it = mail.carbonCopies.begin();
194 it != mail.carbonCopies.end(); ++it) { 194 it != mail.carbonCopies.end(); ++it) {
195 195
196 mail.rawMail += (*it); 196 mail.rawMail += (*it);
197 mail.rawMail += ",\n"; 197 mail.rawMail += ",\n";
198 } 198 }
199 199
200 mail.rawMail += mail.from; 200 mail.rawMail += mail.from;
201 mail.rawMail += "\nSubject: "; 201 mail.rawMail += "\nSubject: ";
202 mail.rawMail += mail.subject; 202 mail.rawMail += mail.subject;
203 mail.rawMail += "\n\n"; 203 mail.rawMail += "\n\n";
204 204
205 attachedFiles = addAtt->returnattachedFiles(); 205 attachedFiles = addAtt->returnattachedFiles();
206 attachmentsType = addAtt->returnFileTypes(); 206 attachmentsType = addAtt->returnFileTypes();
207 207
208 QStringList::Iterator itType = attachmentsType.begin(); 208 QStringList::Iterator itType = attachmentsType.begin();
209 209
210 Enclosure e; 210 Enclosure e;
211 for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { 211 for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) {
212 e.id = idCount; 212 e.id = idCount;
213 e.originalName = (*it).latin1(); 213 e.originalName = (*it).latin1();
214 e.contentType = (*itType).latin1(); 214 e.contentType = (*itType).latin1();
215 e.contentAttribute = (*itType).latin1(); 215 e.contentAttribute = (*itType).latin1();
216 e.saved = TRUE; 216 e.saved = TRUE;
217 mail.addEnclosure(&e); 217 mail.addEnclosure(&e);
218 218
219 itType++; 219 itType++;
220 idCount++; 220 idCount++;
221 } 221 }
222 mail.rawMail += mail.body; 222 mail.rawMail += mail.body;
223 mail.rawMail += "\n"; 223 mail.rawMail += "\n";
224 mail.rawMail += ".\n"; 224 mail.rawMail += ".\n";
225 emit sendMailRequested(mail); 225 emit sendMailRequested(mail);
226 addAtt->clear(); 226 addAtt->clear();
227} 227}
228 228
229void WriteMail::getAddress() 229void WriteMail::getAddress()
230{ 230{
231 showingAddressList = !showingAddressList; 231 showingAddressList = !showingAddressList;
232 232
233 if (showingAddressList) { 233 if (showingAddressList) {
234 emailInput->hide(); 234 emailInput->hide();
235 addressView->show(); 235 addressView->show();
236 okButton->show(); 236 okButton->show();
237 237
238 } else { 238 } else {
239 addressView->hide(); 239 addressView->hide();
240 okButton->hide(); 240 okButton->hide();
241 emailInput->show(); 241 emailInput->show();
242 } 242 }
243} 243}
244 244
245void WriteMail::attachFile() 245void WriteMail::attachFile()
246{ 246{
247 addAtt->showMaximized(); 247 addAtt->showMaximized();
248} 248}
249 249
250void WriteMail::reply(Email replyMail, bool replyAll) 250void WriteMail::reply(Email replyMail, bool replyAll)
251{ 251{
252 int pos; 252 int pos;
253 QString ccRecipients; 253 QString ccRecipients;
254 254
255 mail = replyMail; 255 mail = replyMail;
256 mail.files.clear(); 256 mail.files.clear();
257 257
258 toInput->setText(mail.fromMail); 258 toInput->setText(mail.fromMail);
259 259
260 if (replyAll) 260 if (replyAll)
261 { 261 {
262 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) 262 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it)
263 { 263 {
264 ccRecipients.append(*it); 264 ccRecipients.append(*it);
265 ccRecipients.append(";"); 265 ccRecipients.append(";");
266 } 266 }
267 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end 267 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end
268 ccInput->setText(ccRecipients); 268 ccInput->setText(ccRecipients);
269 } 269 }
270 else ccInput->clear(); 270 else ccInput->clear();
271 271
272 subjectInput->setText(tr("Re: ") + mail.subject); 272 subjectInput->setText(tr("Re: ") + mail.subject);
273 273
274 QString citation=mail.fromMail; 274 QString citation=mail.fromMail;
275 citation.append(tr(" wrote on ")); 275 citation.append(tr(" wrote on "));
276 citation.append(mail.date); 276 citation.append(mail.date);
277 citation.append(":\n"); 277 citation.append(":\n");
278 278
279 279
280 //mail.body.insert(0,tr("On")); 280 //mail.body.insert(0,tr("On"));
281 pos = 0; 281 pos = 0;
282 mail.body.insert(pos, ">"); 282 mail.body.insert(pos, ">");
283 while (pos != -1) { 283 while (pos != -1) {
284 pos = mail.body.find('\n', pos); 284 pos = mail.body.find('\n', pos);
285 if (pos != -1) 285 if (pos != -1)
286 mail.body.insert(++pos, ">>"); 286 mail.body.insert(++pos, ">");
287 } 287 }
288 mail.body.insert(0,citation); 288 mail.body.insert(0,citation);
289 emailInput->setText(mail.body); 289 emailInput->setText(mail.body);
290} 290}
291 291
292void WriteMail::forward(Email forwMail) 292void WriteMail::forward(Email forwMail)
293{ 293{
294 int pos=0; 294 // int pos=0;
295 295
296 QString fwdBody=tr("======forwarded message from "); 296 QString fwdBody=tr("======forwarded message from ");
297 fwdBody.append(forwMail.fromMail); 297 fwdBody.append(forwMail.fromMail);
298 fwdBody.append(tr(" starts======\n\n")); 298 fwdBody.append(tr(" starts======\n\n"));
299 299
300 mail=forwMail; 300 mail=forwMail;
301 toInput->setText(""); 301 toInput->setText("");
302 ccInput->setText(""); 302 ccInput->setText("");
303 subjectInput->setText(tr("FWD: ") + mail.subject); 303 subjectInput->setText(tr("FWD: ") + mail.subject);
304 304
305 fwdBody+=mail.body; 305 fwdBody+=mail.body;
306 fwdBody+=QString(tr("======end of forwarded message======\n\n")); 306 fwdBody+=QString(tr("======end of forwarded message======\n\n"));
307 307
308 emailInput->setText(fwdBody); 308 emailInput->setText(fwdBody);
309} 309}
310 310
311bool WriteMail::getRecipients(bool ccField) 311bool WriteMail::getRecipients(bool ccField)
312{ 312{
313 QString str, temp; 313 QString str, temp;
314 int pos = 0; 314 int pos = 0;
315 315
316 if (ccField) 316 if (ccField)
317 { 317 {
318 mail.carbonCopies.clear(); 318 mail.carbonCopies.clear();
319 temp = ccInput->text(); 319 temp = ccInput->text();
320 } 320 }
321 else 321 else
322 { 322 {
323 mail.recipients.clear(); 323 mail.recipients.clear();
324 temp=toInput->text() ; 324 temp=toInput->text() ;
325 } 325 }
326 326
327 while ( (pos = temp.find(';')) != -1) { 327 while ( (pos = temp.find(';')) != -1) {
328 str = temp.left(pos).stripWhiteSpace(); 328 str = temp.left(pos).stripWhiteSpace();
329 temp = temp.right(temp.length() - (pos + 1)); 329 temp = temp.right(temp.length() - (pos + 1));
330 if ( str.find('@') == -1) 330 if ( str.find('@') == -1)
331 return false; 331 return false;
332 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); 332 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str);
333 //addressList->addContact(str, ""); 333 //addressList->addContact(str, "");
334 } 334 }
335 temp = temp.stripWhiteSpace(); 335 temp = temp.stripWhiteSpace();
336 if ( temp.find('@') == -1) 336 if ( temp.find('@') == -1)
337 return false; 337 return false;
338 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); 338 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp);
339 //addressList->addContact(temp, ""); 339 //addressList->addContact(temp, "");
340 340
341 return TRUE; 341 return TRUE;
342} 342}
343 343
344void WriteMail::addRecipients() 344void WriteMail::addRecipients()
345{ 345{
346 toInput->isVisible() ? addRecipients(false) : addRecipients(true); 346 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
347 } 347}
348 348
349void WriteMail::addRecipients(bool ccField) 349void WriteMail::addRecipients(bool ccField)
350{ 350{
351 QString recipients = ""; 351 QString recipients = "";
352 352
353 mail.recipients.clear(); 353 mail.recipients.clear();
354 354
355 QListViewItem *item = addressView->firstChild(); 355 QListViewItem *item = addressView->firstChild();
356 while (item != NULL) { 356 while (item != NULL) {
357 if ( item->isSelected() ) { 357 if ( item->isSelected() ) {
358 if (recipients == "") { 358 if (recipients == "") {
359 recipients = item->text(1); 359 recipients = item->text(1);
360 } else { 360 } else {
361 recipients += "; " + item->text(1); 361 recipients += "; " + item->text(1);
362 } 362 }
363 } 363 }
364 item = item->nextSibling(); 364 item = item->nextSibling();
365 } 365 }
366 366
367 ccField ? ccInput->setText(recipients):toInput->setText(recipients); 367 ccField ? ccInput->setText(recipients):toInput->setText(recipients);
368 368
369 addressView->hide(); 369 addressView->hide();
370 okButton->hide(); 370 okButton->hide();
371 emailInput->show(); 371 emailInput->show();
372 addressButton->setOn(FALSE); 372 addressButton->setOn(FALSE);
373 showingAddressList = !showingAddressList; 373 showingAddressList = !showingAddressList;
374} 374}
375 375
376void WriteMail::changeRecipients(int selection) 376void WriteMail::changeRecipients(int selection)
377{ 377{
378 if (selection==0) 378 if (selection==0)
379 { 379 {
380 toInput->show(); 380 toInput->show();
381 ccInput->hide(); 381 ccInput->hide();
382 } 382 }
383 else if (selection==1) 383 else if (selection==1)
384 { 384 {
385 toInput->hide(); 385 toInput->hide();
386 ccInput->show(); 386 ccInput->show();
387 } 387 }
388} 388}
389 389
390void WriteMail::setRecipient(const QString &recipient) 390void WriteMail::setRecipient(const QString &recipient)
391{ 391{
392 toInput->setText(recipient); 392 toInput->setText(recipient);
393} 393}
394 394
395void WriteMail::newMail() 395void WriteMail::newMail()
396{ 396{
397 toInput->clear(); 397 toInput->clear();
398 ccInput->clear(); 398 ccInput->clear();
399 subjectInput->clear(); 399 subjectInput->clear();
400 emailInput->clear(); 400 emailInput->clear();
401 setAddressList(addressList); 401 setAddressList(addressList);
402} 402}
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp
index daefac6..19ac58f 100644
--- a/noncore/unsupported/mailit/addatt.cpp
+++ b/noncore/unsupported/mailit/addatt.cpp
@@ -1,224 +1,224 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qhbox.h> 21#include <qhbox.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include "addatt.h" 25#include "addatt.h"
26 26
27FileItem::FileItem(QListView *parent, DocLnk* dl) 27FileItem::FileItem(QListView *parent, DocLnk* dl)
28 : QListViewItem(parent) 28 : QListViewItem(parent)
29{ 29{
30 /*file = fileInfo; 30 /*file = fileInfo;
31 type = fileType;*/ 31 type = fileType;*/
32 32
33 doclnk=dl; 33 doclnk=dl;
34 34
35 setText(0, doclnk->name()); 35 setText(0, doclnk->name());
36 36
37 /*if (fileType == "Picture") { 37 /*if (fileType == "Picture") {
38 setPixmap(0, Resource::loadPixmap("pixmap")); 38 setPixmap(0, Resource::loadPixmap("pixmap"));
39 } else if (fileType == "Document") { 39 } else if (fileType == "Document") {
40 setPixmap(0, Resource::loadPixmap("txt")); 40 setPixmap(0, Resource::loadPixmap("txt"));
41 } else if (fileType == "Sound") { 41 } else if (fileType == "Sound") {
42 setPixmap(0, Resource::loadPixmap("play")); 42 setPixmap(0, Resource::loadPixmap("play"));
43 } else if (fileType == "Movie") { 43 } else if (fileType == "Movie") {
44 setPixmap(0, Resource::loadPixmap("MPEGPlayer")); 44 setPixmap(0, Resource::loadPixmap("MPEGPlayer"));
45 } else if (fileType == "File") { 45 } else if (fileType == "File") {
46 setPixmap(0, Resource::loadPixmap("exec")); 46 setPixmap(0, Resource::loadPixmap("exec"));
47 }*/ 47 }*/
48} 48}
49 49
50FileItem::~FileItem() 50FileItem::~FileItem()
51{ 51{
52 if (doclnk!=NULL) delete doclnk; 52 if (doclnk!=NULL) delete doclnk;
53 doclnk=NULL; 53 doclnk=NULL;
54} 54}
55 55
56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) 56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
57 : QDialog(parent, name, f) 57 : QDialog(parent, name, f)
58{ 58{
59 setCaption("Adding attachments"); 59 setCaption(tr("Adding attachments") );
60 60
61 QGridLayout *top = new QGridLayout(this, 1,1 ); 61 QGridLayout *top = new QGridLayout(this, 1,1 );
62 62
63 QHBox *buttons=new QHBox(this); 63 QHBox *buttons=new QHBox(this);
64 /*fileCategoryButton = new QPushButton(this);*/ 64 /*fileCategoryButton = new QPushButton(this);*/
65 attachButton = new QPushButton(tr("attach..."), buttons); 65 attachButton = new QPushButton(tr("attach..."), buttons);
66 removeButton = new QPushButton(tr("Remove"), buttons); 66 removeButton = new QPushButton(tr("Remove"), buttons);
67 67
68 /*fileCategories = new QPopupMenu(fileCategoryButton); 68 /*fileCategories = new QPopupMenu(fileCategoryButton);
69 fileCategoryButton->setPopup(fileCategories); 69 fileCategoryButton->setPopup(fileCategories);
70 fileCategories->insertItem("Document"); 70 fileCategories->insertItem("Document");
71 fileCategories->insertItem("Picture"); 71 fileCategories->insertItem("Picture");
72 fileCategories->insertItem("Sound"); 72 fileCategories->insertItem("Sound");
73 fileCategories->insertItem("Movie"); 73 fileCategories->insertItem("Movie");
74 fileCategories->insertItem("File"); 74 fileCategories->insertItem("File");
75 75
76 fileCategoryButton->setText("Document"); 76 fileCategoryButton->setText("Document");
77 top->addWidget(fileCategoryButton, 0, 0);*/ 77 top->addWidget(fileCategoryButton, 0, 0);*/
78 78
79 79
80 top->addWidget(buttons,1,0); 80 top->addWidget(buttons,1,0);
81 //buttons->addWidget(attachButton,0,0); 81 //buttons->addWidget(attachButton,0,0);
82 //buttons->addWidget(removeButton,0,1); 82 //buttons->addWidget(removeButton,0,1);
83 83
84 //connect(fileCategories, SIGNAL(activated(int)), this, 84 //connect(fileCategories, SIGNAL(activated(int)), this,
85 //SLOT(fileCategorySelected(int)) );*/ 85 //SLOT(fileCategorySelected(int)) );*/
86 connect(attachButton, SIGNAL(clicked()), this, 86 connect(attachButton, SIGNAL(clicked()), this,
87 SLOT(addattachment()) ); 87 SLOT(addattachment()) );
88 connect(removeButton, SIGNAL(clicked()), this, 88 connect(removeButton, SIGNAL(clicked()), this,
89 SLOT(removeattachment()) ); 89 SLOT(removeattachment()) );
90 90
91 /*listView = new QListView(this, "AttView"); 91 /*listView = new QListView(this, "AttView");
92 listView->addColumn("Documents");* 92 listView->addColumn("Documents");*
93 connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, 93 connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this,
94 SLOT(addattachment()) );*/ 94 SLOT(addattachment()) );*/
95 95
96 96
97 attView = new QListView(this, "Selected"); 97 attView = new QListView(this, "Selected");
98 attView->addColumn(tr("Attached")); 98 attView->addColumn(tr("Attached"));
99 attView->addColumn(tr("File type")); 99 attView->addColumn(tr("File type"));
100 connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, 100 connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this,
101 SLOT(removeattachment()) ); 101 SLOT(removeattachment()) );
102 102
103 //top->addWidget(ofs, 0,0); 103 //top->addWidget(ofs, 0,0);
104 top->addWidget(attView, 0,0); 104 top->addWidget(attView, 0,0);
105 105
106 clear(); 106 clear();
107 107
108 108
109} 109}
110 110
111void AddAtt::clear() 111void AddAtt::clear()
112{ 112{
113 attView->clear(); 113 attView->clear();
114 //getFiles(); 114 //getFiles();
115 modified = FALSE; 115 modified = FALSE;
116} 116}
117 117
118/*void AddAtt::fileCategorySelected(int id) 118/*void AddAtt::fileCategorySelected(int id)
119{ 119{
120 fileCategoryButton->setText(fileCategories->text(id)); 120 fileCategoryButton->setText(fileCategories->text(id));
121 getFiles(); 121 getFiles();
122}*/ 122}*/
123 123
124void AddAtt::addattachment() 124void AddAtt::addattachment()
125 { 125 {// ### FIXME wrong use -zecke
126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); 126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
127 127
128 ofs.showMaximized(); 128 ofs.showMaximized();
129 129
130 if (ofs.exec()==QDialog::Accepted) 130 if (ofs.exec()==QDialog::Accepted)
131 { 131 {
132 DocLnk* dl=new DocLnk(ofs.selectedDocument()); 132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
133 FileItem* fi=new FileItem(attView,dl); 133 FileItem* fi=new FileItem(attView,dl);
134 fi->setPixmap(0,dl->pixmap()); 134 fi->setPixmap(0,dl->pixmap());
135 fi->setText(1,dl->type()); 135 fi->setText(1,dl->type());
136 attView->insertItem(fi); 136 attView->insertItem(fi);
137 modified = TRUE; 137 modified = TRUE;
138 } 138 }
139} 139}
140 140
141void AddAtt::removeattachment() 141void AddAtt::removeattachment()
142{ 142{
143 if (attView->selectedItem() != NULL) 143 if (attView->selectedItem() != NULL)
144 { 144 {
145 attView->takeItem(attView->selectedItem()); 145 attView->takeItem(attView->selectedItem());
146 } 146 }
147 modified = TRUE; 147 modified = TRUE;
148} 148}
149 149
150void AddAtt::reject() 150void AddAtt::reject()
151{ 151{
152 if (modified) { 152 if (modified) {
153 attView->clear(); 153 attView->clear();
154 modified = FALSE; 154 modified = FALSE;
155 } 155 }
156} 156}
157 157
158void AddAtt::accept() 158void AddAtt::accept()
159{ 159{
160 modified = FALSE; 160 modified = FALSE;
161 hide(); 161 hide();
162} 162}
163 163
164void AddAtt::getFiles() 164void AddAtt::getFiles()
165{ 165{
166 QString path, selected; 166 QString path, selected;
167 167
168 /*listView->clear(); 168 /*listView->clear();
169 169
170 selected = fileCategoryButton->text(); 170 selected = fileCategoryButton->text();
171 if (selected == "Picture") { 171 if (selected == "Picture") {
172 path = "../pics/"; 172 path = "../pics/";
173 } else if (selected == "Document") { 173 } else if (selected == "Document") {
174 path = "" ; //sub-dirs not decided 174 path = "" ; //sub-dirs not decided
175 } else if (selected == "Sound") { 175 } else if (selected == "Sound") {
176 path = "../sounds/"; //sub-dirs not decided 176 path = "../sounds/"; //sub-dirs not decided
177 } else if (selected == "Movie") { 177 } else if (selected == "Movie") {
178 path = ""; //sub-dirs not decided 178 path = ""; //sub-dirs not decided
179 } else if (selected == "File") { 179 } else if (selected == "File") {
180 path = ""; //sub-dirs not decided 180 path = ""; //sub-dirs not decided
181 } 181 }
182 182
183 dir = new QDir(path); 183 dir = new QDir(path);
184 dir->setFilter(QDir::Files); 184 dir->setFilter(QDir::Files);
185 const QFileInfoList *dirInfoList = dir->entryInfoList(); 185 const QFileInfoList *dirInfoList = dir->entryInfoList();
186 186
187 QFileInfoListIterator it(*dirInfoList); // create list iterator 187 QFileInfoListIterator it(*dirInfoList); // create list iterator
188 188
189 while ( (fi=it.current()) ) { // for each file... 189 while ( (fi=it.current()) ) { // for each file...
190 item = new FileItem(lis+ütView, *fi, selected); 190 item = new FileItem(lis+ütView, *fi, selected);
191 ++it; // goto next list element 191 ++it; // goto next list element
192 }*/ 192 }*/
193} 193}
194 194
195QStringList AddAtt::returnattachedFiles() 195QStringList AddAtt::returnattachedFiles()
196{ 196{
197 QFileInfo info; 197 QFileInfo info;
198 QStringList list; 198 QStringList list;
199 199
200 item = (FileItem *) attView->firstChild(); 200 item = (FileItem *) attView->firstChild();
201 201
202 202
203 while (item != NULL) { 203 while (item != NULL) {
204 DocLnk* dl=item->getDocLnk(); 204 DocLnk* dl=item->getDocLnk();
205 list+=dl->file(); 205 list+=dl->file();
206 /*info = item->getFileInfo(); 206 /*info = item->getFileInfo();
207 list += info.filePath();*/ 207 list += info.filePath();*/
208 item = (FileItem *) item->nextSibling(); 208 item = (FileItem *) item->nextSibling();
209 } 209 }
210 return list; 210 return list;
211} 211}
212 212
213QStringList AddAtt::returnFileTypes() 213QStringList AddAtt::returnFileTypes()
214{ 214{
215 QStringList list; 215 QStringList list;
216 216
217 item = (FileItem *) attView->firstChild(); 217 item = (FileItem *) attView->firstChild();
218 218
219 while (item != NULL) { 219 while (item != NULL) {
220 list += item->getDocLnk()->type(); 220 list += item->getDocLnk()->type();
221 item = (FileItem *) item->nextSibling(); 221 item = (FileItem *) item->nextSibling();
222 } 222 }
223 return list; 223 return list;
224} 224}
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index da1226c..749a4e9 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -1,257 +1,257 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include <qvbox.h> 22#include <qvbox.h>
23#include <qfile.h> 23#include <qfile.h>
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qmenubar.h> 25#include <qmenubar.h>
26#include <qaction.h> 26#include <qaction.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include "emailclient.h" 29#include "emailclient.h"
30#include "writemail.h" 30#include "writemail.h"
31 31
32QCollection::Item AccountList::newItem(QCollection::Item d) 32QCollection::Item AccountList::newItem(QCollection::Item d)
33{ 33{
34 return dupl( (MailAccount *) d); 34 return dupl( (MailAccount *) d);
35} 35}
36 36
37MailAccount* AccountList::dupl(MailAccount *in) 37MailAccount* AccountList::dupl(MailAccount *in)
38{ 38{
39 ac = new MailAccount(*in); 39 ac = new MailAccount(*in);
40 return ac; 40 return ac;
41} 41}
42 42
43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) 43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
44 : QMainWindow( parent, name, fl ) 44 : QMainWindow( parent, name, fl )
45{ 45{
46 emailHandler = new EmailHandler(); 46 emailHandler = new EmailHandler();
47 addressList = new AddressList(); 47 addressList = new AddressList();
48 48
49 sending = FALSE; 49 sending = FALSE;
50 receiving = FALSE; 50 receiving = FALSE;
51 previewingMail = FALSE; 51 previewingMail = FALSE;
52 mailIdCount = 1; 52 mailIdCount = 1;
53 accountIdCount = 1; 53 accountIdCount = 1;
54 allAccounts = FALSE; 54 allAccounts = FALSE;
55 55
56 init(); 56 init();
57 57
58 58
59 59
60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
61 61
62 connect(emailHandler, SIGNAL(smtpError(int)), this, 62 connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this,
63 SLOT(smtpError(int)) ); 63 SLOT(smtpError(int,const QString &)) );
64 connect(emailHandler, SIGNAL(popError(int)), this, 64 connect(emailHandler, SIGNAL(popError(int,const QString &)), this,
65 SLOT(popError(int)) ); 65 SLOT(popError(int,const QString &)) );
66 66
67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); 67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); 68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
69 69
70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); 70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) );
71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); 71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) );
72 72
73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
74 SLOT(mailArrived(const Email &, bool)) ); 74 SLOT(mailArrived(const Email &, bool)) );
75 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 75 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
76 SLOT(allMailArrived(int)) ); 76 SLOT(allMailArrived(int)) );
77 77
78 mailconf = new Config("mailit"); 78 mailconf = new Config("mailit");
79 //In case Synchronize is not defined in settings.txt 79 //In case Synchronize is not defined in settings.txt
80 80
81 readSettings(); 81 readSettings();
82 82
83 updateAccounts(); 83 updateAccounts();
84 84
85 lineShift = "\n"; 85 lineShift = "\n";
86 readMail(); 86 readMail();
87 lineShift = "\r\n"; 87 lineShift = "\r\n";
88 88
89 mailboxView->setCurrentTab(0); //ensure that inbox has focus 89 mailboxView->setCurrentTab(0); //ensure that inbox has focus
90 90
91 /*channel = new QCopChannel( "QPE/Application/mailit", this ); 91 /*channel = new QCopChannel( "QPE/Application/mailit", this );
92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/ 93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/
94 94
95} 95}
96 96
97 97
98EmailClient::~EmailClient() 98EmailClient::~EmailClient()
99{ 99{
100 //needs to be moved from destructor to closewindow event 100 //needs to be moved from destructor to closewindow event
101 saveMail(getPath(FALSE) + "inbox.txt", inboxView); 101 saveMail(getPath(FALSE) + "inbox.txt", inboxView);
102 //does not currently work. Defining outbox in the same 102 //does not currently work. Defining outbox in the same
103 //format as inbox is not a good solution as they have 103 //format as inbox is not a good solution as they have
104 //different properties 104 //different properties
105 saveMail(getPath(FALSE) + "outbox.txt", outboxView); 105 saveMail(getPath(FALSE) + "outbox.txt", outboxView);
106 saveSettings(); 106 saveSettings();
107 107
108 mailconf->write(); 108 mailconf->write();
109 delete mailconf; 109 delete mailconf;
110 110
111} 111}
112 112
113void EmailClient::init() 113void EmailClient::init()
114{ 114{
115 initStatusBar(this); 115 initStatusBar(this);
116 116
117 setToolBarsMovable(FALSE); 117 setToolBarsMovable(FALSE);
118 118
119 bar = new QToolBar(this); 119 bar = new QToolBar(this);
120 QWhatsThis::add(bar,tr("Main operation toolbar")); 120 QWhatsThis::add(bar,tr("Main operation toolbar"));
121 bar->setHorizontalStretchable( TRUE ); 121 bar->setHorizontalStretchable( TRUE );
122 122
123 mb = new QMenuBar( bar ); 123 mb = new QMenuBar( bar );
124 124
125 QPopupMenu *mail = new QPopupMenu(mb); 125 QPopupMenu *mail = new QPopupMenu(mb);
126 mb->insertItem( tr( "&Mail" ), mail); 126 mb->insertItem( tr( "&Mail" ), mail);
127 127
128 QPopupMenu *configure = new QPopupMenu(mb); 128 QPopupMenu *configure = new QPopupMenu(mb);
129 mb->insertItem( tr( "Accounts" ), configure); 129 mb->insertItem( tr( "Accounts" ), configure);
130 130
131 selectAccountMenu = new QPopupMenu(mb); 131 selectAccountMenu = new QPopupMenu(mb);
132 editAccountMenu = new QPopupMenu(mb); 132 editAccountMenu = new QPopupMenu(mb);
133 deleteAccountMenu = new QPopupMenu(mb); 133 deleteAccountMenu = new QPopupMenu(mb);
134 134
135 mail->insertItem(tr("Get Mail in"), selectAccountMenu); 135 mail->insertItem(tr("Get Mail in"), selectAccountMenu);
136 configure->insertItem(tr("Edit account"), editAccountMenu); 136 configure->insertItem(tr("Edit account"), editAccountMenu);
137 configure->insertItem(tr("Delete account"), deleteAccountMenu); 137 configure->insertItem(tr("Delete account"), deleteAccountMenu);
138 138
139 bar = new QToolBar(this); 139 bar = new QToolBar(this);
140 140
141 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); 141 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar);
142 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); 142 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account."));
143 143
144 getMailButton->setPopup(selectAccountMenu); 144 getMailButton->setPopup(selectAccountMenu);
145 145
146 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); 146 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
147 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); 147 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) );
148 sendMailButton->addTo(bar); 148 sendMailButton->addTo(bar);
149 sendMailButton->addTo(mail); 149 sendMailButton->addTo(mail);
150 sendMailButton->setWhatsThis("Send mail queued in the outbox"); 150 sendMailButton->setWhatsThis("Send mail queued in the outbox");
151 151
152 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 152 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
153 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); 153 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
154 composeButton->addTo(bar); 154 composeButton->addTo(bar);
155 composeButton->addTo(mail); 155 composeButton->addTo(mail);
156 composeButton->setWhatsThis("Compose a new mail"); 156 composeButton->setWhatsThis("Compose a new mail");
157 157
158 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); 158 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
159 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); 159 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
160 cancelButton->addTo(mail); 160 cancelButton->addTo(mail);
161 cancelButton->addTo(bar); 161 cancelButton->addTo(bar);
162 cancelButton->setEnabled(FALSE); 162 cancelButton->setEnabled(FALSE);
163 cancelButton->setWhatsThis("Stop the currently active mail transfer"); 163 cancelButton->setWhatsThis("Stop the currently active mail transfer");
164 164
165 165
166 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); 166 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
167 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); 167 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
168 deleteButton->addTo(bar); 168 deleteButton->addTo(bar);
169 deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); 169 deleteButton->setWhatsThis("Remove the currently selected eMail(s)");
170 170
171 mailboxView = new OTabWidget( this, "mailboxView" ); 171 mailboxView = new OTabWidget( this, "mailboxView" );
172 172
173 QWidget* widget = new QWidget( mailboxView, "widget" ); 173 QWidget* widget = new QWidget( mailboxView, "widget" );
174 grid_2 = new QGridLayout( widget ); 174 grid_2 = new QGridLayout( widget );
175// grid_2->setSpacing(6); 175// grid_2->setSpacing(6);
176// grid_2->setMargin( 11 ); 176// grid_2->setMargin( 11 );
177 177
178 inboxView = new QListView( widget, "inboxView" ); 178 inboxView = new QListView( widget, "inboxView" );
179 inboxView->addColumn( tr( "From" ) ); 179 inboxView->addColumn( tr( "From" ) );
180 inboxView->addColumn( tr( "Subject" ) ); 180 inboxView->addColumn( tr( "Subject" ) );
181 inboxView->addColumn( tr( "Date" ) ); 181 inboxView->addColumn( tr( "Date" ) );
182 inboxView->setMinimumSize( QSize( 0, 0 ) ); 182 inboxView->setMinimumSize( QSize( 0, 0 ) );
183 inboxView->setAllColumnsShowFocus(TRUE); 183 inboxView->setAllColumnsShowFocus(TRUE);
184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n" 184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n"
185 "It keeps the fetched mail which can be \n" 185 "It keeps the fetched mail which can be \n"
186 "viewed by double clicking the entry.\n" 186 "viewed by double clicking the entry.\n"
187 "blue attachment icon shows whether this \n" 187 "blue attachment icon shows whether this \n"
188 "mailhas attachments.\n")); 188 "mailhas attachments.\n"));
189 189
190 grid_2->addWidget( inboxView, 2, 0 ); 190 grid_2->addWidget( inboxView, 2, 0 );
191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); 191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
192 192
193 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); 193 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" );
194 grid_3 = new QGridLayout( widget_2 ); 194 grid_3 = new QGridLayout( widget_2 );
195// grid_3->setSpacing(6); 195// grid_3->setSpacing(6);
196// grid_3->setMargin( 11 ); 196// grid_3->setMargin( 11 );
197 197
198 outboxView = new QListView( widget_2, "outboxView" ); 198 outboxView = new QListView( widget_2, "outboxView" );
199 outboxView->addColumn( tr( "To" ) ); 199 outboxView->addColumn( tr( "To" ) );
200 outboxView->addColumn( tr( "Subject" ) ); 200 outboxView->addColumn( tr( "Subject" ) );
201 outboxView->setAllColumnsShowFocus(TRUE); 201 outboxView->setAllColumnsShowFocus(TRUE);
202 202
203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n" 203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n"
204 "It keeps the queued mails to send which can be \n" 204 "It keeps the queued mails to send which can be \n"
205 "reviewed by double clicking the entry.")); 205 "reviewed by double clicking the entry."));
206 grid_3->addWidget( outboxView, 0, 0 ); 206 grid_3->addWidget( outboxView, 0, 0 );
207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); 207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
208 208
209 setCentralWidget(mailboxView); 209 setCentralWidget(mailboxView);
210 210
211} 211}
212 212
213void EmailClient::initStatusBar(QWidget* parent) 213void EmailClient::initStatusBar(QWidget* parent)
214{ 214{
215 statusBar = new QStatusBar(parent); 215 statusBar = new QStatusBar(parent);
216 statusBar->setSizeGripEnabled(FALSE); 216 statusBar->setSizeGripEnabled(FALSE);
217 217
218 status1Label = new QLabel( tr("Idle"), statusBar); 218 status1Label = new QLabel( tr("Idle"), statusBar);
219 status2Label = new QLabel("", statusBar); 219 status2Label = new QLabel("", statusBar);
220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), 220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
221 status2Label, SLOT(setText(const QString &)) ); 221 status2Label, SLOT(setText(const QString &)) );
222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), 222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
223 status2Label, SLOT(setText(const QString &)) ); 223 status2Label, SLOT(setText(const QString &)) );
224 224
225 progressBar = new QProgressBar(statusBar); 225 progressBar = new QProgressBar(statusBar);
226 226
227 connect(emailHandler, SIGNAL(mailboxSize(int)), 227 connect(emailHandler, SIGNAL(mailboxSize(int)),
228 this, SLOT(setTotalSize(int)) ); 228 this, SLOT(setTotalSize(int)) );
229 connect(emailHandler, SIGNAL(currentMailSize(int)), 229 connect(emailHandler, SIGNAL(currentMailSize(int)),
230 this, SLOT(setMailSize(int)) ); 230 this, SLOT(setMailSize(int)) );
231 connect(emailHandler, SIGNAL(downloadedSize(int)), 231 connect(emailHandler, SIGNAL(downloadedSize(int)),
232 this, SLOT(setDownloadedSize(int)) ); 232 this, SLOT(setDownloadedSize(int)) );
233 233
234 statusBar->addWidget(status1Label); 234 statusBar->addWidget(status1Label);
235 statusBar->addWidget(progressBar); 235 statusBar->addWidget(progressBar);
236 statusBar->addWidget(status2Label); 236 statusBar->addWidget(status2Label);
237 237
238} 238}
239 239
240void EmailClient::compose() 240void EmailClient::compose()
241{ 241{
242 emit composeRequested(); 242 emit composeRequested();
243} 243}
244 244
245void EmailClient::cancel() 245void EmailClient::cancel()
246{ 246{
247 emailHandler->cancel(); 247 emailHandler->cancel();
248} 248}
249 249
250AddressList* EmailClient::getAdrListRef() 250AddressList* EmailClient::getAdrListRef()
251{ 251{
252 return addressList; 252 return addressList;
253} 253}
254 254
255//this needs to be rewritten to syncronize with outboxView 255//this needs to be rewritten to syncronize with outboxView
256void EmailClient::enqueMail(const Email &mail) 256void EmailClient::enqueMail(const Email &mail)
257{ 257{
@@ -291,747 +291,752 @@ void EmailClient::sendQuedMail()
291 while (item != NULL) { 291 while (item != NULL) {
292 quedMessages.append(item->getMail()); 292 quedMessages.append(item->getMail());
293 item = (EmailListItem *) item->nextSibling(); 293 item = (EmailListItem *) item->nextSibling();
294 count++; 294 count++;
295 } 295 }
296 setMailAccount(); 296 setMailAccount();
297 emailHandler->sendMail(&quedMessages); 297 emailHandler->sendMail(&quedMessages);
298 sending = TRUE; 298 sending = TRUE;
299 sendMailButton->setEnabled(FALSE); 299 sendMailButton->setEnabled(FALSE);
300 cancelButton->setEnabled(TRUE); 300 cancelButton->setEnabled(TRUE);
301 } else { 301 } else {
302 qWarning("sendQuedMail(): no messages to send"); 302 qWarning("sendQuedMail(): no messages to send");
303 } 303 }
304 } 304 }
305} 305}
306 306
307void EmailClient::setMailAccount() 307void EmailClient::setMailAccount()
308{ 308{
309 emailHandler->setAccount(*currentAccount); 309 emailHandler->setAccount(*currentAccount);
310} 310}
311 311
312void EmailClient::mailSent() 312void EmailClient::mailSent()
313{ 313{
314 sending = FALSE; 314 sending = FALSE;
315 sendMailButton->setEnabled(TRUE); 315 sendMailButton->setEnabled(TRUE);
316 316
317 quedMessages.clear(); 317 quedMessages.clear();
318 outboxView->clear(); //should be moved to an sentBox 318 outboxView->clear(); //should be moved to an sentBox
319} 319}
320 320
321void EmailClient::getNewMail() { 321void EmailClient::getNewMail() {
322 322
323 if (accountList.count() == 0) { 323 if (accountList.count() == 0) {
324 QMessageBox::warning(qApp->activeWindow(),"No account selected", 324 QMessageBox::warning(qApp->activeWindow(),"No account selected",
325 "You must create an account", "OK\n"); 325 "You must create an account", "OK\n");
326 return; 326 return;
327 } 327 }
328 328
329 setMailAccount(); 329 setMailAccount();
330 330
331 receiving = TRUE; 331 receiving = TRUE;
332 previewingMail = TRUE; 332 previewingMail = TRUE;
333 getMailButton->setEnabled(FALSE); 333 getMailButton->setEnabled(FALSE);
334 cancelButton->setEnabled(TRUE); 334 cancelButton->setEnabled(TRUE);
335 selectAccountMenu->setEnabled(FALSE); 335 selectAccountMenu->setEnabled(FALSE);
336 336
337 status1Label->setText(currentAccount->accountName + " headers"); 337 status1Label->setText(currentAccount->accountName + " headers");
338 progressBar->reset(); 338 progressBar->reset();
339 339
340 //get any previous mails not downloaded and add to queue 340 //get any previous mails not downloaded and add to queue
341 /*mailDownloadList.clear(); 341 /*mailDownloadList.clear();
342 Email *mailPtr; 342 Email *mailPtr;
343 item = (EmailListItem *) inboxView->firstChild(); 343 item = (EmailListItem *) inboxView->firstChild();
344 while (item != NULL) { 344 while (item != NULL) {
345 mailPtr = item->getMail(); 345 mailPtr = item->getMail();
346 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { 346 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) {
347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); 347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
348 } 348 }
349 item = (EmailListItem *) item->nextSibling(); 349 item = (EmailListItem *) item->nextSibling();
350 }*/ 350 }*/
351 351
352 emailHandler->getMailHeaders(); 352 emailHandler->getMailHeaders();
353 353
354} 354}
355 355
356void EmailClient::getAllNewMail() 356void EmailClient::getAllNewMail()
357{ 357{
358 allAccounts = TRUE; 358 allAccounts = TRUE;
359 currentAccount = accountList.first(); 359 currentAccount = accountList.first();
360 getNewMail(); 360 getNewMail();
361} 361}
362 362
363void EmailClient::mailArrived(const Email &mail, bool fromDisk) 363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
364{ 364{
365 Enclosure *ePtr; 365 Enclosure *ePtr;
366 Email newMail; 366 Email newMail;
367 int thisMailId; 367 int thisMailId;
368 emailHandler->parse( mail.rawMail, lineShift, &newMail); 368 emailHandler->parse( mail.rawMail, lineShift, &newMail);
369 mailconf->setGroup(newMail.id); 369 mailconf->setGroup(newMail.id);
370 370
371 if (fromDisk) 371 if (fromDisk)
372 { 372 {
373 373
374 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
375 newMail.size = mailconf->readNumEntry("size"); 375 newMail.size = mailconf->readNumEntry("size");
376 newMail.serverId = mailconf->readNumEntry("serverid"); 376 newMail.serverId = mailconf->readNumEntry("serverid");
377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
378 } 378 }
379 else 379 else
380 { //mail arrived from server 380 { //mail arrived from server
381 381
382 newMail.serverId = mail.serverId; 382 newMail.serverId = mail.serverId;
383 newMail.size = mail.size; 383 newMail.size = mail.size;
384 newMail.downloaded = mail.downloaded; 384 newMail.downloaded = mail.downloaded;
385 385
386 newMail.fromAccountId = emailHandler->getAccount()->id; 386 newMail.fromAccountId = emailHandler->getAccount()->id;
387 mailconf->writeEntry("fromaccountid", newMail.fromAccountId); 387 mailconf->writeEntry("fromaccountid", newMail.fromAccountId);
388 } 388 }
389 389
390 //add if read or not 390 //add if read or not
391 newMail.read = mailconf->readBoolEntry("mailread"); 391 newMail.read = mailconf->readBoolEntry("mailread");
392 392
393 //check if new mail 393 //check if new mail
394 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { 394 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) {
395 thisMailId = mailIdCount; 395 thisMailId = mailIdCount;
396 mailIdCount++; 396 mailIdCount++;
397 397
398 //set server count, so that if the user aborts, the new 398 //set server count, so that if the user aborts, the new
399 //header is not reloaded 399 //header is not reloaded
400 if ((currentAccount)&&(currentAccount->synchronize)) 400 if ((currentAccount)&&(currentAccount->synchronize))
401 currentAccount->lastServerMailCount++; 401 currentAccount->lastServerMailCount++;
402 402
403 mailconf->writeEntry("internalmailid", thisMailId); 403 mailconf->writeEntry("internalmailid", thisMailId);
404 mailconf->writeEntry("downloaded", newMail.downloaded); 404 mailconf->writeEntry("downloaded", newMail.downloaded);
405 mailconf->writeEntry("size", (int) newMail.size); 405 mailconf->writeEntry("size", (int) newMail.size);
406 mailconf->writeEntry("serverid", newMail.serverId); 406 mailconf->writeEntry("serverid", newMail.serverId);
407 407
408 //addressList->addContact(newMail.fromMail, newMail.from); 408 //addressList->addContact(newMail.fromMail, newMail.from);
409 } 409 }
410 410
411 mailconf->writeEntry("downloaded", newMail.downloaded); 411 mailconf->writeEntry("downloaded", newMail.downloaded);
412 412
413 QString stringMailId; 413 QString stringMailId;
414 stringMailId.setNum(thisMailId); 414 stringMailId.setNum(thisMailId);
415 //see if any attatchments needs to be stored 415 //see if any attatchments needs to be stored
416 416
417 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { 417 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
418 QString stringId; 418 QString stringId;
419 stringId.setNum(ePtr->id); 419 stringId.setNum(ePtr->id);
420 420
421 int id = mailconf->readNumEntry("enclosureid_" + stringId); 421 int id = mailconf->readNumEntry("enclosureid_" + stringId);
422 if (id != ePtr->id) { //new entry 422 if (id != ePtr->id) { //new entry
423 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); 423 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id);
424 mailconf->writeEntry("name_" + stringId, ePtr->originalName); 424 mailconf->writeEntry("name_" + stringId, ePtr->originalName);
425 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); 425 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType);
426 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); 426 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute);
427 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 427 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
428 mailconf->writeEntry("installed_" + stringId, FALSE); 428 mailconf->writeEntry("installed_" + stringId, FALSE);
429 429
430 ePtr->name = stringMailId + "_" + stringId; 430 ePtr->name = stringMailId + "_" + stringId;
431 ePtr->path = getPath(TRUE); 431 ePtr->path = getPath(TRUE);
432 if (emailHandler->getEnclosure(ePtr)) { //file saved 432 if (emailHandler->getEnclosure(ePtr)) { //file saved
433 ePtr->saved = TRUE; 433 ePtr->saved = TRUE;
434 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 434 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
435 mailconf->writeEntry("filename_" + stringId, ePtr->name); 435 mailconf->writeEntry("filename_" + stringId, ePtr->name);
436 mailconf->writeEntry("path_" + stringId, ePtr->path); 436 mailconf->writeEntry("path_" + stringId, ePtr->path);
437 } else { 437 } else {
438 ePtr->saved = FALSE; 438 ePtr->saved = FALSE;
439 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 439 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
440 } 440 }
441 } else { 441 } else {
442 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); 442 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
443 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); 443 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
444 if (ePtr->saved) { 444 if (ePtr->saved) {
445 ePtr->name = mailconf->readEntry("filename_" + stringId); 445 ePtr->name = mailconf->readEntry("filename_" + stringId);
446 ePtr->path = mailconf->readEntry("path_" + stringId); 446 ePtr->path = mailconf->readEntry("path_" + stringId);
447 } 447 }
448 } 448 }
449 } 449 }
450 450
451 bool found=false; 451 bool found=false;
452 452
453 if (!fromDisk) 453 if (!fromDisk)
454 { 454 {
455 455
456 Email *mailPtr; 456 Email *mailPtr;
457 item = (EmailListItem *) inboxView->firstChild(); 457 item = (EmailListItem *) inboxView->firstChild();
458 while ((item != NULL)&&(!found)) 458 while ((item != NULL)&&(!found))
459 { 459 {
460 mailPtr = item->getMail(); 460 mailPtr = item->getMail();
461 if (mailPtr->id == newMail.id) { 461 if (mailPtr->id == newMail.id) {
462 item->setMail(newMail); 462 item->setMail(newMail);
463 emit mailUpdated(item->getMail()); 463 emit mailUpdated(item->getMail());
464 found = true; 464 found = true;
465 } 465 }
466 item = (EmailListItem *) item->nextSibling(); 466 item = (EmailListItem *) item->nextSibling();
467 } 467 }
468 } 468 }
469 if ((!found)||(fromDisk)) { 469 if ((!found)||(fromDisk)) {
470 item = new EmailListItem(inboxView, newMail, TRUE); 470 item = new EmailListItem(inboxView, newMail, TRUE);
471 } 471 }
472// if (item->getMail()->files.count()>0) 472// if (item->getMail()->files.count()>0)
473// { 473// {
474// item->setPixmap(0, Resource::loadPixmap("mailit/attach")); 474// item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475// } 475// }
476 /*if (!newMail.downloaded) 476 /*if (!newMail.downloaded)
477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ 477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
478 478
479 mailboxView->setCurrentTab(0); 479 mailboxView->setCurrentTab(0);
480 480
481} 481}
482 482
483void EmailClient::allMailArrived(int count) 483void EmailClient::allMailArrived(int /*count*/)
484{ 484{
485 // not previewing means all mailtransfer has been done 485 // not previewing means all mailtransfer has been done
486 /*if (!previewingMail) {*/ 486 /*if (!previewingMail) {*/
487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
488 emit newCaption("Mailit - " + currentAccount->accountName); 488 emit newCaption("Mailit - " + currentAccount->accountName);
489 getNewMail(); 489 getNewMail();
490 return; 490 return;
491 } else { 491 } else {
492 allAccounts = FALSE; 492 allAccounts = FALSE;
493 receiving = FALSE; 493 receiving = FALSE;
494 getMailButton->setEnabled(TRUE); 494 getMailButton->setEnabled(TRUE);
495 cancelButton->setEnabled(FALSE); 495 cancelButton->setEnabled(FALSE);
496 selectAccountMenu->setEnabled(TRUE); 496 selectAccountMenu->setEnabled(TRUE);
497 status1Label->setText("Idle"); 497 status1Label->setText("Idle");
498 498
499 progressBar->reset(); 499 progressBar->reset();
500 return; 500 return;
501 } 501 }
502 //} 502 //}
503 503
504 // all headers downloaded from server, start downloading remaining mails 504 // all headers downloaded from server, start downloading remaining mails
505 previewingMail = FALSE; 505 previewingMail = FALSE;
506 status1Label->setText(currentAccount->accountName); 506 status1Label->setText(currentAccount->accountName);
507 progressBar->reset(); 507 progressBar->reset();
508 508
509 509
510 mailboxView->setCurrentTab(0); 510 mailboxView->setCurrentTab(0);
511} 511}
512 512
513 513
514void EmailClient::moveMailFront(Email *mailPtr) 514void EmailClient::moveMailFront(Email *mailPtr)
515{ 515{
516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); 517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
518 } 518 }
519} 519}
520 520
521void EmailClient::smtpError(int code) 521void EmailClient::smtpError(int code, const QString & Msg)
522{ 522{
523 QString temp; 523 QString temp;
524 524
525 if (code == ErrUnknownResponse) 525 if (code == ErrUnknownResponse) {
526 temp = "Unknown response from server"; 526 temp = tr("<qt>Unknown response from server</qt>");
527 527 if( ! Msg.isEmpty() )
528 if (code == QSocket::ErrHostNotFound) 528 temp += Msg;
529 temp = "host not found"; 529 } else if (code == QSocket::ErrHostNotFound) {
530 if (code == QSocket::ErrConnectionRefused) 530 temp = tr("<qt>host not found</qt>");
531 temp = "connection refused"; 531 } else if (code == QSocket::ErrConnectionRefused) {
532 if (code == QSocket::ErrSocketRead) 532 temp = tr("<qt>connection refused</qt>");
533 temp = "socket packet error"; 533 } else if (code == QSocket::ErrSocketRead) {
534 temp = tr("<qt>socket packet error</qt>");
535 }
534 536
535 if (code != ErrCancel) { 537 if (code != ErrCancel) {
536 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); 538 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
537 } else { 539 } else {
538 status2Label->setText("Aborted by user"); 540 status2Label->setText("Aborted by user");
539 } 541 }
540 542
541 sending = FALSE; 543 sending = FALSE;
542 sendMailButton->setEnabled(TRUE); 544 sendMailButton->setEnabled(TRUE);
543 cancelButton->setEnabled(FALSE); 545 cancelButton->setEnabled(FALSE);
544 quedMessages.clear(); 546 quedMessages.clear();
545} 547}
546 548
547void EmailClient::popError(int code) 549void EmailClient::popError(int code, const QString & Msg)
548{ 550{
549 QString temp; 551 QString temp;
550 552
551 if (code == ErrUnknownResponse) 553 if (code == ErrUnknownResponse) {
552 temp = "Unknown response from server"; 554 temp = tr("<qt>Unknown response from server</qt>");
553 if (code == ErrLoginFailed) 555 if( ! Msg.isEmpty() )
554 temp = "Login failed\nCheck user name and password"; 556 temp += Msg;
555 557 } else if (code == ErrLoginFailed) {
556 if (code == QSocket::ErrHostNotFound) 558 temp = tr("<qt>Login failed\nCheck user name and password</qt>");
557 temp = "host not found"; 559 } else if (code == QSocket::ErrHostNotFound) {
558 if (code == QSocket::ErrConnectionRefused) 560 temp = tr("<qt>host not found</qt>");
559 temp = "connection refused"; 561 } else if (code == QSocket::ErrConnectionRefused) {
560 if (code == QSocket::ErrSocketRead) 562 temp = tr("<qt>connection refused</qt>");
561 temp = "socket packet error"; 563 } else if (code == QSocket::ErrSocketRead) {
562 564 temp = tr("<qt>socket packet error</qt>");
565 }
566
563 if (code != ErrCancel) { 567 if (code != ErrCancel) {
564 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); 568 QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n"));
569
565 } else { 570 } else {
566 status2Label->setText("Aborted by user"); 571 status2Label->setText("Aborted by user");
567 } 572 }
568 573
569 receiving = FALSE; 574 receiving = FALSE;
570 getMailButton->setEnabled(TRUE); 575 getMailButton->setEnabled(TRUE);
571 cancelButton->setEnabled(FALSE); 576 cancelButton->setEnabled(FALSE);
572 selectAccountMenu->setEnabled(TRUE); 577 selectAccountMenu->setEnabled(TRUE);
573} 578}
574 579
575void EmailClient::inboxItemSelected() 580void EmailClient::inboxItemSelected()
576{ 581{
577 //killTimer(timerID); 582 //killTimer(timerID);
578 583
579 item = (EmailListItem*) inboxView->selectedItem(); 584 item = (EmailListItem*) inboxView->selectedItem();
580 if (item != NULL) { 585 if (item != NULL) {
581 emit viewEmail(inboxView, item->getMail()); 586 emit viewEmail(inboxView, item->getMail());
582 } 587 }
583} 588}
584 589
585void EmailClient::outboxItemSelected() 590void EmailClient::outboxItemSelected()
586{ 591{
587 //killTimer(timerID); 592 //killTimer(timerID);
588 593
589 item = (EmailListItem*) outboxView->selectedItem(); 594 item = (EmailListItem*) outboxView->selectedItem();
590 if (item != NULL) { 595 if (item != NULL) {
591 emit viewEmail(outboxView, item->getMail()); 596 emit viewEmail(outboxView, item->getMail());
592 } 597 }
593 598
594} 599}
595 600
596void EmailClient::readMail() 601void EmailClient::readMail()
597{ 602{
598 Email mail; 603 Email mail;
599 int start, stop; 604 int start, stop;
600 QString s, del; 605 QString s, del;
601 606
602 QFile f(getPath(FALSE) + "inbox.txt"); 607 QFile f(getPath(FALSE) + "inbox.txt");
603 608
604 if ( f.open(IO_ReadOnly) ) { // file opened successfully 609 if ( f.open(IO_ReadOnly) ) { // file opened successfully
605 QTextStream t( &f ); // use a text stream 610 QTextStream t( &f ); // use a text stream
606 s = t.read(); 611 s = t.read();
607 f.close(); 612 f.close();
608 613
609 start = 0; 614 start = 0;
610 del = "\n.\n"; 615 del = "\n.\n";
611 while ((uint) start < s.length()) { 616 while ((uint) start < s.length()) {
612 stop = s.find(del, start); 617 stop = s.find(del, start);
613 if (stop == -1) 618 if (stop == -1)
614 stop = s.length() - del.length(); 619 stop = s.length() - del.length();
615 620
616 mail.rawMail = s.mid(start, stop + del.length() - start ); 621 mail.rawMail = s.mid(start, stop + del.length() - start );
617 start = stop + del.length(); 622 start = stop + del.length();
618 mailArrived(mail, TRUE); 623 mailArrived(mail, TRUE);
619 } 624 }
620 } 625 }
621 626
622 QFile fo(getPath(FALSE) + "outbox.txt"); 627 QFile fo(getPath(FALSE) + "outbox.txt");
623 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 628 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
624 QTextStream t( &fo ); // use a text stream 629 QTextStream t( &fo ); // use a text stream
625 s = t.read(); 630 s = t.read();
626 fo.close(); 631 fo.close();
627 632
628 start = 0; 633 start = 0;
629 del = "\n.\n"; 634 del = "\n.\n";
630 while ((uint) start < s.length()) { 635 while ((uint) start < s.length()) {
631 stop = s.find(del, start); 636 stop = s.find(del, start);
632 if (stop == -1) 637 if (stop == -1)
633 stop = s.length() - del.length(); 638 stop = s.length() - del.length();
634 639
635 mail.rawMail = s.mid(start, stop + del.length() - start ); 640 mail.rawMail = s.mid(start, stop + del.length() - start );
636 start = stop + del.length(); 641 start = stop + del.length();
637 emailHandler->parse(mail.rawMail, lineShift, &mail); 642 emailHandler->parse(mail.rawMail, lineShift, &mail);
638 mail.sent = false; 643 mail.sent = false;
639 mail.received = false; 644 mail.received = false;
640 enqueMail(mail); 645 enqueMail(mail);
641 646
642 } 647 }
643 } 648 }
644} 649}
645 650
646void EmailClient::saveMail(const QString &fileName, QListView *view) 651void EmailClient::saveMail(const QString &fileName, QListView *view)
647{ 652{
648 QFile f(fileName); 653 QFile f(fileName);
649 Email *mail; 654 Email *mail;
650 655
651 if (! f.open(IO_WriteOnly) ) { 656 if (! f.open(IO_WriteOnly) ) {
652 qWarning("could not open file"); 657 qWarning("could not open file");
653 return; 658 return;
654 } 659 }
655 item = (EmailListItem *) view->firstChild(); 660 item = (EmailListItem *) view->firstChild();
656 QTextStream t(&f); 661 QTextStream t(&f);
657 while (item != NULL) { 662 while (item != NULL) {
658 mail = item->getMail(); 663 mail = item->getMail();
659 t << mail->rawMail; 664 t << mail->rawMail;
660 665
661 mailconf->setGroup(mail->id); 666 mailconf->setGroup(mail->id);
662 mailconf->writeEntry("mailread", mail->read); 667 mailconf->writeEntry("mailread", mail->read);
663 668
664 item = (EmailListItem *) item->nextSibling(); 669 item = (EmailListItem *) item->nextSibling();
665 } 670 }
666 f.close(); 671 f.close();
667} 672}
668 673
669//paths for mailit, is settings, inbox, enclosures 674//paths for mailit, is settings, inbox, enclosures
670QString EmailClient::getPath(bool enclosurePath) 675QString EmailClient::getPath(bool enclosurePath)
671{ 676{
672 QString basePath = "qtmail"; 677 QString basePath = "qtmail";
673 QString enclosures = "enclosures"; 678 QString enclosures = "enclosures";
674 679
675 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 680 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
676 if ( !dir.exists() ) 681 if ( !dir.exists() )
677 dir.mkdir( dir.path() ); 682 dir.mkdir( dir.path() );
678 683
679 if (enclosurePath) { 684 if (enclosurePath) {
680 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 685 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
681 686
682 if ( !dir.exists() ) 687 if ( !dir.exists() )
683 dir.mkdir( dir.path() ); 688 dir.mkdir( dir.path() );
684 689
685 return (dir.path() + "/"); 690 return (dir.path() + "/");
686 691
687 } 692 }
688 return (dir.path() + "/"); 693 return (dir.path() + "/");
689} 694}
690 695
691void EmailClient::readSettings() 696void EmailClient::readSettings()
692{ 697{
693 int y,acc_count; 698 int y,acc_count;
694 699
695 mailconf->setGroup("mailitglobal"); 700 mailconf->setGroup("mailitglobal");
696 acc_count=mailconf->readNumEntry("Accounts",0); 701 acc_count=mailconf->readNumEntry("Accounts",0);
697 702
698 for (int accountPos = 0;accountPos<acc_count ; accountPos++) 703 for (int accountPos = 0;accountPos<acc_count ; accountPos++)
699 { 704 {
700 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... 705 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ...
701 account.accountName = mailconf->readEntry("AccName",""); 706 account.accountName = mailconf->readEntry("AccName","");
702 account.name = mailconf->readEntry("UserName",""); 707 account.name = mailconf->readEntry("UserName","");
703 account.emailAddress = mailconf->readEntry("Email",""); 708 account.emailAddress = mailconf->readEntry("Email","");
704 account.popUserName = mailconf->readEntry("POPUser",""); 709 account.popUserName = mailconf->readEntry("POPUser","");
705 account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); 710 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
706 account.popServer = mailconf->readEntry("POPServer",""); 711 account.popServer = mailconf->readEntry("POPServer","");
707 account.smtpServer = mailconf->readEntry("SMTPServer",""); 712 account.smtpServer = mailconf->readEntry("SMTPServer","");
708 account.id = mailconf->readNumEntry("AccountId",0); 713 account.id = mailconf->readNumEntry("AccountId",0);
709 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); 714 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
710 account.lastServerMailCount = 0; 715 account.lastServerMailCount = 0;
711 account.synchronize = FALSE; 716 account.synchronize = FALSE;
712 717
713 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); 718 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
714 if (account.synchronize) 719 if (account.synchronize)
715 { 720 {
716 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); 721 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
717 } 722 }
718 723
719 accountList.append(&account); 724 accountList.append(&account);
720 } 725 }
721 726
722 mailconf->setGroup("mailitglobal"); 727 mailconf->setGroup("mailitglobal");
723 728
724 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) 729 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
725 { 730 {
726 mailIdCount = y; 731 mailIdCount = y;
727 } 732 }
728 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) 733 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
729 { 734 {
730 accountIdCount = y; 735 accountIdCount = y;
731 } 736 }
732} 737}
733 738
734void EmailClient::saveSettings() 739void EmailClient::saveSettings()
735{ 740{
736 int acc_count=0; 741 int acc_count=0;
737 MailAccount *accountPtr; 742 MailAccount *accountPtr;
738 743
739 744
740 if (!mailconf) 745 if (!mailconf)
741 { 746 {
742 qWarning("could not save settings"); 747 qWarning("could not save settings");
743 return; 748 return;
744 } 749 }
745 750
746 for (accountPtr = accountList.first(); accountPtr != 0; 751 for (accountPtr = accountList.first(); accountPtr != 0;
747 accountPtr = accountList.next()) 752 accountPtr = accountList.next())
748 { 753 {
749 mailconf->setGroup("Account_"+QString::number(++acc_count)); 754 mailconf->setGroup("Account_"+QString::number(++acc_count));
750 mailconf->writeEntry("AccName",accountPtr->accountName ); 755 mailconf->writeEntry("AccName",accountPtr->accountName );
751 mailconf->writeEntry("UserName",accountPtr->name); 756 mailconf->writeEntry("UserName",accountPtr->name);
752 mailconf->writeEntry("Email",accountPtr->emailAddress); 757 mailconf->writeEntry("Email",accountPtr->emailAddress);
753 mailconf->writeEntry("POPUser",accountPtr->popUserName); 758 mailconf->writeEntry("POPUser",accountPtr->popUserName);
754 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); 759 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd);
755 mailconf->writeEntry("POPServer",accountPtr->popServer); 760 mailconf->writeEntry("POPServer",accountPtr->popServer);
756 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); 761 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer);
757 mailconf->writeEntry("AccountId",accountPtr->id); 762 mailconf->writeEntry("AccountId",accountPtr->id);
758 if (accountPtr->synchronize) 763 if (accountPtr->synchronize)
759 { 764 {
760 mailconf->writeEntry("Synchronize","Yes"); 765 mailconf->writeEntry("Synchronize","Yes");
761 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); 766 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit);
762 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); 767 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount);
763 } 768 }
764 else 769 else
765 { 770 {
766 mailconf->writeEntry("Synchronize", "No"); 771 mailconf->writeEntry("Synchronize", "No");
767 } 772 }
768 } 773 }
769 774
770 mailconf->setGroup("mailitglobal"); 775 mailconf->setGroup("mailitglobal");
771 mailconf->writeEntry("Accounts",acc_count); 776 mailconf->writeEntry("Accounts",acc_count);
772 mailconf->writeEntry("mailidcount", mailIdCount); 777 mailconf->writeEntry("mailidcount", mailIdCount);
773 mailconf->writeEntry("accountidcount", accountIdCount); 778 mailconf->writeEntry("accountidcount", accountIdCount);
774} 779}
775 780
776void EmailClient::selectAccount(int id) 781void EmailClient::selectAccount(int id)
777{ 782{
778 if (accountList.count() > 0) { 783 if (accountList.count() > 0) {
779 currentAccount = accountList.at(id); 784 currentAccount = accountList.at(id);
780 emit newCaption("Mailit - " + currentAccount->accountName); 785 emit newCaption("Mailit - " + currentAccount->accountName);
781 getNewMail(); 786 getNewMail();
782 } else { 787 } else {
783 emit newCaption("Mailit ! No account defined"); 788 emit newCaption("Mailit ! No account defined");
784 } 789 }
785} 790}
786 791
787void EmailClient::editAccount(int id) 792void EmailClient::editAccount(int id)
788{ 793{
789 MailAccount *newAccount; 794 MailAccount *newAccount;
790 795
791 editAccountView = new EditAccount(this, "account", TRUE); 796 editAccountView = new EditAccount(this, "account", TRUE);
792 if (id == newAccountId) { //new account 797 if (id == newAccountId) { //new account
793 newAccount = new MailAccount; 798 newAccount = new MailAccount;
794 editAccountView->setAccount(newAccount); 799 editAccountView->setAccount(newAccount);
795 } else { 800 } else {
796 newAccount = accountList.at(id); 801 newAccount = accountList.at(id);
797 editAccountView->setAccount(newAccount, FALSE); 802 editAccountView->setAccount(newAccount, FALSE);
798 } 803 }
799 804
800 editAccountView->showMaximized(); 805 editAccountView->showMaximized();
801 editAccountView->exec(); 806 editAccountView->exec();
802 807
803 if (editAccountView->result() == QDialog::Accepted) { 808 if (editAccountView->result() == QDialog::Accepted) {
804 if (id == newAccountId) { 809 if (id == newAccountId) {
805 newAccount->id = accountIdCount; 810 newAccount->id = accountIdCount;
806 accountIdCount++; 811 accountIdCount++;
807 accountList.append(newAccount); 812 accountList.append(newAccount);
808 updateAccounts(); 813 updateAccounts();
809 } else { 814 } else {
810 updateAccounts(); 815 updateAccounts();
811 } 816 }
812 } 817 }
813 818
814 delete editAccountView; 819 delete editAccountView;
815} 820}
816 821
817void EmailClient::deleteAccount(int id) 822void EmailClient::deleteAccount(int id)
818{ 823{
819 MailAccount *newAccount; 824 MailAccount *newAccount;
820 QString message; 825 QString message;
821 826
822 newAccount = accountList.at(id); 827 newAccount = accountList.at(id);
823 message = "Delete account:\n" + newAccount->accountName; 828 message = "Delete account:\n" + newAccount->accountName;
824 switch( QMessageBox::warning( this, "Mailit", message, 829 switch( QMessageBox::warning( this, "Mailit", message,
825 "Yes", "No", 0, 0, 1 ) ) { 830 "Yes", "No", 0, 0, 1 ) ) {
826 831
827 case 0: accountList.remove(id); 832 case 0: accountList.remove(id);
828 updateAccounts(); 833 updateAccounts();
829 break; 834 break;
830 case 1: 835 case 1:
831 break; 836 break;
832 } 837 }
833} 838}
834 839
835void EmailClient::updateAccounts() 840void EmailClient::updateAccounts()
836{ 841{
837 MailAccount *accountPtr; 842 MailAccount *accountPtr;
838 843
839 //rebuild menus, clear all first 844 //rebuild menus, clear all first
840 editAccountMenu->clear(); 845 editAccountMenu->clear();
841 selectAccountMenu->clear(); 846 selectAccountMenu->clear();
842 deleteAccountMenu->clear(); 847 deleteAccountMenu->clear();
843 848
844 newAccountId = editAccountMenu->insertItem("New", this, 849 newAccountId = editAccountMenu->insertItem("New", this,
845 SLOT(editAccount(int)) ); 850 SLOT(editAccount(int)) );
846 editAccountMenu->insertSeparator(); 851 editAccountMenu->insertSeparator();
847 852
848 idCount = 0; 853 idCount = 0;
849 for (accountPtr = accountList.first(); accountPtr != 0; 854 for (accountPtr = accountList.first(); accountPtr != 0;
850 accountPtr = accountList.next()) { 855 accountPtr = accountList.next()) {
851 856
852 editAccountMenu->insertItem(accountPtr->accountName, 857 editAccountMenu->insertItem(accountPtr->accountName,
853 this, SLOT(editAccount(int)), 0, idCount); 858 this, SLOT(editAccount(int)), 0, idCount);
854 selectAccountMenu->insertItem(accountPtr->accountName, 859 selectAccountMenu->insertItem(accountPtr->accountName,
855 this, SLOT(selectAccount(int)), 0, idCount); 860 this, SLOT(selectAccount(int)), 0, idCount);
856 deleteAccountMenu->insertItem(accountPtr->accountName, 861 deleteAccountMenu->insertItem(accountPtr->accountName,
857 this, SLOT(deleteAccount(int)), 0, idCount); 862 this, SLOT(deleteAccount(int)), 0, idCount);
858 idCount++; 863 idCount++;
859 } 864 }
860} 865}
861 866
862void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) 867void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
863{ 868{
864 Email *mPtr; 869 Email *mPtr;
865 Enclosure *ePtr; 870 Enclosure *ePtr;
866 871
867 if (inbox) 872 if (inbox)
868 { 873 {
869 mPtr = mailItem->getMail(); 874 mPtr = mailItem->getMail();
870 875
871 //if mail is in queue for download, remove it from 876 //if mail is in queue for download, remove it from
872 //queue if possible 877 //queue if possible
873 if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { 878 if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) {
874 if ( !mPtr->downloaded ) 879 if ( !mPtr->downloaded )
875 mailDownloadList.remove(mPtr->serverId, mPtr->size); 880 mailDownloadList.remove(mPtr->serverId, mPtr->size);
876 } 881 }
877 882
878 mailconf->setGroup(mPtr->id); 883 mailconf->setGroup(mPtr->id);
879 mailconf->clearGroup(); 884 mailconf->clearGroup();
880 885
881 //delete any temporary attatchemnts storing 886 //delete any temporary attatchemnts storing
882 for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { 887 for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) {
883 if (ePtr->saved) { 888 if (ePtr->saved) {
884 QFile::remove( (ePtr->path + ePtr->name) ); 889 QFile::remove( (ePtr->path + ePtr->name) );
885 } 890 }
886 } 891 }
887 inboxView->takeItem(mailItem); 892 inboxView->takeItem(mailItem);
888 } 893 }
889 else 894 else
890 { 895 {
891 outboxView->takeItem(mailItem); 896 outboxView->takeItem(mailItem);
892 } 897 }
893} 898}
894 899
895void EmailClient::setMailSize(int size) 900void EmailClient::setMailSize(int size)
896{ 901{
897 progressBar->reset(); 902 progressBar->reset();
898 progressBar->setTotalSteps(size); 903 progressBar->setTotalSteps(size);
899} 904}
900 905
901void EmailClient::setTotalSize(int size) 906void EmailClient::setTotalSize(int /*size*/)
902{ 907{
903 908
904} 909}
905 910
906void EmailClient::setDownloadedSize(int size) 911void EmailClient::setDownloadedSize(int size)
907{ 912{
908 int total = progressBar->totalSteps(); 913 int total = progressBar->totalSteps();
909 914
910 if (size < total) { 915 if (size < total) {
911 progressBar->setProgress(size); 916 progressBar->setProgress(size);
912 } else { 917 } else {
913 progressBar->setProgress(total); 918 progressBar->setProgress(total);
914 } 919 }
915} 920}
916 921
917void EmailClient::deleteItem() 922void EmailClient::deleteItem()
918{ 923{
919 bool inbox=mailboxView->currentTab()==0; 924 bool inbox=mailboxView->currentTab()==0;
920 QListView* box; 925 QListView* box;
921 926
922 EmailListItem* eli; 927 EmailListItem* eli;
923 int pos; 928 // int pos;
924 929
925 inbox ? box=inboxView : box=outboxView; 930 inbox ? box=inboxView : box=outboxView;
926 931
927 eli=(EmailListItem*)box->selectedItem(); 932 eli=(EmailListItem*)box->selectedItem();
928 933
929 if (eli) 934 if (eli)
930 { 935 {
931 box->setSelected(eli->itemBelow(),true); //select the previous item 936 box->setSelected(eli->itemBelow(),true); //select the previous item
932 937
933 deleteMail(eli,(bool&)inbox); //remove mail entry 938 deleteMail(eli,(bool&)inbox); //remove mail entry
934 } 939 }
935} 940}
936 941
937void EmailClient::inboxItemPressed() 942void EmailClient::inboxItemPressed()
938{ 943{
939// timerID=startTimer(500); 944// timerID=startTimer(500);
940} 945}
941 946
942void EmailClient::inboxItemReleased() 947void EmailClient::inboxItemReleased()
943{ 948{
944 // killTimer(timerID); 949 // killTimer(timerID);
945} 950}
946 951
947/*void EmailClient::timerEvent(QTimerEvent *e) 952/*void EmailClient::timerEvent(QTimerEvent *e)
948{ 953{
949 /*killTimer(timerID); 954 //killTimer(timerID);
950 955
951 956
952 QPopupMenu *action = new QPopupMenu(this); 957 QPopupMenu *action = new QPopupMenu(this);
953 958
954 int reply=0; 959 int reply=0;
955 960
956 action->insertItem(tr( "Reply To" ),this,SLOT(reply())); 961 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
957 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); 962 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
958 action->insertItem( tr( "Forward" ), this,SLOT(forward())); 963 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
959 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); 964 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
960 965
961 action->exec(QCursor::pos()); 966 action->exec(QCursor::pos());
962 967
963 if (action) delete action; 968 if (action) delete action;
964 969
965}*/ 970}*/
966 971
967Email* EmailClient::getCurrentMail() 972Email* EmailClient::getCurrentMail()
968{ 973{
969 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); 974 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
970 if (eli!=NULL) 975 if (eli!=NULL)
971 return eli->getMail(); 976 return eli->getMail();
972 else 977 else
973 return NULL; 978 return NULL;
974} 979}
975 980
976void EmailClient::download(Email* mail) 981void EmailClient::download(Email* mail)
977{ 982{
978 MailAccount* acc=0; 983 MailAccount* acc=0;
979 984
980 tempMailDownloadList.clear(); 985 tempMailDownloadList.clear();
981 tempMailDownloadList.sizeInsert(mail->serverId, mail->size); 986 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
982 987
983 acc=accountList.at(mail->fromAccountId-1); 988 acc=accountList.at(mail->fromAccountId-1);
984 if (acc) 989 if (acc)
985 { 990 {
986 emailHandler->setAccount(*acc); 991 emailHandler->setAccount(*acc);
987 emailHandler->getMailByList(&tempMailDownloadList); 992 emailHandler->getMailByList(&tempMailDownloadList);
988 } 993 }
989 else 994 else
990 QMessageBox::warning(qApp->activeWindow(), 995 QMessageBox::warning(qApp->activeWindow(),
991 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); 996 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
992} 997}
993 998
994void EmailClient::receive(const QCString& msg, const QByteArray& data) 999void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/)
995{ 1000{
996 /*if (msg=="getMail()") 1001 /*if (msg=="getMail()")
997 { 1002 {
998 /*QDialog qd(qApp->activeWindow(),"Getting mail",true); 1003 //QDialog qd(qApp->activeWindow(),"Getting mail",true);
999 QVBoxLayout *vbProg = new QVBoxLayout( &qd ); 1004 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
1000 1005
1001 initStatusBar(&qd); 1006 initStatusBar(&qd);
1002 1007
1003 if (statusBar==0) 1008 if (statusBar==0)
1004 { 1009 {
1005 qDebug("No Bar ..."); 1010 qDebug("No Bar ...");
1006 //statusBar=new ProgressBar(&qd); 1011 //statusBar=new ProgressBar(&qd);
1007 } 1012 }
1008 statusBar->show(); 1013 statusBar->show();
1009 vbProg->addWidget(statusBar); 1014 vbProg->addWidget(statusBar);
1010 qd.showMaximized(); 1015 qd.showMaximized();
1011 qd.show(); 1016 qd.show();
1012 emit getAllNewMail(); 1017 emit getAllNewMail();
1013 //qd.exec(); 1018 //qd.exec();
1014 } 1019 }
1015 else if (msg=="compose()") 1020 else if (msg=="compose()")
1016 { 1021 {
1017 QDialog qd(qApp->activeWindow(),"Getting mail",true); 1022 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1018 1023
1019 WriteMail wm(&qd,"write new mail"); 1024 WriteMail wm(&qd,"write new mail");
1020 QVBoxLayout vbProg( &qd ); 1025 QVBoxLayout vbProg( &qd );
1021 1026
1022 wm.showMaximized(); 1027 wm.showMaximized();
1023 vbProg.addWidget(&wm); 1028 vbProg.addWidget(&wm);
1024 1029
1025 qd.showMaximized(); 1030 qd.showMaximized();
1026 1031
1027 emit composeRequested(); 1032 emit composeRequested();
1028 qd.exec(); 1033 qd.exec();
1029 1034
1030 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1031 } 1036 }
1032 1037
1033 else if (msg=="dialog()") 1038 else if (msg=="dialog()")
1034 { 1039 {
1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); 1040 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1036 }*/ 1041 }*/
1037} 1042}
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h
index c98cfce..80c6d31 100644
--- a/noncore/unsupported/mailit/emailclient.h
+++ b/noncore/unsupported/mailit/emailclient.h
@@ -1,181 +1,181 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef EMAILCLIENT_H 20#ifndef EMAILCLIENT_H
21#define EMAILCLIENT_H 21#define EMAILCLIENT_H
22 22
23#include <qlist.h> 23#include <qlist.h>
24#include <qcstring.h> 24#include <qcstring.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qaction.h> 32#include <qaction.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qtooltip.h> 34#include <qtooltip.h>
35#include <qtoolbutton.h> 35#include <qtoolbutton.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39#include <qprogressbar.h> 39#include <qprogressbar.h>
40#include <qstatusbar.h> 40#include <qstatusbar.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <opie/otabwidget.h> 43#include <opie/otabwidget.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45#include <qtimer.h> 45#include <qtimer.h>
46 46
47#include "emailhandler.h" 47#include "emailhandler.h"
48#include "emaillistitem.h" 48#include "emaillistitem.h"
49#include "textparser.h" 49#include "textparser.h"
50#include "editaccount.h" 50#include "editaccount.h"
51#include "maillist.h" 51#include "maillist.h"
52#include "addresslist.h" 52#include "addresslist.h"
53 53
54#include <qpe/config.h> 54#include <qpe/config.h>
55 55
56class AccountList : public QList<MailAccount> 56class AccountList : public QList<MailAccount>
57{ 57{
58public: 58public:
59 Item newItem(Item d); 59 Item newItem(Item d);
60private: 60private:
61 MailAccount* dupl(MailAccount *in); 61 MailAccount* dupl(MailAccount *in);
62 MailAccount *ac; 62 MailAccount *ac;
63}; 63};
64 64
65//class EmailClient : public EmailClientBase 65//class EmailClient : public EmailClientBase
66class EmailClient : public QMainWindow 66class EmailClient : public QMainWindow
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 69
70public: 70public:
71 EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); 71 EmailClient( QWidget* parent, const char* name, WFlags fl = 0 );
72 ~EmailClient(); 72 ~EmailClient();
73 AddressList* getAdrListRef(); 73 AddressList* getAdrListRef();
74 74
75protected: 75protected:
76 //void timerEvent(QTimerEvent*); 76 //void timerEvent(QTimerEvent*);
77 77
78signals: 78signals:
79 void composeRequested(); 79 void composeRequested();
80 void viewEmail(QListView *, Email *); 80 void viewEmail(QListView *, Email *);
81 void mailUpdated(Email *); 81 void mailUpdated(Email *);
82 void newCaption(const QString &); 82 void newCaption(const QString &);
83 void replyRequested(Email&, bool&); 83 void replyRequested(Email&, bool&);
84 void forwardRequested(Email&); 84 void forwardRequested(Email&);
85 void removeItem(EmailListItem*, bool&); 85 void removeItem(EmailListItem*, bool&);
86 /*void reply(Email&); 86 /*void reply(Email&);
87 void replyAll(Email&); 87 void replyAll(Email&);
88 void remove(Email&); 88 void remove(Email&);
89 void forward(Email&);*/ 89 void forward(Email&);*/
90 90
91public slots: 91public slots:
92 void compose(); 92 void compose();
93 void cancel(); 93 void cancel();
94 void enqueMail(const Email &mail); 94 void enqueMail(const Email &mail);
95 void setMailAccount(); 95 void setMailAccount();
96 void sendQuedMail(); 96 void sendQuedMail();
97 void mailSent(); 97 void mailSent();
98 void deleteItem(); 98 void deleteItem();
99 void getNewMail(); 99 void getNewMail();
100 void getAllNewMail(); 100 void getAllNewMail();
101 void smtpError(int code); 101 void smtpError(int code, const QString & Msg );
102 void popError(int code); 102 void popError(int code, const QString & Msg);
103 void inboxItemSelected(); 103 void inboxItemSelected();
104 void outboxItemSelected(); 104 void outboxItemSelected();
105 void inboxItemPressed(); 105 void inboxItemPressed();
106 void inboxItemReleased(); 106 void inboxItemReleased();
107 void mailArrived(const Email &mail, bool fromDisk); 107 void mailArrived(const Email &mail, bool fromDisk);
108 void allMailArrived(int); 108 void allMailArrived(int);
109 void saveMail(const QString &fileName, QListView *view); 109 void saveMail(const QString &fileName, QListView *view);
110 void selectAccount(int); 110 void selectAccount(int);
111 void editAccount(int); 111 void editAccount(int);
112 void updateAccounts(); 112 void updateAccounts();
113 void deleteAccount(int); 113 void deleteAccount(int);
114 void deleteMail(EmailListItem *mailItem, bool &inbox); 114 void deleteMail(EmailListItem *mailItem, bool &inbox);
115 void setTotalSize(int); 115 void setTotalSize(int);
116 void setMailSize(int); 116 void setMailSize(int);
117 void setDownloadedSize(int); 117 void setDownloadedSize(int);
118 void moveMailFront(Email *mailPtr); 118 void moveMailFront(Email *mailPtr);
119 void download(Email*); 119 void download(Email*);
120/* void reply(); 120/* void reply();
121 void replyAll(); 121 void replyAll();
122 void forward(); 122 void forward();
123 void remove();*/ 123 void remove();*/
124 124
125private slots: 125private slots:
126 void receive(const QCString&, const QByteArray&); 126 void receive(const QCString&, const QByteArray&);
127 127
128private: 128private:
129 void init(); 129 void init();
130 void initStatusBar(QWidget*); 130 void initStatusBar(QWidget*);
131 void readMail(); 131 void readMail();
132 QString getPath(bool enclosurePath); 132 QString getPath(bool enclosurePath);
133 void readSettings(); 133 void readSettings();
134 void saveSettings(); 134 void saveSettings();
135 Email* getCurrentMail(); 135 Email* getCurrentMail();
136 int timerID; 136 int timerID;
137 Config *mailconf; 137 Config *mailconf;
138 int newAccountId, idCount, mailIdCount; 138 int newAccountId, idCount, mailIdCount;
139 int accountIdCount; 139 int accountIdCount;
140 AccountList accountList; 140 AccountList accountList;
141 AddressList *addressList; 141 AddressList *addressList;
142 142
143 EditAccount *editAccountView; 143 EditAccount *editAccountView;
144 EmailListItem *item; 144 EmailListItem *item;
145 EmailHandler *emailHandler; 145 EmailHandler *emailHandler;
146 QList<Email> quedMessages; 146 QList<Email> quedMessages;
147 MailList mailDownloadList; 147 MailList mailDownloadList;
148 MailList tempMailDownloadList; 148 MailList tempMailDownloadList;
149 149
150 bool sending, receiving, previewingMail, allAccounts; 150 bool sending, receiving, previewingMail, allAccounts;
151 QString lineShift; 151 QString lineShift;
152 MailAccount account, *currentAccount; 152 MailAccount account, *currentAccount;
153 153
154 QCopChannel* channel; 154 QCopChannel* channel;
155 155
156 QToolBar *bar; 156 QToolBar *bar;
157 QProgressBar *progressBar; 157 QProgressBar *progressBar;
158 QStatusBar *statusBar; 158 QStatusBar *statusBar;
159 QLabel *status1Label, *status2Label; 159 QLabel *status1Label, *status2Label;
160 QToolButton *getMailButton; 160 QToolButton *getMailButton;
161 QAction *sendMailButton; 161 QAction *sendMailButton;
162 QAction *composeButton; 162 QAction *composeButton;
163 QAction *cancelButton; 163 QAction *cancelButton;
164 QAction *deleteButton; 164 QAction *deleteButton;
165 //QToolButton *setAccountButton; 165 //QToolButton *setAccountButton;
166 166
167 QMenuBar *mb; 167 QMenuBar *mb;
168 QPopupMenu *selectAccountMenu; 168 QPopupMenu *selectAccountMenu;
169 QPopupMenu *editAccountMenu; 169 QPopupMenu *editAccountMenu;
170 QPopupMenu *deleteAccountMenu; 170 QPopupMenu *deleteAccountMenu;
171 QPopupMenu *setAccountMenu; 171 QPopupMenu *setAccountMenu;
172 172
173 OTabWidget* mailboxView; 173 OTabWidget* mailboxView;
174 QListView* inboxView; 174 QListView* inboxView;
175 QListView* outboxView; 175 QListView* outboxView;
176 176
177 QGridLayout* grid_2; 177 QGridLayout* grid_2;
178 QGridLayout* grid_3; 178 QGridLayout* grid_3;
179}; 179};
180 180
181#endif // EMAILCLIENT_H 181#endif // EMAILCLIENT_H
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 39f693d..5b8bda1 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -1,357 +1,357 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qfileinfo.h> 20#include <qfileinfo.h>
21#include <stdlib.h> 21#include <stdlib.h>
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qcstring.h> 24#include <qcstring.h>
25#include "emailhandler.h" 25#include "emailhandler.h"
26#include <qpe/applnk.h> 26#include <qpe/applnk.h>
27#include <qpe/filemanager.h> 27#include <qpe/filemanager.h>
28 28
29QCollection::Item EnclosureList::newItem(QCollection::Item d) 29QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (Enclosure *) d); 31 return dupl( (Enclosure *) d);
32} 32}
33 33
34Enclosure* EnclosureList::dupl(Enclosure *in) 34Enclosure* EnclosureList::dupl(Enclosure *in)
35{ 35{
36 ac = new Enclosure(*in); 36 ac = new Enclosure(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailHandler::EmailHandler() 40EmailHandler::EmailHandler()
41{ 41{
42 qDebug("EMailHandler::EmailHandler"); 42 qDebug("EMailHandler::EmailHandler");
43 43
44 smtpClient = new SmtpClient(); 44 smtpClient = new SmtpClient();
45 popClient = new PopClient(); 45 popClient = new PopClient();
46 46
47 connect(smtpClient, SIGNAL(errorOccurred(int)), this, 47 connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this,
48 SIGNAL(smtpError(int)) ); 48 SIGNAL(smtpError(int, const QString &)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); 49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, 50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) ); 51 SIGNAL(updateSmtpStatus(const QString &)) );
52 52
53 connect(popClient, SIGNAL(errorOccurred(int)), this, 53 connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this,
54 SIGNAL(popError(int)) ); 54 SIGNAL(popError(int, const QString &)) );
55 connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), 55 connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)),
56 this, SLOT(messageArrived(const QString &, int, uint, bool)) ); 56 this, SLOT(messageArrived(const QString &, int, uint, bool)) );
57 connect(popClient, SIGNAL(updateStatus(const QString &)), this, 57 connect(popClient, SIGNAL(updateStatus(const QString &)), this,
58 SIGNAL(updatePopStatus(const QString &)) ); 58 SIGNAL(updatePopStatus(const QString &)) );
59 connect(popClient, SIGNAL(mailTransfered(int)), this, 59 connect(popClient, SIGNAL(mailTransfered(int)), this,
60 SIGNAL(mailTransfered(int)) ); 60 SIGNAL(mailTransfered(int)) );
61 61
62 62
63 //relaying size information 63 //relaying size information
64 connect(popClient, SIGNAL(currentMailSize(int)), 64 connect(popClient, SIGNAL(currentMailSize(int)),
65 this, SIGNAL(currentMailSize(int)) ); 65 this, SIGNAL(currentMailSize(int)) );
66 connect(popClient, SIGNAL(downloadedSize(int)), 66 connect(popClient, SIGNAL(downloadedSize(int)),
67 this, SIGNAL(downloadedSize(int)) ); 67 this, SIGNAL(downloadedSize(int)) );
68} 68}
69 69
70void EmailHandler::sendMail(QList<Email> *mailList) 70void EmailHandler::sendMail(QList<Email> *mailList)
71{ 71{
72 Email *currentMail; 72 Email *currentMail;
73 QString temp; 73 QString temp;
74 QString userName = mailAccount.name; 74 QString userName = mailAccount.name;
75 userName += " <" + mailAccount.emailAddress + ">"; 75 userName += " <" + mailAccount.emailAddress + ">";
76 76
77 for (currentMail = mailList->first(); currentMail != 0; 77 for (currentMail = mailList->first(); currentMail != 0;
78 currentMail = mailList->next()) { 78 currentMail = mailList->next()) {
79 79
80 if (encodeMime(currentMail) == 0) { 80 if (encodeMime(currentMail) == 0) {
81 smtpClient->addMail(userName, currentMail->subject, 81 smtpClient->addMail(userName, currentMail->subject,
82 currentMail->recipients, currentMail->rawMail); 82 currentMail->recipients, currentMail->rawMail);
83 } else { //error 83 } else { //error
84 temp = tr("Could not locate all files in \nmail with subject: ") + 84 temp = tr("Could not locate all files in \nmail with subject: ") +
85 currentMail->subject; 85 currentMail->subject;
86 temp += tr("\nMail has NOT been sent"); 86 temp += tr("\nMail has NOT been sent");
87 QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); 87 QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n"));
88 88
89 } 89 }
90 } 90 }
91 smtpClient->newConnection(mailAccount.smtpServer, 25); 91 smtpClient->newConnection(mailAccount.smtpServer, 25);
92} 92}
93 93
94void EmailHandler::setAccount(MailAccount account) 94void EmailHandler::setAccount(MailAccount account)
95{ 95{
96 mailAccount = account; 96 mailAccount = account;
97} 97}
98 98
99void EmailHandler::getMail() 99void EmailHandler::getMail()
100{ 100{
101 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); 101 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
102 if (mailAccount.synchronize) { 102 if (mailAccount.synchronize) {
103 popClient->setSynchronize(mailAccount.lastServerMailCount); 103 popClient->setSynchronize(mailAccount.lastServerMailCount);
104 } else { 104 } else {
105 popClient->removeSynchronize(); 105 popClient->removeSynchronize();
106 } 106 }
107 107
108 headers = FALSE; 108 headers = FALSE;
109 //popClient->headersOnly(headers, 0); 109 //popClient->headersOnly(headers, 0);
110 popClient->newConnection(mailAccount.popServer, 110); 110 popClient->newConnection(mailAccount.popServer, 110);
111} 111}
112 112
113void EmailHandler::getMailHeaders() 113void EmailHandler::getMailHeaders()
114{ 114{
115 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); 115 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
116 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); 116 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize();
117 117
118 headers = TRUE; 118 headers = TRUE;
119 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all 119 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
120 qDebug("Initiating connection"); 120 qDebug("Initiating connection");
121 popClient->newConnection(mailAccount.popServer, 110); 121 popClient->newConnection(mailAccount.popServer, 110);
122} 122}
123 123
124void EmailHandler::getMailByList(MailList *mailList) 124void EmailHandler::getMailByList(MailList *mailList)
125{ 125{
126 if (mailList->count() == 0) { //should not occur though 126 if (mailList->count() == 0) { //should not occur though
127 emit mailTransfered(0); 127 emit mailTransfered(0);
128 return; 128 return;
129 } 129 }
130 130
131 headers = FALSE; 131 headers = FALSE;
132 popClient->headersOnly(FALSE, 0); 132 popClient->headersOnly(FALSE, 0);
133 133
134 popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd); 134 popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd);
135 popClient->setSelectedMails(mailList); 135 popClient->setSelectedMails(mailList);
136 popClient->newConnection(mailAccount.popServer, 110); 136 popClient->newConnection(mailAccount.popServer, 110);
137 } 137 }
138 138
139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
140{ 140{
141 Email mail; 141 Email mail;
142 142
143 mail.rawMail = message; 143 mail.rawMail = message;
144 mail.serverId = id; 144 mail.serverId = id;
145 mail.size = size; 145 mail.size = size;
146 mail.downloaded = complete; 146 mail.downloaded = complete;
147 147
148 emit mailArrived(mail, FALSE); 148 emit mailArrived(mail, FALSE);
149} 149}
150 150
151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail) 151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
152{ 152{
153 QString temp, boundary; 153 QString temp, boundary;
154 int pos; 154 int pos;
155 QString delimiter, header, body, mimeHeader, mimeBody; 155 QString delimiter, header, body, mimeHeader, mimeBody;
156 QString content, contentType, contentAttribute, id, encoding; 156 QString content, contentType, contentAttribute, id, encoding;
157 QString fileName, storedName; 157 QString fileName, storedName;
158 int enclosureId = 0; 158 int enclosureId = 0;
159 159
160 mail->rawMail = in; 160 mail->rawMail = in;
161 mail->received = TRUE; 161 mail->received = TRUE;
162 mail->files.setAutoDelete(TRUE); 162 mail->files.setAutoDelete(TRUE);
163 163
164 temp = lineShift + "." + lineShift; 164 temp = lineShift + "." + lineShift;
165 165
166 if (in.right(temp.length()) != temp) { 166 if (in.right(temp.length()) != temp) {
167 mail->rawMail += temp; 167 mail->rawMail += temp;
168 } 168 }
169 169
170 170
171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
172 pos = in.find(delimiter, 0, FALSE); 172 pos = in.find(delimiter, 0, FALSE);
173 header = in.left(pos); 173 header = in.left(pos);
174 body = in.right(in.length() - pos - delimiter.length()); 174 body = in.right(in.length() - pos - delimiter.length());
175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
176 body.truncate(body.length()-2); 176 body.truncate(body.length()-2);
177 177
178 // TextParser p(header, lineShift); 178 // TextParser p(header, lineShift);
179 TextParser * lp = new TextParser(header, lineShift); 179 TextParser * lp = new TextParser(header, lineShift);
180#define p (*lp) 180#define p (*lp)
181 181
182 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { 182 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
183 pos++; 183 pos++;
184 if (p.separatorAt(pos) == ' ') { 184 if (p.separatorAt(pos) == ' ') {
185 mail->from = p.getString(&pos, '<', false); 185 mail->from = p.getString(&pos, '<', false);
186 mail->from = mail->from.stripWhiteSpace(); 186 mail->from = mail->from.stripWhiteSpace();
187 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 187 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
188 mail->from = mail->from.left(mail->from.length() - 1); 188 mail->from = mail->from.left(mail->from.length() - 1);
189 mail->from = mail->from.right(mail->from.length() - 1); 189 mail->from = mail->from.right(mail->from.length() - 1);
190 } 190 }
191 pos++; 191 pos++;
192 mail->fromMail = p.getString(&pos, '>', false); 192 mail->fromMail = p.getString(&pos, '>', false);
193 } else { 193 } else {
194 if (p.separatorAt(pos) == '<') //No name.. nasty 194 if (p.separatorAt(pos) == '<') //No name.. nasty
195 pos++; 195 pos++;
196 //pos++; 196 //pos++;
197 mail->fromMail = p.getString(&pos, 'z', TRUE); 197 mail->fromMail = p.getString(&pos, 'z', TRUE);
198 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 198 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
199 mail->fromMail.truncate(mail->fromMail.length() - 1); 199 mail->fromMail.truncate(mail->fromMail.length() - 1);
200 mail->from=mail->fromMail; 200 mail->from=mail->fromMail;
201 } 201 }
202 } 202 }
203 203
204 pos=0; 204 pos=0;
205 205
206 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: 206 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
207 while((pos = p.find("TO",':', pos+1, TRUE))!=-1) 207 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
208 { 208 {
209 QString rec; 209 QString rec;
210 210
211 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To: 211 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
212 { 212 {
213 pos++; 213 pos++;
214 mail->recipients.append(p.getString(&pos, '\r', TRUE)); 214 mail->recipients.append(p.getString(&pos, '\r', TRUE));
215 } 215 }
216 } 216 }
217 // 217 //
218 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); 218 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
219 219
220 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 220 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
221 { 221 {
222 pos++; 222 pos++;
223 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 223 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
224 } 224 }
225 225
226 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 226 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
227 pos++; 227 pos++;
228 mail->subject = p.getString(&pos, 'z', TRUE); 228 mail->subject = p.getString(&pos, 'z', TRUE);
229 } 229 }
230 230
231 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 231 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
232 pos++; 232 pos++;
233 mail->date = p.getString(&pos, 'z', TRUE); 233 mail->date = p.getString(&pos, 'z', TRUE);
234 } 234 }
235 235
236 236
237 237
238 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { 238 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
239 pos++; 239 pos++;
240 if ( (p.wordAt(pos).upper() == "ID") && 240 if ( (p.wordAt(pos).upper() == "ID") &&
241 (p.separatorAt(pos) == ':') ) { 241 (p.separatorAt(pos) == ':') ) {
242 242
243 id = p.getString(&pos, 'z', TRUE); 243 id = p.getString(&pos, 'z', TRUE);
244 mail->id = id; 244 mail->id = id;
245 } 245 }
246 } 246 }
247 247
248 pos = 0; 248 pos = 0;
249 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { 249 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
250 pos++; 250 pos++;
251 if ( (p.wordAt(pos).upper() == "VERSION") && 251 if ( (p.wordAt(pos).upper() == "VERSION") &&
252 (p.separatorAt(pos) == ':') ) { 252 (p.separatorAt(pos) == ':') ) {
253 pos++; 253 pos++;
254 if (p.getString(&pos, 'z', true) == "1.0") { 254 if (p.getString(&pos, 'z', true) == "1.0") {
255 mail->mimeType = 1; 255 mail->mimeType = 1;
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 if (mail->mimeType == 1) { 260 if (mail->mimeType == 1) {
261 boundary = ""; 261 boundary = "";
262 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { 262 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
263 pos++; 263 pos++;
264 boundary = p.getString(&pos, 'z', true); 264 boundary = p.getString(&pos, 'z', true);
265 if (boundary[0] == '"') { 265 if (boundary[0] == '"') {
266 boundary = boundary.left(boundary.length() - 1); //strip " 266 boundary = boundary.left(boundary.length() - 1); //strip "
267 boundary = boundary.right(boundary.length() - 1); //strip " 267 boundary = boundary.right(boundary.length() - 1); //strip "
268 } 268 }
269 boundary = "--" + boundary; //create boundary field 269 boundary = "--" + boundary; //create boundary field
270 } 270 }
271 271
272 if (boundary == "") { //fooled by Mime-Version 272 if (boundary == "") { //fooled by Mime-Version
273 mail->body = body; 273 mail->body = body;
274 mail->bodyPlain = body; 274 mail->bodyPlain = body;
275 delete lp; 275 delete lp;
276 return mail; 276 return mail;
277 } 277 }
278 278
279 while (body.length() > 0) { 279 while (body.length() > 0) {
280 pos = body.find(boundary, 0, FALSE); 280 pos = body.find(boundary, 0, FALSE);
281 pos = body.find(delimiter, pos, FALSE); 281 pos = body.find(delimiter, pos, FALSE);
282 mimeHeader = body.left(pos); 282 mimeHeader = body.left(pos);
283 mimeBody = body.right(body.length() - pos - delimiter.length()); 283 mimeBody = body.right(body.length() - pos - delimiter.length());
284 TextParser bp(mimeHeader, lineShift); 284 TextParser bp(mimeHeader, lineShift);
285 285
286 contentType = ""; 286 contentType = "";
287 contentAttribute = ""; 287 contentAttribute = "";
288 fileName = ""; 288 fileName = "";
289 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { 289 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
290 pos++; 290 pos++;
291 if ( (bp.wordAt(pos).upper() == "TYPE") && 291 if ( (bp.wordAt(pos).upper() == "TYPE") &&
292 (bp.separatorAt(pos) == ':') ) { 292 (bp.separatorAt(pos) == ':') ) {
293 contentType = bp.nextWord().upper(); 293 contentType = bp.nextWord().upper();
294 if (bp.nextSeparator() == '/') 294 if (bp.nextSeparator() == '/')
295 contentAttribute = bp.nextWord().upper(); 295 contentAttribute = bp.nextWord().upper();
296 content = contentType + "/" + contentAttribute; 296 content = contentType + "/" + contentAttribute;
297 } 297 }
298 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { 298 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
299 pos++; 299 pos++;
300 encoding = bp.getString(&pos, 'z', TRUE); 300 encoding = bp.getString(&pos, 'z', TRUE);
301 } 301 }
302 302
303 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { 303 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
304 pos++; 304 pos++;
305 fileName = bp.getString(&pos, 'z', TRUE); 305 fileName = bp.getString(&pos, 'z', TRUE);
306 fileName = fileName.right(fileName.length() - 1); 306 fileName = fileName.right(fileName.length() - 1);
307 fileName = fileName.left(fileName.length() - 1); 307 fileName = fileName.left(fileName.length() - 1);
308 } 308 }
309 309
310 } 310 }
311 pos = mimeBody.find(boundary, 0, FALSE); 311 pos = mimeBody.find(boundary, 0, FALSE);
312 if (pos == -1) //should not occur, malformed mail 312 if (pos == -1) //should not occur, malformed mail
313 pos = mimeBody.length(); 313 pos = mimeBody.length();
314 body = mimeBody.right(mimeBody.length() - pos); 314 body = mimeBody.right(mimeBody.length() - pos);
315 mimeBody = mimeBody.left(pos); 315 mimeBody = mimeBody.left(pos);
316 316
317 if (fileName != "") { //attatchments of some type, audio, image etc. 317 if (fileName != "") { //attatchments of some type, audio, image etc.
318 318
319 Enclosure e; 319 Enclosure e;
320 e.id = enclosureId; 320 e.id = enclosureId;
321 e.originalName = fileName; 321 e.originalName = fileName;
322 e.contentType = contentType; 322 e.contentType = contentType;
323 e.contentAttribute = contentAttribute; 323 e.contentAttribute = contentAttribute;
324 e.encoding = encoding; 324 e.encoding = encoding;
325 e.body = mimeBody; 325 e.body = mimeBody;
326 e.saved = FALSE; 326 e.saved = FALSE;
327 mail->addEnclosure(&e); 327 mail->addEnclosure(&e);
328 enclosureId++; 328 enclosureId++;
329 329
330 } else if (contentType == "TEXT") { 330 } else if (contentType == "TEXT") {
331 if (contentAttribute == "PLAIN") { 331 if (contentAttribute == "PLAIN") {
332 mail->body = mimeBody; 332 mail->body = mimeBody;
333 mail->bodyPlain = mimeBody; 333 mail->bodyPlain = mimeBody;
334 } 334 }
335 if (contentAttribute == "HTML") { 335 if (contentAttribute == "HTML") {
336 mail->body = mimeBody; 336 mail->body = mimeBody;
337 } 337 }
338 } 338 }
339 } 339 }
340 } else { 340 } else {
341 mail->bodyPlain = body; 341 mail->bodyPlain = body;
342 mail->body = body; 342 mail->body = body;
343 } 343 }
344 delete lp; 344 delete lp;
345 return TRUE; 345 return TRUE;
346} 346}
347 347
348bool EmailHandler::getEnclosure(Enclosure *ePtr) 348bool EmailHandler::getEnclosure(Enclosure *ePtr)
349{ 349{
350 QFile f(ePtr->path + ePtr->name); 350 QFile f(ePtr->path + ePtr->name);
351 char src[4]; 351 char src[4];
352 char *destPtr; 352 char *destPtr;
353 QByteArray buffer; 353 QByteArray buffer;
354 uint bufCount, pos, decodedCount, size, x; 354 uint bufCount, pos, decodedCount, size, x;
355 355
356 if (! f.open(IO_WriteOnly) ) { 356 if (! f.open(IO_WriteOnly) ) {
357 qWarning("could not save: " + ePtr->path + ePtr->name); 357 qWarning("could not save: " + ePtr->path + ePtr->name);
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
index e4e7f46..74a8e4c 100644
--- a/noncore/unsupported/mailit/emailhandler.h
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -1,150 +1,150 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef EmailHandler_H 20#ifndef EmailHandler_H
21#define EmailHandler_H 21#define EmailHandler_H
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlist.h> 26#include <qlist.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qfile.h> 28#include <qfile.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qcollection.h> 30#include <qcollection.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include "smtpclient.h" 33#include "smtpclient.h"
34#include "popclient.h" 34#include "popclient.h"
35#include "textparser.h" 35#include "textparser.h"
36#include "maillist.h" 36#include "maillist.h"
37 37
38struct Enclosure 38struct Enclosure
39{ 39{
40 int id; 40 int id;
41 QString originalName; 41 QString originalName;
42 QString name; 42 QString name;
43 QString path; 43 QString path;
44 QString contentType; 44 QString contentType;
45 QString contentAttribute; 45 QString contentAttribute;
46 QString encoding; 46 QString encoding;
47 QString body; //might use to much mem. check!! 47 QString body; //might use to much mem. check!!
48 bool saved, installed; 48 bool saved, installed;
49}; 49};
50 50
51class EnclosureList : public QList<Enclosure> 51class EnclosureList : public QList<Enclosure>
52{ 52{
53public: 53public:
54 Item newItem(Item d); 54 Item newItem(Item d);
55private: 55private:
56 Enclosure* dupl(Enclosure *in); 56 Enclosure* dupl(Enclosure *in);
57 Enclosure *ac; 57 Enclosure *ac;
58}; 58};
59 59
60struct Email 60struct Email
61{ 61{
62 QString id; 62 QString id;
63 QString from; 63 QString from;
64 QString fromMail; 64 QString fromMail;
65 QStringList recipients; 65 QStringList recipients;
66 QStringList carbonCopies; 66 QStringList carbonCopies;
67 QString date; 67 QString date;
68 QString subject; 68 QString subject;
69 QString body; 69 QString body;
70 QString bodyPlain; 70 QString bodyPlain;
71 bool sent, received, read, downloaded; 71 bool sent, received, read, downloaded;
72 QString rawMail; 72 QString rawMail;
73 int mimeType; //1 = Mime 1.0 73 int mimeType; //1 = Mime 1.0
74 int serverId; 74 int serverId;
75 int internalId; 75 int internalId;
76 int fromAccountId; 76 int fromAccountId;
77 QString contentType; //0 = text 77 QString contentType; //0 = text
78 QString contentAttribute; //0 = plain, 1 = html 78 QString contentAttribute; //0 = plain, 1 = html
79 EnclosureList files; 79 EnclosureList files;
80 uint size; 80 uint size;
81 81
82 void addEnclosure(Enclosure *e) 82 void addEnclosure(Enclosure *e)
83 { 83 {
84 files.append(e); 84 files.append(e);
85 } 85 }
86}; 86};
87 87
88struct MailAccount 88struct MailAccount
89{ 89{
90 QString accountName; 90 QString accountName;
91 QString name; 91 QString name;
92 QString emailAddress; 92 QString emailAddress;
93 QString popUserName; 93 QString popUserName;
94 QString popPasswd; 94 QString popPasswd;
95 QString popServer; 95 QString popServer;
96 QString smtpServer; 96 QString smtpServer;
97 bool synchronize; 97 bool synchronize;
98 int syncLimit; 98 int syncLimit;
99 int lastServerMailCount; 99 int lastServerMailCount;
100 int id; 100 int id;
101}; 101};
102 102
103 const int ErrUnknownResponse = 1001; 103 const int ErrUnknownResponse = 1001;
104 const int ErrLoginFailed = 1002; 104 const int ErrLoginFailed = 1002;
105 const int ErrCancel = 1003; 105 const int ErrCancel = 1003;
106 106
107 107
108class EmailHandler : public QObject 108class EmailHandler : public QObject
109{ 109{
110 Q_OBJECT 110 Q_OBJECT
111 111
112public: 112public:
113 EmailHandler(); 113 EmailHandler();
114 void setAccount(MailAccount account); 114 void setAccount(MailAccount account);
115 MailAccount* getAccount(){return &mailAccount;} 115 MailAccount* getAccount(){return &mailAccount;}
116 void sendMail(QList<Email> *mailList); 116 void sendMail(QList<Email> *mailList);
117 void getMail(); 117 void getMail();
118 void getMailHeaders(); 118 void getMailHeaders();
119 void getMailByList(MailList *mailList); 119 void getMailByList(MailList *mailList);
120 bool parse(const QString &in, const 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(const QString &fileName, QString *toBody); 124 int encodeFile(const QString &fileName, QString *toBody);
125 void encode64base(char *src, QString *dest, int len); 125 void encode64base(char *src, QString *dest, int len);
126 void cancel(); 126 void cancel();
127 127
128signals: 128signals:
129 void mailSent(); 129 void mailSent();
130 void smtpError(int); 130 void smtpError(int, const QString & Msg );
131 void popError(int); 131 void popError(int, const QString & Msg );
132 void mailArrived(const Email &, bool); 132 void mailArrived(const Email &, bool);
133 void updatePopStatus(const QString &); 133 void updatePopStatus(const QString &);
134 void updateSmtpStatus(const QString &); 134 void updateSmtpStatus(const QString &);
135 void mailTransfered(int); 135 void mailTransfered(int);
136 void mailboxSize(int); 136 void mailboxSize(int);
137 void currentMailSize(int); 137 void currentMailSize(int);
138 void downloadedSize(int); 138 void downloadedSize(int);
139 139
140public slots: 140public slots:
141 void messageArrived(const QString &, int id, uint size, bool complete); 141 void messageArrived(const QString &, int id, uint size, bool complete);
142 142
143private: 143private:
144 MailAccount mailAccount; 144 MailAccount mailAccount;
145 SmtpClient *smtpClient; 145 SmtpClient *smtpClient;
146 PopClient *popClient; 146 PopClient *popClient;
147 bool headers; 147 bool headers;
148}; 148};
149 149
150#endif 150#endif
diff --git a/noncore/unsupported/mailit/mailit.pro b/noncore/unsupported/mailit/mailit.pro
index cfbda36..5e9a83a 100644
--- a/noncore/unsupported/mailit/mailit.pro
+++ b/noncore/unsupported/mailit/mailit.pro
@@ -1,62 +1,63 @@
1TEMPLATE = app 1TEMPLATE = app
2TARGET = mailit
2CONFIG = qt warn_on release 3CONFIG = qt warn_on release
3HEADERS = emailclient.h \ 4HEADERS = emailclient.h \
4 emailhandler.h \ 5 emailhandler.h \
5 emaillistitem.h \ 6 emaillistitem.h \
6 mailitwindow.h \ 7 mailitwindow.h \
7 md5.h \ 8 md5.h \
8 popclient.h \ 9 popclient.h \
9 readmail.h \ 10 readmail.h \
10 smtpclient.h \ 11 smtpclient.h \
11 writemail.h \ 12 writemail.h \
12 textparser.h \ 13 textparser.h \
13 viewatt.h \ 14 viewatt.h \
14 addatt.h \ 15 addatt.h \
15 editaccount.h \ 16 editaccount.h \
16 maillist.h \ 17 maillist.h \
17 addresslist.h 18 addresslist.h
18SOURCES = emailclient.cpp \ 19SOURCES = emailclient.cpp \
19 emailhandler.cpp \ 20 emailhandler.cpp \
20 emaillistitem.cpp \ 21 emaillistitem.cpp \
21 mailitwindow.cpp \ 22 mailitwindow.cpp \
22 main.cpp \ 23 main.cpp \
23 md5.c \ 24 md5.c \
24 popclient.cpp \ 25 popclient.cpp \
25 readmail.cpp \ 26 readmail.cpp \
26 smtpclient.cpp \ 27 smtpclient.cpp \
27 writemail.cpp \ 28 writemail.cpp \
28 textparser.cpp \ 29 textparser.cpp \
29 viewatt.cpp \ 30 viewatt.cpp \
30 addatt.cpp \ 31 addatt.cpp \
31 editaccount.cpp \ 32 editaccount.cpp \
32 maillist.cpp \ 33 maillist.cpp \
33 addresslist.cpp 34 addresslist.cpp
34 35
35INCLUDEPATH += $(OPIEDIR)/include 36INCLUDEPATH += $(OPIEDIR)/include
36DEPENDPATH += $(OPIEDIR)/include 37DEPENDPATH += $(OPIEDIR)/include
37LIBS += -lqpe -lopie 38LIBS += -lqpe -lopie
38# -lssl 39# -lssl
39MOC_DIR=qpeobj 40MOC_DIR=qpeobj
40OBJECTS_DIR=qpeobj 41OBJECTS_DIR=qpeobj
41DESTDIR=$(OPIEDIR)/bin 42DESTDIR=$(OPIEDIR)/bin
42 43
43TRANSLATIONS = ../../../i18n/de/mailit.ts \ 44TRANSLATIONS = ../../../i18n/de/mailit.ts \
44 ../../../i18n/nl/mailit.ts \ 45 ../../../i18n/nl/mailit.ts \
45 ../../../i18n/da/mailit.ts \ 46 ../../../i18n/da/mailit.ts \
46 ../../../i18n/xx/mailit.ts \ 47 ../../../i18n/xx/mailit.ts \
47 ../../../i18n/it/mailit.ts \ 48 ../../../i18n/it/mailit.ts \
48 ../../../i18n/en/mailit.ts \ 49 ../../../i18n/en/mailit.ts \
49 ../../../i18n/es/mailit.ts \ 50 ../../../i18n/es/mailit.ts \
50 ../../../i18n/fr/mailit.ts \ 51 ../../../i18n/fr/mailit.ts \
51 ../../../i18n/hu/mailit.ts \ 52 ../../../i18n/hu/mailit.ts \
52 ../../../i18n/ja/mailit.ts \ 53 ../../../i18n/ja/mailit.ts \
53 ../../../i18n/ko/mailit.ts \ 54 ../../../i18n/ko/mailit.ts \
54 ../../../i18n/no/mailit.ts \ 55 ../../../i18n/no/mailit.ts \
55 ../../../i18n/pl/mailit.ts \ 56 ../../../i18n/pl/mailit.ts \
56 ../../../i18n/pt/mailit.ts \ 57 ../../../i18n/pt/mailit.ts \
57 ../../../i18n/pt_BR/mailit.ts \ 58 ../../../i18n/pt_BR/mailit.ts \
58 ../../../i18n/sl/mailit.ts \ 59 ../../../i18n/sl/mailit.ts \
59 ../../../i18n/zh_CN/mailit.ts \ 60 ../../../i18n/zh_CN/mailit.ts \
60 ../../../i18n/zh_TW/mailit.ts 61 ../../../i18n/zh_TW/mailit.ts
61 62
62include ( $(OPIEDIR)/include.pro ) 63include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp
index f945a0f..6e298c7 100644
--- a/noncore/unsupported/mailit/mailitwindow.cpp
+++ b/noncore/unsupported/mailit/mailitwindow.cpp
@@ -1,168 +1,168 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qwhatsthis.h> 20#include <qwhatsthis.h>
21#include <qmessagebox.h> 21#include <qmessagebox.h>
22#include "mailitwindow.h" 22#include "mailitwindow.h"
23 23
24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/)
25 : QMainWindow(parent, name, WStyle_ContextHelp) 25 : QMainWindow(parent, name, WStyle_ContextHelp)
26{ 26{
27 currentCaption = "Mailit"; 27 currentCaption = tr("Mailit");
28 setCaption(tr(currentCaption)); 28 setCaption(tr(currentCaption));
29 views = new QWidgetStack(this); 29 views = new QWidgetStack(this);
30 setCentralWidget(views); 30 setCentralWidget(views);
31 QWhatsThis::add(views,tr("Central view area")); 31 QWhatsThis::add(views,tr("Central view area"));
32 emailClient = new EmailClient(views, "client"); 32 emailClient = new EmailClient(views, "client");
33 writeMail = new WriteMail(views, "writing"); 33 writeMail = new WriteMail(views, "writing");
34 readMail = new ReadMail(views, "reading"); 34 readMail = new ReadMail(views, "reading");
35 35
36 views->raiseWidget(emailClient); 36 views->raiseWidget(emailClient);
37 37
38 connect(emailClient, SIGNAL(composeRequested()), 38 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) ); 39 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) ); 41 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) ); 43 SLOT(updateMailView(Email *)) );
44 44
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) ); 47 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) ); 49 SLOT(enqueMail(const Email &)) );
50 50
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, 52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this,
53 SLOT(composeReply(Email &, bool&)) ); 53 SLOT(composeReply(Email &, bool&)) );
54 connect(readMail, SIGNAL(forwardRequested(Email &)), this, 54 connect(readMail, SIGNAL(forwardRequested(Email &)), this,
55 SLOT(composeForward(Email &)) ); 55 SLOT(composeForward(Email &)) );
56 56
57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
58 SLOT(deleteMail(EmailListItem *, bool &)) ); 58 SLOT(deleteMail(EmailListItem *, bool &)) );
59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
60 SLOT(moveMailFront(Email *)) ); 60 SLOT(moveMailFront(Email *)) );
61 61
62 connect(emailClient, SIGNAL(newCaption(const QString &)), 62 connect(emailClient, SIGNAL(newCaption(const QString &)),
63 this, SLOT(updateCaption(const QString &)) ); 63 this, SLOT(updateCaption(const QString &)) );
64 64
65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) ); 65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) );
66 66
67 viewingMail = FALSE; 67 viewingMail = FALSE;
68} 68}
69 69
70MailItWindow::~MailItWindow() 70MailItWindow::~MailItWindow()
71{ 71{
72} 72}
73 73
74void MailItWindow::closeEvent(QCloseEvent *e) 74void MailItWindow::closeEvent(QCloseEvent *e)
75{ 75{
76 if (views->visibleWidget() == emailClient) { 76 if (views->visibleWidget() == emailClient) {
77 e->accept(); 77 e->accept();
78 } else { 78 } else {
79 showEmailClient(); 79 showEmailClient();
80 } 80 }
81} 81}
82 82
83void MailItWindow::compose() 83void MailItWindow::compose()
84{ 84{
85 viewingMail = FALSE; 85 viewingMail = FALSE;
86 emailClient->hide(); 86 emailClient->hide();
87 readMail->hide(); 87 readMail->hide();
88 views->raiseWidget(writeMail); 88 views->raiseWidget(writeMail);
89 writeMail->setAddressList(emailClient->getAdrListRef()); 89 writeMail->setAddressList(emailClient->getAdrListRef());
90 writeMail->newMail(); 90 writeMail->newMail();
91 setCaption( tr( "Write mail" ) ); 91 setCaption( tr( "Write mail" ) );
92} 92}
93 93
94void MailItWindow::composeReply(Email &mail, bool& replyAll) 94void MailItWindow::composeReply(Email &mail, bool& replyAll)
95{ 95{
96 compose(); 96 compose();
97 writeMail->reply(mail,replyAll) ; 97 writeMail->reply(mail,replyAll) ;
98} 98}
99 99
100void MailItWindow::composeForward(Email &mail) 100void MailItWindow::composeForward(Email &mail)
101{ 101{
102 compose(); 102 compose();
103 writeMail->forward(mail) ; 103 writeMail->forward(mail) ;
104} 104}
105 105
106 106
107void MailItWindow::showEmailClient() 107void MailItWindow::showEmailClient()
108{ 108{
109 viewingMail = FALSE; 109 viewingMail = FALSE;
110 writeMail->hide(); 110 writeMail->hide();
111 readMail->hide(); 111 readMail->hide();
112 views->raiseWidget(emailClient); 112 views->raiseWidget(emailClient);
113 setCaption( tr(currentCaption) ); 113 setCaption( tr(currentCaption) );
114} 114}
115 115
116void MailItWindow::viewMail(QListView *view, Email *mail) 116void MailItWindow::viewMail(QListView *view, Email *mail)
117{ 117{
118 viewingMail = TRUE; 118 viewingMail = TRUE;
119 emailClient->hide(); 119 emailClient->hide();
120 120
121 int result=0; 121 int result=0;
122 122
123 if ((mail->received)&&(!mail->downloaded)) 123 if ((mail->received)&&(!mail->downloaded))
124 { 124 {
125 QMessageBox mb( tr("Mail not downloaded"), 125 QMessageBox mb( tr("Mail not downloaded"),
126 tr("The mail you have clicked \n" 126 tr("The mail you have clicked \n"
127 "has not been downloaded yet.\n " 127 "has not been downloaded yet.\n "
128 "Would you like to do it now ?"), 128 "Would you like to do it now ?"),
129 QMessageBox::Information, 129 QMessageBox::Information,
130 QMessageBox::Yes | QMessageBox::Default, 130 QMessageBox::Yes | QMessageBox::Default,
131 QMessageBox::No | QMessageBox::Escape,0 ); 131 QMessageBox::No | QMessageBox::Escape,0 );
132 132
133 result=mb.exec(); 133 result=mb.exec();
134 134
135 if (result==QMessageBox::Yes) 135 if (result==QMessageBox::Yes)
136 { 136 {
137 emailClient->download(mail); 137 emailClient->download(mail);
138 } 138 }
139 } 139 }
140 140
141 readMail->update(view, mail); 141 readMail->update(view, mail);
142 views->raiseWidget(readMail); 142 views->raiseWidget(readMail);
143 setCaption( tr( "Read Mail" ) ); 143 setCaption( tr( "Read Mail" ) );
144} 144}
145 145
146void MailItWindow::updateMailView(Email *mail) 146void MailItWindow::updateMailView(Email *mail)
147{ 147{
148 if (viewingMail) { 148 if (viewingMail) {
149 readMail->mailUpdated(mail); 149 readMail->mailUpdated(mail);
150 } 150 }
151} 151}
152 152
153void MailItWindow::updateCaption(const QString &newCaption) 153void MailItWindow::updateCaption(const QString &newCaption)
154{ 154{
155 currentCaption = newCaption; 155 currentCaption = newCaption;
156 setCaption(tr(currentCaption)); 156 setCaption(tr(currentCaption));
157} 157}
158 158
159void MailItWindow::setDocument(const QString &_address) 159void MailItWindow::setDocument(const QString &_address)
160{ 160{
161 // strip leading 'mailto:' 161 // strip leading 'mailto:'
162 QString address = _address; 162 QString address = _address;
163 if (address.startsWith("mailto:")) 163 if (address.startsWith("mailto:"))
164 address = address.mid(6); 164 address = address.mid(6);
165 165
166 compose(); 166 compose();
167 writeMail->setRecipient(address); 167 writeMail->setRecipient(address);
168} 168}
diff --git a/noncore/unsupported/mailit/maillist.cpp b/noncore/unsupported/mailit/maillist.cpp
index b5325a9..8c34295 100644
--- a/noncore/unsupported/mailit/maillist.cpp
+++ b/noncore/unsupported/mailit/maillist.cpp
@@ -1,131 +1,131 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "maillist.h" 20#include "maillist.h"
21 21
22void MailList::clear() 22void MailList::clear()
23{ 23{
24 sortedList.setAutoDelete(TRUE); 24 sortedList.setAutoDelete(TRUE);
25 sortedList.clear(); 25 sortedList.clear();
26 currentPos = 0; 26 currentPos = 0;
27} 27}
28 28
29int MailList::count() 29int MailList::count()
30{ 30{
31 return sortedList.count(); 31 return sortedList.count();
32} 32}
33 33
34int* MailList::first() 34int* MailList::first()
35{ 35{
36 dList *mPtr; 36 dList *mPtr;
37 37
38 if (sortedList.count() == 0) 38 if (sortedList.count() == 0)
39 return NULL; 39 return NULL;
40 40
41 mPtr = sortedList.at(0); 41 mPtr = sortedList.at(0);
42 currentPos = 1; 42 currentPos = 1;
43 return &(mPtr->serverId); 43 return &(mPtr->serverId);
44} 44}
45 45
46int* MailList::next() 46int* MailList::next()
47{ 47{
48 dList *mPtr; 48 dList *mPtr;
49 49
50 if ( (currentPos) >= sortedList.count()) 50 if ( (currentPos) >= sortedList.count())
51 return NULL; 51 return NULL;
52 52
53 mPtr = sortedList.at(currentPos); 53 mPtr = sortedList.at(currentPos);
54 currentPos++; 54 currentPos++;
55 return &(mPtr->serverId); 55 return &(mPtr->serverId);
56} 56}
57 57
58void MailList::sizeInsert(int serverId, uint size) 58void MailList::sizeInsert(int serverId, uint size)
59{ 59{
60 dList *tempPtr; 60 dList *tempPtr;
61 int x; 61 int x;
62 62
63 dList *newEntry = new dList; 63 dList *newEntry = new dList;
64 newEntry->serverId = serverId; 64 newEntry->serverId = serverId;
65 newEntry->size = size; 65 newEntry->size = size;
66 66
67 for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) { 67 for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) {
68 if (newEntry->size < tempPtr->size) { 68 if (newEntry->size < tempPtr->size) {
69 x = sortedList.at(); 69 x = sortedList.at();
70 sortedList.insert(x, newEntry); 70 sortedList.insert(x, newEntry);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 sortedList.append(newEntry); 74 sortedList.append(newEntry);
75} 75}
76 76
77void MailList::moveFront(int serverId, uint size) 77void MailList::moveFront(int serverId, uint/* size*/)
78{ 78{
79 dList *currentPtr; 79 dList *currentPtr;
80 uint tempPos; 80 uint tempPos;
81 QString temp; 81 QString temp;
82 82
83 tempPos = currentPos; 83 tempPos = currentPos;
84 if ( tempPos >= sortedList.count() ) 84 if ( tempPos >= sortedList.count() )
85 return; 85 return;
86 currentPtr = sortedList.at(tempPos); 86 currentPtr = sortedList.at(tempPos);
87 while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) { 87 while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
88 tempPos++; 88 tempPos++;
89 currentPtr = sortedList.at(tempPos); 89 currentPtr = sortedList.at(tempPos);
90 } 90 }
91 91
92 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) { 92 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
93 temp.setNum(currentPtr->serverId); 93 temp.setNum(currentPtr->serverId);
94 qWarning("moved to front, message: " + temp); 94 qWarning("moved to front, message: " + temp);
95 95
96 dList *itemPtr = sortedList.take(tempPos); 96 dList *itemPtr = sortedList.take(tempPos);
97 sortedList.insert(currentPos, itemPtr); 97 sortedList.insert(currentPos, itemPtr);
98 } 98 }
99 99
100} 100}
101 101
102//only works if mail is not already in download 102//only works if mail is not already in download
103bool MailList::remove(int serverId, uint size) 103bool MailList::remove(int serverId, uint /*size*/)
104{ 104{
105 dList *currentPtr; 105 dList *currentPtr;
106 uint tempPos; 106 uint tempPos;
107 QString temp; 107 QString temp;
108 108
109 tempPos = currentPos; 109 tempPos = currentPos;
110 if ( tempPos >=sortedList.count() ) 110 if ( tempPos >=sortedList.count() )
111 return FALSE; 111 return FALSE;
112 currentPtr = sortedList.at(tempPos); 112 currentPtr = sortedList.at(tempPos);
113 while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) { 113 while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
114 tempPos++; 114 tempPos++;
115 currentPtr = sortedList.at(tempPos); 115 currentPtr = sortedList.at(tempPos);
116 } 116 }
117 117
118 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) { 118 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
119 temp.setNum(currentPtr->serverId); 119 temp.setNum(currentPtr->serverId);
120 qWarning("deleted message: " + temp); 120 qWarning("deleted message: " + temp);
121 sortedList.remove(tempPos); 121 sortedList.remove(tempPos);
122 122
123 return TRUE; 123 return TRUE;
124 } 124 }
125 return FALSE; 125 return FALSE;
126} 126}
127 127
128void MailList::insert(int pos, int serverId, uint size) 128void MailList::insert(int /*pos*/, int /*serverId*/, uint/* size*/)
129{ 129{
130 //sortedList.insert(pos, mPtr); 130// sortedList.insert(pos, mPtr);
131} 131}
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index dc0116d..5da3bcb 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -1,327 +1,331 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "popclient.h" 20#include "popclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22//#define APOP_TEST 22//#define APOP_TEST
23 23
24extern "C" { 24extern "C" {
25#include "md5.h" 25#include "md5.h"
26} 26}
27 27
28#include <qcstring.h> 28#include <qcstring.h>
29 29
30PopClient::PopClient() 30PopClient::PopClient()
31{ 31{
32 32
33 socket = new QSocket(this, "popClient"); 33 socket = new QSocket(this, "popClient");
34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
37 37
38 stream = new QTextStream(socket); 38 stream = new QTextStream(socket);
39 39
40 receiving = FALSE; 40 receiving = FALSE;
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 preview = FALSE; 44 preview = FALSE;
45} 45}
46 46
47PopClient::~PopClient() 47PopClient::~PopClient()
48{ 48{
49 delete socket; 49 delete socket;
50 delete stream; 50 delete stream;
51} 51}
52 52
53void PopClient::newConnection(const QString &target, int port) 53void PopClient::newConnection(const QString &target, int port)
54{ 54{
55 if (receiving) { 55 if (receiving) {
56 qWarning("socket in use, connection refused"); 56 qWarning("socket in use, connection refused");
57 return; 57 return;
58 } 58 }
59 59
60 status = Init; 60 status = Init;
61 61
62 socket->connectToHost(target, port); 62 socket->connectToHost(target, port);
63 receiving = TRUE; 63 receiving = TRUE;
64 //selected = FALSE; 64 //selected = FALSE;
65 65
66 emit updateStatus("DNS lookup"); 66 emit updateStatus(tr("DNS lookup"));
67} 67}
68 68
69void PopClient::setAccount(const QString &popUser, const QString &popPasswd) 69void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 70{
71 popUserName = popUser; 71 popUserName = popUser;
72 popPassword = popPasswd; 72 popPassword = popPasswd;
73} 73}
74 74
75void PopClient::setSynchronize(int lastCount) 75void PopClient::setSynchronize(int lastCount)
76{ 76{
77 synchronize = TRUE; 77 synchronize = TRUE;
78 lastSync = lastCount; 78 lastSync = lastCount;
79} 79}
80 80
81void PopClient::removeSynchronize() 81void PopClient::removeSynchronize()
82{ 82{
83 synchronize = FALSE; 83 synchronize = FALSE;
84 lastSync = 0; 84 lastSync = 0;
85} 85}
86 86
87void PopClient::headersOnly(bool headers, int limit) 87void PopClient::headersOnly(bool headers, int limit)
88{ 88{
89 preview = headers; 89 preview = headers;
90 headerLimit = limit; 90 headerLimit = limit;
91} 91}
92 92
93void PopClient::setSelectedMails(MailList *list) 93void PopClient::setSelectedMails(MailList *list)
94{ 94{
95 selected = TRUE; 95 selected = TRUE;
96 mailList = list; 96 mailList = list;
97} 97}
98 98
99void PopClient::connectionEstablished() 99void PopClient::connectionEstablished()
100{ 100{
101 emit updateStatus(tr("Connection established")); 101 emit updateStatus(tr("Connection established"));
102} 102}
103 103
104void PopClient::errorHandling(int status) 104void PopClient::errorHandling(int status)
105{ 105{
106 errorHandlingWithMsg( status, QString::null );
107}
108void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
109{
106 emit updateStatus(tr("Error Occured")); 110 emit updateStatus(tr("Error Occured"));
107 emit errorOccurred(status); 111 emit errorOccurred(status, Msg);
108 socket->close(); 112 socket->close();
109 receiving = FALSE; 113 receiving = FALSE;
110} 114}
111 115
112void PopClient::incomingData() 116void PopClient::incomingData()
113{ 117{
114 QString response, temp, temp2, timeStamp; 118 QString response, temp, temp2, timeStamp;
115 QString md5Source; 119 QString md5Source;
116 int start, end; 120 int start, end;
117// char *md5Digest; 121// char *md5Digest;
118 char md5Digest[16]; 122 char md5Digest[16];
119// if ( !socket->canReadLine() ) 123// if ( !socket->canReadLine() )
120// return; 124// return;
121 125
122 126
123 response = socket->readLine(); 127 response = socket->readLine();
124 128
125 switch(status) { 129 switch(status) {
126 //logging in 130 //logging in
127 case Init: { 131 case Init: {
128#ifdef APOP_TEST 132#ifdef APOP_TEST
129 start = response.find('<',0); 133 start = response.find('<',0);
130 end = response.find('>', start); 134 end = response.find('>', start);
131 if( start >= 0 && end > start ) 135 if( start >= 0 && end > start )
132 { 136 {
133 timeStamp = response.mid( start , end - start + 1); 137 timeStamp = response.mid( start , end - start + 1);
134 md5Source = timeStamp + popPassword; 138 md5Source = timeStamp + popPassword;
135 139
136 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 140 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
137 141
138 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 142 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
139 { 143 {
140 printf("%x", md5Digest[j]); 144 printf("%x", md5Digest[j]);
141 } 145 }
142 printf("\n"); 146 printf("\n");
143// qDebug(md5Digest); 147// qDebug(md5Digest);
144 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 148 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
145 // qDebug("%s", stream); 149 // qDebug("%s", stream);
146 status = Stat; 150 status = Stat;
147 } 151 }
148 else 152 else
149#endif 153#endif
150 { 154 {
151 timeStamp = ""; 155 timeStamp = "";
152 *stream << "USER " << popUserName << "\r\n"; 156 *stream << "USER " << popUserName << "\r\n";
153 status = Pass; 157 status = Pass;
154 } 158 }
155 159
156 break; 160 break;
157 } 161 }
158 162
159 case Pass: { 163 case Pass: {
160 *stream << "PASS " << popPassword << "\r\n"; 164 *stream << "PASS " << popPassword << "\r\n";
161 status = Stat; 165 status = Stat;
162 166
163 break; 167 break;
164 } 168 }
165 //ask for number of messages 169 //ask for number of messages
166 case Stat: { 170 case Stat: {
167 if (response[0] == '+') { 171 if (response[0] == '+') {
168 *stream << "STAT" << "\r\n"; 172 *stream << "STAT" << "\r\n";
169 status = Mcnt; 173 status = Mcnt;
170 } else errorHandling(ErrLoginFailed); 174 } else errorHandlingWithMsg(ErrLoginFailed, response);
171 break; 175 break;
172 } 176 }
173 //get count of messages, eg "+OK 4 900.." -> int 4 177 //get count of messages, eg "+OK 4 900.." -> int 4
174 case Mcnt: { 178 case Mcnt: {
175 if (response[0] == '+') { 179 if (response[0] == '+') {
176 temp = response.replace(0, 4, ""); 180 temp = response.replace(0, 4, "");
177 int x = temp.find(" ", 0); 181 int x = temp.find(" ", 0);
178 temp.truncate((uint) x); 182 temp.truncate((uint) x);
179 newMessages = temp.toInt(); 183 newMessages = temp.toInt();
180 messageCount = 1; 184 messageCount = 1;
181 status = List; 185 status = List;
182 186
183 if (synchronize) { 187 if (synchronize) {
184 //messages deleted from server, reload all 188 //messages deleted from server, reload all
185 if (newMessages < lastSync) 189 if (newMessages < lastSync)
186 lastSync = 0; 190 lastSync = 0;
187 messageCount = 1; 191 messageCount = 1;
188 } 192 }
189 193
190 if (selected) { 194 if (selected) {
191 int *ptr = mailList->first(); 195 int *ptr = mailList->first();
192 if (ptr != 0) { 196 if (ptr != 0) {
193 newMessages++; //to ensure no early jumpout 197 newMessages++; //to ensure no early jumpout
194 messageCount = *ptr; 198 messageCount = *ptr;
195 } else newMessages = 0; 199 } else newMessages = 0;
196 } 200 }
197 201
198 } else errorHandling(ErrUnknownResponse); 202 } else errorHandlingWithMsg(ErrUnknownResponse, response);
199 } 203 }
200 //Read message number x, count upwards to messageCount 204 //Read message number x, count upwards to messageCount
201 case List: { 205 case List: {
202 if (messageCount <= newMessages) { 206 if (messageCount <= newMessages) {
203 *stream << "LIST " << messageCount << "\r\n"; 207 *stream << "LIST " << messageCount << "\r\n";
204 status = Size; 208 status = Size;
205 temp2.setNum(newMessages - lastSync); 209 temp2.setNum(newMessages - lastSync);
206 temp.setNum(messageCount - lastSync); 210 temp.setNum(messageCount - lastSync);
207 if (!selected) { 211 if (!selected) {
208 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 212 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
209 } else { 213 } else {
210 //completing a previously closed transfer 214 //completing a previously closed transfer
211 /* if ( (messageCount - lastSync) <= 0) { 215 /* if ( (messageCount - lastSync) <= 0) {
212 temp.setNum(messageCount); 216 temp.setNum(messageCount);
213 emit updateStatus(tr("Previous message ") + temp); 217 emit updateStatus(tr("Previous message ") + temp);
214 } else {*/ 218 } else {*/
215 emit updateStatus(tr("Completing message ") + temp); 219 emit updateStatus(tr("Completing message ") + temp);
216 //} 220 //}
217 } 221 }
218 break; 222 break;
219 } else { 223 } else {
220 emit updateStatus(tr("No new Messages")); 224 emit updateStatus(tr("No new Messages"));
221 status = Quit; 225 status = Quit;
222 } 226 }
223 } 227 }
224 //get size of message, eg "500 characters in message.." -> int 500 228 //get size of message, eg "500 characters in message.." -> int 500
225 case Size: { 229 case Size: {
226 if (status != Quit) { //because of idiotic switch 230 if (status != Quit) { //because of idiotic switch
227 if (response[0] == '+') { 231 if (response[0] == '+') {
228 temp = response.replace(0, 4, ""); 232 temp = response.replace(0, 4, "");
229 int x = temp.find(" ", 0); 233 int x = temp.find(" ", 0);
230 temp = temp.right(temp.length() - ((uint) x + 1) ); 234 temp = temp.right(temp.length() - ((uint) x + 1) );
231 mailSize = temp.toInt(); 235 mailSize = temp.toInt();
232 emit currentMailSize(mailSize); 236 emit currentMailSize(mailSize);
233 237
234 status = Retr; 238 status = Retr;
235 } else { 239 } else {
236 //qWarning(response); 240 //qWarning(response);
237 errorHandling(ErrUnknownResponse); 241 errorHandlingWithMsg(ErrUnknownResponse, response);
238 } 242 }
239 } 243 }
240 } 244 }
241 //Read message number x, count upwards to messageCount 245 //Read message number x, count upwards to messageCount
242 case Retr: { 246 case Retr: {
243 if (status != Quit) { 247 if (status != Quit) {
244 if ((selected)||(mailSize <= headerLimit)) 248 if ((selected)||(mailSize <= headerLimit))
245 { 249 {
246 *stream << "RETR " << messageCount << "\r\n"; 250 *stream << "RETR " << messageCount << "\r\n";
247 } else { //only header 251 } else { //only header
248 *stream << "TOP " << messageCount << " 0\r\n"; 252 *stream << "TOP " << messageCount << " 0\r\n";
249 } 253 }
250 messageCount++; 254 messageCount++;
251 status = Ignore; 255 status = Ignore;
252 break; 256 break;
253 } } 257 } }
254 case Ignore: { 258 case Ignore: {
255 if (status != Quit) { //because of idiotic switch 259 if (status != Quit) { //because of idiotic switch
256 if (response[0] == '+') { 260 if (response[0] == '+') {
257 message = ""; 261 message = "";
258 status = Read; 262 status = Read;
259 if (!socket->canReadLine()) //sync. problems 263 if (!socket->canReadLine()) //sync. problems
260 break; 264 break;
261 response = socket->readLine(); 265 response = socket->readLine();
262 } else errorHandling(ErrUnknownResponse); 266 } else errorHandlingWithMsg(ErrUnknownResponse, response);
263 } 267 }
264 } 268 }
265 //add all incoming lines to body. When size is reached, send 269 //add all incoming lines to body. When size is reached, send
266 //message, and go back to read new message 270 //message, and go back to read new message
267 case Read: { 271 case Read: {
268 if (status != Quit) { //because of idiotic switch 272 if (status != Quit) { //because of idiotic switch
269 message += response; 273 message += response;
270 while ( socket->canReadLine() ) { 274 while ( socket->canReadLine() ) {
271 response = socket->readLine(); 275 response = socket->readLine();
272 message += response; 276 message += response;
273 } 277 }
274 emit downloadedSize(message.length()); 278 emit downloadedSize(message.length());
275 int x = message.find("\r\n.\r\n",-5); 279 int x = message.find("\r\n.\r\n",-5);
276 if (x == -1) { 280 if (x == -1) {
277 break; 281 break;
278 } else { //message reach entire size 282 } else { //message reach entire size
279 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 283 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
280 { 284 {
281 emit newMessage(message, messageCount-1, mailSize, TRUE); 285 emit newMessage(message, messageCount-1, mailSize, TRUE);
282 } else { //incomplete mail downloaded 286 } else { //incomplete mail downloaded
283 emit newMessage(message, messageCount-1, mailSize, FALSE); 287 emit newMessage(message, messageCount-1, mailSize, FALSE);
284 } 288 }
285 289
286 if ((messageCount > newMessages)||(selected)) //last message ? 290 if ((messageCount > newMessages)||(selected)) //last message ?
287 { 291 {
288 status = Quit; 292 status = Quit;
289 if (selected) { //grab next from queue 293 if (selected) { //grab next from queue
290 newMessages--; 294 newMessages--;
291 status = Quit; 295 status = Quit;
292 } 296 }
293 } 297 }
294 else 298 else
295 { 299 {
296 *stream << "LIST " << messageCount << "\r\n"; 300 *stream << "LIST " << messageCount << "\r\n";
297 status = Size; 301 status = Size;
298 temp2.setNum(newMessages - lastSync); 302 temp2.setNum(newMessages - lastSync);
299 temp.setNum(messageCount - lastSync); 303 temp.setNum(messageCount - lastSync);
300 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 304 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
301 305
302 break; 306 break;
303 } 307 }
304 } 308 }
305 } 309 }
306 if (status != Quit) 310 if (status != Quit)
307 break; 311 break;
308 } 312 }
309 case Quit: { 313 case Quit: {
310 *stream << "Quit\r\n"; 314 *stream << "Quit\r\n";
311 status = Done; 315 status = Done;
312 int newM = newMessages - lastSync; 316 int newM = newMessages - lastSync;
313 if (newM > 0) { 317 if (newM > 0) {
314 temp.setNum(newM); 318 temp.setNum(newM);
315 emit updateStatus(temp + tr(" new messages")); 319 emit updateStatus(temp + tr(" new messages"));
316 } else { 320 } else {
317 emit updateStatus(tr("No new messages")); 321 emit updateStatus(tr("No new messages"));
318 } 322 }
319 323
320 socket->close(); 324 socket->close();
321 receiving = FALSE; 325 receiving = FALSE;
322 emit mailTransfered(newM); 326 emit mailTransfered(newM);
323 break; 327 break;
324 } 328 }
325 } 329 }
326 330
327} 331}
diff --git a/noncore/unsupported/mailit/popclient.h b/noncore/unsupported/mailit/popclient.h
index c58bc48..6774ceb 100644
--- a/noncore/unsupported/mailit/popclient.h
+++ b/noncore/unsupported/mailit/popclient.h
@@ -1,76 +1,77 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PopClient_H 20#ifndef PopClient_H
21#define PopClient_H 21#define PopClient_H
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qlist.h> 28#include <qlist.h>
29#include "maillist.h" 29#include "maillist.h"
30 30
31class PopClient: public QObject 31class PopClient: public QObject
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 PopClient(); 36 PopClient();
37 ~PopClient(); 37 ~PopClient();
38 void newConnection(const QString &target, int port); 38 void newConnection(const QString &target, int port);
39 void setAccount(const QString &popUser, const QString &popPasswd); 39 void setAccount(const QString &popUser, const QString &popPasswd);
40 void setSynchronize(int lastCount); 40 void setSynchronize(int lastCount);
41 void removeSynchronize(); 41 void removeSynchronize();
42 void headersOnly(bool headers, int limit); 42 void headersOnly(bool headers, int limit);
43 void setSelectedMails(MailList *list); 43 void setSelectedMails(MailList *list);
44 44
45signals: 45signals:
46 void newMessage(const QString &, int, uint, bool); 46 void newMessage(const QString &, int, uint, bool);
47 void errorOccurred(int status); 47 void errorOccurred(int status, const QString & Msg );
48 void updateStatus(const QString &); 48 void updateStatus(const QString &);
49 void mailTransfered(int); 49 void mailTransfered(int);
50 void mailboxSize(int); 50 void mailboxSize(int);
51 void currentMailSize(int); 51 void currentMailSize(int);
52 void downloadedSize(int); 52 void downloadedSize(int);
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & );
56 57
57protected slots: 58protected slots:
58 void connectionEstablished(); 59 void connectionEstablished();
59 void incomingData(); 60 void incomingData();
60 61
61private: 62private:
62 QSocket *socket; 63 QSocket *socket;
63 QTextStream *stream; 64 QTextStream *stream;
64 enum transferStatus 65 enum transferStatus
65 { 66 {
66 Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks, 67 Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks,
67 Quit, Done, Ignore 68 Quit, Done, Ignore
68 }; 69 };
69 int status, lastSync; 70 int status, lastSync;
70 int messageCount, newMessages, mailSize, headerLimit; 71 int messageCount, newMessages, mailSize, headerLimit;
71 bool receiving, synchronize, preview, selected; 72 bool receiving, synchronize, preview, selected;
72 QString popUserName, popPassword, message; 73 QString popUserName, popPassword, message;
73 MailList *mailList; 74 MailList *mailList;
74}; 75};
75 76
76#endif 77#endif
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 2916f45..5b5ef52 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -1,163 +1,170 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "smtpclient.h" 20#include "smtpclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22 22
23SmtpClient::SmtpClient() 23SmtpClient::SmtpClient()
24{ 24{
25 socket = new QSocket(this, "smtpClient"); 25 socket = new QSocket(this, "smtpClient");
26 stream = new QTextStream(socket); 26 stream = new QTextStream(socket);
27 mailList.setAutoDelete(TRUE); 27 mailList.setAutoDelete(TRUE);
28 28
29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(const QString &target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 emit errorOccurred(status); 76 errorHandlingWithMsg( status, QString::null );
77}
78
79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
80{
81 emit errorOccurred(status, EMsg );
77 socket->close(); 82 socket->close();
78 mailList.clear(); 83 mailList.clear();
79 sending = FALSE; 84 sending = FALSE;
80} 85}
81 86
82void SmtpClient::incomingData() 87void SmtpClient::incomingData()
83{ 88{
84 QString response; 89 QString response;
85 90
86 if (!socket->canReadLine()) 91 if (!socket->canReadLine())
87 return; 92 return;
88 93
89 response = socket->readLine(); 94 response = socket->readLine();
90
91 switch(status) { 95 switch(status) {
92 case Init: { 96 case Init: {
93 if (response[0] == '2') { 97 if (response[0] == '2') {
94 status = From; 98 status = From;
95 mailPtr = mailList.first(); 99 mailPtr = mailList.first();
96 *stream << "HELO there\r\n"; 100 *stream << "HELO there\r\n";
97 } else errorHandling(ErrUnknownResponse); 101 } else errorHandlingWithMsg(ErrUnknownResponse,response);
98 break; 102 break;
99 } 103 }
100 case From: { 104 case From: {
101 if (response[0] == '2') { 105 if (response[0] == '2') {
102 *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; 106 qDebug(mailPtr->from);
107 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n";
103 status = Recv; 108 status = Recv;
104 } else errorHandling(ErrUnknownResponse); 109 } else errorHandlingWithMsg(ErrUnknownResponse, response );
105 break; 110 break;
106 } 111 }
107 case Recv: { 112 case Recv: {
108 if (response[0] == '2') { 113 if (response[0] == '2') {
109 it = mailPtr->to.begin(); 114 it = mailPtr->to.begin();
110 if (it == NULL) 115 if (it == NULL) {
111 errorHandling(ErrUnknownResponse); 116 errorHandlingWithMsg(ErrUnknownResponse,response);
112 *stream << "RCPT TO: " << *it << ">\r\n"; 117 }
118 *stream << "RCPT TO: <" << *it << ">\r\n";
113 status = MRcv; 119 status = MRcv;
114 } else errorHandling(ErrUnknownResponse); 120 } else errorHandlingWithMsg(ErrUnknownResponse,response);
115 break; 121 break;
116 } 122 }
117 case MRcv: { 123 case MRcv: {
118 if (response[0] == '2') { 124 if (response[0] == '2') {
119 it++; 125 it++;
120 if ( it != mailPtr->to.end() ) { 126 if ( it != mailPtr->to.end() ) {
121 *stream << "RCPT TO: <" << *it << ">\r\n"; 127 *stream << "RCPT TO: <" << *it << ">\r\n";
122 break; 128 break;
123 } else { 129 } else {
124 status = Data; 130 status = Data;
125 } 131 }
126 } else errorHandling(ErrUnknownResponse); 132 } else errorHandlingWithMsg(ErrUnknownResponse,response);
127 } 133 }
128 case Data: { 134 case Data: {
129 if (response[0] == '2') { 135 if (response[0] == '2') {
130 *stream << "DATA\r\n"; 136 *stream << "DATA\r\n";
131 status = Body; 137 status = Body;
132 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
133 } else errorHandling(ErrUnknownResponse); 139
140 } else errorHandlingWithMsg(ErrUnknownResponse,response);
134 break; 141 break;
135 } 142 }
136 case Body: { 143 case Body: {
137 if (response[0] == '3') { 144 if (response[0] == '3') {
138 *stream << mailPtr->body << "\r\n.\r\n"; 145 *stream << mailPtr->body << "\r\n.\r\n";
139 mailPtr = mailList.next(); 146 mailPtr = mailList.next();
140 if (mailPtr != NULL) { 147 if (mailPtr != NULL) {
141 status = From; 148 status = From;
142 } else { 149 } else {
143 status = Quit; 150 status = Quit;
144 } 151 }
145 } else errorHandling(ErrUnknownResponse); 152 } else errorHandlingWithMsg(ErrUnknownResponse,response);
146 break; 153 break;
147 } 154 }
148 case Quit: { 155 case Quit: {
149 if (response[0] == '2') { 156 if (response[0] == '2') {
150 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
151 status = Done; 158 status = Done;
152 QString temp; 159 QString temp;
153 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
154 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
155 emit mailSent(); 162 emit mailSent();
156 mailList.clear(); 163 mailList.clear();
157 sending = FALSE; 164 sending = FALSE;
158 socket->close(); 165 socket->close();
159 } else errorHandling(ErrUnknownResponse); 166 } else errorHandlingWithMsg(ErrUnknownResponse,response);
160 break; 167 break;
161 } 168 }
162 } 169 }
163} 170}
diff --git a/noncore/unsupported/mailit/smtpclient.h b/noncore/unsupported/mailit/smtpclient.h
index 45c0703..554ba3f 100644
--- a/noncore/unsupported/mailit/smtpclient.h
+++ b/noncore/unsupported/mailit/smtpclient.h
@@ -1,75 +1,76 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef SmtpClient_H 20#ifndef SmtpClient_H
21#define SmtpClient_H 21#define SmtpClient_H
22 22
23//#include <stdio.h> 23//#include <stdio.h>
24#include <qsocket.h> 24#include <qsocket.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qobject.h> 26#include <qobject.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlist.h> 29#include <qlist.h>
30 30
31struct RawEmail 31struct RawEmail
32{ 32{
33 QString from; 33 QString from;
34 QString subject; 34 QString subject;
35 QStringList to; 35 QStringList to;
36 QString body; 36 QString body;
37}; 37};
38 38
39class SmtpClient: public QObject 39class SmtpClient: public QObject
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 SmtpClient(); 44 SmtpClient();
45 ~SmtpClient(); 45 ~SmtpClient();
46 void newConnection(const QString &target, int port); 46 void newConnection(const QString &target, int port);
47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body); 47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
48 48
49signals: 49signals:
50 void errorOccurred(int); 50 void errorOccurred(int, const QString & LR );
51 void updateStatus(const QString &); 51 void updateStatus(const QString &);
52 void mailSent(); 52 void mailSent();
53 53
54public slots: 54public slots:
55 void errorHandling(int); 55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & LastResponse );
56 57
57protected slots: 58protected slots:
58 void connectionEstablished(); 59 void connectionEstablished();
59 void incomingData(); 60 void incomingData();
60 61
61private: 62private:
62 QSocket *socket; 63 QSocket *socket;
63 QTextStream *stream; 64 QTextStream *stream;
64 enum transferStatus 65 enum transferStatus
65 { 66 {
66 Init, From, Recv, MRcv, Data, Body, Quit, Done 67 Init, From, Recv, MRcv, Data, Body, Quit, Done
67 }; 68 };
68 int status; 69 int status;
69 QList<RawEmail> mailList; 70 QList<RawEmail> mailList;
70 RawEmail *mailPtr; 71 RawEmail *mailPtr;
71 bool sending; 72 bool sending;
72 QStringList::Iterator it; 73 QStringList::Iterator it;
73}; 74};
74 75
75#endif 76#endif
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp
index 21885c2..293e137 100644
--- a/noncore/unsupported/mailit/viewatt.cpp
+++ b/noncore/unsupported/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "resource.h" 20#include "resource.h"
21#include "viewatt.h" 21#include "viewatt.h"
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
27 : QMainWindow(parent, name, f) 27 : QMainWindow(parent, name, f)
28{ 28{
29 setCaption("Exploring attatchments"); 29 setCaption(tr("Exploring attatchments"));
30 30
31 setToolBarsMovable( FALSE ); 31 setToolBarsMovable( FALSE );
32 bar = new QToolBar(this); 32 bar = new QToolBar(this);
33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); 35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
36 36
37 listView = new QListView(this, "AttView"); 37 listView = new QListView(this, "AttView");
38 listView->addColumn( "Attatchment" ); 38 listView->addColumn( tr("Attatchment") );
39 listView->addColumn( "Type" ); 39 listView->addColumn( tr("Type") );
40 listView->addColumn( "Installed" ); 40 listView->addColumn( tr("Installed") );
41 setCentralWidget(listView); 41 setCentralWidget(listView);
42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); 42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
43} 43}
44 44
45void ViewAtt::update(Email *mailIn, bool inbox) 45void ViewAtt::update(Email *mailIn, bool inbox)
46{ 46{
47 QListViewItem *item; 47 QListViewItem *item;
48 Enclosure *ePtr; 48 Enclosure *ePtr;
49 49
50 50
51 51
52 listView->clear(); 52 listView->clear();
53 if (inbox) { 53 if (inbox) {
54 bar->clear(); 54 bar->clear();
55 installButton->addTo( bar ); 55 installButton->addTo( bar );
56 bar->show(); 56 bar->show();
57 } else { 57 } else {
58 bar->hide(); 58 bar->hide();
59 } 59 }
60 60
61 mail = mailIn; 61 mail = mailIn;
62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
63 63
64 QString isInstalled = "No"; 64 QString isInstalled = tr("No");
65 if (ePtr->installed) 65 if (ePtr->installed)
66 isInstalled = "Yes"; 66 isInstalled = tr("Yes");
67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
68 68
69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; 69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
70 70
71 MimeType mt(mtypeDef); 71 MimeType mt(mtypeDef);
72 72
73 item->setPixmap(0, mt.pixmap()); 73 item->setPixmap(0, mt.pixmap());
74 74
75 /* 75 /*
76 if (ePtr->contentType == "TEXT") { 76 if (ePtr->contentType == "TEXT") {
77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
78 actions->addTo(bar); 78 actions->addTo(bar);
79 } 79 }
80 if (ePtr->contentType == "AUDIO") { 80 if (ePtr->contentType == "AUDIO") {
81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
82 actions->addTo(bar); 82 actions->addTo(bar);
83 item->setPixmap(0, Resource::loadPixmap("play")); 83 item->setPixmap(0, Resource::loadPixmap("play"));
84 } 84 }
85 if (ePtr->contentType == "IMAGE") { 85 if (ePtr->contentType == "IMAGE") {
86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
87 actions->addTo(bar); 87 actions->addTo(bar);
88 item->setPixmap(0, Resource::loadPixmap("pixmap")); 88 item->setPixmap(0, Resource::loadPixmap("pixmap"));
89 }*/ 89 }*/
90 } 90 }
91} 91}
92 92
93void ViewAtt::install() 93void ViewAtt::install()
94{ 94{
95 Enclosure *ePtr, *selPtr; 95 Enclosure *ePtr, *selPtr;
96 QListViewItem *item; 96 QListViewItem *item;
97 QString filename; 97 QString filename;
98 DocLnk d; 98 DocLnk d;
99 99
100 item = listView->selectedItem(); 100 item = listView->selectedItem();
101 if (item != NULL) { 101 if (item != NULL) {
102 filename = item->text(0); 102 filename = item->text(0);
103 selPtr = NULL; 103 selPtr = NULL;
104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
105 if (ePtr->originalName == filename) 105 if (ePtr->originalName == filename)
106 selPtr = ePtr; 106 selPtr = ePtr;
107 } 107 }
108 108
109 if (selPtr == NULL) { 109 if (selPtr == NULL) {
110 qWarning("Internal error, file is not installed to documents"); 110 qWarning("Internal error, file is not installed to documents");
111 return; 111 return;
112 } 112 }
113 113
114 d.setName(selPtr->originalName); 114 d.setName(selPtr->originalName);
115 d.setFile(selPtr->path + selPtr->name); 115 d.setFile(selPtr->path + selPtr->name);
116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
117 d.writeLink(); 117 d.writeLink();
118 selPtr->installed = TRUE; 118 selPtr->installed = TRUE;
119 item->setText(2, "Yes"); 119 item->setText(2, tr("Yes"));
120 } 120 }
121} 121}
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp
index 0298cb3..26b9660 100644
--- a/noncore/unsupported/mailit/writemail.cpp
+++ b/noncore/unsupported/mailit/writemail.cpp
@@ -1,402 +1,402 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include "writemail.h" 22#include "writemail.h"
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl ) 25WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl )
26{ 26{
27 showingAddressList = FALSE; 27 showingAddressList = FALSE;
28 init(); 28 init();
29 29
30 addAtt = new AddAtt(0, "Add Attachments"); 30 addAtt = new AddAtt(0, "Add Attachments");
31} 31}
32 32
33WriteMail::~WriteMail() 33WriteMail::~WriteMail()
34{ 34{
35 delete addAtt; 35 delete addAtt;
36} 36}
37 37
38void WriteMail::setAddressList(AddressList *list) 38void WriteMail::setAddressList(AddressList *list)
39{ 39{
40 AContact *cPtr; 40 AContact *cPtr;
41 41
42 addressList = list; 42 addressList = list;
43 43
44 addressView->clear(); 44 addressView->clear();
45 QList<AContact> *cListPtr = addressList->getContactList(); 45 QList<AContact> *cListPtr = addressList->getContactList();
46 QListViewItem *item; 46 QListViewItem *item;
47 for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { 47 for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) {
48 item = new QListViewItem(addressView, cPtr->name, cPtr->email); 48 item = new QListViewItem(addressView, cPtr->name, cPtr->email);
49 } 49 }
50} 50}
51 51
52void WriteMail::init() 52void WriteMail::init()
53{ 53{
54 setToolBarsMovable(FALSE); 54 setToolBarsMovable(FALSE);
55 55
56 bar = new QToolBar(this); 56 bar = new QToolBar(this);
57 bar->setHorizontalStretchable( TRUE ); 57 bar->setHorizontalStretchable( TRUE );
58 58
59 menu = new QMenuBar( bar ); 59 menu = new QMenuBar( bar );
60 60
61 mailMenu = new QPopupMenu(menu); 61 mailMenu = new QPopupMenu(menu);
62 menu->insertItem( tr( "&Mail" ), mailMenu); 62 menu->insertItem( tr( "&Mail" ), mailMenu);
63 addMenu = new QPopupMenu(menu); 63 addMenu = new QPopupMenu(menu);
64 menu->insertItem( tr( "&Add" ), addMenu); 64 menu->insertItem( tr( "&Add" ), addMenu);
65 65
66 bar = new QToolBar(this); 66 bar = new QToolBar(this);
67 attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); 67 attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0);
68 attachButton->addTo(bar); 68 attachButton->addTo(bar);
69 attachButton->addTo(addMenu); 69 attachButton->addTo(addMenu);
70 connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); 70 connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) );
71 attachButton->setWhatsThis(tr("Click here to attach files to your mail")); 71 attachButton->setWhatsThis(tr("Click here to attach files to your mail"));
72 72
73 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); 73 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0);
74 confirmButton->addTo(bar); 74 confirmButton->addTo(bar);
75 confirmButton->addTo(mailMenu); 75 confirmButton->addTo(mailMenu);
76 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); 76 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) );
77 confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); 77 confirmButton->setWhatsThis(tr("This button puts your mail in the send queue"));
78 78
79 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 79 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
80 newButton->addTo(mailMenu); 80 newButton->addTo(mailMenu);
81 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); 81 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
82 newButton->setWhatsThis(tr("Click here to create a new mail")); 82 newButton->setWhatsThis(tr("Click here to create a new mail"));
83 83
84 widget = new QWidget(this, "widget"); 84 widget = new QWidget(this, "widget");
85 grid = new QGridLayout( widget ); 85 grid = new QGridLayout( widget );
86 86
87 recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); 87 recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
88 recipientsBox->insertItem( tr( "To:" ) ); 88 recipientsBox->insertItem( tr( "To:" ) );
89 recipientsBox->insertItem( tr( "CC:" ) ); 89 recipientsBox->insertItem( tr( "CC:" ) );
90 recipientsBox->setCurrentItem(0); 90 recipientsBox->setCurrentItem(0);
91 grid->addWidget( recipientsBox, 0, 0 ); 91 grid->addWidget( recipientsBox, 0, 0 );
92 connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); 92 connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int)));
93 93
94 subjetLabel = new QLabel( widget, "subjetLabel" ); 94 subjetLabel = new QLabel( widget, "subjetLabel" );
95 subjetLabel->setText( tr( "Subject:" ) ); 95 subjetLabel->setText( tr( "Subject:" ) );
96 96
97 grid->addWidget( subjetLabel, 1, 0 ); 97 grid->addWidget( subjetLabel, 1, 0 );
98 98
99 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); 99 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
100 ToolButton13_2->setText( tr( "..." ) ); 100 ToolButton13_2->setText( tr( "..." ) );
101 grid->addWidget( ToolButton13_2, 1, 2 ); 101 grid->addWidget( ToolButton13_2, 1, 2 );
102 102
103 subjectInput = new QLineEdit( widget, "subjectInput" ); 103 subjectInput = new QLineEdit( widget, "subjectInput" );
104 grid->addWidget( subjectInput, 1, 1 ); 104 grid->addWidget( subjectInput, 1, 1 );
105 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); 105 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here"));
106 106
107 toInput = new QLineEdit( widget, "toInput" ); 107 toInput = new QLineEdit( widget, "toInput" );
108 grid->addWidget( toInput, 0, 1 ); 108 grid->addWidget( toInput, 0, 1 );
109 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); 109 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here"));
110 110
111 ccInput = new QLineEdit( widget, "ccInput" ); 111 ccInput = new QLineEdit( widget, "ccInput" );
112 ccInput->hide(); 112 ccInput->hide();
113 grid->addWidget( ccInput, 0, 1 ); 113 grid->addWidget( ccInput, 0, 1 );
114 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); 114 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here"));
115 115
116 addressButton = new QToolButton( widget, "addressButton" ); 116 addressButton = new QToolButton( widget, "addressButton" );
117 addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); 117 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
118 addressButton->setToggleButton(TRUE); 118 addressButton->setToggleButton(TRUE);
119 grid->addWidget( addressButton, 0, 2 ); 119 grid->addWidget( addressButton, 0, 2 );
120 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); 120 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
121 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); 121 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your Opie addressbook"));
122 122
123 emailInput = new QMultiLineEdit( widget, "emailInput" ); 123 emailInput = new QMultiLineEdit( widget, "emailInput" );
124 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); 124 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
125 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); 125 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here"));
126 126
127 addressView = new QListView( widget, "addressView"); 127 addressView = new QListView( widget, "addressView");
128 addressView->addColumn("Name"); 128 addressView->addColumn(tr("Name"));
129 addressView->addColumn("EMail"); 129 addressView->addColumn(tr("EMail") );
130 addressView->setAllColumnsShowFocus(TRUE); 130 addressView->setAllColumnsShowFocus(TRUE);
131 addressView->setMultiSelection(TRUE); 131 addressView->setMultiSelection(TRUE);
132 addressView->hide(); 132 addressView->hide();
133 grid->addMultiCellWidget( addressView, 3, 3, 0, 2); 133 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
134 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); 134 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list"));
135 135
136 okButton = new QToolButton(bar, "ok"); 136 okButton = new QToolButton(bar, "ok");
137 okButton->setPixmap( Resource::loadPixmap("enter") ); 137 okButton->setPixmap( Resource::loadPixmap("enter") );
138 okButton->hide(); 138 okButton->hide();
139 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); 139 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
140 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); 140 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here"));
141 141
142 setCentralWidget(widget); 142 setCentralWidget(widget);
143} 143}
144 144
145void WriteMail::reject() 145void WriteMail::reject()
146{ 146{
147 emit cancelMail(); 147 emit cancelMail();
148} 148}
149 149
150void WriteMail::accept() 150void WriteMail::accept()
151{ 151{
152 QStringList attachedFiles, attachmentsType; 152 QStringList attachedFiles, attachmentsType;
153 int idCount = 0; 153 int idCount = 0;
154 154
155 if (toInput->text() == "") 155 if (toInput->text() == "")
156 { 156 {
157 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); 157 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n"));
158 return; 158 return;
159 } 159 }
160 160
161 if (! getRecipients(false) ) 161 if (! getRecipients(false) )
162 { 162 {
163 QMessageBox::warning(this,tr("Incorrect recipient separator"), 163 QMessageBox::warning(this,tr("Incorrect recipient separator"),
164 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 164 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
165 return; 165 return;
166 } 166 }
167 167
168 if ((ccInput->text()!="") && (! getRecipients(true) )) 168 if ((ccInput->text()!="") && (! getRecipients(true) ))
169 { 169 {
170 QMessageBox::warning(this,tr("Incorrect carbon copy separator"), 170 QMessageBox::warning(this,tr("Incorrect carbon copy separator"),
171 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 171 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
172 return; 172 return;
173 } 173 }
174 174
175 mail.subject = subjectInput->text(); 175 mail.subject = subjectInput->text();
176 mail.body = emailInput->text(); 176 mail.body = emailInput->text();
177 mail.sent = false; 177 mail.sent = false;
178 mail.received = false; 178 mail.received = false;
179 179
180 mail.rawMail = "To: "; 180 mail.rawMail = "To: ";
181 181
182 for (QStringList::Iterator it = mail.recipients.begin(); 182 for (QStringList::Iterator it = mail.recipients.begin();
183 it != mail.recipients.end(); ++it) { 183 it != mail.recipients.end(); ++it) {
184 184
185 mail.rawMail += (*it); 185 mail.rawMail += (*it);
186 mail.rawMail += ",\n"; 186 mail.rawMail += ",\n";
187 } 187 }
188 188
189 mail.rawMail.truncate(mail.rawMail.length()-2); 189 mail.rawMail.truncate(mail.rawMail.length()-2);
190 190
191 mail.rawMail += "\nCC: "; 191 mail.rawMail += "\nCC: ";
192 192
193 for (QStringList::Iterator it = mail.carbonCopies.begin(); 193 for (QStringList::Iterator it = mail.carbonCopies.begin();
194 it != mail.carbonCopies.end(); ++it) { 194 it != mail.carbonCopies.end(); ++it) {
195 195
196 mail.rawMail += (*it); 196 mail.rawMail += (*it);
197 mail.rawMail += ",\n"; 197 mail.rawMail += ",\n";
198 } 198 }
199 199
200 mail.rawMail += mail.from; 200 mail.rawMail += mail.from;
201 mail.rawMail += "\nSubject: "; 201 mail.rawMail += "\nSubject: ";
202 mail.rawMail += mail.subject; 202 mail.rawMail += mail.subject;
203 mail.rawMail += "\n\n"; 203 mail.rawMail += "\n\n";
204 204
205 attachedFiles = addAtt->returnattachedFiles(); 205 attachedFiles = addAtt->returnattachedFiles();
206 attachmentsType = addAtt->returnFileTypes(); 206 attachmentsType = addAtt->returnFileTypes();
207 207
208 QStringList::Iterator itType = attachmentsType.begin(); 208 QStringList::Iterator itType = attachmentsType.begin();
209 209
210 Enclosure e; 210 Enclosure e;
211 for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { 211 for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) {
212 e.id = idCount; 212 e.id = idCount;
213 e.originalName = (*it).latin1(); 213 e.originalName = (*it).latin1();
214 e.contentType = (*itType).latin1(); 214 e.contentType = (*itType).latin1();
215 e.contentAttribute = (*itType).latin1(); 215 e.contentAttribute = (*itType).latin1();
216 e.saved = TRUE; 216 e.saved = TRUE;
217 mail.addEnclosure(&e); 217 mail.addEnclosure(&e);
218 218
219 itType++; 219 itType++;
220 idCount++; 220 idCount++;
221 } 221 }
222 mail.rawMail += mail.body; 222 mail.rawMail += mail.body;
223 mail.rawMail += "\n"; 223 mail.rawMail += "\n";
224 mail.rawMail += ".\n"; 224 mail.rawMail += ".\n";
225 emit sendMailRequested(mail); 225 emit sendMailRequested(mail);
226 addAtt->clear(); 226 addAtt->clear();
227} 227}
228 228
229void WriteMail::getAddress() 229void WriteMail::getAddress()
230{ 230{
231 showingAddressList = !showingAddressList; 231 showingAddressList = !showingAddressList;
232 232
233 if (showingAddressList) { 233 if (showingAddressList) {
234 emailInput->hide(); 234 emailInput->hide();
235 addressView->show(); 235 addressView->show();
236 okButton->show(); 236 okButton->show();
237 237
238 } else { 238 } else {
239 addressView->hide(); 239 addressView->hide();
240 okButton->hide(); 240 okButton->hide();
241 emailInput->show(); 241 emailInput->show();
242 } 242 }
243} 243}
244 244
245void WriteMail::attachFile() 245void WriteMail::attachFile()
246{ 246{
247 addAtt->showMaximized(); 247 addAtt->showMaximized();
248} 248}
249 249
250void WriteMail::reply(Email replyMail, bool replyAll) 250void WriteMail::reply(Email replyMail, bool replyAll)
251{ 251{
252 int pos; 252 int pos;
253 QString ccRecipients; 253 QString ccRecipients;
254 254
255 mail = replyMail; 255 mail = replyMail;
256 mail.files.clear(); 256 mail.files.clear();
257 257
258 toInput->setText(mail.fromMail); 258 toInput->setText(mail.fromMail);
259 259
260 if (replyAll) 260 if (replyAll)
261 { 261 {
262 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) 262 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it)
263 { 263 {
264 ccRecipients.append(*it); 264 ccRecipients.append(*it);
265 ccRecipients.append(";"); 265 ccRecipients.append(";");
266 } 266 }
267 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end 267 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end
268 ccInput->setText(ccRecipients); 268 ccInput->setText(ccRecipients);
269 } 269 }
270 else ccInput->clear(); 270 else ccInput->clear();
271 271
272 subjectInput->setText(tr("Re: ") + mail.subject); 272 subjectInput->setText(tr("Re: ") + mail.subject);
273 273
274 QString citation=mail.fromMail; 274 QString citation=mail.fromMail;
275 citation.append(tr(" wrote on ")); 275 citation.append(tr(" wrote on "));
276 citation.append(mail.date); 276 citation.append(mail.date);
277 citation.append(":\n"); 277 citation.append(":\n");
278 278
279 279
280 //mail.body.insert(0,tr("On")); 280 //mail.body.insert(0,tr("On"));
281 pos = 0; 281 pos = 0;
282 mail.body.insert(pos, ">"); 282 mail.body.insert(pos, ">");
283 while (pos != -1) { 283 while (pos != -1) {
284 pos = mail.body.find('\n', pos); 284 pos = mail.body.find('\n', pos);
285 if (pos != -1) 285 if (pos != -1)
286 mail.body.insert(++pos, ">>"); 286 mail.body.insert(++pos, ">");
287 } 287 }
288 mail.body.insert(0,citation); 288 mail.body.insert(0,citation);
289 emailInput->setText(mail.body); 289 emailInput->setText(mail.body);
290} 290}
291 291
292void WriteMail::forward(Email forwMail) 292void WriteMail::forward(Email forwMail)
293{ 293{
294 int pos=0; 294 // int pos=0;
295 295
296 QString fwdBody=tr("======forwarded message from "); 296 QString fwdBody=tr("======forwarded message from ");
297 fwdBody.append(forwMail.fromMail); 297 fwdBody.append(forwMail.fromMail);
298 fwdBody.append(tr(" starts======\n\n")); 298 fwdBody.append(tr(" starts======\n\n"));
299 299
300 mail=forwMail; 300 mail=forwMail;
301 toInput->setText(""); 301 toInput->setText("");
302 ccInput->setText(""); 302 ccInput->setText("");
303 subjectInput->setText(tr("FWD: ") + mail.subject); 303 subjectInput->setText(tr("FWD: ") + mail.subject);
304 304
305 fwdBody+=mail.body; 305 fwdBody+=mail.body;
306 fwdBody+=QString(tr("======end of forwarded message======\n\n")); 306 fwdBody+=QString(tr("======end of forwarded message======\n\n"));
307 307
308 emailInput->setText(fwdBody); 308 emailInput->setText(fwdBody);
309} 309}
310 310
311bool WriteMail::getRecipients(bool ccField) 311bool WriteMail::getRecipients(bool ccField)
312{ 312{
313 QString str, temp; 313 QString str, temp;
314 int pos = 0; 314 int pos = 0;
315 315
316 if (ccField) 316 if (ccField)
317 { 317 {
318 mail.carbonCopies.clear(); 318 mail.carbonCopies.clear();
319 temp = ccInput->text(); 319 temp = ccInput->text();
320 } 320 }
321 else 321 else
322 { 322 {
323 mail.recipients.clear(); 323 mail.recipients.clear();
324 temp=toInput->text() ; 324 temp=toInput->text() ;
325 } 325 }
326 326
327 while ( (pos = temp.find(';')) != -1) { 327 while ( (pos = temp.find(';')) != -1) {
328 str = temp.left(pos).stripWhiteSpace(); 328 str = temp.left(pos).stripWhiteSpace();
329 temp = temp.right(temp.length() - (pos + 1)); 329 temp = temp.right(temp.length() - (pos + 1));
330 if ( str.find('@') == -1) 330 if ( str.find('@') == -1)
331 return false; 331 return false;
332 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); 332 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str);
333 //addressList->addContact(str, ""); 333 //addressList->addContact(str, "");
334 } 334 }
335 temp = temp.stripWhiteSpace(); 335 temp = temp.stripWhiteSpace();
336 if ( temp.find('@') == -1) 336 if ( temp.find('@') == -1)
337 return false; 337 return false;
338 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); 338 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp);
339 //addressList->addContact(temp, ""); 339 //addressList->addContact(temp, "");
340 340
341 return TRUE; 341 return TRUE;
342} 342}
343 343
344void WriteMail::addRecipients() 344void WriteMail::addRecipients()
345{ 345{
346 toInput->isVisible() ? addRecipients(false) : addRecipients(true); 346 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
347 } 347}
348 348
349void WriteMail::addRecipients(bool ccField) 349void WriteMail::addRecipients(bool ccField)
350{ 350{
351 QString recipients = ""; 351 QString recipients = "";
352 352
353 mail.recipients.clear(); 353 mail.recipients.clear();
354 354
355 QListViewItem *item = addressView->firstChild(); 355 QListViewItem *item = addressView->firstChild();
356 while (item != NULL) { 356 while (item != NULL) {
357 if ( item->isSelected() ) { 357 if ( item->isSelected() ) {
358 if (recipients == "") { 358 if (recipients == "") {
359 recipients = item->text(1); 359 recipients = item->text(1);
360 } else { 360 } else {
361 recipients += "; " + item->text(1); 361 recipients += "; " + item->text(1);
362 } 362 }
363 } 363 }
364 item = item->nextSibling(); 364 item = item->nextSibling();
365 } 365 }
366 366
367 ccField ? ccInput->setText(recipients):toInput->setText(recipients); 367 ccField ? ccInput->setText(recipients):toInput->setText(recipients);
368 368
369 addressView->hide(); 369 addressView->hide();
370 okButton->hide(); 370 okButton->hide();
371 emailInput->show(); 371 emailInput->show();
372 addressButton->setOn(FALSE); 372 addressButton->setOn(FALSE);
373 showingAddressList = !showingAddressList; 373 showingAddressList = !showingAddressList;
374} 374}
375 375
376void WriteMail::changeRecipients(int selection) 376void WriteMail::changeRecipients(int selection)
377{ 377{
378 if (selection==0) 378 if (selection==0)
379 { 379 {
380 toInput->show(); 380 toInput->show();
381 ccInput->hide(); 381 ccInput->hide();
382 } 382 }
383 else if (selection==1) 383 else if (selection==1)
384 { 384 {
385 toInput->hide(); 385 toInput->hide();
386 ccInput->show(); 386 ccInput->show();
387 } 387 }
388} 388}
389 389
390void WriteMail::setRecipient(const QString &recipient) 390void WriteMail::setRecipient(const QString &recipient)
391{ 391{
392 toInput->setText(recipient); 392 toInput->setText(recipient);
393} 393}
394 394
395void WriteMail::newMail() 395void WriteMail::newMail()
396{ 396{
397 toInput->clear(); 397 toInput->clear();
398 ccInput->clear(); 398 ccInput->clear();
399 subjectInput->clear(); 399 subjectInput->clear();
400 emailInput->clear(); 400 emailInput->clear();
401 setAddressList(addressList); 401 setAddressList(addressList);
402} 402}