summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-04-13 10:29:05 (UTC)
committer groucho <groucho>2003-04-13 10:29:05 (UTC)
commit8cc217bed9c122a7c7448e2cd59bfde330dfcfad (patch) (unidiff)
treef802c03bbddf54ecc541ce23bdc43da0fc8b390b
parent64d6b3e723b9b2fc3b1f3eea6da6344c5f26ce1e (diff)
downloadopie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.zip
opie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.tar.gz
opie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.tar.bz2
- Uses mime types for attachment reading
- Addresses are read from ocontactacess
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/addatt.cpp34
-rw-r--r--noncore/net/mailit/addatt.h8
-rw-r--r--noncore/net/mailit/addresslist.cpp20
-rw-r--r--noncore/net/mailit/emailclient.cpp2
-rw-r--r--noncore/net/mailit/mailitwindow.cpp4
-rw-r--r--noncore/net/mailit/viewatt.cpp15
-rw-r--r--noncore/net/mailit/writemail.cpp5
-rw-r--r--noncore/unsupported/mailit/addatt.cpp34
-rw-r--r--noncore/unsupported/mailit/addatt.h8
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp20
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp2
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp4
-rw-r--r--noncore/unsupported/mailit/viewatt.cpp15
-rw-r--r--noncore/unsupported/mailit/writemail.cpp5
14 files changed, 110 insertions, 66 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp
index f279f52..c8be865 100644
--- a/noncore/net/mailit/addatt.cpp
+++ b/noncore/net/mailit/addatt.cpp
@@ -1,230 +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 <qdir.h> 22#include <qdir.h>
22#include <qstringlist.h> 23#include <qstringlist.h>
23#include "resource.h" 24#include "resource.h"
24#include "addatt.h" 25#include "addatt.h"
25 26
26FileItem::FileItem(QListView *parent, DocLnk* dl) 27FileItem::FileItem(QListView *parent, DocLnk* dl)
27 : QListViewItem(parent) 28 : QListViewItem(parent)
28{ 29{
29 /*file = fileInfo; 30 /*file = fileInfo;
30 type = fileType;*/ 31 type = fileType;*/
31 32
32 doclnk=dl; 33 doclnk=dl;
33 34
34 setText(0, doclnk->name()); 35 setText(0, doclnk->name());
35 36
36 /*if (fileType == "Picture") { 37 /*if (fileType == "Picture") {
37 setPixmap(0, Resource::loadPixmap("pixmap")); 38 setPixmap(0, Resource::loadPixmap("pixmap"));
38 } else if (fileType == "Document") { 39 } else if (fileType == "Document") {
39 setPixmap(0, Resource::loadPixmap("txt")); 40 setPixmap(0, Resource::loadPixmap("txt"));
40 } else if (fileType == "Sound") { 41 } else if (fileType == "Sound") {
41 setPixmap(0, Resource::loadPixmap("play")); 42 setPixmap(0, Resource::loadPixmap("play"));
42 } else if (fileType == "Movie") { 43 } else if (fileType == "Movie") {
43 setPixmap(0, Resource::loadPixmap("MPEGPlayer")); 44 setPixmap(0, Resource::loadPixmap("MPEGPlayer"));
44 } else if (fileType == "File") { 45 } else if (fileType == "File") {
45 setPixmap(0, Resource::loadPixmap("exec")); 46 setPixmap(0, Resource::loadPixmap("exec"));
46 }*/ 47 }*/
47} 48}
48 49
49FileItem::~FileItem() 50FileItem::~FileItem()
50{ 51{
51 if (doclnk!=NULL) delete doclnk; 52 if (doclnk!=NULL) delete doclnk;
52 doclnk=NULL; 53 doclnk=NULL;
53} 54}
54 55
55AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) 56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
56 : QDialog(parent, name, f) 57 : QDialog(parent, name, f)
57{ 58{
58 setCaption("Adding attatchments"); 59 setCaption("Adding attatchments");
59 60
60 QGridLayout *top = new QGridLayout(this, 3,1 ); 61 QGridLayout *top = new QGridLayout(this, 1,1 );
61 62
62 63 QHBox *buttons=new QHBox(this);
63 /*fileCategoryButton = new QPushButton(this);*/ 64 /*fileCategoryButton = new QPushButton(this);*/
64 attatchButton = new QPushButton("Attatch ->", this); 65 attatchButton = new QPushButton("Attatch ->", buttons);
65 removeButton = new QPushButton("Remove", this); 66 removeButton = new QPushButton("Remove", buttons);
66 67
67 /*fileCategories = new QPopupMenu(fileCategoryButton); 68 /*fileCategories = new QPopupMenu(fileCategoryButton);
68 fileCategoryButton->setPopup(fileCategories); 69 fileCategoryButton->setPopup(fileCategories);
69 fileCategories->insertItem("Document"); 70 fileCategories->insertItem("Document");
70 fileCategories->insertItem("Picture"); 71 fileCategories->insertItem("Picture");
71 fileCategories->insertItem("Sound"); 72 fileCategories->insertItem("Sound");
72 fileCategories->insertItem("Movie"); 73 fileCategories->insertItem("Movie");
73 fileCategories->insertItem("File"); 74 fileCategories->insertItem("File");
74 75
75 fileCategoryButton->setText("Document"); 76 fileCategoryButton->setText("Document");
76 top->addWidget(fileCategoryButton, 0, 0);*/ 77 top->addWidget(fileCategoryButton, 0, 0);*/
77 78
78 //ofs=new OFileSelector(this,2,0,"/root/Documents");
79
80
81 top->addWidget(attatchButton,1,0);
82 top->addWidget(removeButton,2,0);
83 79
84 /*connect(fileCategories, SIGNAL(activated(int)), this, 80 top->addWidget(buttons,1,0);
85 SLOT(fileCategorySelected(int)) );*/ 81 //buttons->addWidget(attatchButton,0,0);
82 //buttons->addWidget(removeButton,0,1);
83
84 //connect(fileCategories, SIGNAL(activated(int)), this,
85 //SLOT(fileCategorySelected(int)) );*/
86 connect(attatchButton, SIGNAL(clicked()), this, 86 connect(attatchButton, SIGNAL(clicked()), this,
87 SLOT(addAttatchment()) ); 87 SLOT(addAttatchment()) );
88 connect(removeButton, SIGNAL(clicked()), this, 88 connect(removeButton, SIGNAL(clicked()), this,
89 SLOT(removeAttatchment()) ); 89 SLOT(removeAttatchment()) );
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(addAttatchment()) );*/ 94 SLOT(addAttatchment()) );*/
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(removeAttatchment()) ); 101 SLOT(removeAttatchment()) );
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::addAttatchment() 124void AddAtt::addAttatchment()
125 { 125 {
126 QDialog qd(this,tr("Select attachment"),true); 126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
127
128 QGridLayout top(&qd,1,1);
129
130 OFileSelector ofs(&qd,1,0,"/root/Documents");
131
132 top.addWidget(&ofs,0,0);
133 127
134 qd.showMaximized(); 128 ofs.showMaximized();
135 129
136 if (qd.exec()==QDialog::Accepted) 130 if (ofs.exec()==QDialog::Accepted)
137 { 131 {
138 DocLnk* dl=new DocLnk(ofs.selectedDocument()); 132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
139 FileItem* fi=new FileItem(attView,dl); 133 FileItem* fi=new FileItem(attView,dl);
140 fi->setPixmap(0,dl->pixmap()); 134 fi->setPixmap(0,dl->pixmap());
141 fi->setText(1,dl->type()); 135 fi->setText(1,dl->type());
142 attView->insertItem(fi); 136 attView->insertItem(fi);
143 modified = TRUE; 137 modified = TRUE;
144 } 138 }
145} 139}
146 140
147void AddAtt::removeAttatchment() 141void AddAtt::removeAttatchment()
148{ 142{
149 if (attView->selectedItem() != NULL) 143 if (attView->selectedItem() != NULL)
150 { 144 {
151 attView->takeItem(attView->selectedItem()); 145 attView->takeItem(attView->selectedItem());
152 } 146 }
153 modified = TRUE; 147 modified = TRUE;
154} 148}
155 149
156void AddAtt::reject() 150void AddAtt::reject()
157{ 151{
158 if (modified) { 152 if (modified) {
159 attView->clear(); 153 attView->clear();
160 modified = FALSE; 154 modified = FALSE;
161 } 155 }
162} 156}
163 157
164void AddAtt::accept() 158void AddAtt::accept()
165{ 159{
166 modified = FALSE; 160 modified = FALSE;
167 hide(); 161 hide();
168} 162}
169 163
170void AddAtt::getFiles() 164void AddAtt::getFiles()
171{ 165{
172 QString path, selected; 166 QString path, selected;
173 167
174 /*listView->clear(); 168 /*listView->clear();
175 169
176 selected = fileCategoryButton->text(); 170 selected = fileCategoryButton->text();
177 if (selected == "Picture") { 171 if (selected == "Picture") {
178 path = "../pics/"; 172 path = "../pics/";
179 } else if (selected == "Document") { 173 } else if (selected == "Document") {
180 path = "" ; //sub-dirs not decided 174 path = "" ; //sub-dirs not decided
181 } else if (selected == "Sound") { 175 } else if (selected == "Sound") {
182 path = "../sounds/"; //sub-dirs not decided 176 path = "../sounds/"; //sub-dirs not decided
183 } else if (selected == "Movie") { 177 } else if (selected == "Movie") {
184 path = ""; //sub-dirs not decided 178 path = ""; //sub-dirs not decided
185 } else if (selected == "File") { 179 } else if (selected == "File") {
186 path = ""; //sub-dirs not decided 180 path = ""; //sub-dirs not decided
187 } 181 }
188 182
189 dir = new QDir(path); 183 dir = new QDir(path);
190 dir->setFilter(QDir::Files); 184 dir->setFilter(QDir::Files);
191 const QFileInfoList *dirInfoList = dir->entryInfoList(); 185 const QFileInfoList *dirInfoList = dir->entryInfoList();
192 186
193 QFileInfoListIterator it(*dirInfoList); // create list iterator 187 QFileInfoListIterator it(*dirInfoList); // create list iterator
194 188
195 while ( (fi=it.current()) ) { // for each file... 189 while ( (fi=it.current()) ) { // for each file...
196 item = new FileItem(lis+ütView, *fi, selected); 190 item = new FileItem(lis+ütView, *fi, selected);
197 ++it; // goto next list element 191 ++it; // goto next list element
198 }*/ 192 }*/
199} 193}
200 194
201QStringList AddAtt::returnAttatchedFiles() 195QStringList AddAtt::returnAttatchedFiles()
202{ 196{
203 QFileInfo info; 197 QFileInfo info;
204 QStringList list; 198 QStringList list;
205 199
206 item = (FileItem *) attView->firstChild(); 200 item = (FileItem *) attView->firstChild();
207 201
208 202
209 while (item != NULL) { 203 while (item != NULL) {
210 DocLnk* dl=item->getDocLnk(); 204 DocLnk* dl=item->getDocLnk();
211 list+=dl->file(); 205 list+=dl->file();
212 /*info = item->getFileInfo(); 206 /*info = item->getFileInfo();
213 list += info.filePath();*/ 207 list += info.filePath();*/
214 item = (FileItem *) item->nextSibling(); 208 item = (FileItem *) item->nextSibling();
215 } 209 }
216 return list; 210 return list;
217} 211}
218 212
219QStringList AddAtt::returnFileTypes() 213QStringList AddAtt::returnFileTypes()
220{ 214{
221 QStringList list; 215 QStringList list;
222 216
223 item = (FileItem *) attView->firstChild(); 217 item = (FileItem *) attView->firstChild();
224 218
225 while (item != NULL) { 219 while (item != NULL) {
226 list += item->getDocLnk()->type(); 220 list += item->getDocLnk()->type();
227 item = (FileItem *) item->nextSibling(); 221 item = (FileItem *) item->nextSibling();
228 } 222 }
229 return list; 223 return list;
230} 224}
diff --git a/noncore/net/mailit/addatt.h b/noncore/net/mailit/addatt.h
index 73062e2..fcf3279 100644
--- a/noncore/net/mailit/addatt.h
+++ b/noncore/net/mailit/addatt.h
@@ -1,76 +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 ADDATT_H 20#ifndef ADDATT_H
21#define ADDATT_H 21#define ADDATT_H
22 22
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qlistview.h> 24#include <qlistview.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qpopupmenu.h> 26#include <qpopupmenu.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qfileinfo.h> 28#include <qfileinfo.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <opie/ofileselector.h> 30#include <opie/ofiledialog.h>
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32 32
33class FileItem : public QListViewItem 33class FileItem : public QListViewItem
34{ 34{
35public: 35public:
36 //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); 36 //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType);
37 FileItem(QListView*, DocLnk*); 37 FileItem(QListView*, DocLnk*);
38 ~FileItem(); 38 ~FileItem();
39 DocLnk* getDocLnk() {return doclnk;} 39 DocLnk* getDocLnk() {return doclnk;}
40 40
41 41
42private: 42private:
43 DocLnk* doclnk; 43 DocLnk* doclnk;
44}; 44};
45 45
46class AddAtt : public QDialog 46class AddAtt : public QDialog
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 51 AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
52 QStringList returnAttatchedFiles(); 52 QStringList returnAttatchedFiles();
53 QStringList returnFileTypes(); 53 QStringList returnFileTypes();
54 void getFiles(); 54 void getFiles();
55 void clear(); 55 void clear();
56 56
57 57
58public slots: 58public slots:
59 //void fileCategorySelected(int); 59 //void fileCategorySelected(int);
60 void addAttatchment(); 60 void addAttatchment();
61 void removeAttatchment(); 61 void removeAttatchment();
62 void reject(); 62 void reject();
63 void accept(); 63 void accept();
64 64
65private: 65private:
66 FileItem* item; 66 FileItem* item;
67 QListView *attView; 67 QListView *attView;
68 QPushButton *fileCategoryButton, *attatchButton, *removeButton; 68 QPushButton *attatchButton, *removeButton;
69 QPopupMenu *fileCategories; 69 QPopupMenu *fileCategories;
70 bool modified; 70 bool modified;
71 QFileInfo *fi; 71 //QFileInfo *fi;
72 72
73 OFileSelector* ofs; 73 OFileDialog* ofs;
74}; 74};
75 75
76#endif 76#endif
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
index 1cf2562..43e3830 100644
--- a/noncore/net/mailit/addresslist.cpp
+++ b/noncore/net/mailit/addresslist.cpp
@@ -1,167 +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#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h>
22 24
23#include "addresslist.h" 25#include "addresslist.h"
24 26
25AddressList::AddressList(QString file) 27AddressList::AddressList(QString file)
26{ 28{
27 addresses.setAutoDelete(TRUE); 29 addresses.setAutoDelete(TRUE);
28 filename = file; 30 filename = file;
29 read(); 31 read();
30 dirty = FALSE; 32 dirty = FALSE;
31} 33}
32 34
33AddressList::~AddressList() 35AddressList::~AddressList()
34{ 36{
35 write(); 37 write();
36 addresses.clear(); 38 addresses.clear();
37} 39}
38 40
39void AddressList::addContact(QString email, QString name) 41void AddressList::addContact(QString email, QString name)
40{ 42{
41 //skip if not a valid email address, 43 //skip if not a valid email address,
42 if (email.find( '@') == -1) 44 if (email.find( '@') == -1)
43 return; 45 return;
44 46
45 if ( ! containsEmail(email) ) { 47 if ( ! containsEmail(email) ) {
46 Contact *in = new Contact; 48 Contact *in = new Contact;
47 in->email = email; 49 in->email = email;
48 in->name = name; 50 in->name = name;
49 addresses.append(in); 51 addresses.append(in);
50 dirty = TRUE; 52 dirty = TRUE;
51 } 53 }
52} 54}
53 55
54bool AddressList::containsEmail(QString email) 56bool AddressList::containsEmail(QString email)
55{ 57{
56 return ( getEmailRef(email) != -1 ); 58 return ( getEmailRef(email) != -1 );
57} 59}
58 60
59bool AddressList::containsName(QString name) 61bool AddressList::containsName(QString name)
60{ 62{
61 return ( getNameRef(name) != -1 ); 63 return ( getNameRef(name) != -1 );
62} 64}
63 65
64QString AddressList::getNameByEmail(QString email) 66QString AddressList::getNameByEmail(QString email)
65{ 67{
66 int pos = getEmailRef(email); 68 int pos = getEmailRef(email);
67 if (pos != -1) { 69 if (pos != -1) {
68 Contact *ptr = addresses.at(pos); 70 Contact *ptr = addresses.at(pos);
69 return ptr->name; 71 return ptr->name;
70 } 72 }
71 73
72 return NULL; 74 return NULL;
73} 75}
74 76
75QString AddressList::getEmailByName(QString name) 77QString AddressList::getEmailByName(QString name)
76{ 78{
77 int pos = getNameRef(name); 79 int pos = getNameRef(name);
78 if (pos != -1) { 80 if (pos != -1) {
79 Contact *ptr = addresses.at(pos); 81 Contact *ptr = addresses.at(pos);
80 return ptr->email; 82 return ptr->email;
81 } 83 }
82 84
83 return NULL; 85 return NULL;
84} 86}
85 87
86int AddressList::getEmailRef(QString email) 88int AddressList::getEmailRef(QString email)
87{ 89{
88 int pos = 0; 90 int pos = 0;
89 Contact *ptr; 91 Contact *ptr;
90 92
91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 93 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
92 if (ptr->email == email) 94 if (ptr->email == email)
93 return pos; 95 return pos;
94 pos++; 96 pos++;
95 } 97 }
96 return -1; 98 return -1;
97} 99}
98 100
99int AddressList::getNameRef(QString name) 101int AddressList::getNameRef(QString name)
100{ 102{
101 int pos = 0; 103 int pos = 0;
102 Contact *ptr; 104 Contact *ptr;
103 105
104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 106 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
105 if (ptr->name == name) 107 if (ptr->name == name)
106 return pos; 108 return pos;
107 pos++; 109 pos++;
108 } 110 }
109 return -1; 111 return -1;
110} 112}
111 113
112QList<Contact>* AddressList::getContactList() 114QList<Contact>* AddressList::getContactList()
113{ 115{
114 return &addresses; 116 return &addresses;
115} 117}
116 118
117void AddressList::read() 119void AddressList::read()
118{ 120{
119 QFile f(filename); 121 OContactAccess::List::Iterator it;
122
123 //QFile f(filename);
120 QString lineEmail, lineName, email, name; 124 QString lineEmail, lineName, email, name;
125 OContactAccess m_contactdb("mailit");
126 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
127 //OContact* oc;
121 128
122 if (! f.open(IO_ReadOnly) ) 129 for ( it = m_list.begin(); it != m_list.end(); ++it )
130 {
131 //oc=(OContact*) it;
132 if ((*it).defaultEmail().length()!=0)
133 addContact((*it).defaultEmail(),(*it).fullName());
134 }
135
136 /*if (! f.open(IO_ReadOnly) )
123 return; 137 return;
124 138
125 QTextStream stream(&f); 139 QTextStream stream(&f);
126 140
127 while (! stream.atEnd() ) { 141 while (! stream.atEnd() ) {
128 lineEmail = stream.readLine(); 142 lineEmail = stream.readLine();
129 if (! stream.atEnd() ) 143 if (! stream.atEnd() )
130 lineName = stream.readLine(); 144 lineName = stream.readLine();
131 else return; 145 else return;
132 146
133 email = getRightString(lineEmail); 147 email = getRightString(lineEmail);
134 name = getRightString(lineName); 148 name = getRightString(lineName);
135 addContact(email, name); 149 addContact(email, name);
136 } 150 }
137 f.close(); 151 f.close();*/
138} 152}
139 153
140QString AddressList::getRightString(QString in) 154QString AddressList::getRightString(QString in)
141{ 155{
142 QString out = ""; 156 QString out = "";
143 157
144 int pos = in.find('='); 158 int pos = in.find('=');
145 if (pos != -1) { 159 if (pos != -1) {
146 out = in.mid(pos+1).stripWhiteSpace(); 160 out = in.mid(pos+1).stripWhiteSpace();
147 } 161 }
148 return out; 162 return out;
149} 163}
150 164
151void AddressList::write() 165void AddressList::write()
152{ 166{
153 if ( (addresses.count() == 0) || (!dirty) ) 167 if ( (addresses.count() == 0) || (!dirty) )
154 return; 168 return;
155 169
156 QFile f(filename); 170 QFile f(filename);
157 if (! f.open(IO_WriteOnly) ) 171 if (! f.open(IO_WriteOnly) )
158 return; 172 return;
159 173
160 QTextStream stream(&f); 174 QTextStream stream(&f);
161 Contact *ptr; 175 Contact *ptr;
162 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 176 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
163 stream << "email = " + ptr->email + "\n"; 177 stream << "email = " + ptr->email + "\n";
164 stream << "name = " + ptr->name + "\n"; 178 stream << "name = " + ptr->name + "\n";
165 } 179 }
166 f.close(); 180 f.close();
167} 181}
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index 9258aac..2943986 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -1,663 +1,663 @@
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 <qfile.h> 22#include <qfile.h>
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qmenubar.h> 24#include <qmenubar.h>
25#include <qaction.h> 25#include <qaction.h>
26#include "resource.h" 26#include "resource.h"
27#include "emailclient.h" 27#include "emailclient.h"
28 28
29QCollection::Item AccountList::newItem(QCollection::Item d) 29QCollection::Item AccountList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (MailAccount *) d); 31 return dupl( (MailAccount *) d);
32} 32}
33 33
34MailAccount* AccountList::dupl(MailAccount *in) 34MailAccount* AccountList::dupl(MailAccount *in)
35{ 35{
36 ac = new MailAccount(*in); 36 ac = new MailAccount(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) 40EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
41 : QMainWindow( parent, name, fl ) 41 : QMainWindow( parent, name, fl )
42{ 42{
43 emailHandler = new EmailHandler(); 43 emailHandler = new EmailHandler();
44 addressList = new AddressList( getPath(FALSE) + "mail_adr"); 44 addressList = new AddressList( getPath(FALSE) + "mail_adr");
45 45
46 sending = FALSE; 46 sending = FALSE;
47 receiving = FALSE; 47 receiving = FALSE;
48 previewingMail = FALSE; 48 previewingMail = FALSE;
49 mailIdCount = 1; 49 mailIdCount = 1;
50 accountIdCount = 1; 50 accountIdCount = 1;
51 allAccounts = FALSE; 51 allAccounts = FALSE;
52 52
53 init(); 53 init();
54 54
55 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 55 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
56 56
57 connect(emailHandler, SIGNAL(smtpError(int)), this, 57 connect(emailHandler, SIGNAL(smtpError(int)), this,
58 SLOT(smtpError(int)) ); 58 SLOT(smtpError(int)) );
59 connect(emailHandler, SIGNAL(popError(int)), this, 59 connect(emailHandler, SIGNAL(popError(int)), this,
60 SLOT(popError(int)) ); 60 SLOT(popError(int)) );
61 61
62 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); 62 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
63 connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); 63 connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
64 64
65 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 65 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
66 SLOT(mailArrived(const Email &, bool)) ); 66 SLOT(mailArrived(const Email &, bool)) );
67 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 67 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
68 SLOT(allMailArrived(int)) ); 68 SLOT(allMailArrived(int)) );
69 69
70 mailconf = new Config("mailit"); 70 mailconf = new Config("mailit");
71 //In case Synchronize is not defined in settings.txt 71 //In case Synchronize is not defined in settings.txt
72 72
73 readSettings(); 73 readSettings();
74 74
75 updateAccounts(); 75 updateAccounts();
76 76
77 lineShift = "\n"; 77 lineShift = "\n";
78 readMail(); 78 readMail();
79 lineShift = "\r\n"; 79 lineShift = "\r\n";
80 80
81} 81}
82 82
83 83
84EmailClient::~EmailClient() 84EmailClient::~EmailClient()
85{ 85{
86 //needs to be moved from destructor to closewindow event 86 //needs to be moved from destructor to closewindow event
87 saveMail(getPath(FALSE) + "inbox.txt", inboxView); 87 saveMail(getPath(FALSE) + "inbox.txt", inboxView);
88 //does not currently work. Defining outbox in the same 88 //does not currently work. Defining outbox in the same
89 //format as inbox is not a good solution as they have 89 //format as inbox is not a good solution as they have
90 //different properties 90 //different properties
91 saveMail(getPath(FALSE) + "outbox.txt", outboxView); 91 saveMail(getPath(FALSE) + "outbox.txt", outboxView);
92 saveSettings(); 92 saveSettings();
93 93
94 mailconf->write(); 94 mailconf->write();
95 delete mailconf; 95 delete mailconf;
96 96
97} 97}
98 98
99void EmailClient::init() 99void EmailClient::init()
100{ 100{
101 statusBar = new QStatusBar(this); 101 statusBar = new QStatusBar(this);
102 statusBar->setSizeGripEnabled(FALSE); 102 statusBar->setSizeGripEnabled(FALSE);
103 103
104 status1Label = new QLabel( tr("Idle"), statusBar); 104 status1Label = new QLabel( tr("Idle"), statusBar);
105 status2Label = new QLabel("", statusBar); 105 status2Label = new QLabel("", statusBar);
106 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), 106 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
107 status2Label, SLOT(setText(const QString &)) ); 107 status2Label, SLOT(setText(const QString &)) );
108 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), 108 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
109 status2Label, SLOT(setText(const QString &)) ); 109 status2Label, SLOT(setText(const QString &)) );
110 110
111 progressBar = new QProgressBar(statusBar); 111 progressBar = new QProgressBar(statusBar);
112 connect(emailHandler, SIGNAL(mailboxSize(int)), 112 connect(emailHandler, SIGNAL(mailboxSize(int)),
113 this, SLOT(setTotalSize(int)) ); 113 this, SLOT(setTotalSize(int)) );
114 connect(emailHandler, SIGNAL(currentMailSize(int)), 114 connect(emailHandler, SIGNAL(currentMailSize(int)),
115 this, SLOT(setMailSize(int)) ); 115 this, SLOT(setMailSize(int)) );
116 connect(emailHandler, SIGNAL(downloadedSize(int)), 116 connect(emailHandler, SIGNAL(downloadedSize(int)),
117 this, SLOT(setDownloadedSize(int)) ); 117 this, SLOT(setDownloadedSize(int)) );
118 118
119 statusBar->addWidget(status1Label); 119 statusBar->addWidget(status1Label);
120 statusBar->addWidget(progressBar); 120 statusBar->addWidget(progressBar);
121 statusBar->addWidget(status2Label); 121 statusBar->addWidget(status2Label);
122 122
123 setToolBarsMovable(FALSE); 123 setToolBarsMovable(FALSE);
124 124
125 bar = new QToolBar(this); 125 bar = new QToolBar(this);
126 bar->setHorizontalStretchable( TRUE ); 126 bar->setHorizontalStretchable( TRUE );
127 127
128 mb = new QMenuBar( bar ); 128 mb = new QMenuBar( bar );
129 129
130 QPopupMenu *mail = new QPopupMenu(mb); 130 QPopupMenu *mail = new QPopupMenu(mb);
131 mb->insertItem( tr( "&Mail" ), mail); 131 mb->insertItem( tr( "&Mail" ), mail);
132 132
133 QPopupMenu *configure = new QPopupMenu(mb); 133 QPopupMenu *configure = new QPopupMenu(mb);
134 mb->insertItem( tr( "Accounts" ), configure); 134 mb->insertItem( tr( "Accounts" ), configure);
135 135
136 selectAccountMenu = new QPopupMenu(mb); 136 selectAccountMenu = new QPopupMenu(mb);
137 editAccountMenu = new QPopupMenu(mb); 137 editAccountMenu = new QPopupMenu(mb);
138 deleteAccountMenu = new QPopupMenu(mb); 138 deleteAccountMenu = new QPopupMenu(mb);
139 139
140 mail->insertItem(tr("Get Mail in"), selectAccountMenu); 140 mail->insertItem(tr("Get Mail in"), selectAccountMenu);
141 configure->insertItem(tr("Edit account"), editAccountMenu); 141 configure->insertItem(tr("Edit account"), editAccountMenu);
142 configure->insertItem(tr("Delete account"), deleteAccountMenu); 142 configure->insertItem(tr("Delete account"), deleteAccountMenu);
143 143
144 bar = new QToolBar(this); 144 bar = new QToolBar(this);
145 145
146 getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); 146 getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0);
147 connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); 147 connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) );
148 getMailButton->addTo(bar); 148 getMailButton->addTo(bar);
149 getMailButton->addTo(mail); 149 getMailButton->addTo(mail);
150 150
151 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); 151 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
152 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); 152 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) );
153 sendMailButton->addTo(bar); 153 sendMailButton->addTo(bar);
154 sendMailButton->addTo(mail); 154 sendMailButton->addTo(mail);
155 155
156 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 156 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
157 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); 157 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
158 composeButton->addTo(bar); 158 composeButton->addTo(bar);
159 composeButton->addTo(mail); 159 composeButton->addTo(mail);
160 160
161 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); 161 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
162 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); 162 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
163 cancelButton->addTo(mail); 163 cancelButton->addTo(mail);
164 cancelButton->addTo(bar); 164 cancelButton->addTo(bar);
165 cancelButton->setEnabled(FALSE); 165 cancelButton->setEnabled(FALSE);
166 166
167 mailboxView = new OTabWidget( this, "mailboxView" ); 167 mailboxView = new OTabWidget( this, "mailboxView" );
168 168
169 QWidget* widget = new QWidget( mailboxView, "widget" ); 169 QWidget* widget = new QWidget( mailboxView, "widget" );
170 grid_2 = new QGridLayout( widget ); 170 grid_2 = new QGridLayout( widget );
171// grid_2->setSpacing(6); 171// grid_2->setSpacing(6);
172// grid_2->setMargin( 11 ); 172// grid_2->setMargin( 11 );
173 173
174 inboxView = new QListView( widget, "inboxView" ); 174 inboxView = new QListView( widget, "inboxView" );
175 inboxView->addColumn( tr( "From" ) ); 175 inboxView->addColumn( tr( "From" ) );
176 inboxView->addColumn( tr( "Subject" ) ); 176 inboxView->addColumn( tr( "Subject" ) );
177 inboxView->addColumn( tr( "Date" ) ); 177 inboxView->addColumn( tr( "Date" ) );
178 inboxView->setMinimumSize( QSize( 0, 0 ) ); 178 inboxView->setMinimumSize( QSize( 0, 0 ) );
179 inboxView->setAllColumnsShowFocus(TRUE); 179 inboxView->setAllColumnsShowFocus(TRUE);
180 180
181 grid_2->addWidget( inboxView, 2, 0 ); 181 grid_2->addWidget( inboxView, 2, 0 );
182 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); 182 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
183 183
184 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); 184 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" );
185 grid_3 = new QGridLayout( widget_2 ); 185 grid_3 = new QGridLayout( widget_2 );
186// grid_3->setSpacing(6); 186// grid_3->setSpacing(6);
187// grid_3->setMargin( 11 ); 187// grid_3->setMargin( 11 );
188 188
189 outboxView = new QListView( widget_2, "outboxView" ); 189 outboxView = new QListView( widget_2, "outboxView" );
190 outboxView->addColumn( tr( "To" ) ); 190 outboxView->addColumn( tr( "To" ) );
191 outboxView->addColumn( tr( "Subject" ) ); 191 outboxView->addColumn( tr( "Subject" ) );
192 outboxView->setAllColumnsShowFocus(TRUE); 192 outboxView->setAllColumnsShowFocus(TRUE);
193 193
194 grid_3->addWidget( outboxView, 0, 0 ); 194 grid_3->addWidget( outboxView, 0, 0 );
195 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); 195 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
196 196
197 setCentralWidget(mailboxView); 197 setCentralWidget(mailboxView);
198} 198}
199 199
200void EmailClient::compose() 200void EmailClient::compose()
201{ 201{
202 emit composeRequested(); 202 emit composeRequested();
203} 203}
204 204
205void EmailClient::cancel() 205void EmailClient::cancel()
206{ 206{
207 emailHandler->cancel(); 207 emailHandler->cancel();
208} 208}
209 209
210AddressList* EmailClient::getAdrListRef() 210AddressList* EmailClient::getAdrListRef()
211{ 211{
212 return addressList; 212 return addressList;
213} 213}
214 214
215//this needs to be rewritten to syncronize with outboxView 215//this needs to be rewritten to syncronize with outboxView
216void EmailClient::enqueMail(const Email &mail) 216void EmailClient::enqueMail(const Email &mail)
217{ 217{
218 if (accountList.count() == 0) { 218 if (accountList.count() == 0) {
219 QMessageBox::warning(qApp->activeWindow(), 219 QMessageBox::warning(qApp->activeWindow(),
220 tr("No account selected"), tr("You must create an account"), "OK\n"); 220 tr("No account selected"), tr("You must create an account"), "OK\n");
221 return; 221 return;
222 } 222 }
223 223
224 if (accountList.count() > 0) { 224 if (accountList.count() > 0) {
225 currentAccount = accountList.first(); 225 currentAccount = accountList.first();
226 qWarning("using account " + currentAccount->name); 226 qWarning("using account " + currentAccount->name);
227 } 227 }
228 228
229 Email addMail = mail; 229 Email addMail = mail;
230 addMail.from = currentAccount->name; 230 addMail.from = currentAccount->name;
231 addMail.fromMail = currentAccount->emailAddress; 231 addMail.fromMail = currentAccount->emailAddress;
232 addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); 232 addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n");
233 item = new EmailListItem(outboxView, addMail, false); 233 item = new EmailListItem(outboxView, addMail, false);
234 234
235} 235}
236 236
237void EmailClient::sendQuedMail() 237void EmailClient::sendQuedMail()
238{ 238{
239 int count = 0; 239 int count = 0;
240 240
241 if (accountList.count() == 0) { 241 if (accountList.count() == 0) {
242 QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); 242 QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n");
243 return; 243 return;
244 } 244 }
245 //traverse listview, find messages to send 245 //traverse listview, find messages to send
246 if (! sending) { 246 if (! sending) {
247 item = (EmailListItem *) outboxView->firstChild(); 247 item = (EmailListItem *) outboxView->firstChild();
248 if (item != NULL) { 248 if (item != NULL) {
249 while (item != NULL) { 249 while (item != NULL) {
250 quedMessages.append(item->getMail()); 250 quedMessages.append(item->getMail());
251 item = (EmailListItem *) item->nextSibling(); 251 item = (EmailListItem *) item->nextSibling();
252 count++; 252 count++;
253 } 253 }
254 setMailAccount(); 254 setMailAccount();
255 emailHandler->sendMail(&quedMessages); 255 emailHandler->sendMail(&quedMessages);
256 sending = TRUE; 256 sending = TRUE;
257 sendMailButton->setEnabled(FALSE); 257 sendMailButton->setEnabled(FALSE);
258 cancelButton->setEnabled(TRUE); 258 cancelButton->setEnabled(TRUE);
259 } else { 259 } else {
260 qWarning("sendQuedMail(): no messages to send"); 260 qWarning("sendQuedMail(): no messages to send");
261 } 261 }
262 } 262 }
263} 263}
264 264
265void EmailClient::setMailAccount() 265void EmailClient::setMailAccount()
266{ 266{
267 emailHandler->setAccount(*currentAccount); 267 emailHandler->setAccount(*currentAccount);
268} 268}
269 269
270void EmailClient::mailSent() 270void EmailClient::mailSent()
271{ 271{
272 sending = FALSE; 272 sending = FALSE;
273 sendMailButton->setEnabled(TRUE); 273 sendMailButton->setEnabled(TRUE);
274 274
275 quedMessages.clear(); 275 quedMessages.clear();
276 outboxView->clear(); //should be moved to an sentBox 276 outboxView->clear(); //should be moved to an sentBox
277} 277}
278 278
279void EmailClient::getNewMail() { 279void EmailClient::getNewMail() {
280 280
281 if (accountList.count() == 0) { 281 if (accountList.count() == 0) {
282 QMessageBox::warning(qApp->activeWindow(),"No account selected", 282 QMessageBox::warning(qApp->activeWindow(),"No account selected",
283 "You must create an account", "OK\n"); 283 "You must create an account", "OK\n");
284 return; 284 return;
285 } 285 }
286 286
287 setMailAccount(); 287 setMailAccount();
288 288
289 receiving = TRUE; 289 receiving = TRUE;
290 previewingMail = TRUE; 290 previewingMail = TRUE;
291 getMailButton->setEnabled(FALSE); 291 getMailButton->setEnabled(FALSE);
292 cancelButton->setEnabled(TRUE); 292 cancelButton->setEnabled(TRUE);
293 selectAccountMenu->setEnabled(FALSE); 293 selectAccountMenu->setEnabled(FALSE);
294 294
295 status1Label->setText(currentAccount->accountName + " headers"); 295 status1Label->setText(currentAccount->accountName + " headers");
296 progressBar->reset(); 296 progressBar->reset();
297 297
298 //get any previous mails not downloaded and add to queue 298 //get any previous mails not downloaded and add to queue
299 mailDownloadList.clear(); 299 mailDownloadList.clear();
300 Email *mailPtr; 300 Email *mailPtr;
301 item = (EmailListItem *) inboxView->firstChild(); 301 item = (EmailListItem *) inboxView->firstChild();
302 while (item != NULL) { 302 while (item != NULL) {
303 mailPtr = item->getMail(); 303 mailPtr = item->getMail();
304 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { 304 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) {
305 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); 305 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
306 } 306 }
307 item = (EmailListItem *) item->nextSibling(); 307 item = (EmailListItem *) item->nextSibling();
308 } 308 }
309 309
310 emailHandler->getMailHeaders(); 310 emailHandler->getMailHeaders();
311} 311}
312 312
313void EmailClient::getAllNewMail() 313void EmailClient::getAllNewMail()
314{ 314{
315 allAccounts = TRUE; 315 allAccounts = TRUE;
316 currentAccount = accountList.first(); 316 currentAccount = accountList.first();
317 getNewMail(); 317 getNewMail();
318} 318}
319 319
320void EmailClient::mailArrived(const Email &mail, bool fromDisk) 320void EmailClient::mailArrived(const Email &mail, bool fromDisk)
321{ 321{
322 Enclosure *ePtr; 322 Enclosure *ePtr;
323 Email newMail; 323 Email newMail;
324 int thisMailId; 324 int thisMailId;
325 emailHandler->parse(mail.rawMail, lineShift, &newMail); 325 emailHandler->parse(mail.rawMail, lineShift, &newMail);
326 326
327 mailconf->setGroup(newMail.id); 327 mailconf->setGroup(newMail.id);
328 328
329 if (fromDisk) { 329 if (fromDisk) {
330 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 330 newMail.downloaded = mailconf->readBoolEntry("downloaded");
331 newMail.size = mailconf->readNumEntry("size"); 331 newMail.size = mailconf->readNumEntry("size");
332 newMail.serverId = mailconf->readNumEntry("serverid"); 332 newMail.serverId = mailconf->readNumEntry("serverid");
333 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 333 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
334 } else { //mail arrived from server 334 } else { //mail arrived from server
335 newMail.serverId = mail.serverId; 335 newMail.serverId = mail.serverId;
336 newMail.size = mail.size; 336 newMail.size = mail.size;
337 newMail.downloaded = mail.downloaded; 337 newMail.downloaded = mail.downloaded;
338 338
339 newMail.fromAccountId = currentAccount->id; 339 newMail.fromAccountId = currentAccount->id;
340 mailconf->writeEntry("fromaccountid", newMail.fromAccountId); 340 mailconf->writeEntry("fromaccountid", newMail.fromAccountId);
341 } 341 }
342 342
343 //add if read or not 343 //add if read or not
344 newMail.read = mailconf->readBoolEntry("mailread"); 344 newMail.read = mailconf->readBoolEntry("mailread");
345 345
346 //check if new mail 346 //check if new mail
347 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { 347 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) {
348 thisMailId = mailIdCount; 348 thisMailId = mailIdCount;
349 mailIdCount++; 349 mailIdCount++;
350 350
351 //set server count, so that if the user aborts, the new 351 //set server count, so that if the user aborts, the new
352 //header is not reloaded 352 //header is not reloaded
353 if (currentAccount->synchronize) 353 if (currentAccount->synchronize)
354 currentAccount->lastServerMailCount++; 354 currentAccount->lastServerMailCount++;
355 355
356 mailconf->writeEntry("internalmailid", thisMailId); 356 mailconf->writeEntry("internalmailid", thisMailId);
357 mailconf->writeEntry("downloaded", newMail.downloaded); 357 mailconf->writeEntry("downloaded", newMail.downloaded);
358 mailconf->writeEntry("size", (int) newMail.size); 358 mailconf->writeEntry("size", (int) newMail.size);
359 mailconf->writeEntry("serverid", newMail.serverId); 359 mailconf->writeEntry("serverid", newMail.serverId);
360 360
361 addressList->addContact(newMail.fromMail, newMail.from); 361 addressList->addContact(newMail.fromMail, newMail.from);
362 } else if (!fromDisk) { //body to header arrived 362 } else if (!fromDisk) { //body to header arrived
363 mailconf->writeEntry("downloaded", TRUE); 363 mailconf->writeEntry("downloaded", TRUE);
364 } 364 }
365 QString stringMailId; 365 QString stringMailId;
366 stringMailId.setNum(thisMailId); 366 stringMailId.setNum(thisMailId);
367 //se if any attatchments needs to be stored 367 //se if any attatchments needs to be stored
368 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { 368 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
369 QString stringId; 369 QString stringId;
370 stringId.setNum(ePtr->id); 370 stringId.setNum(ePtr->id);
371 371
372 int id = mailconf->readNumEntry("enclosureid_" + stringId); 372 int id = mailconf->readNumEntry("enclosureid_" + stringId);
373 if (id != ePtr->id) { //new entry 373 if (id != ePtr->id) { //new entry
374 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); 374 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id);
375 mailconf->writeEntry("name_" + stringId, ePtr->originalName); 375 mailconf->writeEntry("name_" + stringId, ePtr->originalName);
376 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); 376 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType);
377 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); 377 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute);
378 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 378 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
379 mailconf->writeEntry("installed_" + stringId, FALSE); 379 mailconf->writeEntry("installed_" + stringId, FALSE);
380 380
381 ePtr->name = stringMailId + "_" + stringId; 381 ePtr->name = stringMailId + "_" + stringId;
382 ePtr->path = getPath(TRUE); 382 ePtr->path = getPath(TRUE);
383 if (emailHandler->getEnclosure(ePtr)) { //file saved 383 if (emailHandler->getEnclosure(ePtr)) { //file saved
384 ePtr->saved = TRUE; 384 ePtr->saved = TRUE;
385 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 385 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
386 mailconf->writeEntry("filename_" + stringId, ePtr->name); 386 mailconf->writeEntry("filename_" + stringId, ePtr->name);
387 mailconf->writeEntry("path_" + stringId, ePtr->path); 387 mailconf->writeEntry("path_" + stringId, ePtr->path);
388 } else { 388 } else {
389 ePtr->saved = FALSE; 389 ePtr->saved = FALSE;
390 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 390 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
391 } 391 }
392 } else { 392 } else {
393 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); 393 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
394 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); 394 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
395 if (ePtr->saved) { 395 if (ePtr->saved) {
396 ePtr->name = mailconf->readEntry("filename_" + stringId); 396 ePtr->name = mailconf->readEntry("filename_" + stringId);
397 ePtr->path = mailconf->readEntry("path_" + stringId); 397 ePtr->path = mailconf->readEntry("path_" + stringId);
398 } 398 }
399 } 399 }
400 } 400 }
401 if (!previewingMail && !fromDisk) { 401 if (!previewingMail && !fromDisk) {
402 Email *mailPtr; 402 Email *mailPtr;
403 item = (EmailListItem *) inboxView->firstChild(); 403 item = (EmailListItem *) inboxView->firstChild();
404 while (item != NULL) { 404 while (item != NULL) {
405 mailPtr = item->getMail(); 405 mailPtr = item->getMail();
406 if (mailPtr->id == newMail.id) { 406 if (mailPtr->id == newMail.id) {
407 item->setMail(newMail); 407 item->setMail(newMail);
408 emit mailUpdated(item->getMail()); 408 emit mailUpdated(item->getMail());
409 } 409 }
410 item = (EmailListItem *) item->nextSibling(); 410 item = (EmailListItem *) item->nextSibling();
411 } 411 }
412 } else { 412 } else {
413 item = new EmailListItem(inboxView, newMail, TRUE); 413 item = new EmailListItem(inboxView, newMail, TRUE);
414 if (!newMail.downloaded) 414 if (!newMail.downloaded)
415 mailDownloadList.sizeInsert(newMail.serverId, newMail.size); 415 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
416 } 416 }
417 417
418} 418}
419 419
420void EmailClient::allMailArrived(int count) 420void EmailClient::allMailArrived(int count)
421{ 421{
422 // not previewing means all mailtransfer has been done 422 // not previewing means all mailtransfer has been done
423 if (!previewingMail) { 423 if (!previewingMail) {
424 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 424 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
425 emit newCaption("Mailit - " + currentAccount->accountName); 425 emit newCaption("Mailit - " + currentAccount->accountName);
426 getNewMail(); 426 getNewMail();
427 return; 427 return;
428 } else { 428 } else {
429 allAccounts = FALSE; 429 allAccounts = FALSE;
430 receiving = FALSE; 430 receiving = FALSE;
431 getMailButton->setEnabled(TRUE); 431 getMailButton->setEnabled(TRUE);
432 cancelButton->setEnabled(FALSE); 432 cancelButton->setEnabled(FALSE);
433 selectAccountMenu->setEnabled(TRUE); 433 selectAccountMenu->setEnabled(TRUE);
434 status1Label->setText("Idle"); 434 status1Label->setText("Idle");
435 435
436 progressBar->reset(); 436 progressBar->reset();
437 return; 437 return;
438 } 438 }
439 } 439 }
440 440
441 // all headers downloaded from server, start downloading remaining mails 441 // all headers downloaded from server, start downloading remaining mails
442 previewingMail = FALSE; 442 previewingMail = FALSE;
443 status1Label->setText(currentAccount->accountName); 443 status1Label->setText(currentAccount->accountName);
444 progressBar->reset(); 444 progressBar->reset();
445 445
446 emailHandler->getMailByList(&mailDownloadList); 446 emailHandler->getMailByList(&mailDownloadList);
447} 447}
448 448
449void EmailClient::moveMailFront(Email *mailPtr) 449void EmailClient::moveMailFront(Email *mailPtr)
450{ 450{
451 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 451 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
452 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); 452 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
453 } 453 }
454} 454}
455 455
456void EmailClient::smtpError(int code) 456void EmailClient::smtpError(int code)
457{ 457{
458 QString temp; 458 QString temp;
459 459
460 if (code == ErrUnknownResponse) 460 if (code == ErrUnknownResponse)
461 temp = "Unknown response from server"; 461 temp = "Unknown response from server";
462 462
463 if (code == QSocket::ErrHostNotFound) 463 if (code == QSocket::ErrHostNotFound)
464 temp = "host not found"; 464 temp = "host not found";
465 if (code == QSocket::ErrConnectionRefused) 465 if (code == QSocket::ErrConnectionRefused)
466 temp = "connection refused"; 466 temp = "connection refused";
467 if (code == QSocket::ErrSocketRead) 467 if (code == QSocket::ErrSocketRead)
468 temp = "socket packet error"; 468 temp = "socket packet error";
469 469
470 if (code != ErrCancel) { 470 if (code != ErrCancel) {
471 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); 471 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
472 } else { 472 } else {
473 status2Label->setText("Aborted by user"); 473 status2Label->setText("Aborted by user");
474 } 474 }
475 475
476 sending = FALSE; 476 sending = FALSE;
477 sendMailButton->setEnabled(TRUE); 477 sendMailButton->setEnabled(TRUE);
478 cancelButton->setEnabled(FALSE); 478 cancelButton->setEnabled(FALSE);
479 quedMessages.clear(); 479 quedMessages.clear();
480} 480}
481 481
482void EmailClient::popError(int code) 482void EmailClient::popError(int code)
483{ 483{
484 QString temp; 484 QString temp;
485 485
486 if (code == ErrUnknownResponse) 486 if (code == ErrUnknownResponse)
487 temp = "Unknown response from server"; 487 temp = "Unknown response from server";
488 if (code == ErrLoginFailed) 488 if (code == ErrLoginFailed)
489 temp = "Login failed\nCheck user name and password"; 489 temp = "Login failed\nCheck user name and password";
490 490
491 if (code == QSocket::ErrHostNotFound) 491 if (code == QSocket::ErrHostNotFound)
492 temp = "host not found"; 492 temp = "host not found";
493 if (code == QSocket::ErrConnectionRefused) 493 if (code == QSocket::ErrConnectionRefused)
494 temp = "connection refused"; 494 temp = "connection refused";
495 if (code == QSocket::ErrSocketRead) 495 if (code == QSocket::ErrSocketRead)
496 temp = "socket packet error"; 496 temp = "socket packet error";
497 497
498 if (code != ErrCancel) { 498 if (code != ErrCancel) {
499 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); 499 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n");
500 } else { 500 } else {
501 status2Label->setText("Aborted by user"); 501 status2Label->setText("Aborted by user");
502 } 502 }
503 503
504 receiving = FALSE; 504 receiving = FALSE;
505 getMailButton->setEnabled(TRUE); 505 getMailButton->setEnabled(TRUE);
506 cancelButton->setEnabled(FALSE); 506 cancelButton->setEnabled(FALSE);
507 selectAccountMenu->setEnabled(TRUE); 507 selectAccountMenu->setEnabled(TRUE);
508} 508}
509 509
510void EmailClient::inboxItemSelected() 510void EmailClient::inboxItemSelected()
511{ 511{
512 item = (EmailListItem*) inboxView->selectedItem(); 512 item = (EmailListItem*) inboxView->selectedItem();
513 if (item != NULL) { 513 if (item != NULL) {
514 emit viewEmail(inboxView, item->getMail()); 514 emit viewEmail(inboxView, item->getMail());
515 } 515 }
516} 516}
517 517
518void EmailClient::outboxItemSelected() 518void EmailClient::outboxItemSelected()
519{ 519{
520 item = (EmailListItem*) outboxView->selectedItem(); 520 item = (EmailListItem*) outboxView->selectedItem();
521 if (item != NULL) { 521 if (item != NULL) {
522 emit viewEmail(outboxView, item->getMail()); 522 emit viewEmail(outboxView, item->getMail());
523 } 523 }
524 524
525} 525}
526 526
527void EmailClient::readMail() 527void EmailClient::readMail()
528{ 528{
529 Email mail; 529 Email mail;
530 int start, stop; 530 int start, stop;
531 QString s, del; 531 QString s, del;
532 532
533 QFile f(getPath(FALSE) + "inbox.txt"); 533 QFile f(getPath(FALSE) + "inbox.txt");
534// QFileInfo fi(f); 534// QFileInfo fi(f);
535 qDebug( f.name()); 535 qDebug( f.name());
536 536
537 if ( f.open(IO_ReadOnly) ) { // file opened successfully 537 if ( f.open(IO_ReadOnly) ) { // file opened successfully
538 QTextStream t( &f ); // use a text stream 538 QTextStream t( &f ); // use a text stream
539 s = t.read(); 539 s = t.read();
540 f.close(); 540 f.close();
541 541
542 start = 0; 542 start = 0;
543 del = "\n.\n"; 543 del = "\n.\n";
544 while ((uint) start < s.length()) { 544 while ((uint) start < s.length()) {
545 stop = s.find(del, start); 545 stop = s.find(del, start);
546 if (stop == -1) 546 if (stop == -1)
547 stop = s.length() - del.length(); 547 stop = s.length() - del.length();
548 548
549 mail.rawMail = s.mid(start, stop + del.length() - start ); 549 mail.rawMail = s.mid(start, stop + del.length() - start );
550 start = stop + del.length(); 550 start = stop + del.length();
551 mailArrived(mail, TRUE); 551 mailArrived(mail, TRUE);
552 } 552 }
553 } 553 }
554 554
555 QFile fo(getPath(FALSE) + "outbox.txt"); 555 QFile fo(getPath(FALSE) + "outbox.txt");
556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
557 QTextStream t( &fo ); // use a text stream 557 QTextStream t( &fo ); // use a text stream
558 s = t.read(); 558 s = t.read();
559 fo.close(); 559 fo.close();
560 560
561 start = 0; 561 start = 0;
562 del = "\n.\n"; 562 del = "\n.\n";
563 while ((uint) start < s.length()) { 563 while ((uint) start < s.length()) {
564 stop = s.find(del, start); 564 stop = s.find(del, start);
565 if (stop == -1) 565 if (stop == -1)
566 stop = s.length() - del.length(); 566 stop = s.length() - del.length();
567 567
568 mail.rawMail = s.mid(start, stop + del.length() - start ); 568 mail.rawMail = s.mid(start, stop + del.length() - start );
569 start = stop + del.length(); 569 start = stop + del.length();
570 emailHandler->parse(mail.rawMail, lineShift, &mail); 570 emailHandler->parse(mail.rawMail, lineShift, &mail);
571 mail.sent = false; 571 mail.sent = false;
572 mail.received = false; 572 mail.received = false;
573 enqueMail(mail); 573 enqueMail(mail);
574 574
575 } 575 }
576 } 576 }
577} 577}
578 578
579void EmailClient::saveMail(QString fileName, QListView *view) 579void EmailClient::saveMail(QString fileName, QListView *view)
580{ 580{
581 QFile f(fileName); 581 QFile f(fileName);
582 Email *mail; 582 Email *mail;
583 583
584 if (! f.open(IO_WriteOnly) ) { 584 if (! f.open(IO_WriteOnly) ) {
585 qWarning("could not open file"); 585 qWarning("could not open file");
586 return; 586 return;
587 } 587 }
588 item = (EmailListItem *) view->firstChild(); 588 item = (EmailListItem *) view->firstChild();
589 qDebug (QString("Write : ") ); 589 qDebug (QString("Write : ") );
590 QTextStream t(&f); 590 QTextStream t(&f);
591 while (item != NULL) { 591 while (item != NULL) {
592 mail = item->getMail(); 592 mail = item->getMail();
593 qDebug(mail->rawMail); 593 qDebug(mail->rawMail);
594 qDebug(mail->recipients.first()); 594 qDebug(mail->recipients.first());
595 t << mail->rawMail; 595 t << mail->rawMail;
596 596
597 mailconf->setGroup(mail->id); 597 mailconf->setGroup(mail->id);
598 mailconf->writeEntry("mailread", mail->read); 598 mailconf->writeEntry("mailread", mail->read);
599 599
600 item = (EmailListItem *) item->nextSibling(); 600 item = (EmailListItem *) item->nextSibling();
601 } 601 }
602 f.close(); 602 f.close();
603} 603}
604 604
605//paths for mailit, is settings, inbox, enclosures 605//paths for mailit, is settings, inbox, enclosures
606QString EmailClient::getPath(bool enclosurePath) 606QString EmailClient::getPath(bool enclosurePath)
607{ 607{
608 QString basePath = "qtmail"; 608 QString basePath = "qtmail";
609 QString enclosures = "enclosures"; 609 QString enclosures = "enclosures";
610 610
611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
612 if ( !dir.exists() ) 612 if ( !dir.exists() )
613 dir.mkdir( dir.path() ); 613 dir.mkdir( dir.path() );
614 614
615 if (enclosurePath) { 615 if (enclosurePath) {
616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
617 617
618 if ( !dir.exists() ) 618 if ( !dir.exists() )
619 dir.mkdir( dir.path() ); 619 dir.mkdir( dir.path() );
620 620
621 return (dir.path() + "/"); 621 return (dir.path() + "/");
622 622
623 } 623 }
624 return (dir.path() + "/"); 624 return (dir.path() + "/");
625} 625}
626 626
627void EmailClient::readSettings() 627void EmailClient::readSettings()
628{ 628{
629 TextParser *p; 629 TextParser *p;
630 QString s; 630 QString s;
631 int pos, accountPos, y; 631 int pos, accountPos, y;
632 QFile f( getPath(FALSE) + "settings.txt"); 632 QFile f( getPath(FALSE) + "settings.txt");
633 633
634 if ( f.open(IO_ReadOnly) ) { // file opened successfully 634 if ( f.open(IO_ReadOnly) ) { // file opened successfully
635 QTextStream t( &f ); // use a text stream 635 QTextStream t( &f ); // use a text stream
636 s = t.read(); 636 s = t.read();
637 f.close(); 637 f.close();
638 638
639 p = new TextParser(s, "\n"); 639 p = new TextParser(s, "\n");
640 640
641 accountPos = 0; 641 accountPos = 0;
642 while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { 642 while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) {
643 accountPos++; 643 accountPos++;
644 if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) 644 if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 )
645 account.accountName = p->getString(& ++pos, 'z', TRUE); 645 account.accountName = p->getString(& ++pos, 'z', TRUE);
646 if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) 646 if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1)
647 account.name = p->getString(& ++pos, 'z', TRUE); 647 account.name = p->getString(& ++pos, 'z', TRUE);
648 if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) 648 if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1)
649 account.emailAddress = p->getString(& ++pos, 'z', TRUE); 649 account.emailAddress = p->getString(& ++pos, 'z', TRUE);
650 if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) 650 if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1)
651 account.popUserName = p->getString(& ++pos, 'z', TRUE); 651 account.popUserName = p->getString(& ++pos, 'z', TRUE);
652 if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) 652 if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1)
653 account.popPasswd = p->getString(& ++pos, 'z', TRUE); 653 account.popPasswd = p->getString(& ++pos, 'z', TRUE);
654 if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) 654 if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1)
655 account.popServer = p->getString(& ++pos, 'z', TRUE); 655 account.popServer = p->getString(& ++pos, 'z', TRUE);
656 if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) 656 if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1)
657 account.smtpServer = p->getString(& ++pos, 'z', TRUE); 657 account.smtpServer = p->getString(& ++pos, 'z', TRUE);
658 if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { 658 if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) {
659 s = p->getString(& ++pos, 'z', TRUE); 659 s = p->getString(& ++pos, 'z', TRUE);
660 account.id = s.toInt(); 660 account.id = s.toInt();
661 } 661 }
662 662
663 account.lastServerMailCount = 0; 663 account.lastServerMailCount = 0;
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp
index f9b6de2..fd49c1f 100644
--- a/noncore/net/mailit/mailitwindow.cpp
+++ b/noncore/net/mailit/mailitwindow.cpp
@@ -1,132 +1,136 @@
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 "mailitwindow.h" 20#include "mailitwindow.h"
21 21
22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
23 : QMainWindow(parent, name, fl) 23 : QMainWindow(parent, name, fl)
24{ 24{
25 currentCaption = "Mailit"; 25 currentCaption = "Mailit";
26 setCaption(tr(currentCaption)); 26 setCaption(tr(currentCaption));
27 views = new QWidgetStack(this); 27 views = new QWidgetStack(this);
28 setCentralWidget(views); 28 setCentralWidget(views);
29 29
30 qWarning("***Starting writeMail");
30 emailClient = new EmailClient(views, "client"); 31 emailClient = new EmailClient(views, "client");
31 writeMail = new WriteMail(views, "writing"); 32 writeMail = new WriteMail(views, "writing");
32 readMail = new ReadMail(views, "reading"); 33 readMail = new ReadMail(views, "reading");
34 qWarning("***Finished readMail");
33 35
34 views->raiseWidget(emailClient); 36 views->raiseWidget(emailClient);
35 37
36 connect(emailClient, SIGNAL(composeRequested()), 38 connect(emailClient, SIGNAL(composeRequested()),
37 this, SLOT(compose()) ); 39 this, SLOT(compose()) );
38 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
39 SLOT(viewMail(QListView *, Email *)) ); 41 SLOT(viewMail(QListView *, Email *)) );
40 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
41 SLOT(updateMailView(Email *)) ); 43 SLOT(updateMailView(Email *)) );
42 44
43 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
44 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
45 SLOT(showEmailClient()) ); 47 SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
47 SLOT(enqueMail(const Email &)) ); 49 SLOT(enqueMail(const Email &)) );
48 50
49 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
50 connect(readMail, SIGNAL(replyRequested(Email &)), this, 52 connect(readMail, SIGNAL(replyRequested(Email &)), this,
51 SLOT(composeReply(Email &)) ); 53 SLOT(composeReply(Email &)) );
52 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 54 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
53 SLOT(deleteMail(EmailListItem *, bool &)) ); 55 SLOT(deleteMail(EmailListItem *, bool &)) );
54 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 56 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
55 SLOT(moveMailFront(Email *)) ); 57 SLOT(moveMailFront(Email *)) );
56 58
57 connect(emailClient, SIGNAL(newCaption(const QString &)), 59 connect(emailClient, SIGNAL(newCaption(const QString &)),
58 this, SLOT(updateCaption(const QString &)) ); 60 this, SLOT(updateCaption(const QString &)) );
59 viewingMail = FALSE; 61 viewingMail = FALSE;
62
63 qWarning("***Finished MailitWindow");
60} 64}
61 65
62MailItWindow::~MailItWindow() 66MailItWindow::~MailItWindow()
63{ 67{
64} 68}
65 69
66void MailItWindow::closeEvent(QCloseEvent *e) 70void MailItWindow::closeEvent(QCloseEvent *e)
67{ 71{
68 if (views->visibleWidget() == emailClient) { 72 if (views->visibleWidget() == emailClient) {
69 e->accept(); 73 e->accept();
70 } else { 74 } else {
71 showEmailClient(); 75 showEmailClient();
72 } 76 }
73} 77}
74 78
75void MailItWindow::compose() 79void MailItWindow::compose()
76{ 80{
77 viewingMail = FALSE; 81 viewingMail = FALSE;
78 emailClient->hide(); 82 emailClient->hide();
79 readMail->hide(); 83 readMail->hide();
80 views->raiseWidget(writeMail); 84 views->raiseWidget(writeMail);
81 writeMail->setAddressList(emailClient->getAdrListRef()); 85 writeMail->setAddressList(emailClient->getAdrListRef());
82 setCaption( tr( "Write mail" ) ); 86 setCaption( tr( "Write mail" ) );
83} 87}
84 88
85void MailItWindow::composeReply(Email &mail) 89void MailItWindow::composeReply(Email &mail)
86{ 90{
87 compose(); 91 compose();
88 writeMail->reply(mail); 92 writeMail->reply(mail);
89} 93}
90 94
91void MailItWindow::showEmailClient() 95void MailItWindow::showEmailClient()
92{ 96{
93 viewingMail = FALSE; 97 viewingMail = FALSE;
94 writeMail->hide(); 98 writeMail->hide();
95 readMail->hide(); 99 readMail->hide();
96 views->raiseWidget(emailClient); 100 views->raiseWidget(emailClient);
97 setCaption( tr(currentCaption) ); 101 setCaption( tr(currentCaption) );
98} 102}
99 103
100void MailItWindow::viewMail(QListView *view, Email *mail) 104void MailItWindow::viewMail(QListView *view, Email *mail)
101{ 105{
102 viewingMail = TRUE; 106 viewingMail = TRUE;
103 emailClient->hide(); 107 emailClient->hide();
104 readMail->update(view, mail); 108 readMail->update(view, mail);
105 views->raiseWidget(readMail); 109 views->raiseWidget(readMail);
106 setCaption( tr( "Examine mail" ) ); 110 setCaption( tr( "Examine mail" ) );
107} 111}
108 112
109void MailItWindow::updateMailView(Email *mail) 113void MailItWindow::updateMailView(Email *mail)
110{ 114{
111 if (viewingMail) { 115 if (viewingMail) {
112 readMail->mailUpdated(mail); 116 readMail->mailUpdated(mail);
113 } 117 }
114} 118}
115 119
116void MailItWindow::updateCaption(const QString &newCaption) 120void MailItWindow::updateCaption(const QString &newCaption)
117{ 121{
118 currentCaption = newCaption; 122 currentCaption = newCaption;
119 setCaption(tr(currentCaption)); 123 setCaption(tr(currentCaption));
120} 124}
121 125
122void MailItWindow::setDocument(const QString &_address) 126void MailItWindow::setDocument(const QString &_address)
123{ 127{
124 // strip leading 'mailto:' 128 // strip leading 'mailto:'
125 QString address = _address; 129 QString address = _address;
126 if (address.startsWith("mailto:")) 130 if (address.startsWith("mailto:"))
127 address = address.mid(6); 131 address = address.mid(6);
128 132
129 compose(); 133 compose();
130 writeMail->setRecipient(address); 134 writeMail->setRecipient(address);
131} 135}
132 136
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp
index 86f119f..b6f5015 100644
--- a/noncore/net/mailit/viewatt.cpp
+++ b/noncore/net/mailit/viewatt.cpp
@@ -1,109 +1,118 @@
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 <qpe/applnk.h> 22#include <qpe/applnk.h>
23#include <qpe/mimetype.h>
23 24
24ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 25ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
25 : QMainWindow(parent, name, f) 26 : QMainWindow(parent, name, f)
26{ 27{
27 setCaption("Exploring attatchments"); 28 setCaption("Exploring attatchments");
28 29
29 setToolBarsMovable( FALSE ); 30 setToolBarsMovable( FALSE );
30 bar = new QToolBar(this); 31 bar = new QToolBar(this);
31 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 32 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
32 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 33 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
33 34
34 listView = new QListView(this, "AttView"); 35 listView = new QListView(this, "AttView");
35 listView->addColumn( "Attatchment" ); 36 listView->addColumn( "Attatchment" );
36 listView->addColumn( "Type" ); 37 listView->addColumn( "Type" );
37 listView->addColumn( "Installed" ); 38 listView->addColumn( "Installed" );
38 setCentralWidget(listView); 39 setCentralWidget(listView);
39} 40}
40 41
41void ViewAtt::update(Email *mailIn, bool inbox) 42void ViewAtt::update(Email *mailIn, bool inbox)
42{ 43{
43 QListViewItem *item; 44 QListViewItem *item;
44 Enclosure *ePtr; 45 Enclosure *ePtr;
45 46
47
48
46 listView->clear(); 49 listView->clear();
47 if (inbox) { 50 if (inbox) {
48 bar->clear(); 51 bar->clear();
49 installButton->addTo( bar ); 52 installButton->addTo( bar );
50 bar->show(); 53 bar->show();
51 } else { 54 } else {
52 bar->hide(); 55 bar->hide();
53 } 56 }
54 57
55 mail = mailIn; 58 mail = mailIn;
56 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 59 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
57 60
58 QString isInstalled = "No"; 61 QString isInstalled = "No";
59 if (ePtr->installed) 62 if (ePtr->installed)
60 isInstalled = "Yes"; 63 isInstalled = "Yes";
61 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 64 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
62 65
66 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
67
68 MimeType mt(mtypeDef);
69
70 item->setPixmap(0, mt.pixmap());
71
72 /*
63 if (ePtr->contentType == "TEXT") { 73 if (ePtr->contentType == "TEXT") {
64 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 74 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
65 actions->addTo(bar); 75 actions->addTo(bar);
66 item->setPixmap(0, Resource::loadPixmap("txt")); 76 }
67 }
68 if (ePtr->contentType == "AUDIO") { 77 if (ePtr->contentType == "AUDIO") {
69 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 78 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
70 actions->addTo(bar); 79 actions->addTo(bar);
71 item->setPixmap(0, Resource::loadPixmap("play")); 80 item->setPixmap(0, Resource::loadPixmap("play"));
72 } 81 }
73 if (ePtr->contentType == "IMAGE") { 82 if (ePtr->contentType == "IMAGE") {
74 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 83 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
75 actions->addTo(bar); 84 actions->addTo(bar);
76 item->setPixmap(0, Resource::loadPixmap("pixmap")); 85 item->setPixmap(0, Resource::loadPixmap("pixmap"));
77 } 86 }*/
78 } 87 }
79} 88}
80 89
81void ViewAtt::install() 90void ViewAtt::install()
82{ 91{
83 Enclosure *ePtr, *selPtr; 92 Enclosure *ePtr, *selPtr;
84 QListViewItem *item; 93 QListViewItem *item;
85 QString filename; 94 QString filename;
86 DocLnk d; 95 DocLnk d;
87 96
88 item = listView->selectedItem(); 97 item = listView->selectedItem();
89 if (item != NULL) { 98 if (item != NULL) {
90 filename = item->text(0); 99 filename = item->text(0);
91 selPtr = NULL; 100 selPtr = NULL;
92 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 101 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
93 if (ePtr->originalName == filename) 102 if (ePtr->originalName == filename)
94 selPtr = ePtr; 103 selPtr = ePtr;
95 } 104 }
96 105
97 if (selPtr == NULL) { 106 if (selPtr == NULL) {
98 qWarning("Internal error, file is not installed to documents"); 107 qWarning("Internal error, file is not installed to documents");
99 return; 108 return;
100 } 109 }
101 110
102 d.setName(selPtr->originalName); 111 d.setName(selPtr->originalName);
103 d.setFile(selPtr->path + selPtr->name); 112 d.setFile(selPtr->path + selPtr->name);
104 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 113 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
105 d.writeLink(); 114 d.writeLink();
106 selPtr->installed = TRUE; 115 selPtr->installed = TRUE;
107 item->setText(2, "Yes"); 116 item->setText(2, "Yes");
108 } 117 }
109} 118}
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp
index 70332a9..a45cfd2 100644
--- a/noncore/net/mailit/writemail.cpp
+++ b/noncore/net/mailit/writemail.cpp
@@ -1,297 +1,298 @@
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 "writemail.h" 21#include "writemail.h"
22#include "resource.h" 22#include "resource.h"
23 23
24WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) 24WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl )
25 : QMainWindow( parent, name, fl ) 25 : QMainWindow( parent, name, fl )
26{ 26{
27 showingAddressList = FALSE; 27 showingAddressList = FALSE;
28 init(); 28 init();
29 29
30 addAtt = new AddAtt(0, "Add Attatchments"); 30 addAtt = new AddAtt(0, "Add Attatchments");
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 Contact *cPtr; 40 Contact *cPtr;
41 41
42 addressList = list; 42 addressList = list;
43 43
44 addressView->clear(); 44 addressView->clear();
45 QList<Contact> *cListPtr = addressList->getContactList(); 45 QList<Contact> *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->email, cPtr->name); 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 attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); 67 attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0);
68 attatchButton->addTo(bar); 68 attatchButton->addTo(bar);
69 attatchButton->addTo(addMenu); 69 attatchButton->addTo(addMenu);
70 connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); 70 connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) );
71 71
72 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); 72 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0);
73 confirmButton->addTo(bar); 73 confirmButton->addTo(bar);
74 confirmButton->addTo(mailMenu); 74 confirmButton->addTo(mailMenu);
75 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); 75 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) );
76 76
77 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 77 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
78 newButton->addTo(mailMenu); 78 newButton->addTo(mailMenu);
79 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); 79 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
80 80
81 widget = new QWidget(this, "widget"); 81 widget = new QWidget(this, "widget");
82 grid = new QGridLayout( widget ); 82 grid = new QGridLayout( widget );
83 83
84 recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); 84 recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
85 recipientsBox->insertItem( tr( "To:" ) ); 85 recipientsBox->insertItem( tr( "To:" ) );
86 recipientsBox->insertItem( tr( "CC:" ) ); 86 recipientsBox->insertItem( tr( "CC:" ) );
87 recipientsBox->setCurrentItem(0); 87 recipientsBox->setCurrentItem(0);
88 grid->addWidget( recipientsBox, 0, 0 ); 88 grid->addWidget( recipientsBox, 0, 0 );
89 89
90 subjetLabel = new QLabel( widget, "subjetLabel" ); 90 subjetLabel = new QLabel( widget, "subjetLabel" );
91 subjetLabel->setText( tr( "Subject:" ) ); 91 subjetLabel->setText( tr( "Subject:" ) );
92 92
93 grid->addWidget( subjetLabel, 1, 0 ); 93 grid->addWidget( subjetLabel, 1, 0 );
94 94
95 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); 95 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
96 ToolButton13_2->setText( tr( "..." ) ); 96 ToolButton13_2->setText( tr( "..." ) );
97 grid->addWidget( ToolButton13_2, 1, 2 ); 97 grid->addWidget( ToolButton13_2, 1, 2 );
98 98
99 subjectInput = new QLineEdit( widget, "subjectInput" ); 99 subjectInput = new QLineEdit( widget, "subjectInput" );
100 grid->addWidget( subjectInput, 1, 1 ); 100 grid->addWidget( subjectInput, 1, 1 );
101 101
102 toInput = new QLineEdit( widget, "toInput" ); 102 toInput = new QLineEdit( widget, "toInput" );
103 grid->addWidget( toInput, 0, 1 ); 103 grid->addWidget( toInput, 0, 1 );
104 104
105 addressButton = new QToolButton( widget, "addressButton" ); 105 addressButton = new QToolButton( widget, "addressButton" );
106 addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); 106 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
107 addressButton->setToggleButton(TRUE); 107 addressButton->setToggleButton(TRUE);
108 grid->addWidget( addressButton, 0, 2 ); 108 grid->addWidget( addressButton, 0, 2 );
109 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); 109 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
110 110
111 emailInput = new QMultiLineEdit( widget, "emailInput" ); 111 emailInput = new QMultiLineEdit( widget, "emailInput" );
112 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); 112 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
113
113 114
114 addressView = new QListView( widget, "addressView"); 115 addressView = new QListView( widget, "addressView");
115 addressView->addColumn("Email");
116 addressView->addColumn("Name"); 116 addressView->addColumn("Name");
117 addressView->addColumn("EMail");
117 addressView->setAllColumnsShowFocus(TRUE); 118 addressView->setAllColumnsShowFocus(TRUE);
118 addressView->setMultiSelection(TRUE); 119 addressView->setMultiSelection(TRUE);
119 addressView->hide(); 120 addressView->hide();
120 grid->addMultiCellWidget( addressView, 3, 3, 0, 2); 121 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
121 122
122 okButton = new QToolButton(bar, "ok"); 123 okButton = new QToolButton(bar, "ok");
123 okButton->setPixmap( Resource::loadPixmap("enter") ); 124 okButton->setPixmap( Resource::loadPixmap("enter") );
124 okButton->hide(); 125 okButton->hide();
125 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); 126 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
126 127
127 setCentralWidget(widget); 128 setCentralWidget(widget);
128} 129}
129 130
130void WriteMail::reject() 131void WriteMail::reject()
131{ 132{
132 emit cancelMail(); 133 emit cancelMail();
133} 134}
134 135
135// need to insert date 136// need to insert date
136void WriteMail::accept() 137void WriteMail::accept()
137{ 138{
138 QStringList attatchedFiles, attatchmentsType; 139 QStringList attatchedFiles, attatchmentsType;
139 int idCount = 0; 140 int idCount = 0;
140 141
141 if (toInput->text() == "") { 142 if (toInput->text() == "") {
142 QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); 143 QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n");
143 return; 144 return;
144 } 145 }
145 if (! getRecipients() ) { 146 if (! getRecipients() ) {
146 QMessageBox::warning(this,"Incorrect recipient separator", 147 QMessageBox::warning(this,"Incorrect recipient separator",
147 "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); 148 "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n");
148 return; 149 return;
149 } 150 }
150 mail.subject = subjectInput->text(); 151 mail.subject = subjectInput->text();
151 mail.body = emailInput->text(); 152 mail.body = emailInput->text();
152 mail.sent = false; 153 mail.sent = false;
153 mail.received = false; 154 mail.received = false;
154 mail.rawMail = "To: "; 155 mail.rawMail = "To: ";
155 156
156 for (QStringList::Iterator it = mail.recipients.begin(); 157 for (QStringList::Iterator it = mail.recipients.begin();
157 it != mail.recipients.end(); ++it) { 158 it != mail.recipients.end(); ++it) {
158 159
159 mail.rawMail += (*it); 160 mail.rawMail += (*it);
160 mail.rawMail += ",\n"; 161 mail.rawMail += ",\n";
161 } 162 }
162 mail.rawMail.truncate(mail.rawMail.length()-2); 163 mail.rawMail.truncate(mail.rawMail.length()-2);
163 mail.rawMail += mail.from; 164 mail.rawMail += mail.from;
164 mail.rawMail += "\nSubject: "; 165 mail.rawMail += "\nSubject: ";
165 mail.rawMail += mail.subject; 166 mail.rawMail += mail.subject;
166 mail.rawMail += "\n\n"; 167 mail.rawMail += "\n\n";
167 168
168 attatchedFiles = addAtt->returnAttatchedFiles(); 169 attatchedFiles = addAtt->returnAttatchedFiles();
169 attatchmentsType = addAtt->returnFileTypes(); 170 attatchmentsType = addAtt->returnFileTypes();
170 171
171 QStringList::Iterator itType = attatchmentsType.begin(); 172 QStringList::Iterator itType = attatchmentsType.begin();
172 173
173 Enclosure e; 174 Enclosure e;
174 for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { 175 for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) {
175 e.id = idCount; 176 e.id = idCount;
176 e.originalName = (*it).latin1(); 177 e.originalName = (*it).latin1();
177 e.contentType = (*itType).latin1(); 178 e.contentType = (*itType).latin1();
178 e.contentAttribute = (*itType).latin1(); 179 e.contentAttribute = (*itType).latin1();
179 e.saved = TRUE; 180 e.saved = TRUE;
180 mail.addEnclosure(&e); 181 mail.addEnclosure(&e);
181 182
182 itType++; 183 itType++;
183 idCount++; 184 idCount++;
184 } 185 }
185 mail.rawMail += mail.body; 186 mail.rawMail += mail.body;
186 mail.rawMail += "\n"; 187 mail.rawMail += "\n";
187 mail.rawMail += ".\n"; 188 mail.rawMail += ".\n";
188 emit sendMailRequested(mail); 189 emit sendMailRequested(mail);
189 addAtt->clear(); 190 addAtt->clear();
190} 191}
191 192
192void WriteMail::getAddress() 193void WriteMail::getAddress()
193{ 194{
194 showingAddressList = !showingAddressList; 195 showingAddressList = !showingAddressList;
195 196
196 if (showingAddressList) { 197 if (showingAddressList) {
197 emailInput->hide(); 198 emailInput->hide();
198 addressView->show(); 199 addressView->show();
199 okButton->show(); 200 okButton->show();
200 201
201 } else { 202 } else {
202 addressView->hide(); 203 addressView->hide();
203 okButton->hide(); 204 okButton->hide();
204 emailInput->show(); 205 emailInput->show();
205 } 206 }
206} 207}
207 208
208void WriteMail::attatchFile() 209void WriteMail::attatchFile()
209{ 210{
210 addAtt->showMaximized(); 211 addAtt->showMaximized();
211} 212}
212 213
213void WriteMail::reply(Email replyMail) 214void WriteMail::reply(Email replyMail)
214{ 215{
215 int pos; 216 int pos;
216 217
217 mail = replyMail; 218 mail = replyMail;
218 mail.files.clear(); 219 mail.files.clear();
219 220
220 toInput->setText(mail.fromMail); 221 toInput->setText(mail.fromMail);
221 subjectInput->setText("Re: " + mail.subject); 222 subjectInput->setText("Re: " + mail.subject);
222 223
223 pos = 0; 224 pos = 0;
224 mail.body.insert(pos, ">>"); 225 mail.body.insert(pos, ">>");
225 while (pos != -1) { 226 while (pos != -1) {
226 pos = mail.body.find('\n', pos); 227 pos = mail.body.find('\n', pos);
227 if (pos != -1) 228 if (pos != -1)
228 mail.body.insert(++pos, ">>"); 229 mail.body.insert(++pos, ">>");
229 } 230 }
230 231
231 emailInput->setText(mail.body); 232 emailInput->setText(mail.body);
232} 233}
233 234
234bool WriteMail::getRecipients() 235bool WriteMail::getRecipients()
235{ 236{
236 QString str, temp; 237 QString str, temp;
237 int pos = 0; 238 int pos = 0;
238 239
239 mail.recipients.clear(); 240 mail.recipients.clear();
240 241
241 temp = toInput->text(); 242 temp = toInput->text();
242 while ( (pos = temp.find(';')) != -1) { 243 while ( (pos = temp.find(';')) != -1) {
243 str = temp.left(pos).stripWhiteSpace(); 244 str = temp.left(pos).stripWhiteSpace();
244 temp = temp.right(temp.length() - (pos + 1)); 245 temp = temp.right(temp.length() - (pos + 1));
245 if ( str.find('@') == -1) 246 if ( str.find('@') == -1)
246 return false; 247 return false;
247 mail.recipients.append(str); 248 mail.recipients.append(str);
248 addressList->addContact(str, ""); 249 addressList->addContact(str, "");
249 } 250 }
250 temp = temp.stripWhiteSpace(); 251 temp = temp.stripWhiteSpace();
251 if ( temp.find('@') == -1) 252 if ( temp.find('@') == -1)
252 return false; 253 return false;
253 mail.recipients.append(temp); 254 mail.recipients.append(temp);
254 addressList->addContact(temp, ""); 255 addressList->addContact(temp, "");
255 256
256 return TRUE; 257 return TRUE;
257} 258}
258 259
259 260
260void WriteMail::addRecipients() 261void WriteMail::addRecipients()
261{ 262{
262 QString recipients = ""; 263 QString recipients = "";
263 264
264 mail.recipients.clear(); 265 mail.recipients.clear();
265 QListViewItem *item = addressView->firstChild(); 266 QListViewItem *item = addressView->firstChild();
266 while (item != NULL) { 267 while (item != NULL) {
267 if ( item->isSelected() ) { 268 if ( item->isSelected() ) {
268 if (recipients == "") { 269 if (recipients == "") {
269 recipients = item->text(0); 270 recipients = item->text(0);
270 } else { 271 } else {
271 recipients += "; " + item->text(0); 272 recipients += "; " + item->text(0);
272 } 273 }
273 } 274 }
274 item = item->nextSibling(); 275 item = item->nextSibling();
275 } 276 }
276 toInput->setText(recipients); 277 toInput->setText(recipients);
277 278
278 addressView->hide(); 279 addressView->hide();
279 okButton->hide(); 280 okButton->hide();
280 emailInput->show(); 281 emailInput->show();
281 addressButton->setOn(FALSE); 282 addressButton->setOn(FALSE);
282 showingAddressList = !showingAddressList; 283 showingAddressList = !showingAddressList;
283} 284}
284 285
285void WriteMail::setRecipient(const QString &recipient) 286void WriteMail::setRecipient(const QString &recipient)
286{ 287{
287 toInput->setText(recipient); 288 toInput->setText(recipient);
288} 289}
289 290
290void WriteMail::newMail() 291void WriteMail::newMail()
291{ 292{
292 toInput->clear(); 293 toInput->clear();
293 subjectInput->clear(); 294 subjectInput->clear();
294 emailInput->clear(); 295 emailInput->clear();
295 //to clear selected 296 //to clear selected
296 setAddressList(addressList); 297 setAddressList(addressList);
297} 298}
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp
index f279f52..c8be865 100644
--- a/noncore/unsupported/mailit/addatt.cpp
+++ b/noncore/unsupported/mailit/addatt.cpp
@@ -1,230 +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 <qdir.h> 22#include <qdir.h>
22#include <qstringlist.h> 23#include <qstringlist.h>
23#include "resource.h" 24#include "resource.h"
24#include "addatt.h" 25#include "addatt.h"
25 26
26FileItem::FileItem(QListView *parent, DocLnk* dl) 27FileItem::FileItem(QListView *parent, DocLnk* dl)
27 : QListViewItem(parent) 28 : QListViewItem(parent)
28{ 29{
29 /*file = fileInfo; 30 /*file = fileInfo;
30 type = fileType;*/ 31 type = fileType;*/
31 32
32 doclnk=dl; 33 doclnk=dl;
33 34
34 setText(0, doclnk->name()); 35 setText(0, doclnk->name());
35 36
36 /*if (fileType == "Picture") { 37 /*if (fileType == "Picture") {
37 setPixmap(0, Resource::loadPixmap("pixmap")); 38 setPixmap(0, Resource::loadPixmap("pixmap"));
38 } else if (fileType == "Document") { 39 } else if (fileType == "Document") {
39 setPixmap(0, Resource::loadPixmap("txt")); 40 setPixmap(0, Resource::loadPixmap("txt"));
40 } else if (fileType == "Sound") { 41 } else if (fileType == "Sound") {
41 setPixmap(0, Resource::loadPixmap("play")); 42 setPixmap(0, Resource::loadPixmap("play"));
42 } else if (fileType == "Movie") { 43 } else if (fileType == "Movie") {
43 setPixmap(0, Resource::loadPixmap("MPEGPlayer")); 44 setPixmap(0, Resource::loadPixmap("MPEGPlayer"));
44 } else if (fileType == "File") { 45 } else if (fileType == "File") {
45 setPixmap(0, Resource::loadPixmap("exec")); 46 setPixmap(0, Resource::loadPixmap("exec"));
46 }*/ 47 }*/
47} 48}
48 49
49FileItem::~FileItem() 50FileItem::~FileItem()
50{ 51{
51 if (doclnk!=NULL) delete doclnk; 52 if (doclnk!=NULL) delete doclnk;
52 doclnk=NULL; 53 doclnk=NULL;
53} 54}
54 55
55AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) 56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
56 : QDialog(parent, name, f) 57 : QDialog(parent, name, f)
57{ 58{
58 setCaption("Adding attatchments"); 59 setCaption("Adding attatchments");
59 60
60 QGridLayout *top = new QGridLayout(this, 3,1 ); 61 QGridLayout *top = new QGridLayout(this, 1,1 );
61 62
62 63 QHBox *buttons=new QHBox(this);
63 /*fileCategoryButton = new QPushButton(this);*/ 64 /*fileCategoryButton = new QPushButton(this);*/
64 attatchButton = new QPushButton("Attatch ->", this); 65 attatchButton = new QPushButton("Attatch ->", buttons);
65 removeButton = new QPushButton("Remove", this); 66 removeButton = new QPushButton("Remove", buttons);
66 67
67 /*fileCategories = new QPopupMenu(fileCategoryButton); 68 /*fileCategories = new QPopupMenu(fileCategoryButton);
68 fileCategoryButton->setPopup(fileCategories); 69 fileCategoryButton->setPopup(fileCategories);
69 fileCategories->insertItem("Document"); 70 fileCategories->insertItem("Document");
70 fileCategories->insertItem("Picture"); 71 fileCategories->insertItem("Picture");
71 fileCategories->insertItem("Sound"); 72 fileCategories->insertItem("Sound");
72 fileCategories->insertItem("Movie"); 73 fileCategories->insertItem("Movie");
73 fileCategories->insertItem("File"); 74 fileCategories->insertItem("File");
74 75
75 fileCategoryButton->setText("Document"); 76 fileCategoryButton->setText("Document");
76 top->addWidget(fileCategoryButton, 0, 0);*/ 77 top->addWidget(fileCategoryButton, 0, 0);*/
77 78
78 //ofs=new OFileSelector(this,2,0,"/root/Documents");
79
80
81 top->addWidget(attatchButton,1,0);
82 top->addWidget(removeButton,2,0);
83 79
84 /*connect(fileCategories, SIGNAL(activated(int)), this, 80 top->addWidget(buttons,1,0);
85 SLOT(fileCategorySelected(int)) );*/ 81 //buttons->addWidget(attatchButton,0,0);
82 //buttons->addWidget(removeButton,0,1);
83
84 //connect(fileCategories, SIGNAL(activated(int)), this,
85 //SLOT(fileCategorySelected(int)) );*/
86 connect(attatchButton, SIGNAL(clicked()), this, 86 connect(attatchButton, SIGNAL(clicked()), this,
87 SLOT(addAttatchment()) ); 87 SLOT(addAttatchment()) );
88 connect(removeButton, SIGNAL(clicked()), this, 88 connect(removeButton, SIGNAL(clicked()), this,
89 SLOT(removeAttatchment()) ); 89 SLOT(removeAttatchment()) );
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(addAttatchment()) );*/ 94 SLOT(addAttatchment()) );*/
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(removeAttatchment()) ); 101 SLOT(removeAttatchment()) );
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::addAttatchment() 124void AddAtt::addAttatchment()
125 { 125 {
126 QDialog qd(this,tr("Select attachment"),true); 126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
127
128 QGridLayout top(&qd,1,1);
129
130 OFileSelector ofs(&qd,1,0,"/root/Documents");
131
132 top.addWidget(&ofs,0,0);
133 127
134 qd.showMaximized(); 128 ofs.showMaximized();
135 129
136 if (qd.exec()==QDialog::Accepted) 130 if (ofs.exec()==QDialog::Accepted)
137 { 131 {
138 DocLnk* dl=new DocLnk(ofs.selectedDocument()); 132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
139 FileItem* fi=new FileItem(attView,dl); 133 FileItem* fi=new FileItem(attView,dl);
140 fi->setPixmap(0,dl->pixmap()); 134 fi->setPixmap(0,dl->pixmap());
141 fi->setText(1,dl->type()); 135 fi->setText(1,dl->type());
142 attView->insertItem(fi); 136 attView->insertItem(fi);
143 modified = TRUE; 137 modified = TRUE;
144 } 138 }
145} 139}
146 140
147void AddAtt::removeAttatchment() 141void AddAtt::removeAttatchment()
148{ 142{
149 if (attView->selectedItem() != NULL) 143 if (attView->selectedItem() != NULL)
150 { 144 {
151 attView->takeItem(attView->selectedItem()); 145 attView->takeItem(attView->selectedItem());
152 } 146 }
153 modified = TRUE; 147 modified = TRUE;
154} 148}
155 149
156void AddAtt::reject() 150void AddAtt::reject()
157{ 151{
158 if (modified) { 152 if (modified) {
159 attView->clear(); 153 attView->clear();
160 modified = FALSE; 154 modified = FALSE;
161 } 155 }
162} 156}
163 157
164void AddAtt::accept() 158void AddAtt::accept()
165{ 159{
166 modified = FALSE; 160 modified = FALSE;
167 hide(); 161 hide();
168} 162}
169 163
170void AddAtt::getFiles() 164void AddAtt::getFiles()
171{ 165{
172 QString path, selected; 166 QString path, selected;
173 167
174 /*listView->clear(); 168 /*listView->clear();
175 169
176 selected = fileCategoryButton->text(); 170 selected = fileCategoryButton->text();
177 if (selected == "Picture") { 171 if (selected == "Picture") {
178 path = "../pics/"; 172 path = "../pics/";
179 } else if (selected == "Document") { 173 } else if (selected == "Document") {
180 path = "" ; //sub-dirs not decided 174 path = "" ; //sub-dirs not decided
181 } else if (selected == "Sound") { 175 } else if (selected == "Sound") {
182 path = "../sounds/"; //sub-dirs not decided 176 path = "../sounds/"; //sub-dirs not decided
183 } else if (selected == "Movie") { 177 } else if (selected == "Movie") {
184 path = ""; //sub-dirs not decided 178 path = ""; //sub-dirs not decided
185 } else if (selected == "File") { 179 } else if (selected == "File") {
186 path = ""; //sub-dirs not decided 180 path = ""; //sub-dirs not decided
187 } 181 }
188 182
189 dir = new QDir(path); 183 dir = new QDir(path);
190 dir->setFilter(QDir::Files); 184 dir->setFilter(QDir::Files);
191 const QFileInfoList *dirInfoList = dir->entryInfoList(); 185 const QFileInfoList *dirInfoList = dir->entryInfoList();
192 186
193 QFileInfoListIterator it(*dirInfoList); // create list iterator 187 QFileInfoListIterator it(*dirInfoList); // create list iterator
194 188
195 while ( (fi=it.current()) ) { // for each file... 189 while ( (fi=it.current()) ) { // for each file...
196 item = new FileItem(lis+ütView, *fi, selected); 190 item = new FileItem(lis+ütView, *fi, selected);
197 ++it; // goto next list element 191 ++it; // goto next list element
198 }*/ 192 }*/
199} 193}
200 194
201QStringList AddAtt::returnAttatchedFiles() 195QStringList AddAtt::returnAttatchedFiles()
202{ 196{
203 QFileInfo info; 197 QFileInfo info;
204 QStringList list; 198 QStringList list;
205 199
206 item = (FileItem *) attView->firstChild(); 200 item = (FileItem *) attView->firstChild();
207 201
208 202
209 while (item != NULL) { 203 while (item != NULL) {
210 DocLnk* dl=item->getDocLnk(); 204 DocLnk* dl=item->getDocLnk();
211 list+=dl->file(); 205 list+=dl->file();
212 /*info = item->getFileInfo(); 206 /*info = item->getFileInfo();
213 list += info.filePath();*/ 207 list += info.filePath();*/
214 item = (FileItem *) item->nextSibling(); 208 item = (FileItem *) item->nextSibling();
215 } 209 }
216 return list; 210 return list;
217} 211}
218 212
219QStringList AddAtt::returnFileTypes() 213QStringList AddAtt::returnFileTypes()
220{ 214{
221 QStringList list; 215 QStringList list;
222 216
223 item = (FileItem *) attView->firstChild(); 217 item = (FileItem *) attView->firstChild();
224 218
225 while (item != NULL) { 219 while (item != NULL) {
226 list += item->getDocLnk()->type(); 220 list += item->getDocLnk()->type();
227 item = (FileItem *) item->nextSibling(); 221 item = (FileItem *) item->nextSibling();
228 } 222 }
229 return list; 223 return list;
230} 224}
diff --git a/noncore/unsupported/mailit/addatt.h b/noncore/unsupported/mailit/addatt.h
index 73062e2..fcf3279 100644
--- a/noncore/unsupported/mailit/addatt.h
+++ b/noncore/unsupported/mailit/addatt.h
@@ -1,76 +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 ADDATT_H 20#ifndef ADDATT_H
21#define ADDATT_H 21#define ADDATT_H
22 22
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qlistview.h> 24#include <qlistview.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qpopupmenu.h> 26#include <qpopupmenu.h>
27#include <qstring.h> 27#include <qstring.h>
28#include <qfileinfo.h> 28#include <qfileinfo.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <opie/ofileselector.h> 30#include <opie/ofiledialog.h>
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32 32
33class FileItem : public QListViewItem 33class FileItem : public QListViewItem
34{ 34{
35public: 35public:
36 //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); 36 //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType);
37 FileItem(QListView*, DocLnk*); 37 FileItem(QListView*, DocLnk*);
38 ~FileItem(); 38 ~FileItem();
39 DocLnk* getDocLnk() {return doclnk;} 39 DocLnk* getDocLnk() {return doclnk;}
40 40
41 41
42private: 42private:
43 DocLnk* doclnk; 43 DocLnk* doclnk;
44}; 44};
45 45
46class AddAtt : public QDialog 46class AddAtt : public QDialog
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 51 AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
52 QStringList returnAttatchedFiles(); 52 QStringList returnAttatchedFiles();
53 QStringList returnFileTypes(); 53 QStringList returnFileTypes();
54 void getFiles(); 54 void getFiles();
55 void clear(); 55 void clear();
56 56
57 57
58public slots: 58public slots:
59 //void fileCategorySelected(int); 59 //void fileCategorySelected(int);
60 void addAttatchment(); 60 void addAttatchment();
61 void removeAttatchment(); 61 void removeAttatchment();
62 void reject(); 62 void reject();
63 void accept(); 63 void accept();
64 64
65private: 65private:
66 FileItem* item; 66 FileItem* item;
67 QListView *attView; 67 QListView *attView;
68 QPushButton *fileCategoryButton, *attatchButton, *removeButton; 68 QPushButton *attatchButton, *removeButton;
69 QPopupMenu *fileCategories; 69 QPopupMenu *fileCategories;
70 bool modified; 70 bool modified;
71 QFileInfo *fi; 71 //QFileInfo *fi;
72 72
73 OFileSelector* ofs; 73 OFileDialog* ofs;
74}; 74};
75 75
76#endif 76#endif
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 1cf2562..43e3830 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -1,167 +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#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h>
22 24
23#include "addresslist.h" 25#include "addresslist.h"
24 26
25AddressList::AddressList(QString file) 27AddressList::AddressList(QString file)
26{ 28{
27 addresses.setAutoDelete(TRUE); 29 addresses.setAutoDelete(TRUE);
28 filename = file; 30 filename = file;
29 read(); 31 read();
30 dirty = FALSE; 32 dirty = FALSE;
31} 33}
32 34
33AddressList::~AddressList() 35AddressList::~AddressList()
34{ 36{
35 write(); 37 write();
36 addresses.clear(); 38 addresses.clear();
37} 39}
38 40
39void AddressList::addContact(QString email, QString name) 41void AddressList::addContact(QString email, QString name)
40{ 42{
41 //skip if not a valid email address, 43 //skip if not a valid email address,
42 if (email.find( '@') == -1) 44 if (email.find( '@') == -1)
43 return; 45 return;
44 46
45 if ( ! containsEmail(email) ) { 47 if ( ! containsEmail(email) ) {
46 Contact *in = new Contact; 48 Contact *in = new Contact;
47 in->email = email; 49 in->email = email;
48 in->name = name; 50 in->name = name;
49 addresses.append(in); 51 addresses.append(in);
50 dirty = TRUE; 52 dirty = TRUE;
51 } 53 }
52} 54}
53 55
54bool AddressList::containsEmail(QString email) 56bool AddressList::containsEmail(QString email)
55{ 57{
56 return ( getEmailRef(email) != -1 ); 58 return ( getEmailRef(email) != -1 );
57} 59}
58 60
59bool AddressList::containsName(QString name) 61bool AddressList::containsName(QString name)
60{ 62{
61 return ( getNameRef(name) != -1 ); 63 return ( getNameRef(name) != -1 );
62} 64}
63 65
64QString AddressList::getNameByEmail(QString email) 66QString AddressList::getNameByEmail(QString email)
65{ 67{
66 int pos = getEmailRef(email); 68 int pos = getEmailRef(email);
67 if (pos != -1) { 69 if (pos != -1) {
68 Contact *ptr = addresses.at(pos); 70 Contact *ptr = addresses.at(pos);
69 return ptr->name; 71 return ptr->name;
70 } 72 }
71 73
72 return NULL; 74 return NULL;
73} 75}
74 76
75QString AddressList::getEmailByName(QString name) 77QString AddressList::getEmailByName(QString name)
76{ 78{
77 int pos = getNameRef(name); 79 int pos = getNameRef(name);
78 if (pos != -1) { 80 if (pos != -1) {
79 Contact *ptr = addresses.at(pos); 81 Contact *ptr = addresses.at(pos);
80 return ptr->email; 82 return ptr->email;
81 } 83 }
82 84
83 return NULL; 85 return NULL;
84} 86}
85 87
86int AddressList::getEmailRef(QString email) 88int AddressList::getEmailRef(QString email)
87{ 89{
88 int pos = 0; 90 int pos = 0;
89 Contact *ptr; 91 Contact *ptr;
90 92
91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 93 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
92 if (ptr->email == email) 94 if (ptr->email == email)
93 return pos; 95 return pos;
94 pos++; 96 pos++;
95 } 97 }
96 return -1; 98 return -1;
97} 99}
98 100
99int AddressList::getNameRef(QString name) 101int AddressList::getNameRef(QString name)
100{ 102{
101 int pos = 0; 103 int pos = 0;
102 Contact *ptr; 104 Contact *ptr;
103 105
104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 106 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
105 if (ptr->name == name) 107 if (ptr->name == name)
106 return pos; 108 return pos;
107 pos++; 109 pos++;
108 } 110 }
109 return -1; 111 return -1;
110} 112}
111 113
112QList<Contact>* AddressList::getContactList() 114QList<Contact>* AddressList::getContactList()
113{ 115{
114 return &addresses; 116 return &addresses;
115} 117}
116 118
117void AddressList::read() 119void AddressList::read()
118{ 120{
119 QFile f(filename); 121 OContactAccess::List::Iterator it;
122
123 //QFile f(filename);
120 QString lineEmail, lineName, email, name; 124 QString lineEmail, lineName, email, name;
125 OContactAccess m_contactdb("mailit");
126 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
127 //OContact* oc;
121 128
122 if (! f.open(IO_ReadOnly) ) 129 for ( it = m_list.begin(); it != m_list.end(); ++it )
130 {
131 //oc=(OContact*) it;
132 if ((*it).defaultEmail().length()!=0)
133 addContact((*it).defaultEmail(),(*it).fullName());
134 }
135
136 /*if (! f.open(IO_ReadOnly) )
123 return; 137 return;
124 138
125 QTextStream stream(&f); 139 QTextStream stream(&f);
126 140
127 while (! stream.atEnd() ) { 141 while (! stream.atEnd() ) {
128 lineEmail = stream.readLine(); 142 lineEmail = stream.readLine();
129 if (! stream.atEnd() ) 143 if (! stream.atEnd() )
130 lineName = stream.readLine(); 144 lineName = stream.readLine();
131 else return; 145 else return;
132 146
133 email = getRightString(lineEmail); 147 email = getRightString(lineEmail);
134 name = getRightString(lineName); 148 name = getRightString(lineName);
135 addContact(email, name); 149 addContact(email, name);
136 } 150 }
137 f.close(); 151 f.close();*/
138} 152}
139 153
140QString AddressList::getRightString(QString in) 154QString AddressList::getRightString(QString in)
141{ 155{
142 QString out = ""; 156 QString out = "";
143 157
144 int pos = in.find('='); 158 int pos = in.find('=');
145 if (pos != -1) { 159 if (pos != -1) {
146 out = in.mid(pos+1).stripWhiteSpace(); 160 out = in.mid(pos+1).stripWhiteSpace();
147 } 161 }
148 return out; 162 return out;
149} 163}
150 164
151void AddressList::write() 165void AddressList::write()
152{ 166{
153 if ( (addresses.count() == 0) || (!dirty) ) 167 if ( (addresses.count() == 0) || (!dirty) )
154 return; 168 return;
155 169
156 QFile f(filename); 170 QFile f(filename);
157 if (! f.open(IO_WriteOnly) ) 171 if (! f.open(IO_WriteOnly) )
158 return; 172 return;
159 173
160 QTextStream stream(&f); 174 QTextStream stream(&f);
161 Contact *ptr; 175 Contact *ptr;
162 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { 176 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
163 stream << "email = " + ptr->email + "\n"; 177 stream << "email = " + ptr->email + "\n";
164 stream << "name = " + ptr->name + "\n"; 178 stream << "name = " + ptr->name + "\n";
165 } 179 }
166 f.close(); 180 f.close();
167} 181}
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index 9258aac..2943986 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -1,663 +1,663 @@
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 <qfile.h> 22#include <qfile.h>
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qmenubar.h> 24#include <qmenubar.h>
25#include <qaction.h> 25#include <qaction.h>
26#include "resource.h" 26#include "resource.h"
27#include "emailclient.h" 27#include "emailclient.h"
28 28
29QCollection::Item AccountList::newItem(QCollection::Item d) 29QCollection::Item AccountList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (MailAccount *) d); 31 return dupl( (MailAccount *) d);
32} 32}
33 33
34MailAccount* AccountList::dupl(MailAccount *in) 34MailAccount* AccountList::dupl(MailAccount *in)
35{ 35{
36 ac = new MailAccount(*in); 36 ac = new MailAccount(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) 40EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
41 : QMainWindow( parent, name, fl ) 41 : QMainWindow( parent, name, fl )
42{ 42{
43 emailHandler = new EmailHandler(); 43 emailHandler = new EmailHandler();
44 addressList = new AddressList( getPath(FALSE) + "mail_adr"); 44 addressList = new AddressList( getPath(FALSE) + "mail_adr");
45 45
46 sending = FALSE; 46 sending = FALSE;
47 receiving = FALSE; 47 receiving = FALSE;
48 previewingMail = FALSE; 48 previewingMail = FALSE;
49 mailIdCount = 1; 49 mailIdCount = 1;
50 accountIdCount = 1; 50 accountIdCount = 1;
51 allAccounts = FALSE; 51 allAccounts = FALSE;
52 52
53 init(); 53 init();
54 54
55 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); 55 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
56 56
57 connect(emailHandler, SIGNAL(smtpError(int)), this, 57 connect(emailHandler, SIGNAL(smtpError(int)), this,
58 SLOT(smtpError(int)) ); 58 SLOT(smtpError(int)) );
59 connect(emailHandler, SIGNAL(popError(int)), this, 59 connect(emailHandler, SIGNAL(popError(int)), this,
60 SLOT(popError(int)) ); 60 SLOT(popError(int)) );
61 61
62 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); 62 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
63 connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); 63 connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
64 64
65 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, 65 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
66 SLOT(mailArrived(const Email &, bool)) ); 66 SLOT(mailArrived(const Email &, bool)) );
67 connect(emailHandler, SIGNAL(mailTransfered(int)), this, 67 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
68 SLOT(allMailArrived(int)) ); 68 SLOT(allMailArrived(int)) );
69 69
70 mailconf = new Config("mailit"); 70 mailconf = new Config("mailit");
71 //In case Synchronize is not defined in settings.txt 71 //In case Synchronize is not defined in settings.txt
72 72
73 readSettings(); 73 readSettings();
74 74
75 updateAccounts(); 75 updateAccounts();
76 76
77 lineShift = "\n"; 77 lineShift = "\n";
78 readMail(); 78 readMail();
79 lineShift = "\r\n"; 79 lineShift = "\r\n";
80 80
81} 81}
82 82
83 83
84EmailClient::~EmailClient() 84EmailClient::~EmailClient()
85{ 85{
86 //needs to be moved from destructor to closewindow event 86 //needs to be moved from destructor to closewindow event
87 saveMail(getPath(FALSE) + "inbox.txt", inboxView); 87 saveMail(getPath(FALSE) + "inbox.txt", inboxView);
88 //does not currently work. Defining outbox in the same 88 //does not currently work. Defining outbox in the same
89 //format as inbox is not a good solution as they have 89 //format as inbox is not a good solution as they have
90 //different properties 90 //different properties
91 saveMail(getPath(FALSE) + "outbox.txt", outboxView); 91 saveMail(getPath(FALSE) + "outbox.txt", outboxView);
92 saveSettings(); 92 saveSettings();
93 93
94 mailconf->write(); 94 mailconf->write();
95 delete mailconf; 95 delete mailconf;
96 96
97} 97}
98 98
99void EmailClient::init() 99void EmailClient::init()
100{ 100{
101 statusBar = new QStatusBar(this); 101 statusBar = new QStatusBar(this);
102 statusBar->setSizeGripEnabled(FALSE); 102 statusBar->setSizeGripEnabled(FALSE);
103 103
104 status1Label = new QLabel( tr("Idle"), statusBar); 104 status1Label = new QLabel( tr("Idle"), statusBar);
105 status2Label = new QLabel("", statusBar); 105 status2Label = new QLabel("", statusBar);
106 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), 106 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
107 status2Label, SLOT(setText(const QString &)) ); 107 status2Label, SLOT(setText(const QString &)) );
108 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), 108 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
109 status2Label, SLOT(setText(const QString &)) ); 109 status2Label, SLOT(setText(const QString &)) );
110 110
111 progressBar = new QProgressBar(statusBar); 111 progressBar = new QProgressBar(statusBar);
112 connect(emailHandler, SIGNAL(mailboxSize(int)), 112 connect(emailHandler, SIGNAL(mailboxSize(int)),
113 this, SLOT(setTotalSize(int)) ); 113 this, SLOT(setTotalSize(int)) );
114 connect(emailHandler, SIGNAL(currentMailSize(int)), 114 connect(emailHandler, SIGNAL(currentMailSize(int)),
115 this, SLOT(setMailSize(int)) ); 115 this, SLOT(setMailSize(int)) );
116 connect(emailHandler, SIGNAL(downloadedSize(int)), 116 connect(emailHandler, SIGNAL(downloadedSize(int)),
117 this, SLOT(setDownloadedSize(int)) ); 117 this, SLOT(setDownloadedSize(int)) );
118 118
119 statusBar->addWidget(status1Label); 119 statusBar->addWidget(status1Label);
120 statusBar->addWidget(progressBar); 120 statusBar->addWidget(progressBar);
121 statusBar->addWidget(status2Label); 121 statusBar->addWidget(status2Label);
122 122
123 setToolBarsMovable(FALSE); 123 setToolBarsMovable(FALSE);
124 124
125 bar = new QToolBar(this); 125 bar = new QToolBar(this);
126 bar->setHorizontalStretchable( TRUE ); 126 bar->setHorizontalStretchable( TRUE );
127 127
128 mb = new QMenuBar( bar ); 128 mb = new QMenuBar( bar );
129 129
130 QPopupMenu *mail = new QPopupMenu(mb); 130 QPopupMenu *mail = new QPopupMenu(mb);
131 mb->insertItem( tr( "&Mail" ), mail); 131 mb->insertItem( tr( "&Mail" ), mail);
132 132
133 QPopupMenu *configure = new QPopupMenu(mb); 133 QPopupMenu *configure = new QPopupMenu(mb);
134 mb->insertItem( tr( "Accounts" ), configure); 134 mb->insertItem( tr( "Accounts" ), configure);
135 135
136 selectAccountMenu = new QPopupMenu(mb); 136 selectAccountMenu = new QPopupMenu(mb);
137 editAccountMenu = new QPopupMenu(mb); 137 editAccountMenu = new QPopupMenu(mb);
138 deleteAccountMenu = new QPopupMenu(mb); 138 deleteAccountMenu = new QPopupMenu(mb);
139 139
140 mail->insertItem(tr("Get Mail in"), selectAccountMenu); 140 mail->insertItem(tr("Get Mail in"), selectAccountMenu);
141 configure->insertItem(tr("Edit account"), editAccountMenu); 141 configure->insertItem(tr("Edit account"), editAccountMenu);
142 configure->insertItem(tr("Delete account"), deleteAccountMenu); 142 configure->insertItem(tr("Delete account"), deleteAccountMenu);
143 143
144 bar = new QToolBar(this); 144 bar = new QToolBar(this);
145 145
146 getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); 146 getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0);
147 connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); 147 connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) );
148 getMailButton->addTo(bar); 148 getMailButton->addTo(bar);
149 getMailButton->addTo(mail); 149 getMailButton->addTo(mail);
150 150
151 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); 151 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
152 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); 152 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) );
153 sendMailButton->addTo(bar); 153 sendMailButton->addTo(bar);
154 sendMailButton->addTo(mail); 154 sendMailButton->addTo(mail);
155 155
156 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 156 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
157 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); 157 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
158 composeButton->addTo(bar); 158 composeButton->addTo(bar);
159 composeButton->addTo(mail); 159 composeButton->addTo(mail);
160 160
161 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); 161 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
162 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); 162 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
163 cancelButton->addTo(mail); 163 cancelButton->addTo(mail);
164 cancelButton->addTo(bar); 164 cancelButton->addTo(bar);
165 cancelButton->setEnabled(FALSE); 165 cancelButton->setEnabled(FALSE);
166 166
167 mailboxView = new OTabWidget( this, "mailboxView" ); 167 mailboxView = new OTabWidget( this, "mailboxView" );
168 168
169 QWidget* widget = new QWidget( mailboxView, "widget" ); 169 QWidget* widget = new QWidget( mailboxView, "widget" );
170 grid_2 = new QGridLayout( widget ); 170 grid_2 = new QGridLayout( widget );
171// grid_2->setSpacing(6); 171// grid_2->setSpacing(6);
172// grid_2->setMargin( 11 ); 172// grid_2->setMargin( 11 );
173 173
174 inboxView = new QListView( widget, "inboxView" ); 174 inboxView = new QListView( widget, "inboxView" );
175 inboxView->addColumn( tr( "From" ) ); 175 inboxView->addColumn( tr( "From" ) );
176 inboxView->addColumn( tr( "Subject" ) ); 176 inboxView->addColumn( tr( "Subject" ) );
177 inboxView->addColumn( tr( "Date" ) ); 177 inboxView->addColumn( tr( "Date" ) );
178 inboxView->setMinimumSize( QSize( 0, 0 ) ); 178 inboxView->setMinimumSize( QSize( 0, 0 ) );
179 inboxView->setAllColumnsShowFocus(TRUE); 179 inboxView->setAllColumnsShowFocus(TRUE);
180 180
181 grid_2->addWidget( inboxView, 2, 0 ); 181 grid_2->addWidget( inboxView, 2, 0 );
182 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); 182 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
183 183
184 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); 184 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" );
185 grid_3 = new QGridLayout( widget_2 ); 185 grid_3 = new QGridLayout( widget_2 );
186// grid_3->setSpacing(6); 186// grid_3->setSpacing(6);
187// grid_3->setMargin( 11 ); 187// grid_3->setMargin( 11 );
188 188
189 outboxView = new QListView( widget_2, "outboxView" ); 189 outboxView = new QListView( widget_2, "outboxView" );
190 outboxView->addColumn( tr( "To" ) ); 190 outboxView->addColumn( tr( "To" ) );
191 outboxView->addColumn( tr( "Subject" ) ); 191 outboxView->addColumn( tr( "Subject" ) );
192 outboxView->setAllColumnsShowFocus(TRUE); 192 outboxView->setAllColumnsShowFocus(TRUE);
193 193
194 grid_3->addWidget( outboxView, 0, 0 ); 194 grid_3->addWidget( outboxView, 0, 0 );
195 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); 195 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
196 196
197 setCentralWidget(mailboxView); 197 setCentralWidget(mailboxView);
198} 198}
199 199
200void EmailClient::compose() 200void EmailClient::compose()
201{ 201{
202 emit composeRequested(); 202 emit composeRequested();
203} 203}
204 204
205void EmailClient::cancel() 205void EmailClient::cancel()
206{ 206{
207 emailHandler->cancel(); 207 emailHandler->cancel();
208} 208}
209 209
210AddressList* EmailClient::getAdrListRef() 210AddressList* EmailClient::getAdrListRef()
211{ 211{
212 return addressList; 212 return addressList;
213} 213}
214 214
215//this needs to be rewritten to syncronize with outboxView 215//this needs to be rewritten to syncronize with outboxView
216void EmailClient::enqueMail(const Email &mail) 216void EmailClient::enqueMail(const Email &mail)
217{ 217{
218 if (accountList.count() == 0) { 218 if (accountList.count() == 0) {
219 QMessageBox::warning(qApp->activeWindow(), 219 QMessageBox::warning(qApp->activeWindow(),
220 tr("No account selected"), tr("You must create an account"), "OK\n"); 220 tr("No account selected"), tr("You must create an account"), "OK\n");
221 return; 221 return;
222 } 222 }
223 223
224 if (accountList.count() > 0) { 224 if (accountList.count() > 0) {
225 currentAccount = accountList.first(); 225 currentAccount = accountList.first();
226 qWarning("using account " + currentAccount->name); 226 qWarning("using account " + currentAccount->name);
227 } 227 }
228 228
229 Email addMail = mail; 229 Email addMail = mail;
230 addMail.from = currentAccount->name; 230 addMail.from = currentAccount->name;
231 addMail.fromMail = currentAccount->emailAddress; 231 addMail.fromMail = currentAccount->emailAddress;
232 addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); 232 addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n");
233 item = new EmailListItem(outboxView, addMail, false); 233 item = new EmailListItem(outboxView, addMail, false);
234 234
235} 235}
236 236
237void EmailClient::sendQuedMail() 237void EmailClient::sendQuedMail()
238{ 238{
239 int count = 0; 239 int count = 0;
240 240
241 if (accountList.count() == 0) { 241 if (accountList.count() == 0) {
242 QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); 242 QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n");
243 return; 243 return;
244 } 244 }
245 //traverse listview, find messages to send 245 //traverse listview, find messages to send
246 if (! sending) { 246 if (! sending) {
247 item = (EmailListItem *) outboxView->firstChild(); 247 item = (EmailListItem *) outboxView->firstChild();
248 if (item != NULL) { 248 if (item != NULL) {
249 while (item != NULL) { 249 while (item != NULL) {
250 quedMessages.append(item->getMail()); 250 quedMessages.append(item->getMail());
251 item = (EmailListItem *) item->nextSibling(); 251 item = (EmailListItem *) item->nextSibling();
252 count++; 252 count++;
253 } 253 }
254 setMailAccount(); 254 setMailAccount();
255 emailHandler->sendMail(&quedMessages); 255 emailHandler->sendMail(&quedMessages);
256 sending = TRUE; 256 sending = TRUE;
257 sendMailButton->setEnabled(FALSE); 257 sendMailButton->setEnabled(FALSE);
258 cancelButton->setEnabled(TRUE); 258 cancelButton->setEnabled(TRUE);
259 } else { 259 } else {
260 qWarning("sendQuedMail(): no messages to send"); 260 qWarning("sendQuedMail(): no messages to send");
261 } 261 }
262 } 262 }
263} 263}
264 264
265void EmailClient::setMailAccount() 265void EmailClient::setMailAccount()
266{ 266{
267 emailHandler->setAccount(*currentAccount); 267 emailHandler->setAccount(*currentAccount);
268} 268}
269 269
270void EmailClient::mailSent() 270void EmailClient::mailSent()
271{ 271{
272 sending = FALSE; 272 sending = FALSE;
273 sendMailButton->setEnabled(TRUE); 273 sendMailButton->setEnabled(TRUE);
274 274
275 quedMessages.clear(); 275 quedMessages.clear();
276 outboxView->clear(); //should be moved to an sentBox 276 outboxView->clear(); //should be moved to an sentBox
277} 277}
278 278
279void EmailClient::getNewMail() { 279void EmailClient::getNewMail() {
280 280
281 if (accountList.count() == 0) { 281 if (accountList.count() == 0) {
282 QMessageBox::warning(qApp->activeWindow(),"No account selected", 282 QMessageBox::warning(qApp->activeWindow(),"No account selected",
283 "You must create an account", "OK\n"); 283 "You must create an account", "OK\n");
284 return; 284 return;
285 } 285 }
286 286
287 setMailAccount(); 287 setMailAccount();
288 288
289 receiving = TRUE; 289 receiving = TRUE;
290 previewingMail = TRUE; 290 previewingMail = TRUE;
291 getMailButton->setEnabled(FALSE); 291 getMailButton->setEnabled(FALSE);
292 cancelButton->setEnabled(TRUE); 292 cancelButton->setEnabled(TRUE);
293 selectAccountMenu->setEnabled(FALSE); 293 selectAccountMenu->setEnabled(FALSE);
294 294
295 status1Label->setText(currentAccount->accountName + " headers"); 295 status1Label->setText(currentAccount->accountName + " headers");
296 progressBar->reset(); 296 progressBar->reset();
297 297
298 //get any previous mails not downloaded and add to queue 298 //get any previous mails not downloaded and add to queue
299 mailDownloadList.clear(); 299 mailDownloadList.clear();
300 Email *mailPtr; 300 Email *mailPtr;
301 item = (EmailListItem *) inboxView->firstChild(); 301 item = (EmailListItem *) inboxView->firstChild();
302 while (item != NULL) { 302 while (item != NULL) {
303 mailPtr = item->getMail(); 303 mailPtr = item->getMail();
304 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { 304 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) {
305 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); 305 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
306 } 306 }
307 item = (EmailListItem *) item->nextSibling(); 307 item = (EmailListItem *) item->nextSibling();
308 } 308 }
309 309
310 emailHandler->getMailHeaders(); 310 emailHandler->getMailHeaders();
311} 311}
312 312
313void EmailClient::getAllNewMail() 313void EmailClient::getAllNewMail()
314{ 314{
315 allAccounts = TRUE; 315 allAccounts = TRUE;
316 currentAccount = accountList.first(); 316 currentAccount = accountList.first();
317 getNewMail(); 317 getNewMail();
318} 318}
319 319
320void EmailClient::mailArrived(const Email &mail, bool fromDisk) 320void EmailClient::mailArrived(const Email &mail, bool fromDisk)
321{ 321{
322 Enclosure *ePtr; 322 Enclosure *ePtr;
323 Email newMail; 323 Email newMail;
324 int thisMailId; 324 int thisMailId;
325 emailHandler->parse(mail.rawMail, lineShift, &newMail); 325 emailHandler->parse(mail.rawMail, lineShift, &newMail);
326 326
327 mailconf->setGroup(newMail.id); 327 mailconf->setGroup(newMail.id);
328 328
329 if (fromDisk) { 329 if (fromDisk) {
330 newMail.downloaded = mailconf->readBoolEntry("downloaded"); 330 newMail.downloaded = mailconf->readBoolEntry("downloaded");
331 newMail.size = mailconf->readNumEntry("size"); 331 newMail.size = mailconf->readNumEntry("size");
332 newMail.serverId = mailconf->readNumEntry("serverid"); 332 newMail.serverId = mailconf->readNumEntry("serverid");
333 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); 333 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
334 } else { //mail arrived from server 334 } else { //mail arrived from server
335 newMail.serverId = mail.serverId; 335 newMail.serverId = mail.serverId;
336 newMail.size = mail.size; 336 newMail.size = mail.size;
337 newMail.downloaded = mail.downloaded; 337 newMail.downloaded = mail.downloaded;
338 338
339 newMail.fromAccountId = currentAccount->id; 339 newMail.fromAccountId = currentAccount->id;
340 mailconf->writeEntry("fromaccountid", newMail.fromAccountId); 340 mailconf->writeEntry("fromaccountid", newMail.fromAccountId);
341 } 341 }
342 342
343 //add if read or not 343 //add if read or not
344 newMail.read = mailconf->readBoolEntry("mailread"); 344 newMail.read = mailconf->readBoolEntry("mailread");
345 345
346 //check if new mail 346 //check if new mail
347 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { 347 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) {
348 thisMailId = mailIdCount; 348 thisMailId = mailIdCount;
349 mailIdCount++; 349 mailIdCount++;
350 350
351 //set server count, so that if the user aborts, the new 351 //set server count, so that if the user aborts, the new
352 //header is not reloaded 352 //header is not reloaded
353 if (currentAccount->synchronize) 353 if (currentAccount->synchronize)
354 currentAccount->lastServerMailCount++; 354 currentAccount->lastServerMailCount++;
355 355
356 mailconf->writeEntry("internalmailid", thisMailId); 356 mailconf->writeEntry("internalmailid", thisMailId);
357 mailconf->writeEntry("downloaded", newMail.downloaded); 357 mailconf->writeEntry("downloaded", newMail.downloaded);
358 mailconf->writeEntry("size", (int) newMail.size); 358 mailconf->writeEntry("size", (int) newMail.size);
359 mailconf->writeEntry("serverid", newMail.serverId); 359 mailconf->writeEntry("serverid", newMail.serverId);
360 360
361 addressList->addContact(newMail.fromMail, newMail.from); 361 addressList->addContact(newMail.fromMail, newMail.from);
362 } else if (!fromDisk) { //body to header arrived 362 } else if (!fromDisk) { //body to header arrived
363 mailconf->writeEntry("downloaded", TRUE); 363 mailconf->writeEntry("downloaded", TRUE);
364 } 364 }
365 QString stringMailId; 365 QString stringMailId;
366 stringMailId.setNum(thisMailId); 366 stringMailId.setNum(thisMailId);
367 //se if any attatchments needs to be stored 367 //se if any attatchments needs to be stored
368 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { 368 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
369 QString stringId; 369 QString stringId;
370 stringId.setNum(ePtr->id); 370 stringId.setNum(ePtr->id);
371 371
372 int id = mailconf->readNumEntry("enclosureid_" + stringId); 372 int id = mailconf->readNumEntry("enclosureid_" + stringId);
373 if (id != ePtr->id) { //new entry 373 if (id != ePtr->id) { //new entry
374 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); 374 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id);
375 mailconf->writeEntry("name_" + stringId, ePtr->originalName); 375 mailconf->writeEntry("name_" + stringId, ePtr->originalName);
376 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); 376 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType);
377 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); 377 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute);
378 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 378 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
379 mailconf->writeEntry("installed_" + stringId, FALSE); 379 mailconf->writeEntry("installed_" + stringId, FALSE);
380 380
381 ePtr->name = stringMailId + "_" + stringId; 381 ePtr->name = stringMailId + "_" + stringId;
382 ePtr->path = getPath(TRUE); 382 ePtr->path = getPath(TRUE);
383 if (emailHandler->getEnclosure(ePtr)) { //file saved 383 if (emailHandler->getEnclosure(ePtr)) { //file saved
384 ePtr->saved = TRUE; 384 ePtr->saved = TRUE;
385 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 385 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
386 mailconf->writeEntry("filename_" + stringId, ePtr->name); 386 mailconf->writeEntry("filename_" + stringId, ePtr->name);
387 mailconf->writeEntry("path_" + stringId, ePtr->path); 387 mailconf->writeEntry("path_" + stringId, ePtr->path);
388 } else { 388 } else {
389 ePtr->saved = FALSE; 389 ePtr->saved = FALSE;
390 mailconf->writeEntry("saved_" + stringId, ePtr->saved); 390 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
391 } 391 }
392 } else { 392 } else {
393 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); 393 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
394 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); 394 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
395 if (ePtr->saved) { 395 if (ePtr->saved) {
396 ePtr->name = mailconf->readEntry("filename_" + stringId); 396 ePtr->name = mailconf->readEntry("filename_" + stringId);
397 ePtr->path = mailconf->readEntry("path_" + stringId); 397 ePtr->path = mailconf->readEntry("path_" + stringId);
398 } 398 }
399 } 399 }
400 } 400 }
401 if (!previewingMail && !fromDisk) { 401 if (!previewingMail && !fromDisk) {
402 Email *mailPtr; 402 Email *mailPtr;
403 item = (EmailListItem *) inboxView->firstChild(); 403 item = (EmailListItem *) inboxView->firstChild();
404 while (item != NULL) { 404 while (item != NULL) {
405 mailPtr = item->getMail(); 405 mailPtr = item->getMail();
406 if (mailPtr->id == newMail.id) { 406 if (mailPtr->id == newMail.id) {
407 item->setMail(newMail); 407 item->setMail(newMail);
408 emit mailUpdated(item->getMail()); 408 emit mailUpdated(item->getMail());
409 } 409 }
410 item = (EmailListItem *) item->nextSibling(); 410 item = (EmailListItem *) item->nextSibling();
411 } 411 }
412 } else { 412 } else {
413 item = new EmailListItem(inboxView, newMail, TRUE); 413 item = new EmailListItem(inboxView, newMail, TRUE);
414 if (!newMail.downloaded) 414 if (!newMail.downloaded)
415 mailDownloadList.sizeInsert(newMail.serverId, newMail.size); 415 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
416 } 416 }
417 417
418} 418}
419 419
420void EmailClient::allMailArrived(int count) 420void EmailClient::allMailArrived(int count)
421{ 421{
422 // not previewing means all mailtransfer has been done 422 // not previewing means all mailtransfer has been done
423 if (!previewingMail) { 423 if (!previewingMail) {
424 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { 424 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
425 emit newCaption("Mailit - " + currentAccount->accountName); 425 emit newCaption("Mailit - " + currentAccount->accountName);
426 getNewMail(); 426 getNewMail();
427 return; 427 return;
428 } else { 428 } else {
429 allAccounts = FALSE; 429 allAccounts = FALSE;
430 receiving = FALSE; 430 receiving = FALSE;
431 getMailButton->setEnabled(TRUE); 431 getMailButton->setEnabled(TRUE);
432 cancelButton->setEnabled(FALSE); 432 cancelButton->setEnabled(FALSE);
433 selectAccountMenu->setEnabled(TRUE); 433 selectAccountMenu->setEnabled(TRUE);
434 status1Label->setText("Idle"); 434 status1Label->setText("Idle");
435 435
436 progressBar->reset(); 436 progressBar->reset();
437 return; 437 return;
438 } 438 }
439 } 439 }
440 440
441 // all headers downloaded from server, start downloading remaining mails 441 // all headers downloaded from server, start downloading remaining mails
442 previewingMail = FALSE; 442 previewingMail = FALSE;
443 status1Label->setText(currentAccount->accountName); 443 status1Label->setText(currentAccount->accountName);
444 progressBar->reset(); 444 progressBar->reset();
445 445
446 emailHandler->getMailByList(&mailDownloadList); 446 emailHandler->getMailByList(&mailDownloadList);
447} 447}
448 448
449void EmailClient::moveMailFront(Email *mailPtr) 449void EmailClient::moveMailFront(Email *mailPtr)
450{ 450{
451 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { 451 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
452 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); 452 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
453 } 453 }
454} 454}
455 455
456void EmailClient::smtpError(int code) 456void EmailClient::smtpError(int code)
457{ 457{
458 QString temp; 458 QString temp;
459 459
460 if (code == ErrUnknownResponse) 460 if (code == ErrUnknownResponse)
461 temp = "Unknown response from server"; 461 temp = "Unknown response from server";
462 462
463 if (code == QSocket::ErrHostNotFound) 463 if (code == QSocket::ErrHostNotFound)
464 temp = "host not found"; 464 temp = "host not found";
465 if (code == QSocket::ErrConnectionRefused) 465 if (code == QSocket::ErrConnectionRefused)
466 temp = "connection refused"; 466 temp = "connection refused";
467 if (code == QSocket::ErrSocketRead) 467 if (code == QSocket::ErrSocketRead)
468 temp = "socket packet error"; 468 temp = "socket packet error";
469 469
470 if (code != ErrCancel) { 470 if (code != ErrCancel) {
471 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); 471 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
472 } else { 472 } else {
473 status2Label->setText("Aborted by user"); 473 status2Label->setText("Aborted by user");
474 } 474 }
475 475
476 sending = FALSE; 476 sending = FALSE;
477 sendMailButton->setEnabled(TRUE); 477 sendMailButton->setEnabled(TRUE);
478 cancelButton->setEnabled(FALSE); 478 cancelButton->setEnabled(FALSE);
479 quedMessages.clear(); 479 quedMessages.clear();
480} 480}
481 481
482void EmailClient::popError(int code) 482void EmailClient::popError(int code)
483{ 483{
484 QString temp; 484 QString temp;
485 485
486 if (code == ErrUnknownResponse) 486 if (code == ErrUnknownResponse)
487 temp = "Unknown response from server"; 487 temp = "Unknown response from server";
488 if (code == ErrLoginFailed) 488 if (code == ErrLoginFailed)
489 temp = "Login failed\nCheck user name and password"; 489 temp = "Login failed\nCheck user name and password";
490 490
491 if (code == QSocket::ErrHostNotFound) 491 if (code == QSocket::ErrHostNotFound)
492 temp = "host not found"; 492 temp = "host not found";
493 if (code == QSocket::ErrConnectionRefused) 493 if (code == QSocket::ErrConnectionRefused)
494 temp = "connection refused"; 494 temp = "connection refused";
495 if (code == QSocket::ErrSocketRead) 495 if (code == QSocket::ErrSocketRead)
496 temp = "socket packet error"; 496 temp = "socket packet error";
497 497
498 if (code != ErrCancel) { 498 if (code != ErrCancel) {
499 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); 499 QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n");
500 } else { 500 } else {
501 status2Label->setText("Aborted by user"); 501 status2Label->setText("Aborted by user");
502 } 502 }
503 503
504 receiving = FALSE; 504 receiving = FALSE;
505 getMailButton->setEnabled(TRUE); 505 getMailButton->setEnabled(TRUE);
506 cancelButton->setEnabled(FALSE); 506 cancelButton->setEnabled(FALSE);
507 selectAccountMenu->setEnabled(TRUE); 507 selectAccountMenu->setEnabled(TRUE);
508} 508}
509 509
510void EmailClient::inboxItemSelected() 510void EmailClient::inboxItemSelected()
511{ 511{
512 item = (EmailListItem*) inboxView->selectedItem(); 512 item = (EmailListItem*) inboxView->selectedItem();
513 if (item != NULL) { 513 if (item != NULL) {
514 emit viewEmail(inboxView, item->getMail()); 514 emit viewEmail(inboxView, item->getMail());
515 } 515 }
516} 516}
517 517
518void EmailClient::outboxItemSelected() 518void EmailClient::outboxItemSelected()
519{ 519{
520 item = (EmailListItem*) outboxView->selectedItem(); 520 item = (EmailListItem*) outboxView->selectedItem();
521 if (item != NULL) { 521 if (item != NULL) {
522 emit viewEmail(outboxView, item->getMail()); 522 emit viewEmail(outboxView, item->getMail());
523 } 523 }
524 524
525} 525}
526 526
527void EmailClient::readMail() 527void EmailClient::readMail()
528{ 528{
529 Email mail; 529 Email mail;
530 int start, stop; 530 int start, stop;
531 QString s, del; 531 QString s, del;
532 532
533 QFile f(getPath(FALSE) + "inbox.txt"); 533 QFile f(getPath(FALSE) + "inbox.txt");
534// QFileInfo fi(f); 534// QFileInfo fi(f);
535 qDebug( f.name()); 535 qDebug( f.name());
536 536
537 if ( f.open(IO_ReadOnly) ) { // file opened successfully 537 if ( f.open(IO_ReadOnly) ) { // file opened successfully
538 QTextStream t( &f ); // use a text stream 538 QTextStream t( &f ); // use a text stream
539 s = t.read(); 539 s = t.read();
540 f.close(); 540 f.close();
541 541
542 start = 0; 542 start = 0;
543 del = "\n.\n"; 543 del = "\n.\n";
544 while ((uint) start < s.length()) { 544 while ((uint) start < s.length()) {
545 stop = s.find(del, start); 545 stop = s.find(del, start);
546 if (stop == -1) 546 if (stop == -1)
547 stop = s.length() - del.length(); 547 stop = s.length() - del.length();
548 548
549 mail.rawMail = s.mid(start, stop + del.length() - start ); 549 mail.rawMail = s.mid(start, stop + del.length() - start );
550 start = stop + del.length(); 550 start = stop + del.length();
551 mailArrived(mail, TRUE); 551 mailArrived(mail, TRUE);
552 } 552 }
553 } 553 }
554 554
555 QFile fo(getPath(FALSE) + "outbox.txt"); 555 QFile fo(getPath(FALSE) + "outbox.txt");
556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully 556 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
557 QTextStream t( &fo ); // use a text stream 557 QTextStream t( &fo ); // use a text stream
558 s = t.read(); 558 s = t.read();
559 fo.close(); 559 fo.close();
560 560
561 start = 0; 561 start = 0;
562 del = "\n.\n"; 562 del = "\n.\n";
563 while ((uint) start < s.length()) { 563 while ((uint) start < s.length()) {
564 stop = s.find(del, start); 564 stop = s.find(del, start);
565 if (stop == -1) 565 if (stop == -1)
566 stop = s.length() - del.length(); 566 stop = s.length() - del.length();
567 567
568 mail.rawMail = s.mid(start, stop + del.length() - start ); 568 mail.rawMail = s.mid(start, stop + del.length() - start );
569 start = stop + del.length(); 569 start = stop + del.length();
570 emailHandler->parse(mail.rawMail, lineShift, &mail); 570 emailHandler->parse(mail.rawMail, lineShift, &mail);
571 mail.sent = false; 571 mail.sent = false;
572 mail.received = false; 572 mail.received = false;
573 enqueMail(mail); 573 enqueMail(mail);
574 574
575 } 575 }
576 } 576 }
577} 577}
578 578
579void EmailClient::saveMail(QString fileName, QListView *view) 579void EmailClient::saveMail(QString fileName, QListView *view)
580{ 580{
581 QFile f(fileName); 581 QFile f(fileName);
582 Email *mail; 582 Email *mail;
583 583
584 if (! f.open(IO_WriteOnly) ) { 584 if (! f.open(IO_WriteOnly) ) {
585 qWarning("could not open file"); 585 qWarning("could not open file");
586 return; 586 return;
587 } 587 }
588 item = (EmailListItem *) view->firstChild(); 588 item = (EmailListItem *) view->firstChild();
589 qDebug (QString("Write : ") ); 589 qDebug (QString("Write : ") );
590 QTextStream t(&f); 590 QTextStream t(&f);
591 while (item != NULL) { 591 while (item != NULL) {
592 mail = item->getMail(); 592 mail = item->getMail();
593 qDebug(mail->rawMail); 593 qDebug(mail->rawMail);
594 qDebug(mail->recipients.first()); 594 qDebug(mail->recipients.first());
595 t << mail->rawMail; 595 t << mail->rawMail;
596 596
597 mailconf->setGroup(mail->id); 597 mailconf->setGroup(mail->id);
598 mailconf->writeEntry("mailread", mail->read); 598 mailconf->writeEntry("mailread", mail->read);
599 599
600 item = (EmailListItem *) item->nextSibling(); 600 item = (EmailListItem *) item->nextSibling();
601 } 601 }
602 f.close(); 602 f.close();
603} 603}
604 604
605//paths for mailit, is settings, inbox, enclosures 605//paths for mailit, is settings, inbox, enclosures
606QString EmailClient::getPath(bool enclosurePath) 606QString EmailClient::getPath(bool enclosurePath)
607{ 607{
608 QString basePath = "qtmail"; 608 QString basePath = "qtmail";
609 QString enclosures = "enclosures"; 609 QString enclosures = "enclosures";
610 610
611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); 611 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
612 if ( !dir.exists() ) 612 if ( !dir.exists() )
613 dir.mkdir( dir.path() ); 613 dir.mkdir( dir.path() );
614 614
615 if (enclosurePath) { 615 if (enclosurePath) {
616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); 616 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
617 617
618 if ( !dir.exists() ) 618 if ( !dir.exists() )
619 dir.mkdir( dir.path() ); 619 dir.mkdir( dir.path() );
620 620
621 return (dir.path() + "/"); 621 return (dir.path() + "/");
622 622
623 } 623 }
624 return (dir.path() + "/"); 624 return (dir.path() + "/");
625} 625}
626 626
627void EmailClient::readSettings() 627void EmailClient::readSettings()
628{ 628{
629 TextParser *p; 629 TextParser *p;
630 QString s; 630 QString s;
631 int pos, accountPos, y; 631 int pos, accountPos, y;
632 QFile f( getPath(FALSE) + "settings.txt"); 632 QFile f( getPath(FALSE) + "settings.txt");
633 633
634 if ( f.open(IO_ReadOnly) ) { // file opened successfully 634 if ( f.open(IO_ReadOnly) ) { // file opened successfully
635 QTextStream t( &f ); // use a text stream 635 QTextStream t( &f ); // use a text stream
636 s = t.read(); 636 s = t.read();
637 f.close(); 637 f.close();
638 638
639 p = new TextParser(s, "\n"); 639 p = new TextParser(s, "\n");
640 640
641 accountPos = 0; 641 accountPos = 0;
642 while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { 642 while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) {
643 accountPos++; 643 accountPos++;
644 if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) 644 if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 )
645 account.accountName = p->getString(& ++pos, 'z', TRUE); 645 account.accountName = p->getString(& ++pos, 'z', TRUE);
646 if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) 646 if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1)
647 account.name = p->getString(& ++pos, 'z', TRUE); 647 account.name = p->getString(& ++pos, 'z', TRUE);
648 if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) 648 if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1)
649 account.emailAddress = p->getString(& ++pos, 'z', TRUE); 649 account.emailAddress = p->getString(& ++pos, 'z', TRUE);
650 if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) 650 if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1)
651 account.popUserName = p->getString(& ++pos, 'z', TRUE); 651 account.popUserName = p->getString(& ++pos, 'z', TRUE);
652 if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) 652 if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1)
653 account.popPasswd = p->getString(& ++pos, 'z', TRUE); 653 account.popPasswd = p->getString(& ++pos, 'z', TRUE);
654 if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) 654 if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1)
655 account.popServer = p->getString(& ++pos, 'z', TRUE); 655 account.popServer = p->getString(& ++pos, 'z', TRUE);
656 if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) 656 if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1)
657 account.smtpServer = p->getString(& ++pos, 'z', TRUE); 657 account.smtpServer = p->getString(& ++pos, 'z', TRUE);
658 if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { 658 if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) {
659 s = p->getString(& ++pos, 'z', TRUE); 659 s = p->getString(& ++pos, 'z', TRUE);
660 account.id = s.toInt(); 660 account.id = s.toInt();
661 } 661 }
662 662
663 account.lastServerMailCount = 0; 663 account.lastServerMailCount = 0;
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp
index f9b6de2..fd49c1f 100644
--- a/noncore/unsupported/mailit/mailitwindow.cpp
+++ b/noncore/unsupported/mailit/mailitwindow.cpp
@@ -1,132 +1,136 @@
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 "mailitwindow.h" 20#include "mailitwindow.h"
21 21
22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 22MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
23 : QMainWindow(parent, name, fl) 23 : QMainWindow(parent, name, fl)
24{ 24{
25 currentCaption = "Mailit"; 25 currentCaption = "Mailit";
26 setCaption(tr(currentCaption)); 26 setCaption(tr(currentCaption));
27 views = new QWidgetStack(this); 27 views = new QWidgetStack(this);
28 setCentralWidget(views); 28 setCentralWidget(views);
29 29
30 qWarning("***Starting writeMail");
30 emailClient = new EmailClient(views, "client"); 31 emailClient = new EmailClient(views, "client");
31 writeMail = new WriteMail(views, "writing"); 32 writeMail = new WriteMail(views, "writing");
32 readMail = new ReadMail(views, "reading"); 33 readMail = new ReadMail(views, "reading");
34 qWarning("***Finished readMail");
33 35
34 views->raiseWidget(emailClient); 36 views->raiseWidget(emailClient);
35 37
36 connect(emailClient, SIGNAL(composeRequested()), 38 connect(emailClient, SIGNAL(composeRequested()),
37 this, SLOT(compose()) ); 39 this, SLOT(compose()) );
38 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, 40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
39 SLOT(viewMail(QListView *, Email *)) ); 41 SLOT(viewMail(QListView *, Email *)) );
40 connect(emailClient, SIGNAL(mailUpdated(Email *)), this, 42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
41 SLOT(updateMailView(Email *)) ); 43 SLOT(updateMailView(Email *)) );
42 44
43 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); 45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
44 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, 46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
45 SLOT(showEmailClient()) ); 47 SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, 48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
47 SLOT(enqueMail(const Email &)) ); 49 SLOT(enqueMail(const Email &)) );
48 50
49 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); 51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
50 connect(readMail, SIGNAL(replyRequested(Email &)), this, 52 connect(readMail, SIGNAL(replyRequested(Email &)), this,
51 SLOT(composeReply(Email &)) ); 53 SLOT(composeReply(Email &)) );
52 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, 54 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
53 SLOT(deleteMail(EmailListItem *, bool &)) ); 55 SLOT(deleteMail(EmailListItem *, bool &)) );
54 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, 56 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
55 SLOT(moveMailFront(Email *)) ); 57 SLOT(moveMailFront(Email *)) );
56 58
57 connect(emailClient, SIGNAL(newCaption(const QString &)), 59 connect(emailClient, SIGNAL(newCaption(const QString &)),
58 this, SLOT(updateCaption(const QString &)) ); 60 this, SLOT(updateCaption(const QString &)) );
59 viewingMail = FALSE; 61 viewingMail = FALSE;
62
63 qWarning("***Finished MailitWindow");
60} 64}
61 65
62MailItWindow::~MailItWindow() 66MailItWindow::~MailItWindow()
63{ 67{
64} 68}
65 69
66void MailItWindow::closeEvent(QCloseEvent *e) 70void MailItWindow::closeEvent(QCloseEvent *e)
67{ 71{
68 if (views->visibleWidget() == emailClient) { 72 if (views->visibleWidget() == emailClient) {
69 e->accept(); 73 e->accept();
70 } else { 74 } else {
71 showEmailClient(); 75 showEmailClient();
72 } 76 }
73} 77}
74 78
75void MailItWindow::compose() 79void MailItWindow::compose()
76{ 80{
77 viewingMail = FALSE; 81 viewingMail = FALSE;
78 emailClient->hide(); 82 emailClient->hide();
79 readMail->hide(); 83 readMail->hide();
80 views->raiseWidget(writeMail); 84 views->raiseWidget(writeMail);
81 writeMail->setAddressList(emailClient->getAdrListRef()); 85 writeMail->setAddressList(emailClient->getAdrListRef());
82 setCaption( tr( "Write mail" ) ); 86 setCaption( tr( "Write mail" ) );
83} 87}
84 88
85void MailItWindow::composeReply(Email &mail) 89void MailItWindow::composeReply(Email &mail)
86{ 90{
87 compose(); 91 compose();
88 writeMail->reply(mail); 92 writeMail->reply(mail);
89} 93}
90 94
91void MailItWindow::showEmailClient() 95void MailItWindow::showEmailClient()
92{ 96{
93 viewingMail = FALSE; 97 viewingMail = FALSE;
94 writeMail->hide(); 98 writeMail->hide();
95 readMail->hide(); 99 readMail->hide();
96 views->raiseWidget(emailClient); 100 views->raiseWidget(emailClient);
97 setCaption( tr(currentCaption) ); 101 setCaption( tr(currentCaption) );
98} 102}
99 103
100void MailItWindow::viewMail(QListView *view, Email *mail) 104void MailItWindow::viewMail(QListView *view, Email *mail)
101{ 105{
102 viewingMail = TRUE; 106 viewingMail = TRUE;
103 emailClient->hide(); 107 emailClient->hide();
104 readMail->update(view, mail); 108 readMail->update(view, mail);
105 views->raiseWidget(readMail); 109 views->raiseWidget(readMail);
106 setCaption( tr( "Examine mail" ) ); 110 setCaption( tr( "Examine mail" ) );
107} 111}
108 112
109void MailItWindow::updateMailView(Email *mail) 113void MailItWindow::updateMailView(Email *mail)
110{ 114{
111 if (viewingMail) { 115 if (viewingMail) {
112 readMail->mailUpdated(mail); 116 readMail->mailUpdated(mail);
113 } 117 }
114} 118}
115 119
116void MailItWindow::updateCaption(const QString &newCaption) 120void MailItWindow::updateCaption(const QString &newCaption)
117{ 121{
118 currentCaption = newCaption; 122 currentCaption = newCaption;
119 setCaption(tr(currentCaption)); 123 setCaption(tr(currentCaption));
120} 124}
121 125
122void MailItWindow::setDocument(const QString &_address) 126void MailItWindow::setDocument(const QString &_address)
123{ 127{
124 // strip leading 'mailto:' 128 // strip leading 'mailto:'
125 QString address = _address; 129 QString address = _address;
126 if (address.startsWith("mailto:")) 130 if (address.startsWith("mailto:"))
127 address = address.mid(6); 131 address = address.mid(6);
128 132
129 compose(); 133 compose();
130 writeMail->setRecipient(address); 134 writeMail->setRecipient(address);
131} 135}
132 136
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp
index 86f119f..b6f5015 100644
--- a/noncore/unsupported/mailit/viewatt.cpp
+++ b/noncore/unsupported/mailit/viewatt.cpp
@@ -1,109 +1,118 @@
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 <qpe/applnk.h> 22#include <qpe/applnk.h>
23#include <qpe/mimetype.h>
23 24
24ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 25ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
25 : QMainWindow(parent, name, f) 26 : QMainWindow(parent, name, f)
26{ 27{
27 setCaption("Exploring attatchments"); 28 setCaption("Exploring attatchments");
28 29
29 setToolBarsMovable( FALSE ); 30 setToolBarsMovable( FALSE );
30 bar = new QToolBar(this); 31 bar = new QToolBar(this);
31 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 32 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
32 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 33 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
33 34
34 listView = new QListView(this, "AttView"); 35 listView = new QListView(this, "AttView");
35 listView->addColumn( "Attatchment" ); 36 listView->addColumn( "Attatchment" );
36 listView->addColumn( "Type" ); 37 listView->addColumn( "Type" );
37 listView->addColumn( "Installed" ); 38 listView->addColumn( "Installed" );
38 setCentralWidget(listView); 39 setCentralWidget(listView);
39} 40}
40 41
41void ViewAtt::update(Email *mailIn, bool inbox) 42void ViewAtt::update(Email *mailIn, bool inbox)
42{ 43{
43 QListViewItem *item; 44 QListViewItem *item;
44 Enclosure *ePtr; 45 Enclosure *ePtr;
45 46
47
48
46 listView->clear(); 49 listView->clear();
47 if (inbox) { 50 if (inbox) {
48 bar->clear(); 51 bar->clear();
49 installButton->addTo( bar ); 52 installButton->addTo( bar );
50 bar->show(); 53 bar->show();
51 } else { 54 } else {
52 bar->hide(); 55 bar->hide();
53 } 56 }
54 57
55 mail = mailIn; 58 mail = mailIn;
56 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 59 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
57 60
58 QString isInstalled = "No"; 61 QString isInstalled = "No";
59 if (ePtr->installed) 62 if (ePtr->installed)
60 isInstalled = "Yes"; 63 isInstalled = "Yes";
61 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 64 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
62 65
66 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
67
68 MimeType mt(mtypeDef);
69
70 item->setPixmap(0, mt.pixmap());
71
72 /*
63 if (ePtr->contentType == "TEXT") { 73 if (ePtr->contentType == "TEXT") {
64 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 74 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
65 actions->addTo(bar); 75 actions->addTo(bar);
66 item->setPixmap(0, Resource::loadPixmap("txt")); 76 }
67 }
68 if (ePtr->contentType == "AUDIO") { 77 if (ePtr->contentType == "AUDIO") {
69 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 78 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
70 actions->addTo(bar); 79 actions->addTo(bar);
71 item->setPixmap(0, Resource::loadPixmap("play")); 80 item->setPixmap(0, Resource::loadPixmap("play"));
72 } 81 }
73 if (ePtr->contentType == "IMAGE") { 82 if (ePtr->contentType == "IMAGE") {
74 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 83 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
75 actions->addTo(bar); 84 actions->addTo(bar);
76 item->setPixmap(0, Resource::loadPixmap("pixmap")); 85 item->setPixmap(0, Resource::loadPixmap("pixmap"));
77 } 86 }*/
78 } 87 }
79} 88}
80 89
81void ViewAtt::install() 90void ViewAtt::install()
82{ 91{
83 Enclosure *ePtr, *selPtr; 92 Enclosure *ePtr, *selPtr;
84 QListViewItem *item; 93 QListViewItem *item;
85 QString filename; 94 QString filename;
86 DocLnk d; 95 DocLnk d;
87 96
88 item = listView->selectedItem(); 97 item = listView->selectedItem();
89 if (item != NULL) { 98 if (item != NULL) {
90 filename = item->text(0); 99 filename = item->text(0);
91 selPtr = NULL; 100 selPtr = NULL;
92 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 101 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
93 if (ePtr->originalName == filename) 102 if (ePtr->originalName == filename)
94 selPtr = ePtr; 103 selPtr = ePtr;
95 } 104 }
96 105
97 if (selPtr == NULL) { 106 if (selPtr == NULL) {
98 qWarning("Internal error, file is not installed to documents"); 107 qWarning("Internal error, file is not installed to documents");
99 return; 108 return;
100 } 109 }
101 110
102 d.setName(selPtr->originalName); 111 d.setName(selPtr->originalName);
103 d.setFile(selPtr->path + selPtr->name); 112 d.setFile(selPtr->path + selPtr->name);
104 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 113 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
105 d.writeLink(); 114 d.writeLink();
106 selPtr->installed = TRUE; 115 selPtr->installed = TRUE;
107 item->setText(2, "Yes"); 116 item->setText(2, "Yes");
108 } 117 }
109} 118}
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp
index 70332a9..a45cfd2 100644
--- a/noncore/unsupported/mailit/writemail.cpp
+++ b/noncore/unsupported/mailit/writemail.cpp
@@ -1,297 +1,298 @@
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 "writemail.h" 21#include "writemail.h"
22#include "resource.h" 22#include "resource.h"
23 23
24WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) 24WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl )
25 : QMainWindow( parent, name, fl ) 25 : QMainWindow( parent, name, fl )
26{ 26{
27 showingAddressList = FALSE; 27 showingAddressList = FALSE;
28 init(); 28 init();
29 29
30 addAtt = new AddAtt(0, "Add Attatchments"); 30 addAtt = new AddAtt(0, "Add Attatchments");
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 Contact *cPtr; 40 Contact *cPtr;
41 41
42 addressList = list; 42 addressList = list;
43 43
44 addressView->clear(); 44 addressView->clear();
45 QList<Contact> *cListPtr = addressList->getContactList(); 45 QList<Contact> *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->email, cPtr->name); 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 attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); 67 attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0);
68 attatchButton->addTo(bar); 68 attatchButton->addTo(bar);
69 attatchButton->addTo(addMenu); 69 attatchButton->addTo(addMenu);
70 connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); 70 connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) );
71 71
72 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); 72 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0);
73 confirmButton->addTo(bar); 73 confirmButton->addTo(bar);
74 confirmButton->addTo(mailMenu); 74 confirmButton->addTo(mailMenu);
75 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); 75 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) );
76 76
77 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 77 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
78 newButton->addTo(mailMenu); 78 newButton->addTo(mailMenu);
79 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); 79 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
80 80
81 widget = new QWidget(this, "widget"); 81 widget = new QWidget(this, "widget");
82 grid = new QGridLayout( widget ); 82 grid = new QGridLayout( widget );
83 83
84 recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); 84 recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
85 recipientsBox->insertItem( tr( "To:" ) ); 85 recipientsBox->insertItem( tr( "To:" ) );
86 recipientsBox->insertItem( tr( "CC:" ) ); 86 recipientsBox->insertItem( tr( "CC:" ) );
87 recipientsBox->setCurrentItem(0); 87 recipientsBox->setCurrentItem(0);
88 grid->addWidget( recipientsBox, 0, 0 ); 88 grid->addWidget( recipientsBox, 0, 0 );
89 89
90 subjetLabel = new QLabel( widget, "subjetLabel" ); 90 subjetLabel = new QLabel( widget, "subjetLabel" );
91 subjetLabel->setText( tr( "Subject:" ) ); 91 subjetLabel->setText( tr( "Subject:" ) );
92 92
93 grid->addWidget( subjetLabel, 1, 0 ); 93 grid->addWidget( subjetLabel, 1, 0 );
94 94
95 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); 95 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
96 ToolButton13_2->setText( tr( "..." ) ); 96 ToolButton13_2->setText( tr( "..." ) );
97 grid->addWidget( ToolButton13_2, 1, 2 ); 97 grid->addWidget( ToolButton13_2, 1, 2 );
98 98
99 subjectInput = new QLineEdit( widget, "subjectInput" ); 99 subjectInput = new QLineEdit( widget, "subjectInput" );
100 grid->addWidget( subjectInput, 1, 1 ); 100 grid->addWidget( subjectInput, 1, 1 );
101 101
102 toInput = new QLineEdit( widget, "toInput" ); 102 toInput = new QLineEdit( widget, "toInput" );
103 grid->addWidget( toInput, 0, 1 ); 103 grid->addWidget( toInput, 0, 1 );
104 104
105 addressButton = new QToolButton( widget, "addressButton" ); 105 addressButton = new QToolButton( widget, "addressButton" );
106 addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); 106 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
107 addressButton->setToggleButton(TRUE); 107 addressButton->setToggleButton(TRUE);
108 grid->addWidget( addressButton, 0, 2 ); 108 grid->addWidget( addressButton, 0, 2 );
109 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); 109 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
110 110
111 emailInput = new QMultiLineEdit( widget, "emailInput" ); 111 emailInput = new QMultiLineEdit( widget, "emailInput" );
112 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); 112 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
113
113 114
114 addressView = new QListView( widget, "addressView"); 115 addressView = new QListView( widget, "addressView");
115 addressView->addColumn("Email");
116 addressView->addColumn("Name"); 116 addressView->addColumn("Name");
117 addressView->addColumn("EMail");
117 addressView->setAllColumnsShowFocus(TRUE); 118 addressView->setAllColumnsShowFocus(TRUE);
118 addressView->setMultiSelection(TRUE); 119 addressView->setMultiSelection(TRUE);
119 addressView->hide(); 120 addressView->hide();
120 grid->addMultiCellWidget( addressView, 3, 3, 0, 2); 121 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
121 122
122 okButton = new QToolButton(bar, "ok"); 123 okButton = new QToolButton(bar, "ok");
123 okButton->setPixmap( Resource::loadPixmap("enter") ); 124 okButton->setPixmap( Resource::loadPixmap("enter") );
124 okButton->hide(); 125 okButton->hide();
125 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); 126 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
126 127
127 setCentralWidget(widget); 128 setCentralWidget(widget);
128} 129}
129 130
130void WriteMail::reject() 131void WriteMail::reject()
131{ 132{
132 emit cancelMail(); 133 emit cancelMail();
133} 134}
134 135
135// need to insert date 136// need to insert date
136void WriteMail::accept() 137void WriteMail::accept()
137{ 138{
138 QStringList attatchedFiles, attatchmentsType; 139 QStringList attatchedFiles, attatchmentsType;
139 int idCount = 0; 140 int idCount = 0;
140 141
141 if (toInput->text() == "") { 142 if (toInput->text() == "") {
142 QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); 143 QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n");
143 return; 144 return;
144 } 145 }
145 if (! getRecipients() ) { 146 if (! getRecipients() ) {
146 QMessageBox::warning(this,"Incorrect recipient separator", 147 QMessageBox::warning(this,"Incorrect recipient separator",
147 "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); 148 "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n");
148 return; 149 return;
149 } 150 }
150 mail.subject = subjectInput->text(); 151 mail.subject = subjectInput->text();
151 mail.body = emailInput->text(); 152 mail.body = emailInput->text();
152 mail.sent = false; 153 mail.sent = false;
153 mail.received = false; 154 mail.received = false;
154 mail.rawMail = "To: "; 155 mail.rawMail = "To: ";
155 156
156 for (QStringList::Iterator it = mail.recipients.begin(); 157 for (QStringList::Iterator it = mail.recipients.begin();
157 it != mail.recipients.end(); ++it) { 158 it != mail.recipients.end(); ++it) {
158 159
159 mail.rawMail += (*it); 160 mail.rawMail += (*it);
160 mail.rawMail += ",\n"; 161 mail.rawMail += ",\n";
161 } 162 }
162 mail.rawMail.truncate(mail.rawMail.length()-2); 163 mail.rawMail.truncate(mail.rawMail.length()-2);
163 mail.rawMail += mail.from; 164 mail.rawMail += mail.from;
164 mail.rawMail += "\nSubject: "; 165 mail.rawMail += "\nSubject: ";
165 mail.rawMail += mail.subject; 166 mail.rawMail += mail.subject;
166 mail.rawMail += "\n\n"; 167 mail.rawMail += "\n\n";
167 168
168 attatchedFiles = addAtt->returnAttatchedFiles(); 169 attatchedFiles = addAtt->returnAttatchedFiles();
169 attatchmentsType = addAtt->returnFileTypes(); 170 attatchmentsType = addAtt->returnFileTypes();
170 171
171 QStringList::Iterator itType = attatchmentsType.begin(); 172 QStringList::Iterator itType = attatchmentsType.begin();
172 173
173 Enclosure e; 174 Enclosure e;
174 for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { 175 for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) {
175 e.id = idCount; 176 e.id = idCount;
176 e.originalName = (*it).latin1(); 177 e.originalName = (*it).latin1();
177 e.contentType = (*itType).latin1(); 178 e.contentType = (*itType).latin1();
178 e.contentAttribute = (*itType).latin1(); 179 e.contentAttribute = (*itType).latin1();
179 e.saved = TRUE; 180 e.saved = TRUE;
180 mail.addEnclosure(&e); 181 mail.addEnclosure(&e);
181 182
182 itType++; 183 itType++;
183 idCount++; 184 idCount++;
184 } 185 }
185 mail.rawMail += mail.body; 186 mail.rawMail += mail.body;
186 mail.rawMail += "\n"; 187 mail.rawMail += "\n";
187 mail.rawMail += ".\n"; 188 mail.rawMail += ".\n";
188 emit sendMailRequested(mail); 189 emit sendMailRequested(mail);
189 addAtt->clear(); 190 addAtt->clear();
190} 191}
191 192
192void WriteMail::getAddress() 193void WriteMail::getAddress()
193{ 194{
194 showingAddressList = !showingAddressList; 195 showingAddressList = !showingAddressList;
195 196
196 if (showingAddressList) { 197 if (showingAddressList) {
197 emailInput->hide(); 198 emailInput->hide();
198 addressView->show(); 199 addressView->show();
199 okButton->show(); 200 okButton->show();
200 201
201 } else { 202 } else {
202 addressView->hide(); 203 addressView->hide();
203 okButton->hide(); 204 okButton->hide();
204 emailInput->show(); 205 emailInput->show();
205 } 206 }
206} 207}
207 208
208void WriteMail::attatchFile() 209void WriteMail::attatchFile()
209{ 210{
210 addAtt->showMaximized(); 211 addAtt->showMaximized();
211} 212}
212 213
213void WriteMail::reply(Email replyMail) 214void WriteMail::reply(Email replyMail)
214{ 215{
215 int pos; 216 int pos;
216 217
217 mail = replyMail; 218 mail = replyMail;
218 mail.files.clear(); 219 mail.files.clear();
219 220
220 toInput->setText(mail.fromMail); 221 toInput->setText(mail.fromMail);
221 subjectInput->setText("Re: " + mail.subject); 222 subjectInput->setText("Re: " + mail.subject);
222 223
223 pos = 0; 224 pos = 0;
224 mail.body.insert(pos, ">>"); 225 mail.body.insert(pos, ">>");
225 while (pos != -1) { 226 while (pos != -1) {
226 pos = mail.body.find('\n', pos); 227 pos = mail.body.find('\n', pos);
227 if (pos != -1) 228 if (pos != -1)
228 mail.body.insert(++pos, ">>"); 229 mail.body.insert(++pos, ">>");
229 } 230 }
230 231
231 emailInput->setText(mail.body); 232 emailInput->setText(mail.body);
232} 233}
233 234
234bool WriteMail::getRecipients() 235bool WriteMail::getRecipients()
235{ 236{
236 QString str, temp; 237 QString str, temp;
237 int pos = 0; 238 int pos = 0;
238 239
239 mail.recipients.clear(); 240 mail.recipients.clear();
240 241
241 temp = toInput->text(); 242 temp = toInput->text();
242 while ( (pos = temp.find(';')) != -1) { 243 while ( (pos = temp.find(';')) != -1) {
243 str = temp.left(pos).stripWhiteSpace(); 244 str = temp.left(pos).stripWhiteSpace();
244 temp = temp.right(temp.length() - (pos + 1)); 245 temp = temp.right(temp.length() - (pos + 1));
245 if ( str.find('@') == -1) 246 if ( str.find('@') == -1)
246 return false; 247 return false;
247 mail.recipients.append(str); 248 mail.recipients.append(str);
248 addressList->addContact(str, ""); 249 addressList->addContact(str, "");
249 } 250 }
250 temp = temp.stripWhiteSpace(); 251 temp = temp.stripWhiteSpace();
251 if ( temp.find('@') == -1) 252 if ( temp.find('@') == -1)
252 return false; 253 return false;
253 mail.recipients.append(temp); 254 mail.recipients.append(temp);
254 addressList->addContact(temp, ""); 255 addressList->addContact(temp, "");
255 256
256 return TRUE; 257 return TRUE;
257} 258}
258 259
259 260
260void WriteMail::addRecipients() 261void WriteMail::addRecipients()
261{ 262{
262 QString recipients = ""; 263 QString recipients = "";
263 264
264 mail.recipients.clear(); 265 mail.recipients.clear();
265 QListViewItem *item = addressView->firstChild(); 266 QListViewItem *item = addressView->firstChild();
266 while (item != NULL) { 267 while (item != NULL) {
267 if ( item->isSelected() ) { 268 if ( item->isSelected() ) {
268 if (recipients == "") { 269 if (recipients == "") {
269 recipients = item->text(0); 270 recipients = item->text(0);
270 } else { 271 } else {
271 recipients += "; " + item->text(0); 272 recipients += "; " + item->text(0);
272 } 273 }
273 } 274 }
274 item = item->nextSibling(); 275 item = item->nextSibling();
275 } 276 }
276 toInput->setText(recipients); 277 toInput->setText(recipients);
277 278
278 addressView->hide(); 279 addressView->hide();
279 okButton->hide(); 280 okButton->hide();
280 emailInput->show(); 281 emailInput->show();
281 addressButton->setOn(FALSE); 282 addressButton->setOn(FALSE);
282 showingAddressList = !showingAddressList; 283 showingAddressList = !showingAddressList;
283} 284}
284 285
285void WriteMail::setRecipient(const QString &recipient) 286void WriteMail::setRecipient(const QString &recipient)
286{ 287{
287 toInput->setText(recipient); 288 toInput->setText(recipient);
288} 289}
289 290
290void WriteMail::newMail() 291void WriteMail::newMail()
291{ 292{
292 toInput->clear(); 293 toInput->clear();
293 subjectInput->clear(); 294 subjectInput->clear();
294 emailInput->clear(); 295 emailInput->clear();
295 //to clear selected 296 //to clear selected
296 setAddressList(addressList); 297 setAddressList(addressList);
297} 298}