summaryrefslogtreecommitdiff
authoralwin <alwin>2004-02-22 23:56:05 (UTC)
committer alwin <alwin>2004-02-22 23:56:05 (UTC)
commiteba25a5ebeca30b7124e7fae80685dbd1c9a985d (patch) (unidiff)
treed62dd266e9b57f3eae34612f5d0fc4cf0b625c20
parent666a49773d06ac94c19996d763854725c2f7a578 (diff)
downloadopie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.zip
opie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.tar.gz
opie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.tar.bz2
moved mailit into unsupported area 'cause replaced by opiemail3
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/.cvsignore2
-rw-r--r--noncore/net/mailit/README83
-rw-r--r--noncore/net/mailit/addatt.cpp224
-rw-r--r--noncore/net/mailit/addatt.h76
-rw-r--r--noncore/net/mailit/addresslist.cpp161
-rw-r--r--noncore/net/mailit/addresslist.h58
-rw-r--r--noncore/net/mailit/config.in4
-rw-r--r--noncore/net/mailit/editaccount.cpp133
-rw-r--r--noncore/net/mailit/editaccount.h69
-rw-r--r--noncore/net/mailit/emailclient.cpp1042
-rw-r--r--noncore/net/mailit/emailclient.h181
-rw-r--r--noncore/net/mailit/emailhandler.cpp630
-rw-r--r--noncore/net/mailit/emailhandler.h150
-rw-r--r--noncore/net/mailit/emaillistitem.cpp158
-rw-r--r--noncore/net/mailit/emaillistitem.h45
-rw-r--r--noncore/net/mailit/mailit.pro40
-rw-r--r--noncore/net/mailit/mailitwindow.cpp168
-rw-r--r--noncore/net/mailit/mailitwindow.h65
-rw-r--r--noncore/net/mailit/maillist.cpp131
-rw-r--r--noncore/net/mailit/maillist.h50
-rw-r--r--noncore/net/mailit/main.cpp25
-rw-r--r--noncore/net/mailit/md5.c251
-rw-r--r--noncore/net/mailit/md5.h55
-rw-r--r--noncore/net/mailit/opie-mailit.control9
-rw-r--r--noncore/net/mailit/popclient.cpp332
-rw-r--r--noncore/net/mailit/popclient.h77
-rw-r--r--noncore/net/mailit/readmail.cpp399
-rw-r--r--noncore/net/mailit/readmail.h95
-rw-r--r--noncore/net/mailit/smtpclient.cpp170
-rw-r--r--noncore/net/mailit/smtpclient.h76
-rw-r--r--noncore/net/mailit/textparser.cpp304
-rw-r--r--noncore/net/mailit/textparser.h85
-rw-r--r--noncore/net/mailit/viewatt.cpp121
-rw-r--r--noncore/net/mailit/viewatt.h46
-rw-r--r--noncore/net/mailit/writemail.cpp402
-rw-r--r--noncore/net/mailit/writemail.h96
-rw-r--r--packages2
37 files changed, 1 insertions, 6014 deletions
diff --git a/noncore/net/mailit/.cvsignore b/noncore/net/mailit/.cvsignore
deleted file mode 100644
index 6fc3d98..0000000
--- a/noncore/net/mailit/.cvsignore
+++ b/dev/null
@@ -1,2 +0,0 @@
1Makefile
2qpeobj
diff --git a/noncore/net/mailit/README b/noncore/net/mailit/README
deleted file mode 100644
index 01781b4..0000000
--- a/noncore/net/mailit/README
+++ b/dev/null
@@ -1,83 +0,0 @@
1Issues regarding Mailit
2-----------------------
3
4Mailit is still in development and is lacking some
5features to make it completely usable. Listed below are the
6most important issues.
7
8Due to the development status, numerous messages are passed too
9the console during usage of the program.
10No messages are deleted from the POP server after retrival.
11
12Synchronization:
13---------------------
14Works by comparing the last known size of the mailbox on the server
15to the current size.
16Possible problem: If a popserver shuffles the order of the mails
17when it receives a new mail, mailit won't know since it only uses
18the messagecount as a reference. If this occurs, turn sync off in
19the account settings.
20Haven't encountered this problem on the currently tested servers,
21but if it turns out that several servers do this, it will be resolved.
22
23Mail parsing
24------------
25Parsing of MIME-encoded email works for all currently tested cases.
26BASE64 decoding works.
27Attatchments are saved in the enclosure subdirectory of qtmail
28(in the Documents directory). You can install the files to the documents
29folder (creates a doclnk)
30Adding enclosures is limited to the preselected directories, and they
31are not really correct at the moment (trivial issue awaiting decision
32of fileplacements in QPE)
33attatched pictures will be displayed (jpg dependant on qte compilation)
34
35
36SMTP
37----
38The SMTP-client now supports attatchments, but it's not completly done.
39Encoding works, but it doesn't examine the file to check what type of
40file you are attatching. In other words, if it doesn't know that you
41are attatching a picture, the mime setting for content type could be
42wrong. Mail clients with inline viewing of pictures (like hotmail) could
43have a problem with displaying the mail correctly.
44(Should be fixed soon)
45
46You can now have multiple recipients.
47
48
49POP
50---
51The popclient connects to the all accounts in turn, downloads all headers
52and emails smaller than 2000 bytes. After its done, it reconnects
53and downloads the mails that were too big (> 2000)
54The to-be-downloaded mails are sorted according to size. If you view
55a mail, it is shifted to the front of the queue. Deleting a mail(header)
56while the download is in progress will remove it from the queue of
57mails to download (except if the mail is currently in transfer)
58You may exit mailit during a transfer of mails/headers. Next time
59you reconnect to the same server it will continue downloading from
60where it left off.
61
62You can now choose between getting mail from only one account or all.
63The get all option is just added and not fully testet yet. Get from
64a single account should work fine. The current way of downloading
65does not work well without sync turned on if you keep old mails in
66the inbox.
67
68Experienced some problems with servers reporting mail size less and
69bigger than actual size. Don't know whats causing this yet, but I
70have added a workaround. It now scans the mail for endofmail
71definition ("\r\n.\r\n"), disregarding size.
72
73
74Saving/Retrieving mail
75----------------------
76The inbox is saved and retrieved. Any mail not sent from the outbox
77is not saved (will of course be added)
78
79Miscelaneous issues
80-------------------
81Numerous cosmetic changes, including icons (which are temporary)
82
83Very little error checking is done on usertyped variables.
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp
deleted file mode 100644
index 19ac58f..0000000
--- a/noncore/net/mailit/addatt.cpp
+++ b/dev/null
@@ -1,224 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qlayout.h>
21#include <qhbox.h>
22#include <qdir.h>
23#include <qstringlist.h>
24#include <qpe/resource.h>
25#include "addatt.h"
26
27FileItem::FileItem(QListView *parent, DocLnk* dl)
28 : QListViewItem(parent)
29{
30 /*file = fileInfo;
31 type = fileType;*/
32
33 doclnk=dl;
34
35 setText(0, doclnk->name());
36
37 /*if (fileType == "Picture") {
38 setPixmap(0, Resource::loadPixmap("pixmap"));
39 } else if (fileType == "Document") {
40 setPixmap(0, Resource::loadPixmap("txt"));
41 } else if (fileType == "Sound") {
42 setPixmap(0, Resource::loadPixmap("play"));
43 } else if (fileType == "Movie") {
44 setPixmap(0, Resource::loadPixmap("MPEGPlayer"));
45 } else if (fileType == "File") {
46 setPixmap(0, Resource::loadPixmap("exec"));
47 }*/
48}
49
50FileItem::~FileItem()
51{
52 if (doclnk!=NULL) delete doclnk;
53 doclnk=NULL;
54}
55
56AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f)
57 : QDialog(parent, name, f)
58{
59 setCaption(tr("Adding attachments") );
60
61 QGridLayout *top = new QGridLayout(this, 1,1 );
62
63 QHBox *buttons=new QHBox(this);
64 /*fileCategoryButton = new QPushButton(this);*/
65 attachButton = new QPushButton(tr("attach..."), buttons);
66 removeButton = new QPushButton(tr("Remove"), buttons);
67
68 /*fileCategories = new QPopupMenu(fileCategoryButton);
69 fileCategoryButton->setPopup(fileCategories);
70 fileCategories->insertItem("Document");
71 fileCategories->insertItem("Picture");
72 fileCategories->insertItem("Sound");
73 fileCategories->insertItem("Movie");
74 fileCategories->insertItem("File");
75
76 fileCategoryButton->setText("Document");
77 top->addWidget(fileCategoryButton, 0, 0);*/
78
79
80 top->addWidget(buttons,1,0);
81 //buttons->addWidget(attachButton,0,0);
82 //buttons->addWidget(removeButton,0,1);
83
84 //connect(fileCategories, SIGNAL(activated(int)), this,
85 //SLOT(fileCategorySelected(int)) );*/
86 connect(attachButton, SIGNAL(clicked()), this,
87 SLOT(addattachment()) );
88 connect(removeButton, SIGNAL(clicked()), this,
89 SLOT(removeattachment()) );
90
91 /*listView = new QListView(this, "AttView");
92 listView->addColumn("Documents");*
93 connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this,
94 SLOT(addattachment()) );*/
95
96
97 attView = new QListView(this, "Selected");
98 attView->addColumn(tr("Attached"));
99 attView->addColumn(tr("File type"));
100 connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this,
101 SLOT(removeattachment()) );
102
103 //top->addWidget(ofs, 0,0);
104 top->addWidget(attView, 0,0);
105
106 clear();
107
108
109}
110
111void AddAtt::clear()
112{
113 attView->clear();
114 //getFiles();
115 modified = FALSE;
116}
117
118/*void AddAtt::fileCategorySelected(int id)
119{
120 fileCategoryButton->setText(fileCategories->text(id));
121 getFiles();
122}*/
123
124void AddAtt::addattachment()
125 {// ### FIXME wrong use -zecke
126 OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
127
128 ofs.showMaximized();
129
130 if (ofs.exec()==QDialog::Accepted)
131 {
132 DocLnk* dl=new DocLnk(ofs.selectedDocument());
133 FileItem* fi=new FileItem(attView,dl);
134 fi->setPixmap(0,dl->pixmap());
135 fi->setText(1,dl->type());
136 attView->insertItem(fi);
137 modified = TRUE;
138 }
139}
140
141void AddAtt::removeattachment()
142{
143 if (attView->selectedItem() != NULL)
144 {
145 attView->takeItem(attView->selectedItem());
146 }
147 modified = TRUE;
148}
149
150void AddAtt::reject()
151{
152 if (modified) {
153 attView->clear();
154 modified = FALSE;
155 }
156}
157
158void AddAtt::accept()
159{
160 modified = FALSE;
161 hide();
162}
163
164void AddAtt::getFiles()
165{
166 QString path, selected;
167
168 /*listView->clear();
169
170 selected = fileCategoryButton->text();
171 if (selected == "Picture") {
172 path = "../pics/";
173 } else if (selected == "Document") {
174 path = "" ; //sub-dirs not decided
175 } else if (selected == "Sound") {
176 path = "../sounds/"; //sub-dirs not decided
177 } else if (selected == "Movie") {
178 path = ""; //sub-dirs not decided
179 } else if (selected == "File") {
180 path = ""; //sub-dirs not decided
181 }
182
183 dir = new QDir(path);
184 dir->setFilter(QDir::Files);
185 const QFileInfoList *dirInfoList = dir->entryInfoList();
186
187 QFileInfoListIterator it(*dirInfoList); // create list iterator
188
189 while ( (fi=it.current()) ) { // for each file...
190 item = new FileItem(lis+ütView, *fi, selected);
191 ++it; // goto next list element
192 }*/
193}
194
195QStringList AddAtt::returnattachedFiles()
196{
197 QFileInfo info;
198 QStringList list;
199
200 item = (FileItem *) attView->firstChild();
201
202
203 while (item != NULL) {
204 DocLnk* dl=item->getDocLnk();
205 list+=dl->file();
206 /*info = item->getFileInfo();
207 list += info.filePath();*/
208 item = (FileItem *) item->nextSibling();
209 }
210 return list;
211}
212
213QStringList AddAtt::returnFileTypes()
214{
215 QStringList list;
216
217 item = (FileItem *) attView->firstChild();
218
219 while (item != NULL) {
220 list += item->getDocLnk()->type();
221 item = (FileItem *) item->nextSibling();
222 }
223 return list;
224}
diff --git a/noncore/net/mailit/addatt.h b/noncore/net/mailit/addatt.h
deleted file mode 100644
index a365947..0000000
--- a/noncore/net/mailit/addatt.h
+++ b/dev/null
@@ -1,76 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef ADDATT_H
21#define ADDATT_H
22
23#include <qdialog.h>
24#include <qlistview.h>
25#include <qpushbutton.h>
26#include <qpopupmenu.h>
27#include <qstring.h>
28#include <qfileinfo.h>
29#include <qstringlist.h>
30#include <opie/ofiledialog.h>
31#include <qpe/applnk.h>
32
33class FileItem : public QListViewItem
34{
35public:
36 //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType);
37 FileItem(QListView*, DocLnk*);
38 ~FileItem();
39 DocLnk* getDocLnk() {return doclnk;}
40
41
42private:
43 DocLnk* doclnk;
44};
45
46class AddAtt : public QDialog
47{
48 Q_OBJECT
49
50public:
51 AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
52 QStringList returnattachedFiles();
53 QStringList returnFileTypes();
54 void getFiles();
55 void clear();
56
57
58public slots:
59 //void fileCategorySelected(int);
60 void addattachment();
61 void removeattachment();
62 void reject();
63 void accept();
64
65private:
66 FileItem* item;
67 QListView *attView;
68 QPushButton *attachButton, *removeButton;
69 QPopupMenu *fileCategories;
70 bool modified;
71 //QFileInfo *fi;
72
73 OFileDialog* ofs;
74};
75
76#endif
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
deleted file mode 100644
index f2b027c..0000000
--- a/noncore/net/mailit/addresslist.cpp
+++ b/dev/null
@@ -1,161 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qfile.h>
21#include <qtextstream.h>
22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h>
24
25#include "addresslist.h"
26
27AddressList::AddressList()
28{
29 addresses.setAutoDelete(TRUE);
30 read();
31 dirty = FALSE;
32}
33
34AddressList::~AddressList()
35{
36 addresses.clear();
37}
38
39void AddressList::addContact(const QString &email, const QString &name)
40{
41 //skip if not a valid email address,
42 if (email.find( '@') == -1)
43 return;
44
45 if ( ! containsEmail(email) ) {
46 AContact *in = new AContact;
47 in->email = email;
48 in->name = name;
49 addresses.append(in);
50 dirty = TRUE;
51 }
52}
53
54bool AddressList::containsEmail(const QString &email)
55{
56 return ( getEmailRef(email) != -1 );
57}
58
59bool AddressList::containsName(const QString &name)
60{
61 return ( getNameRef(name) != -1 );
62}
63
64QString AddressList::getNameByEmail(const QString &email)
65{
66 int pos = getEmailRef(email);
67 if (pos != -1) {
68 AContact *ptr = addresses.at(pos);
69 return ptr->name;
70 }
71
72 return QString::null;
73}
74
75QString AddressList::getEmailByName(const QString &name)
76{
77 int pos = getNameRef(name);
78 if (pos != -1) {
79 AContact *ptr = addresses.at(pos);
80 return ptr->email;
81 }
82
83 return QString::null;
84}
85
86int AddressList::getEmailRef(const QString &email)
87{
88 int pos = 0;
89 AContact *ptr;
90
91 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
92 if (ptr->email == email)
93 return pos;
94 pos++;
95 }
96 return -1;
97}
98
99int AddressList::getNameRef(const QString &name)
100{
101 int pos = 0;
102 AContact *ptr;
103
104 for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) {
105 if (ptr->name == name)
106 return pos;
107 pos++;
108 }
109 return -1;
110}
111
112QList<AContact>* AddressList::getContactList()
113{
114 return &addresses;
115}
116
117void AddressList::read()
118{
119 OContactAccess::List::Iterator it;
120
121 QString lineEmail, lineName, email, name;
122 OContactAccess m_contactdb("mailit");
123 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
124 //OContact* oc;(*it).defaultEmail()
125
126 for ( it = m_list.begin(); it != m_list.end(); ++it )
127 {
128 //oc=(OContact*) it;
129 if ((*it).defaultEmail().length()!=0)
130 addContact((*it).defaultEmail(),(*it).fileAs());
131 }
132
133 /*if (! f.open(IO_ReadOnly) )
134 return;
135
136 QTextStream stream(&f);
137
138 while (! stream.atEnd() ) {
139 lineEmail = stream.readLine();
140 if (! stream.atEnd() )
141 lineName = stream.readLine();
142 else return;
143
144 email = getRightString(lineEmail);
145 name = getRightString(lineName);
146 addContact(email, name);
147 }
148 f.close();*/
149}
150
151QString AddressList::getRightString(const QString &in)
152{
153 QString out = "";
154
155 int pos = in.find('=');
156 if (pos != -1) {
157 out = in.mid(pos+1).stripWhiteSpace();
158 }
159 return out;
160}
161
diff --git a/noncore/net/mailit/addresslist.h b/noncore/net/mailit/addresslist.h
deleted file mode 100644
index 763b6d4..0000000
--- a/noncore/net/mailit/addresslist.h
+++ b/dev/null
@@ -1,58 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef ADDRESSLIST_H
21#define ADDRESSLIST_H
22
23#include <qobject.h>
24#include <qlist.h>
25
26struct AContact
27{
28 QString email;
29 QString name;
30};
31
32class AddressList : public QObject
33{
34 Q_OBJECT
35
36public:
37 AddressList();
38 ~AddressList();
39 void addContact(const QString &email, const QString &name);
40 bool containsEmail(const QString &email);
41 bool containsName(const QString &name);
42 QString getNameByEmail(const QString &email);
43 QString getEmailByName(const QString &name);
44 QList<AContact>* getContactList();
45
46private:
47 int getEmailRef(const QString &email);
48 int getNameRef(const QString &name);
49 QString getRightString(const QString &in);
50 void read();
51
52private:
53 QList<AContact> addresses;
54 QString filename;
55 bool dirty;
56};
57
58#endif
diff --git a/noncore/net/mailit/config.in b/noncore/net/mailit/config.in
deleted file mode 100644
index 142b840..0000000
--- a/noncore/net/mailit/config.in
+++ b/dev/null
@@ -1,4 +0,0 @@
1 config MAILIT
2 boolean "opie-mailit (a simple POP3 email client)"
3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/net/mailit/editaccount.cpp b/noncore/net/mailit/editaccount.cpp
deleted file mode 100644
index c0afbb2..0000000
--- a/noncore/net/mailit/editaccount.cpp
+++ b/dev/null
@@ -1,133 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18***
19**********************************************************************/
20
21#include <qhbox.h>
22#include "editaccount.h"
23
24EditAccount::EditAccount( QWidget* parent, const char* name, WFlags fl )
25 : QDialog(parent, name, fl)
26{
27 setCaption( tr("Edit Account") );
28 init();
29 popPasswInput->setEchoMode(QLineEdit::Password);
30}
31
32void EditAccount::setAccount(MailAccount *in, bool newOne)
33{
34 account = in;
35 if (newOne) {
36 accountNameInput->setText("");
37 nameInput->setText("");
38 emailInput->setText("");
39 popUserInput->setText("");
40 popPasswInput->setText("");
41 popServerInput->setText("");
42 smtpServerInput->setText("");
43 syncCheckBox->setChecked(TRUE);
44 syncLimitInput->setValue(2);
45
46 setCaption( tr("Create new Account") );
47 } else {
48 accountNameInput->setText(account->accountName);
49 nameInput->setText(account->name);
50 emailInput->setText(account->emailAddress);
51 popUserInput->setText(account->popUserName);
52 popPasswInput->setText(account->popPasswd);
53 popServerInput->setText(account->popServer);
54 smtpServerInput->setText(account->smtpServer);
55 syncCheckBox->setChecked(account->synchronize);
56 syncLimitInput->setValue(account->syncLimit/1000);
57 }
58}
59
60void EditAccount::init()
61{
62 grid = new QGridLayout(this);
63 grid->setSpacing( 6 );
64 grid->setMargin( 11 );
65
66 accountNameInputLabel = new QLabel(tr("Account name"), this);
67 grid->addWidget( accountNameInputLabel, 0, 0 );
68 accountNameInput = new QLineEdit( this, "account nameInput" );
69 grid->addWidget( accountNameInput, 0, 1 );
70
71 nameInputLabel = new QLabel(tr("Your name"), this);
72 grid->addWidget( nameInputLabel, 1, 0 );
73 nameInput = new QLineEdit( this, "nameInput" );
74 grid->addWidget( nameInput, 1, 1 );
75
76 emailInputLabel = new QLabel(tr("Email"), this);
77 grid->addWidget(emailInputLabel, 2, 0 );
78 emailInput = new QLineEdit( this, "emailInput" );
79 grid->addWidget( emailInput, 2, 1 );
80
81 popUserInputLabel = new QLabel(tr("POP username"), this);
82 grid->addWidget( popUserInputLabel, 3, 0 );
83 popUserInput = new QLineEdit( this, "popUserInput" );
84 grid->addWidget( popUserInput, 3, 1 );
85
86 popPasswInputLabel = new QLabel( tr("POP password"), this);
87 grid->addWidget( popPasswInputLabel, 4, 0 );
88 popPasswInput = new QLineEdit( this, "popPasswInput" );
89 grid->addWidget( popPasswInput, 4, 1 );
90
91 popServerInputLabel = new QLabel(tr("POP server"), this);
92 grid->addWidget( popServerInputLabel, 5, 0 );
93 popServerInput = new QLineEdit( this, "popServerInput" );
94 grid->addWidget( popServerInput, 5, 1 );
95
96 smtpServerInputLabel = new QLabel(tr("SMTP server"), this );
97 grid->addWidget( smtpServerInputLabel, 6, 0 );
98 smtpServerInput = new QLineEdit( this, "smtpServerInput" );
99 grid->addWidget( smtpServerInput, 6, 1 );
100
101 QHBox* syncBox=new QHBox(this);
102 grid->addWidget( syncBox, 7, 1 );
103
104 syncCheckBox = new QCheckBox( tr( "Synchronize" ), this);
105 syncCheckBox->setChecked( TRUE );
106 grid->addWidget( syncCheckBox,7,0);
107
108 syncLimitInputLabel = new QLabel(tr("Mail Size (k)"), syncBox);
109 //syncBox->addWidget( syncLimitInputLabel);
110 syncLimitInput = new QSpinBox( syncBox, "syncSize" );
111 //syncBox->addWidget(syncLimitInput);
112
113}
114
115
116void EditAccount::accept()
117{
118 account->accountName = accountNameInput->text();
119 account->name = nameInput->text();
120 account->emailAddress = emailInput->text();
121 account->popUserName = popUserInput->text();
122 account->popPasswd = popPasswInput->text();
123 account->popServer = popServerInput->text();
124 account->smtpServer = smtpServerInput->text();
125 account->synchronize = syncCheckBox->isChecked();
126 account->syncLimit = syncLimitInput->value()*1000;//Display in kB
127
128 QDialog::accept();
129}
130
131void EditAccount::reject()
132{
133}
diff --git a/noncore/net/mailit/editaccount.h b/noncore/net/mailit/editaccount.h
deleted file mode 100644
index 1e15047..0000000
--- a/noncore/net/mailit/editaccount.h
+++ b/dev/null
@@ -1,69 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef EDITACCOUNT_H
21#define EDITACCOUNT_H
22
23#include <qdialog.h>
24#include <qlabel.h>
25#include <qlineedit.h>
26#include <qcheckbox.h>
27#include <qlayout.h>
28#include <qspinbox.h>
29#include "emailhandler.h"
30
31class EditAccount : public QDialog
32{
33 Q_OBJECT
34
35public:
36 EditAccount( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
37 void setAccount(MailAccount *in, bool newOne = TRUE);
38 void init();
39
40public slots:
41 void accept();
42 void reject();
43
44private:
45 MailAccount thisAccount, *account;
46
47 QLabel *accountNameInputLabel;
48 QLabel *nameInputLabel;
49 QLabel *emailInputLabel;
50 QLabel *popUserInputLabel;
51 QLabel *popPasswInputLabel;
52 QLabel *popServerInputLabel;
53 QLabel *smtpServerInputLabel;
54 QLabel *syncLimitInputLabel;
55
56 QLineEdit *accountNameInput;
57 QLineEdit *nameInput;
58 QLineEdit *emailInput;
59 QLineEdit *popUserInput;
60 QLineEdit *popPasswInput;
61 QLineEdit *popServerInput;
62 QLineEdit *smtpServerInput;
63 QSpinBox *syncLimitInput;
64 QCheckBox *syncCheckBox;
65
66 QGridLayout *grid;
67};
68
69#endif
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
deleted file mode 100644
index 8359acf..0000000
--- a/noncore/net/mailit/emailclient.cpp
+++ b/dev/null
@@ -1,1042 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qapplication.h>
21#include <qmessagebox.h>
22#include <qvbox.h>
23#include <qfile.h>
24#include <qcheckbox.h>
25#include <qmenubar.h>
26#include <qaction.h>
27#include <qwhatsthis.h>
28#include <qpe/resource.h>
29#include "emailclient.h"
30#include "writemail.h"
31
32QCollection::Item AccountList::newItem(QCollection::Item d)
33{
34 return dupl( (MailAccount *) d);
35}
36
37MailAccount* AccountList::dupl(MailAccount *in)
38{
39 ac = new MailAccount(*in);
40 return ac;
41}
42
43EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
44 : QMainWindow( parent, name, fl )
45{
46 emailHandler = new EmailHandler();
47 addressList = new AddressList();
48
49 sending = FALSE;
50 receiving = FALSE;
51 previewingMail = FALSE;
52 mailIdCount = 1;
53 accountIdCount = 1;
54 allAccounts = FALSE;
55
56 init();
57
58
59
60 connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
61
62 connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this,
63 SLOT(smtpError(int,const QString &)) );
64 connect(emailHandler, SIGNAL(popError(int,const QString &)), this,
65 SLOT(popError(int,const QString &)) );
66
67 connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) );
68 connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) );
69
70 connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) );
71 connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) );
72
73 connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this,
74 SLOT(mailArrived(const Email &, bool)) );
75 connect(emailHandler, SIGNAL(mailTransfered(int)), this,
76 SLOT(allMailArrived(int)) );
77
78 mailconf = new Config("mailit");
79 //In case Synchronize is not defined in settings.txt
80
81 readSettings();
82
83 updateAccounts();
84
85 lineShift = "\n";
86 readMail();
87 lineShift = "\r\n";
88
89 mailboxView->setCurrentTab(0); //ensure that inbox has focus
90
91 /*channel = new QCopChannel( "QPE/Application/mailit", this );
92 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
93 this, SLOT(receive(const QCString&, const QByteArray&)) );*/
94
95}
96
97
98EmailClient::~EmailClient()
99{
100 //needs to be moved from destructor to closewindow event
101 saveMail(getPath(FALSE) + "inbox.txt", inboxView);
102 //does not currently work. Defining outbox in the same
103 //format as inbox is not a good solution as they have
104 //different properties
105 saveMail(getPath(FALSE) + "outbox.txt", outboxView);
106 saveSettings();
107
108 mailconf->write();
109 delete mailconf;
110
111}
112
113void EmailClient::init()
114{
115 initStatusBar(this);
116
117 setToolBarsMovable(FALSE);
118
119 bar = new QToolBar(this);
120 QWhatsThis::add(bar,tr("Main operation toolbar"));
121 bar->setHorizontalStretchable( TRUE );
122
123 mb = new QMenuBar( bar );
124
125 QPopupMenu *mail = new QPopupMenu(mb);
126 mb->insertItem( tr( "&Mail" ), mail);
127
128 QPopupMenu *configure = new QPopupMenu(mb);
129 mb->insertItem( tr( "Accounts" ), configure);
130
131 selectAccountMenu = new QPopupMenu(mb);
132 editAccountMenu = new QPopupMenu(mb);
133 deleteAccountMenu = new QPopupMenu(mb);
134
135 mail->insertItem(tr("Get Mail in"), selectAccountMenu);
136 configure->insertItem(tr("Edit account"), editAccountMenu);
137 configure->insertItem(tr("Delete account"), deleteAccountMenu);
138
139 bar = new QToolBar(this);
140
141 getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar);
142 QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account."));
143
144 getMailButton->setPopup(selectAccountMenu);
145
146 sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0);
147 connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) );
148 sendMailButton->addTo(bar);
149 sendMailButton->addTo(mail);
150 sendMailButton->setWhatsThis("Send mail queued in the outbox");
151
152 composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
153 connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
154 composeButton->addTo(bar);
155 composeButton->addTo(mail);
156 composeButton->setWhatsThis("Compose a new mail");
157
158 cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
159 connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
160 cancelButton->addTo(mail);
161 cancelButton->addTo(bar);
162 cancelButton->setEnabled(FALSE);
163 cancelButton->setWhatsThis("Stop the currently active mail transfer");
164
165
166 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
167 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
168 deleteButton->addTo(bar);
169 deleteButton->setWhatsThis("Remove the currently selected eMail(s)");
170
171 mailboxView = new OTabWidget( this, "mailboxView" );
172
173 QWidget* widget = new QWidget( mailboxView, "widget" );
174 grid_2 = new QGridLayout( widget );
175// grid_2->setSpacing(6);
176// grid_2->setMargin( 11 );
177
178 inboxView = new QListView( widget, "inboxView" );
179 inboxView->addColumn( tr( "From" ) );
180 inboxView->addColumn( tr( "Subject" ) );
181 inboxView->addColumn( tr( "Date" ) );
182 inboxView->setMinimumSize( QSize( 0, 0 ) );
183 inboxView->setAllColumnsShowFocus(TRUE);
184 QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n"
185 "It keeps the fetched mail which can be \n"
186 "viewed by double clicking the entry.\n"
187 "blue attachment icon shows whether this \n"
188 "mailhas attachments.\n"));
189
190 grid_2->addWidget( inboxView, 2, 0 );
191 mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) );
192
193 QWidget* widget_2 = new QWidget( mailboxView, "widget_2" );
194 grid_3 = new QGridLayout( widget_2 );
195// grid_3->setSpacing(6);
196// grid_3->setMargin( 11 );
197
198 outboxView = new QListView( widget_2, "outboxView" );
199 outboxView->addColumn( tr( "To" ) );
200 outboxView->addColumn( tr( "Subject" ) );
201 outboxView->setAllColumnsShowFocus(TRUE);
202
203 QWhatsThis::add(outboxView,QWidget::tr("This is the outbox view.\n"
204 "It keeps the queued mails to send which can be \n"
205 "reviewed by double clicking the entry."));
206 grid_3->addWidget( outboxView, 0, 0 );
207 mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
208
209 setCentralWidget(mailboxView);
210
211}
212
213void EmailClient::initStatusBar(QWidget* parent)
214{
215 statusBar = new QStatusBar(parent);
216 statusBar->setSizeGripEnabled(FALSE);
217
218 status1Label = new QLabel( tr("Idle"), statusBar);
219 status2Label = new QLabel("", statusBar);
220 connect(emailHandler, SIGNAL(updatePopStatus(const QString &)),
221 status2Label, SLOT(setText(const QString &)) );
222 connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)),
223 status2Label, SLOT(setText(const QString &)) );
224
225 progressBar = new QProgressBar(statusBar);
226
227 connect(emailHandler, SIGNAL(mailboxSize(int)),
228 this, SLOT(setTotalSize(int)) );
229 connect(emailHandler, SIGNAL(currentMailSize(int)),
230 this, SLOT(setMailSize(int)) );
231 connect(emailHandler, SIGNAL(downloadedSize(int)),
232 this, SLOT(setDownloadedSize(int)) );
233
234 statusBar->addWidget(status1Label);
235 statusBar->addWidget(progressBar);
236 statusBar->addWidget(status2Label);
237
238}
239
240void EmailClient::compose()
241{
242 emit composeRequested();
243}
244
245void EmailClient::cancel()
246{
247 emailHandler->cancel();
248}
249
250AddressList* EmailClient::getAdrListRef()
251{
252 return addressList;
253}
254
255//this needs to be rewritten to syncronize with outboxView
256void EmailClient::enqueMail(const Email &mail)
257{
258 if (accountList.count() == 0) {
259 QMessageBox::warning(qApp->activeWindow(),
260 tr("No account selected"), tr("You must create an account"), "OK\n");
261 return;
262 }
263
264 if (accountList.count() > 0) {
265 currentAccount = accountList.first();
266 qWarning("using account " + currentAccount->name);
267 }
268
269 Email addMail = mail;
270 addMail.from = currentAccount->name;
271 addMail.fromMail = currentAccount->emailAddress;
272 addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n");
273 item = new EmailListItem(outboxView, addMail, false);
274
275 mailboxView->setCurrentTab(1);
276
277}
278
279void EmailClient::sendQuedMail()
280{
281 int count = 0;
282
283 if (accountList.count() == 0) {
284 QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n");
285 return;
286 }
287 //traverse listview, find messages to send
288 if (! sending) {
289 item = (EmailListItem *) outboxView->firstChild();
290 if (item != NULL) {
291 while (item != NULL) {
292 quedMessages.append(item->getMail());
293 item = (EmailListItem *) item->nextSibling();
294 count++;
295 }
296 setMailAccount();
297 emailHandler->sendMail(&quedMessages);
298 sending = TRUE;
299 sendMailButton->setEnabled(FALSE);
300 cancelButton->setEnabled(TRUE);
301 } else {
302 qWarning("sendQuedMail(): no messages to send");
303 }
304 }
305}
306
307void EmailClient::setMailAccount()
308{
309 emailHandler->setAccount(*currentAccount);
310}
311
312void EmailClient::mailSent()
313{
314 sending = FALSE;
315 sendMailButton->setEnabled(TRUE);
316
317 quedMessages.clear();
318 outboxView->clear(); //should be moved to an sentBox
319}
320
321void EmailClient::getNewMail() {
322
323 if (accountList.count() == 0) {
324 QMessageBox::warning(qApp->activeWindow(),tr("No account selected"),
325 tr("You must create an account"), "OK\n");
326 return;
327 }
328
329 setMailAccount();
330
331 receiving = TRUE;
332 previewingMail = TRUE;
333 getMailButton->setEnabled(FALSE);
334 cancelButton->setEnabled(TRUE);
335 selectAccountMenu->setEnabled(FALSE);
336
337 status1Label->setText(currentAccount->accountName + " headers");
338 progressBar->reset();
339
340 //get any previous mails not downloaded and add to queue
341 /*mailDownloadList.clear();
342 Email *mailPtr;
343 item = (EmailListItem *) inboxView->firstChild();
344 while (item != NULL) {
345 mailPtr = item->getMail();
346 if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) {
347 mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
348 }
349 item = (EmailListItem *) item->nextSibling();
350 }*/
351
352 emailHandler->getMailHeaders();
353
354}
355
356void EmailClient::getAllNewMail()
357{
358 allAccounts = TRUE;
359 currentAccount = accountList.first();
360 getNewMail();
361}
362
363void EmailClient::mailArrived(const Email &mail, bool fromDisk)
364{
365 Enclosure *ePtr;
366 Email newMail;
367 int thisMailId;
368 emailHandler->parse( mail.rawMail, lineShift, &newMail);
369 mailconf->setGroup(newMail.id);
370
371 if (fromDisk)
372 {
373
374 newMail.downloaded = mailconf->readBoolEntry("downloaded");
375 newMail.size = mailconf->readNumEntry("size");
376 newMail.serverId = mailconf->readNumEntry("serverid");
377 newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
378 }
379 else
380 { //mail arrived from server
381
382 newMail.serverId = mail.serverId;
383 newMail.size = mail.size;
384 newMail.downloaded = mail.downloaded;
385
386 newMail.fromAccountId = emailHandler->getAccount()->id;
387 mailconf->writeEntry("fromaccountid", newMail.fromAccountId);
388 }
389
390 //add if read or not
391 newMail.read = mailconf->readBoolEntry("mailread");
392
393 //check if new mail
394 if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) {
395 thisMailId = mailIdCount;
396 mailIdCount++;
397
398 //set server count, so that if the user aborts, the new
399 //header is not reloaded
400 if ((currentAccount)&&(currentAccount->synchronize))
401 currentAccount->lastServerMailCount++;
402
403 mailconf->writeEntry("internalmailid", thisMailId);
404 mailconf->writeEntry("downloaded", newMail.downloaded);
405 mailconf->writeEntry("size", (int) newMail.size);
406 mailconf->writeEntry("serverid", newMail.serverId);
407
408 //addressList->addContact(newMail.fromMail, newMail.from);
409 }
410
411 mailconf->writeEntry("downloaded", newMail.downloaded);
412
413 QString stringMailId;
414 stringMailId.setNum(thisMailId);
415 //see if any attatchments needs to be stored
416
417 for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) {
418 QString stringId;
419 stringId.setNum(ePtr->id);
420
421 int id = mailconf->readNumEntry("enclosureid_" + stringId);
422 if (id != ePtr->id) { //new entry
423 mailconf->writeEntry("enclosureid_" + stringId, ePtr->id);
424 mailconf->writeEntry("name_" + stringId, ePtr->originalName);
425 mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType);
426 mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute);
427 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
428 mailconf->writeEntry("installed_" + stringId, FALSE);
429
430 ePtr->name = stringMailId + "_" + stringId;
431 ePtr->path = getPath(TRUE);
432 if (emailHandler->getEnclosure(ePtr)) { //file saved
433 ePtr->saved = TRUE;
434 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
435 mailconf->writeEntry("filename_" + stringId, ePtr->name);
436 mailconf->writeEntry("path_" + stringId, ePtr->path);
437 } else {
438 ePtr->saved = FALSE;
439 mailconf->writeEntry("saved_" + stringId, ePtr->saved);
440 }
441 } else {
442 ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
443 ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
444 if (ePtr->saved) {
445 ePtr->name = mailconf->readEntry("filename_" + stringId);
446 ePtr->path = mailconf->readEntry("path_" + stringId);
447 }
448 }
449 }
450
451 bool found=false;
452
453 if (!fromDisk)
454 {
455
456 Email *mailPtr;
457 item = (EmailListItem *) inboxView->firstChild();
458 while ((item != NULL)&&(!found))
459 {
460 mailPtr = item->getMail();
461 if (mailPtr->id == newMail.id) {
462 item->setMail(newMail);
463 emit mailUpdated(item->getMail());
464 found = true;
465 }
466 item = (EmailListItem *) item->nextSibling();
467 }
468 }
469 if ((!found)||(fromDisk)) {
470 item = new EmailListItem(inboxView, newMail, TRUE);
471 }
472// if (item->getMail()->files.count()>0)
473// {
474// item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
475// }
476 /*if (!newMail.downloaded)
477 mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
478
479 mailboxView->setCurrentTab(0);
480
481}
482
483void EmailClient::allMailArrived(int /*count*/)
484{
485 // not previewing means all mailtransfer has been done
486 /*if (!previewingMail) {*/
487 if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
488 emit newCaption("Mailit - " + currentAccount->accountName);
489 getNewMail();
490 return;
491 } else {
492 allAccounts = FALSE;
493 receiving = FALSE;
494 getMailButton->setEnabled(TRUE);
495 cancelButton->setEnabled(FALSE);
496 selectAccountMenu->setEnabled(TRUE);
497 status1Label->setText("Idle");
498
499 progressBar->reset();
500 return;
501 }
502 //}
503
504 // all headers downloaded from server, start downloading remaining mails
505 previewingMail = FALSE;
506 status1Label->setText(currentAccount->accountName);
507 progressBar->reset();
508
509
510 mailboxView->setCurrentTab(0);
511}
512
513
514void EmailClient::moveMailFront(Email *mailPtr)
515{
516 if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
517 mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
518 }
519}
520
521void EmailClient::smtpError(int code, const QString & Msg)
522{
523 QString temp;
524
525 if (code == ErrUnknownResponse) {
526 temp = tr("<qt>Unknown response from server</qt>");
527 if( ! Msg.isEmpty() )
528 temp += Msg;
529 } else if (code == QSocket::ErrHostNotFound) {
530 temp = tr("<qt>host not found</qt>");
531 } else if (code == QSocket::ErrConnectionRefused) {
532 temp = tr("<qt>connection refused</qt>");
533 } else if (code == QSocket::ErrSocketRead) {
534 temp = tr("<qt>socket packet error</qt>");
535 }
536
537 if (code != ErrCancel) {
538 QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
539 } else {
540 status2Label->setText("Aborted by user");
541 }
542
543 sending = FALSE;
544 sendMailButton->setEnabled(TRUE);
545 cancelButton->setEnabled(FALSE);
546 quedMessages.clear();
547}
548
549void EmailClient::popError(int code, const QString & Msg)
550{
551 QString temp;
552
553 if (code == ErrUnknownResponse) {
554 temp = tr("<qt>Unknown response from server</qt>");
555 if( ! Msg.isEmpty() )
556 temp += Msg;
557 } else if (code == ErrLoginFailed) {
558 temp = tr("<qt>Login failed\nCheck user name and password</qt>");
559 } else if (code == QSocket::ErrHostNotFound) {
560 temp = tr("<qt>host not found</qt>");
561 } else if (code == QSocket::ErrConnectionRefused) {
562 temp = tr("<qt>connection refused</qt>");
563 } else if (code == QSocket::ErrSocketRead) {
564 temp = tr("<qt>socket packet error</qt>");
565 }
566
567 if (code != ErrCancel) {
568 QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n"));
569
570 } else {
571 status2Label->setText("Aborted by user");
572 }
573
574 receiving = FALSE;
575 getMailButton->setEnabled(TRUE);
576 cancelButton->setEnabled(FALSE);
577 selectAccountMenu->setEnabled(TRUE);
578}
579
580void EmailClient::inboxItemSelected()
581{
582 //killTimer(timerID);
583
584 item = (EmailListItem*) inboxView->selectedItem();
585 if (item != NULL) {
586 emit viewEmail(inboxView, item->getMail());
587 }
588}
589
590void EmailClient::outboxItemSelected()
591{
592 //killTimer(timerID);
593
594 item = (EmailListItem*) outboxView->selectedItem();
595 if (item != NULL) {
596 emit viewEmail(outboxView, item->getMail());
597 }
598
599}
600
601void EmailClient::readMail()
602{
603 Email mail;
604 int start, stop;
605 QString s, del;
606
607 QFile f(getPath(FALSE) + "inbox.txt");
608
609 if ( f.open(IO_ReadOnly) ) { // file opened successfully
610 QTextStream t( &f ); // use a text stream
611 s = t.read();
612 f.close();
613
614 start = 0;
615 del = "\n.\n";
616 while ((uint) start < s.length()) {
617 stop = s.find(del, start);
618 if (stop == -1)
619 stop = s.length() - del.length();
620
621 mail.rawMail = s.mid(start, stop + del.length() - start );
622 start = stop + del.length();
623 mailArrived(mail, TRUE);
624 }
625 }
626
627 QFile fo(getPath(FALSE) + "outbox.txt");
628 if ( fo.open(IO_ReadOnly) ) { // file opened successfully
629 QTextStream t( &fo ); // use a text stream
630 s = t.read();
631 fo.close();
632
633 start = 0;
634 del = "\n.\n";
635 while ((uint) start < s.length()) {
636 stop = s.find(del, start);
637 if (stop == -1)
638 stop = s.length() - del.length();
639
640 mail.rawMail = s.mid(start, stop + del.length() - start );
641 start = stop + del.length();
642 emailHandler->parse(mail.rawMail, lineShift, &mail);
643 mail.sent = false;
644 mail.received = false;
645 enqueMail(mail);
646
647 }
648 }
649}
650
651void EmailClient::saveMail(const QString &fileName, QListView *view)
652{
653 QFile f(fileName);
654 Email *mail;
655
656 if (! f.open(IO_WriteOnly) ) {
657 qWarning("could not open file");
658 return;
659 }
660 item = (EmailListItem *) view->firstChild();
661 QTextStream t(&f);
662 while (item != NULL) {
663 mail = item->getMail();
664 t << mail->rawMail;
665
666 mailconf->setGroup(mail->id);
667 mailconf->writeEntry("mailread", mail->read);
668
669 item = (EmailListItem *) item->nextSibling();
670 }
671 f.close();
672}
673
674//paths for mailit, is settings, inbox, enclosures
675QString EmailClient::getPath(bool enclosurePath)
676{
677 QString basePath = "qtmail";
678 QString enclosures = "enclosures";
679
680 QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
681 if ( !dir.exists() )
682 dir.mkdir( dir.path() );
683
684 if (enclosurePath) {
685 dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
686
687 if ( !dir.exists() )
688 dir.mkdir( dir.path() );
689
690 return (dir.path() + "/");
691
692 }
693 return (dir.path() + "/");
694}
695
696void EmailClient::readSettings()
697{
698 int y,acc_count;
699
700 mailconf->setGroup("mailitglobal");
701 acc_count=mailconf->readNumEntry("Accounts",0);
702
703 for (int accountPos = 0;accountPos<acc_count ; accountPos++)
704 {
705 mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ...
706 account.accountName = mailconf->readEntry("AccName","");
707 account.name = mailconf->readEntry("UserName","");
708 account.emailAddress = mailconf->readEntry("Email","");
709 account.popUserName = mailconf->readEntry("POPUser","");
710 account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
711 account.popServer = mailconf->readEntry("POPServer","");
712 account.smtpServer = mailconf->readEntry("SMTPServer","");
713 account.id = mailconf->readNumEntry("AccountId",0);
714 account.syncLimit = mailconf->readNumEntry("HeaderLimit",0);
715 account.lastServerMailCount = 0;
716 account.synchronize = FALSE;
717
718 account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes");
719 if (account.synchronize)
720 {
721 mailconf->readNumEntry("LASTSERVERMAILCOUNT",0);
722 }
723
724 accountList.append(&account);
725 }
726
727 mailconf->setGroup("mailitglobal");
728
729 if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1)
730 {
731 mailIdCount = y;
732 }
733 if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1)
734 {
735 accountIdCount = y;
736 }
737}
738
739void EmailClient::saveSettings()
740{
741 int acc_count=0;
742 MailAccount *accountPtr;
743
744
745 if (!mailconf)
746 {
747 qWarning("could not save settings");
748 return;
749 }
750
751 for (accountPtr = accountList.first(); accountPtr != 0;
752 accountPtr = accountList.next())
753 {
754 mailconf->setGroup("Account_"+QString::number(++acc_count));
755 mailconf->writeEntry("AccName",accountPtr->accountName );
756 mailconf->writeEntry("UserName",accountPtr->name);
757 mailconf->writeEntry("Email",accountPtr->emailAddress);
758 mailconf->writeEntry("POPUser",accountPtr->popUserName);
759 mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd);
760 mailconf->writeEntry("POPServer",accountPtr->popServer);
761 mailconf->writeEntry("SMTPServer",accountPtr->smtpServer);
762 mailconf->writeEntry("AccountId",accountPtr->id);
763 if (accountPtr->synchronize)
764 {
765 mailconf->writeEntry("Synchronize","Yes");
766 mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit);
767 mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount);
768 }
769 else
770 {
771 mailconf->writeEntry("Synchronize", "No");
772 }
773 }
774
775 mailconf->setGroup("mailitglobal");
776 mailconf->writeEntry("Accounts",acc_count);
777 mailconf->writeEntry("mailidcount", mailIdCount);
778 mailconf->writeEntry("accountidcount", accountIdCount);
779}
780
781void EmailClient::selectAccount(int id)
782{
783 if (accountList.count() > 0) {
784 currentAccount = accountList.at(id);
785 emit newCaption("Mailit - " + currentAccount->accountName);
786 getNewMail();
787 } else {
788 emit newCaption( tr("Mailit ! No account defined") );
789 }
790}
791
792void EmailClient::editAccount(int id)
793{
794 MailAccount *newAccount;
795
796 editAccountView = new EditAccount(this, "account", TRUE);
797 if (id == newAccountId) { //new account
798 newAccount = new MailAccount;
799 editAccountView->setAccount(newAccount);
800 } else {
801 newAccount = accountList.at(id);
802 editAccountView->setAccount(newAccount, FALSE);
803 }
804
805 editAccountView->showMaximized();
806 editAccountView->exec();
807
808 if (editAccountView->result() == QDialog::Accepted) {
809 if (id == newAccountId) {
810 newAccount->id = accountIdCount;
811 accountIdCount++;
812 accountList.append(newAccount);
813 updateAccounts();
814 } else {
815 updateAccounts();
816 }
817 }
818
819 delete editAccountView;
820}
821
822void EmailClient::deleteAccount(int id)
823{
824 MailAccount *newAccount;
825 QString message;
826
827 newAccount = accountList.at(id);
828 message = tr("Delete account:\n") + newAccount->accountName;
829 switch( QMessageBox::warning( this, "Mailit", message,
830 "Yes", "No", 0, 0, 1 ) ) {
831
832 case 0: accountList.remove(id);
833 updateAccounts();
834 break;
835 case 1:
836 break;
837 }
838}
839
840void EmailClient::updateAccounts()
841{
842 MailAccount *accountPtr;
843
844 //rebuild menus, clear all first
845 editAccountMenu->clear();
846 selectAccountMenu->clear();
847 deleteAccountMenu->clear();
848
849 newAccountId = editAccountMenu->insertItem( tr("New"), this,
850 SLOT(editAccount(int)) );
851 editAccountMenu->insertSeparator();
852
853 idCount = 0;
854 for (accountPtr = accountList.first(); accountPtr != 0;
855 accountPtr = accountList.next()) {
856
857 editAccountMenu->insertItem(accountPtr->accountName,
858 this, SLOT(editAccount(int)), 0, idCount);
859 selectAccountMenu->insertItem(accountPtr->accountName,
860 this, SLOT(selectAccount(int)), 0, idCount);
861 deleteAccountMenu->insertItem(accountPtr->accountName,
862 this, SLOT(deleteAccount(int)), 0, idCount);
863 idCount++;
864 }
865}
866
867void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
868{
869 Email *mPtr;
870 Enclosure *ePtr;
871
872 if (inbox)
873 {
874 mPtr = mailItem->getMail();
875
876 //if mail is in queue for download, remove it from
877 //queue if possible
878 if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) {
879 if ( !mPtr->downloaded )
880 mailDownloadList.remove(mPtr->serverId, mPtr->size);
881 }
882
883 mailconf->setGroup(mPtr->id);
884 mailconf->clearGroup();
885
886 //delete any temporary attatchemnts storing
887 for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) {
888 if (ePtr->saved) {
889 QFile::remove( (ePtr->path + ePtr->name) );
890 }
891 }
892 inboxView->takeItem(mailItem);
893 }
894 else
895 {
896 outboxView->takeItem(mailItem);
897 }
898}
899
900void EmailClient::setMailSize(int size)
901{
902 progressBar->reset();
903 progressBar->setTotalSteps(size);
904}
905
906void EmailClient::setTotalSize(int /*size*/)
907{
908
909}
910
911void EmailClient::setDownloadedSize(int size)
912{
913 int total = progressBar->totalSteps();
914
915 if (size < total) {
916 progressBar->setProgress(size);
917 } else {
918 progressBar->setProgress(total);
919 }
920}
921
922void EmailClient::deleteItem()
923{
924 bool inbox=mailboxView->currentTab()==0;
925 QListView* box;
926
927 EmailListItem* eli;
928 // int pos;
929
930 inbox ? box=inboxView : box=outboxView;
931
932 eli=(EmailListItem*)box->selectedItem();
933
934 if (eli)
935 {
936 box->setSelected(eli->itemBelow(),true); //select the previous item
937
938 deleteMail(eli,(bool&)inbox); //remove mail entry
939 }
940}
941
942void EmailClient::inboxItemPressed()
943{
944// timerID=startTimer(500);
945}
946
947void EmailClient::inboxItemReleased()
948{
949 // killTimer(timerID);
950}
951
952/*void EmailClient::timerEvent(QTimerEvent *e)
953{
954 //killTimer(timerID);
955
956
957 QPopupMenu *action = new QPopupMenu(this);
958
959 int reply=0;
960
961 action->insertItem(tr( "Reply To" ),this,SLOT(reply()));
962 action->insertItem( tr( "Reply All" ),this,SLOT(replyAll()));
963 action->insertItem( tr( "Forward" ), this,SLOT(forward()));
964 action->insertItem( tr( "Remove Mail" ), this,SLOT(remove()));
965
966 action->exec(QCursor::pos());
967
968 if (action) delete action;
969
970}*/
971
972Email* EmailClient::getCurrentMail()
973{
974 EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
975 if (eli!=NULL)
976 return eli->getMail();
977 else
978 return NULL;
979}
980
981void EmailClient::download(Email* mail)
982{
983 MailAccount* acc=0;
984
985 tempMailDownloadList.clear();
986 tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
987
988 acc=accountList.at(mail->fromAccountId-1);
989 if (acc)
990 {
991 emailHandler->setAccount(*acc);
992 emailHandler->getMailByList(&tempMailDownloadList);
993 }
994 else
995 QMessageBox::warning(qApp->activeWindow(),
996 tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n");
997}
998
999void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/)
1000{
1001 /*if (msg=="getMail()")
1002 {
1003 //QDialog qd(qApp->activeWindow(),"Getting mail",true);
1004 QVBoxLayout *vbProg = new QVBoxLayout( &qd );
1005
1006 initStatusBar(&qd);
1007
1008 if (statusBar==0)
1009 {
1010 qDebug("No Bar ...");
1011 //statusBar=new ProgressBar(&qd);
1012 }
1013 statusBar->show();
1014 vbProg->addWidget(statusBar);
1015 qd.showMaximized();
1016 qd.show();
1017 emit getAllNewMail();
1018 //qd.exec();
1019 }
1020 else if (msg=="compose()")
1021 {
1022 QDialog qd(qApp->activeWindow(),"Getting mail",true);
1023
1024 WriteMail wm(&qd,"write new mail");
1025 QVBoxLayout vbProg( &qd );
1026
1027 wm.showMaximized();
1028 vbProg.addWidget(&wm);
1029
1030 qd.showMaximized();
1031
1032 emit composeRequested();
1033 qd.exec();
1034
1035 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1036 }
1037
1038 else if (msg=="dialog()")
1039 {
1040 QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n");
1041 }*/
1042}
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h
deleted file mode 100644
index 80c6d31..0000000
--- a/noncore/net/mailit/emailclient.h
+++ b/dev/null
@@ -1,181 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef EMAILCLIENT_H
21#define EMAILCLIENT_H
22
23#include <qlist.h>
24#include <qcstring.h>
25#include <qmainwindow.h>
26
27#include <qtoolbar.h>
28#include <qcheckbox.h>
29#include <qlabel.h>
30#include <qlineedit.h>
31#include <qlistview.h>
32#include <qaction.h>
33#include <qlayout.h>
34#include <qtooltip.h>
35#include <qtoolbutton.h>
36#include <qimage.h>
37#include <qpixmap.h>
38#include <qstringlist.h>
39#include <qprogressbar.h>
40#include <qstatusbar.h>
41#include <qdir.h>
42#include <stdlib.h>
43#include <opie/otabwidget.h>
44#include <qpe/qcopenvelope_qws.h>
45#include <qtimer.h>
46
47#include "emailhandler.h"
48#include "emaillistitem.h"
49#include "textparser.h"
50#include "editaccount.h"
51#include "maillist.h"
52#include "addresslist.h"
53
54#include <qpe/config.h>
55
56class AccountList : public QList<MailAccount>
57{
58public:
59 Item newItem(Item d);
60private:
61 MailAccount* dupl(MailAccount *in);
62 MailAccount *ac;
63};
64
65//class EmailClient : public EmailClientBase
66class EmailClient : public QMainWindow
67{
68 Q_OBJECT
69
70public:
71 EmailClient( QWidget* parent, const char* name, WFlags fl = 0 );
72 ~EmailClient();
73 AddressList* getAdrListRef();
74
75protected:
76 //void timerEvent(QTimerEvent*);
77
78signals:
79 void composeRequested();
80 void viewEmail(QListView *, Email *);
81 void mailUpdated(Email *);
82 void newCaption(const QString &);
83 void replyRequested(Email&, bool&);
84 void forwardRequested(Email&);
85 void removeItem(EmailListItem*, bool&);
86 /*void reply(Email&);
87 void replyAll(Email&);
88 void remove(Email&);
89 void forward(Email&);*/
90
91public slots:
92 void compose();
93 void cancel();
94 void enqueMail(const Email &mail);
95 void setMailAccount();
96 void sendQuedMail();
97 void mailSent();
98 void deleteItem();
99 void getNewMail();
100 void getAllNewMail();
101 void smtpError(int code, const QString & Msg );
102 void popError(int code, const QString & Msg);
103 void inboxItemSelected();
104 void outboxItemSelected();
105 void inboxItemPressed();
106 void inboxItemReleased();
107 void mailArrived(const Email &mail, bool fromDisk);
108 void allMailArrived(int);
109 void saveMail(const QString &fileName, QListView *view);
110 void selectAccount(int);
111 void editAccount(int);
112 void updateAccounts();
113 void deleteAccount(int);
114 void deleteMail(EmailListItem *mailItem, bool &inbox);
115 void setTotalSize(int);
116 void setMailSize(int);
117 void setDownloadedSize(int);
118 void moveMailFront(Email *mailPtr);
119 void download(Email*);
120/* void reply();
121 void replyAll();
122 void forward();
123 void remove();*/
124
125private slots:
126 void receive(const QCString&, const QByteArray&);
127
128private:
129 void init();
130 void initStatusBar(QWidget*);
131 void readMail();
132 QString getPath(bool enclosurePath);
133 void readSettings();
134 void saveSettings();
135 Email* getCurrentMail();
136 int timerID;
137 Config *mailconf;
138 int newAccountId, idCount, mailIdCount;
139 int accountIdCount;
140 AccountList accountList;
141 AddressList *addressList;
142
143 EditAccount *editAccountView;
144 EmailListItem *item;
145 EmailHandler *emailHandler;
146 QList<Email> quedMessages;
147 MailList mailDownloadList;
148 MailList tempMailDownloadList;
149
150 bool sending, receiving, previewingMail, allAccounts;
151 QString lineShift;
152 MailAccount account, *currentAccount;
153
154 QCopChannel* channel;
155
156 QToolBar *bar;
157 QProgressBar *progressBar;
158 QStatusBar *statusBar;
159 QLabel *status1Label, *status2Label;
160 QToolButton *getMailButton;
161 QAction *sendMailButton;
162 QAction *composeButton;
163 QAction *cancelButton;
164 QAction *deleteButton;
165 //QToolButton *setAccountButton;
166
167 QMenuBar *mb;
168 QPopupMenu *selectAccountMenu;
169 QPopupMenu *editAccountMenu;
170 QPopupMenu *deleteAccountMenu;
171 QPopupMenu *setAccountMenu;
172
173 OTabWidget* mailboxView;
174 QListView* inboxView;
175 QListView* outboxView;
176
177 QGridLayout* grid_2;
178 QGridLayout* grid_3;
179};
180
181#endif // EMAILCLIENT_H
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
deleted file mode 100644
index 06e978d..0000000
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/dev/null
@@ -1,630 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qfileinfo.h>
21#include <stdlib.h>
22#include <qapplication.h>
23#include <qmessagebox.h>
24#include <qcstring.h>
25#include "emailhandler.h"
26#include <qpe/applnk.h>
27#include <qpe/filemanager.h>
28
29QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{
31 return dupl( (Enclosure *) d);
32}
33
34Enclosure* EnclosureList::dupl(Enclosure *in)
35{
36 ac = new Enclosure(*in);
37 return ac;
38}
39
40EmailHandler::EmailHandler()
41{
42 qDebug("EMailHandler::EmailHandler");
43
44 smtpClient = new SmtpClient();
45 popClient = new PopClient();
46
47 connect(smtpClient, SIGNAL(errorOccurred(int, const QString &)), this,
48 SIGNAL(smtpError(int, const QString &)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) );
52
53 connect(popClient, SIGNAL(errorOccurred(int, const QString &)), this,
54 SIGNAL(popError(int, const QString &)) );
55 connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)),
56 this, SLOT(messageArrived(const QString &, int, uint, bool)) );
57 connect(popClient, SIGNAL(updateStatus(const QString &)), this,
58 SIGNAL(updatePopStatus(const QString &)) );
59 connect(popClient, SIGNAL(mailTransfered(int)), this,
60 SIGNAL(mailTransfered(int)) );
61
62
63 //relaying size information
64 connect(popClient, SIGNAL(currentMailSize(int)),
65 this, SIGNAL(currentMailSize(int)) );
66 connect(popClient, SIGNAL(downloadedSize(int)),
67 this, SIGNAL(downloadedSize(int)) );
68}
69
70void EmailHandler::sendMail(QList<Email> *mailList)
71{
72 Email *currentMail;
73 QString temp;
74 QString userName = QString::null;
75 // not supported by ALL SMTP servers in the MAIL From field
76 // userName = "\""+mailAccount.name+"\"";
77 userName += "<" + mailAccount.emailAddress + ">";
78
79 for (currentMail = mailList->first(); currentMail != 0;
80 currentMail = mailList->next()) {
81
82 if (encodeMime(currentMail) == 0) {
83 smtpClient->addMail(userName, currentMail->subject,
84 currentMail->recipients, currentMail->rawMail);
85 } else { //error
86 temp = tr("Could not locate all files in \nmail with subject: ") +
87 currentMail->subject;
88 temp += tr("\nMail has NOT been sent");
89 QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n"));
90
91 }
92 }
93 smtpClient->newConnection(mailAccount.smtpServer, 25);
94}
95
96void EmailHandler::setAccount(MailAccount account)
97{
98 mailAccount = account;
99}
100
101void EmailHandler::getMail()
102{
103 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
104 if (mailAccount.synchronize) {
105 popClient->setSynchronize(mailAccount.lastServerMailCount);
106 } else {
107 popClient->removeSynchronize();
108 }
109
110 headers = FALSE;
111 //popClient->headersOnly(headers, 0);
112 popClient->newConnection(mailAccount.popServer, 110);
113}
114
115void EmailHandler::getMailHeaders()
116{
117 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
118 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize();
119
120 headers = TRUE;
121 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
122 qDebug("Initiating connection");
123 popClient->newConnection(mailAccount.popServer, 110);
124}
125
126void EmailHandler::getMailByList(MailList *mailList)
127{
128 if (mailList->count() == 0) { //should not occur though
129 emit mailTransfered(0);
130 return;
131 }
132
133 headers = FALSE;
134 popClient->headersOnly(FALSE, 0);
135
136 popClient->setAccount(mailAccount.popUserName,mailAccount.popPasswd);
137 popClient->setSelectedMails(mailList);
138 popClient->newConnection(mailAccount.popServer, 110);
139 }
140
141void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
142{
143 Email mail;
144
145 mail.rawMail = message;
146 mail.serverId = id;
147 mail.size = size;
148 mail.downloaded = complete;
149
150 emit mailArrived(mail, FALSE);
151}
152
153bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
154{
155 QString temp, boundary;
156 int pos;
157 QString delimiter, header, body, mimeHeader, mimeBody;
158 QString content, contentType, contentAttribute, id, encoding;
159 QString fileName, storedName;
160 int enclosureId = 0;
161
162 mail->rawMail = in;
163 mail->received = TRUE;
164 mail->files.setAutoDelete(TRUE);
165
166 temp = lineShift + "." + lineShift;
167
168 if (in.right(temp.length()) != temp) {
169 mail->rawMail += temp;
170 }
171
172
173 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
174 pos = in.find(delimiter, 0, FALSE);
175 header = in.left(pos);
176 body = in.right(in.length() - pos - delimiter.length());
177 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
178 body.truncate(body.length()-2);
179
180 // TextParser p(header, lineShift);
181 TextParser * lp = new TextParser(header, lineShift);
182#define p (*lp)
183
184 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
185 pos++;
186 if (p.separatorAt(pos) == ' ') {
187 mail->from = p.getString(&pos, '<', false);
188 mail->from = mail->from.stripWhiteSpace();
189 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
190 mail->from = mail->from.left(mail->from.length() - 1);
191 mail->from = mail->from.right(mail->from.length() - 1);
192 }
193 pos++;
194 mail->fromMail = p.getString(&pos, '>', false);
195 } else {
196 if (p.separatorAt(pos) == '<') //No name.. nasty
197 pos++;
198 //pos++;
199 mail->fromMail = p.getString(&pos, 'z', TRUE);
200 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
201 mail->fromMail.truncate(mail->fromMail.length() - 1);
202 mail->from=mail->fromMail;
203 }
204 }
205
206 pos=0;
207
208 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
209 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
210 {
211 QString rec;
212
213 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
214 {
215 pos++;
216 mail->recipients.append(p.getString(&pos, '\r', TRUE));
217 }
218 }
219 //
220 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
221
222 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
223 {
224 pos++;
225 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
226 }
227
228 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
229 pos++;
230 mail->subject = p.getString(&pos, 'z', TRUE);
231 }
232
233 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
234 pos++;
235 mail->date = p.getString(&pos, 'z', TRUE);
236 }
237
238
239
240 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
241 pos++;
242 if ( (p.wordAt(pos).upper() == "ID") &&
243 (p.separatorAt(pos) == ':') ) {
244
245 id = p.getString(&pos, 'z', TRUE);
246 mail->id = id;
247 }
248 }
249
250 pos = 0;
251 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
252 pos++;
253 if ( (p.wordAt(pos).upper() == "VERSION") &&
254 (p.separatorAt(pos) == ':') ) {
255 pos++;
256 if (p.getString(&pos, 'z', true) == "1.0") {
257 mail->mimeType = 1;
258 }
259 }
260 }
261
262 if (mail->mimeType == 1) {
263 boundary = "";
264 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
265 pos++;
266 boundary = p.getString(&pos, 'z', true);
267 if (boundary[0] == '"') {
268 boundary = boundary.left(boundary.length() - 1); //strip "
269 boundary = boundary.right(boundary.length() - 1); //strip "
270 }
271 boundary = "--" + boundary; //create boundary field
272 }
273
274 if (boundary == "") { //fooled by Mime-Version
275 mail->body = body;
276 mail->bodyPlain = body;
277 delete lp;
278 return mail;
279 }
280
281 while (body.length() > 0) {
282 pos = body.find(boundary, 0, FALSE);
283 pos = body.find(delimiter, pos, FALSE);
284 mimeHeader = body.left(pos);
285 mimeBody = body.right(body.length() - pos - delimiter.length());
286 TextParser bp(mimeHeader, lineShift);
287
288 contentType = "";
289 contentAttribute = "";
290 fileName = "";
291 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
292 pos++;
293 if ( (bp.wordAt(pos).upper() == "TYPE") &&
294 (bp.separatorAt(pos) == ':') ) {
295 contentType = bp.nextWord().upper();
296 if (bp.nextSeparator() == '/')
297 contentAttribute = bp.nextWord().upper();
298 content = contentType + "/" + contentAttribute;
299 }
300 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
301 pos++;
302 encoding = bp.getString(&pos, 'z', TRUE);
303 }
304
305 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
306 pos++;
307 fileName = bp.getString(&pos, 'z', TRUE);
308 fileName = fileName.right(fileName.length() - 1);
309 fileName = fileName.left(fileName.length() - 1);
310 }
311
312 }
313 pos = mimeBody.find(boundary, 0, FALSE);
314 if (pos == -1) //should not occur, malformed mail
315 pos = mimeBody.length();
316 body = mimeBody.right(mimeBody.length() - pos);
317 mimeBody = mimeBody.left(pos);
318
319 if (fileName != "") { //attatchments of some type, audio, image etc.
320
321 Enclosure e;
322 e.id = enclosureId;
323 e.originalName = fileName;
324 e.contentType = contentType;
325 e.contentAttribute = contentAttribute;
326 e.encoding = encoding;
327 e.body = mimeBody;
328 e.saved = FALSE;
329 mail->addEnclosure(&e);
330 enclosureId++;
331
332 } else if (contentType == "TEXT") {
333 if (contentAttribute == "PLAIN") {
334 mail->body = mimeBody;
335 mail->bodyPlain = mimeBody;
336 }
337 if (contentAttribute == "HTML") {
338 mail->body = mimeBody;
339 }
340 }
341 }
342 } else {
343 mail->bodyPlain = body;
344 mail->body = body;
345 }
346 delete lp;
347 return TRUE;
348}
349
350bool EmailHandler::getEnclosure(Enclosure *ePtr)
351{
352 QFile f(ePtr->path + ePtr->name);
353 char src[4];
354 char *destPtr;
355 QByteArray buffer;
356 uint bufCount, pos, decodedCount, size, x;
357
358 if (! f.open(IO_WriteOnly) ) {
359 qWarning("could not save: " + ePtr->path + ePtr->name);
360 return FALSE;
361 }
362
363 if (ePtr->encoding.upper() == "BASE64") {
364 size = (ePtr->body.length() * 3 / 4); //approximate size (always above)
365 buffer.resize(size);
366 bufCount = 0;
367 pos = 0;
368 destPtr = buffer.data();
369
370 while (pos < ePtr->body.length()) {
371 decodedCount = 4;
372 x = 0;
373 while ( (x < 4) && (pos < ePtr->body.length()) ) {
374 src[x] = ePtr->body[pos].latin1();
375 pos++;
376 if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ')
377 x--;
378 x++;
379 }
380 if (x > 1) {
381 decodedCount = parse64base(src, destPtr);
382 destPtr += decodedCount;
383 bufCount += decodedCount;
384 }
385 }
386
387 buffer.resize(bufCount); //set correct length of file
388 f.writeBlock(buffer);
389 } else {
390 QTextStream t(&f);
391 t << ePtr->body;
392 }
393 return TRUE;
394}
395
396int EmailHandler::parse64base(char *src, char *bufOut) {
397
398 char c, z;
399 char li[4];
400 int processed;
401
402 //conversion table withouth table...
403 for (int x = 0; x < 4; x++) {
404 c = src[x];
405
406 if ( (int) c >= 'A' && (int) c <= 'Z')
407 li[x] = (int) c - (int) 'A';
408 if ( (int) c >= 'a' && (int) c <= 'z')
409 li[x] = (int) c - (int) 'a' + 26;
410 if ( (int) c >= '0' && (int) c <= '9')
411 li[x] = (int) c - (int) '0' + 52;
412 if (c == '+')
413 li[x] = 62;
414 if (c == '/')
415 li[x] = 63;
416 }
417
418 processed = 1;
419 bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits
420 bufOut[0] <<= 2;
421 z = li[1] >> 4;
422 bufOut[0] = bufOut[0] | z; //first byte retrived
423
424 if (src[2] != '=') {
425 bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits
426 bufOut[1] <<= 4;
427 z = li[2] >> 2;
428 bufOut[1] = bufOut[1] | z; //second byte retrived
429 processed++;
430
431 if (src[3] != '=') {
432 bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits
433 bufOut[2] <<= 6;
434 z = li[3];
435 bufOut[2] = bufOut[2] | z; //third byte retrieved
436 processed++;
437 }
438 }
439 return processed;
440}
441
442int EmailHandler::encodeMime(Email *mail)
443{
444
445 QString fileName, fileType, contentType, newBody, boundary;
446 Enclosure *ePtr;
447 QString userName;
448
449 if ( ! mailAccount.name.isEmpty() ) {
450 userName = "\"" + mailAccount.name + "\" <" + mailAccount.emailAddress + ">";
451 } else {
452 userName = "<" + mailAccount.emailAddress + ">";
453 }
454
455 //add standard headers
456 newBody = "From: " + userName + "\r\nTo: ";
457 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) {
458 newBody += *it + " ";
459 }
460
461 newBody += "\r\nCC: ";
462
463 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) {
464 newBody += *it + " ";
465 }
466
467 newBody += "\r\nSubject: " + mail->subject + "\r\n";
468
469 if (mail->files.count() == 0) { //just a simple mail
470 newBody += "\r\n" + mail->body;
471 mail->rawMail = newBody;
472 return 0;
473 }
474
475 //Build mime encoded mail
476 boundary = "-----4345=next_bound=0495----";
477
478 newBody += "Mime-Version: 1.0\r\n";
479 newBody += "Content-Type: multipart/mixed; boundary=\"" +
480 boundary + "\"\r\n\r\n";
481
482 newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n";
483 newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n";
484 newBody += mail->body;
485
486 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
487 fileName = ePtr->originalName;
488 fileType = ePtr->contentType;
489 QFileInfo fi(fileName);
490
491 // This specification of contentType is temporary
492 contentType = "";
493 if (fileType == "Picture") {
494 contentType = "image/x-image";
495 } else if (fileType == "Document") {
496 contentType = "text/plain";
497 } else if (fileType == "Sound") {
498 contentType = "audio/x-wav";
499 } else if (fileType == "Movie") {
500 contentType = "video/mpeg";
501 } else {
502 contentType = "application/octet-stream";
503 }
504
505 newBody += "\r\n\r\n--" + boundary + "\r\n";
506 newBody += "Content-Type: " + contentType + "; name=\"" +
507 fi.fileName() + "\"\r\n";
508 newBody += "Content-Transfer-Encoding: base64\r\n";
509 newBody += "Content-Disposition: inline; filename=\"" +
510 fi.fileName() + "\"\r\n\r\n";
511
512 if (encodeFile(fileName, &newBody) == -1) //file not found?
513 return -1;
514 }
515
516 newBody += "\r\n\r\n--" + boundary + "--";
517 mail->rawMail = newBody;
518
519 return 0;
520}
521
522int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
523{
524 char *fileData;
525 char *dataPtr;
526 QString temp;
527 uint dataSize, count;
528 QFile f(fileName);
529
530 if (! f.open(IO_ReadOnly) ) {
531 qWarning("could not open file: " + fileName);
532 return -1;
533 }
534 QTextStream s(&f);
535 dataSize = f.size();
536 fileData = (char *) malloc(dataSize + 3);
537 s.readRawBytes(fileData, dataSize);
538
539 temp = "";
540 dataPtr = fileData;
541 count = 0;
542 while (dataSize > 0) {
543 if (dataSize < 3) {
544 encode64base(dataPtr, &temp, dataSize);
545 dataSize = 0;
546 } else {
547 encode64base(dataPtr, &temp, 3);
548 dataSize -= 3;
549 dataPtr += 3;
550 count += 4;
551 }
552 if (count > 72) {
553 count = 0;
554 temp += "\r\n";
555 }
556 }
557 toBody->append(temp);
558
559 delete(fileData);
560 f.close();
561 return 0;
562}
563
564void EmailHandler::encode64base(char *src, QString *dest, int len)
565{
566 QString temp;
567 uchar c;
568 uchar bufOut[4];
569
570 bufOut[0] = src[0];
571 bufOut[0] >>= 2; //Done byte 0
572
573 bufOut[1] = src[0];
574 bufOut[1] = bufOut[1] & (1 + 2); //mask out top 6 bits
575 bufOut[1] <<= 4; //copy up 4 places
576 if (len > 1) {
577 c = src[1];
578 } else {
579 c = 0;
580 }
581
582 c = c & (16 + 32 + 64 + 128);
583 c >>= 4;
584 bufOut[1] = bufOut[1] | c; //Done byte 1
585
586 bufOut[2] = src[1];
587 bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8);
588 bufOut[2] <<= 2;
589 if (len > 2) {
590 c = src[2];
591 } else {
592 c = 0;
593 }
594 c >>= 6;
595 bufOut[2] = bufOut[2] | c;
596
597 bufOut[3] = src[2];
598 bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32);
599
600 if (len == 1) {
601 bufOut[2] = 64;
602 bufOut[3] = 64;
603 }
604 if (len == 2) {
605 bufOut[3] = 64;
606 }
607 for (int x = 0; x < 4; x++) {
608 if (bufOut[x] <= 25)
609 bufOut[x] += (uint) 'A';
610 else if (bufOut[x] >= 26 && bufOut[x] <= 51)
611 bufOut[x] += (uint) 'a' - 26;
612 else if (bufOut[x] >= 52 && bufOut[x] <= 61)
613 bufOut[x] += (uint) '0' - 52;
614 else if (bufOut[x] == 62)
615 bufOut[x] = '+';
616 else if (bufOut[x] == 63)
617 bufOut[x] = '/';
618 else if (bufOut[x] == 64)
619 bufOut[x] = '=';
620
621 dest->append(bufOut[x]);
622 }
623}
624
625void EmailHandler::cancel()
626{
627 popClient->errorHandling(ErrCancel);
628 smtpClient->errorHandling(ErrCancel);
629}
630
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h
deleted file mode 100644
index 74a8e4c..0000000
--- a/noncore/net/mailit/emailhandler.h
+++ b/dev/null
@@ -1,150 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef EmailHandler_H
21#define EmailHandler_H
22
23#include <qobject.h>
24#include <qstring.h>
25#include <qdatetime.h>
26#include <qlist.h>
27#include <qstringlist.h>
28#include <qfile.h>
29#include <qstringlist.h>
30#include <qcollection.h>
31#include <qpe/qcopenvelope_qws.h>
32
33#include "smtpclient.h"
34#include "popclient.h"
35#include "textparser.h"
36#include "maillist.h"
37
38struct Enclosure
39{
40 int id;
41 QString originalName;
42 QString name;
43 QString path;
44 QString contentType;
45 QString contentAttribute;
46 QString encoding;
47 QString body; //might use to much mem. check!!
48 bool saved, installed;
49};
50
51class EnclosureList : public QList<Enclosure>
52{
53public:
54 Item newItem(Item d);
55private:
56 Enclosure* dupl(Enclosure *in);
57 Enclosure *ac;
58};
59
60struct Email
61{
62 QString id;
63 QString from;
64 QString fromMail;
65 QStringList recipients;
66 QStringList carbonCopies;
67 QString date;
68 QString subject;
69 QString body;
70 QString bodyPlain;
71 bool sent, received, read, downloaded;
72 QString rawMail;
73 int mimeType; //1 = Mime 1.0
74 int serverId;
75 int internalId;
76 int fromAccountId;
77 QString contentType; //0 = text
78 QString contentAttribute; //0 = plain, 1 = html
79 EnclosureList files;
80 uint size;
81
82 void addEnclosure(Enclosure *e)
83 {
84 files.append(e);
85 }
86};
87
88struct MailAccount
89{
90 QString accountName;
91 QString name;
92 QString emailAddress;
93 QString popUserName;
94 QString popPasswd;
95 QString popServer;
96 QString smtpServer;
97 bool synchronize;
98 int syncLimit;
99 int lastServerMailCount;
100 int id;
101};
102
103 const int ErrUnknownResponse = 1001;
104 const int ErrLoginFailed = 1002;
105 const int ErrCancel = 1003;
106
107
108class EmailHandler : public QObject
109{
110 Q_OBJECT
111
112public:
113 EmailHandler();
114 void setAccount(MailAccount account);
115 MailAccount* getAccount(){return &mailAccount;}
116 void sendMail(QList<Email> *mailList);
117 void getMail();
118 void getMailHeaders();
119 void getMailByList(MailList *mailList);
120 bool parse(const QString &in, const QString &lineShift, Email *mail);
121 bool getEnclosure(Enclosure *ePtr);
122 int parse64base(char *src, char *dest);
123 int encodeMime(Email *mail);
124 int encodeFile(const QString &fileName, QString *toBody);
125 void encode64base(char *src, QString *dest, int len);
126 void cancel();
127
128signals:
129 void mailSent();
130 void smtpError(int, const QString & Msg );
131 void popError(int, const QString & Msg );
132 void mailArrived(const Email &, bool);
133 void updatePopStatus(const QString &);
134 void updateSmtpStatus(const QString &);
135 void mailTransfered(int);
136 void mailboxSize(int);
137 void currentMailSize(int);
138 void downloadedSize(int);
139
140public slots:
141 void messageArrived(const QString &, int id, uint size, bool complete);
142
143private:
144 MailAccount mailAccount;
145 SmtpClient *smtpClient;
146 PopClient *popClient;
147 bool headers;
148};
149
150#endif
diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp
deleted file mode 100644
index a25f93a..0000000
--- a/noncore/net/mailit/emaillistitem.cpp
+++ b/dev/null
@@ -1,158 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qstring.h>
21#include <qpe/resource.h>
22#include "emaillistitem.h"
23
24EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox)
25 : QListViewItem(parent)
26{
27 QString temp;
28
29 mail = mailIn;
30
31 if (inbox) {
32 setText(0, mail.from);
33 } else {
34 QStringList::Iterator it = mail.recipients.begin();
35 temp = *it;
36 if (mail.recipients.count() > 1)
37 temp += "...";
38 setText(0, temp);
39 }
40 setText(1, mail.subject);
41 // setText(2,mail.date);
42 setText(2,dateFromULCString(mail.date));
43
44 if (mailIn.files.count()>0)
45 {
46 setPixmap(0, Resource::loadPixmap("mailit/attach"));
47 }
48
49 selected = FALSE;
50}
51
52Email* EmailListItem::getMail()
53{
54 return &mail;
55}
56
57void EmailListItem::setMail(Email newMail)
58{
59 mail = newMail;
60 repaint();
61}
62
63void EmailListItem::setItemSelected(bool enable)
64{
65 selected = enable;
66 setSelected(enable);
67 repaint();
68}
69
70bool EmailListItem::isItemSelected()
71{
72 return selected;
73}
74
75void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg,
76 int column, int width, int alignment )
77{
78
79 QColorGroup _cg( cg );
80 QColor c = _cg.text();
81
82 if ( (! mail.read) && (mail.received) )
83 _cg.setColor( QColorGroup::Text, Qt::blue);
84 if (!mail.downloaded)
85 _cg.setColor( QColorGroup::Text, Qt::red);
86
87/* if (selected) {
88 _cg.setColor(QColorGroup::Base, Qt::blue);
89 _cg.setColor(QColorGroup::Text, Qt::yellow);
90 if (isSelected()) {
91 _cg.setColor(QColorGroup::HighlightedText, Qt::yellow);
92 } else {
93 _cg.setColor(QColorGroup::Highlight, Qt::blue);
94 }
95 }
96*/
97 QListViewItem::paintCell( p, _cg, column, width, alignment );
98
99 _cg.setColor( QColorGroup::Text, c );
100}
101
102/*
103 * Converts an E-Mail date (ULC) RFC 2822 conform to a QDateTime.
104 * Returning a QString with formatting of "YYYY-MM-DD HH:MM:SS"
105 * (zodiac: This method was tested with more than 300 inbox mails,
106 * it didn't slow down the loading of mail-it.)
107 */
108QString EmailListItem::dateFromULCString( QString ulcDate )
109{
110 QString sTemp, sTime;
111 int iPos, iDay, iMon=1, iYear;
112
113 iPos=ulcDate.find(',');
114 if (iPos) { // it has a day-of-week
115 ulcDate=ulcDate.remove(0,++iPos); //.stripWhiteSpace();
116 }
117
118 QStringList dateEntries = QStringList::split(" ",ulcDate,FALSE);
119 QStringList::Iterator iter = dateEntries.begin();
120
121 // Get day as DD
122 iDay = (*iter++).toInt();
123
124 // Get month as string Mmm
125 sTemp = (*iter++);
126 if (sTemp =="Jan") {iMon=1;} else
127 if (sTemp =="Feb") {iMon=2;} else
128 if (sTemp =="Mar") {iMon=3;} else
129 if (sTemp =="Apr") {iMon=4;} else
130 if (sTemp =="May") {iMon=5;} else
131 if (sTemp =="Jun") {iMon=6;} else
132 if (sTemp =="Jul") {iMon=7;} else
133 if (sTemp =="Aug") {iMon=8;} else
134 if (sTemp =="Sep") {iMon=9;} else
135 if (sTemp =="Oct") {iMon=10;} else
136 if (sTemp =="Nov") {iMon=11;} else
137 if (sTemp =="Dec") {iMon=12;}
138
139 // Get year as YYYY or YY
140 iYear = (*iter++).toInt();
141
142 QDate date = QDate(iYear, iMon, iDay);
143
144 // Convert timestring into a QTime
145 QStringList timeEntries = QStringList::split(":",(*iter++),FALSE);
146 QStringList::Iterator iterTime = timeEntries.begin();
147 iYear=(*iterTime++).toInt(); // var reuse.. *cough*
148 iMon=(*iterTime++).toInt();
149 iDay=(*iterTime++).toInt();
150 QTime time = QTime(iYear,iMon,iDay);
151
152 return QString::number(date.year())+"-"
153 +QString::number(date.month()).rightJustify(2,'0')+"-"
154 +QString::number(date.day()).rightJustify(2,'0')+" "
155 +time.toString();
156}
157
158
diff --git a/noncore/net/mailit/emaillistitem.h b/noncore/net/mailit/emaillistitem.h
deleted file mode 100644
index 129a774..0000000
--- a/noncore/net/mailit/emaillistitem.h
+++ b/dev/null
@@ -1,45 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef EMAILLISTITEM_H
21#define EMAILLISTITEM_H
22
23#include <qlistview.h>
24#include "emailhandler.h"
25
26class EmailListItem: public QListViewItem
27{
28public:
29 EmailListItem(QListView *parent, Email mailIn, bool inbox);
30 Email* getMail();
31 void setMail(Email newMail);
32 void setItemSelected(bool enable);
33 bool isItemSelected();
34 bool itemSelected();
35
36protected:
37 void paintCell( QPainter *p, const QColorGroup &cg,
38 int column, int width, int alignment );
39private:
40 Email mail;
41 bool selected;
42 QString dateFromULCString( QString ulc );
43};
44
45#endif
diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro
deleted file mode 100644
index bdb89be..0000000
--- a/noncore/net/mailit/mailit.pro
+++ b/dev/null
@@ -1,40 +0,0 @@
1TARGET = mailit
2CONFIG = qt warn_on release quick-app
3HEADERS = emailclient.h \
4 emailhandler.h \
5 emaillistitem.h \
6 mailitwindow.h \
7 md5.h \
8 popclient.h \
9 readmail.h \
10 smtpclient.h \
11 writemail.h \
12 textparser.h \
13 viewatt.h \
14 addatt.h \
15 editaccount.h \
16 maillist.h \
17 addresslist.h
18SOURCES = emailclient.cpp \
19 emailhandler.cpp \
20 emaillistitem.cpp \
21 mailitwindow.cpp \
22 main.cpp \
23 md5.c \
24 popclient.cpp \
25 readmail.cpp \
26 smtpclient.cpp \
27 writemail.cpp \
28 textparser.cpp \
29 viewatt.cpp \
30 addatt.cpp \
31 editaccount.cpp \
32 maillist.cpp \
33 addresslist.cpp
34
35INCLUDEPATH += $(OPIEDIR)/include
36DEPENDPATH += $(OPIEDIR)/include
37LIBS += -lqpe -lopie
38# -lssl
39
40include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp
deleted file mode 100644
index 6e298c7..0000000
--- a/noncore/net/mailit/mailitwindow.cpp
+++ b/dev/null
@@ -1,168 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qwhatsthis.h>
21#include <qmessagebox.h>
22#include "mailitwindow.h"
23
24MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags /*fl*/)
25 : QMainWindow(parent, name, WStyle_ContextHelp)
26{
27 currentCaption = tr("Mailit");
28 setCaption(tr(currentCaption));
29 views = new QWidgetStack(this);
30 setCentralWidget(views);
31 QWhatsThis::add(views,tr("Central view area"));
32 emailClient = new EmailClient(views, "client");
33 writeMail = new WriteMail(views, "writing");
34 readMail = new ReadMail(views, "reading");
35
36 views->raiseWidget(emailClient);
37
38 connect(emailClient, SIGNAL(composeRequested()),
39 this, SLOT(compose()) );
40 connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this,
41 SLOT(viewMail(QListView *, Email *)) );
42 connect(emailClient, SIGNAL(mailUpdated(Email *)), this,
43 SLOT(updateMailView(Email *)) );
44
45 connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
46 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
47 SLOT(showEmailClient()) );
48 connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient,
49 SLOT(enqueMail(const Email &)) );
50
51 connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) );
52 connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this,
53 SLOT(composeReply(Email &, bool&)) );
54 connect(readMail, SIGNAL(forwardRequested(Email &)), this,
55 SLOT(composeForward(Email &)) );
56
57 connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient,
58 SLOT(deleteMail(EmailListItem *, bool &)) );
59 connect(readMail, SIGNAL(viewingMail(Email *)), emailClient,
60 SLOT(moveMailFront(Email *)) );
61
62 connect(emailClient, SIGNAL(newCaption(const QString &)),
63 this, SLOT(updateCaption(const QString &)) );
64
65 connect(readMail, SIGNAL(download(Email *)), emailClient, SLOT(download(Email*)) );
66
67 viewingMail = FALSE;
68}
69
70MailItWindow::~MailItWindow()
71{
72}
73
74void MailItWindow::closeEvent(QCloseEvent *e)
75{
76 if (views->visibleWidget() == emailClient) {
77 e->accept();
78 } else {
79 showEmailClient();
80 }
81}
82
83void MailItWindow::compose()
84{
85 viewingMail = FALSE;
86 emailClient->hide();
87 readMail->hide();
88 views->raiseWidget(writeMail);
89 writeMail->setAddressList(emailClient->getAdrListRef());
90 writeMail->newMail();
91 setCaption( tr( "Write mail" ) );
92}
93
94void MailItWindow::composeReply(Email &mail, bool& replyAll)
95{
96 compose();
97 writeMail->reply(mail,replyAll) ;
98}
99
100void MailItWindow::composeForward(Email &mail)
101{
102 compose();
103 writeMail->forward(mail) ;
104}
105
106
107void MailItWindow::showEmailClient()
108{
109 viewingMail = FALSE;
110 writeMail->hide();
111 readMail->hide();
112 views->raiseWidget(emailClient);
113 setCaption( tr(currentCaption) );
114}
115
116void MailItWindow::viewMail(QListView *view, Email *mail)
117{
118 viewingMail = TRUE;
119 emailClient->hide();
120
121 int result=0;
122
123 if ((mail->received)&&(!mail->downloaded))
124 {
125 QMessageBox mb( tr("Mail not downloaded"),
126 tr("The mail you have clicked \n"
127 "has not been downloaded yet.\n "
128 "Would you like to do it now ?"),
129 QMessageBox::Information,
130 QMessageBox::Yes | QMessageBox::Default,
131 QMessageBox::No | QMessageBox::Escape,0 );
132
133 result=mb.exec();
134
135 if (result==QMessageBox::Yes)
136 {
137 emailClient->download(mail);
138 }
139 }
140
141 readMail->update(view, mail);
142 views->raiseWidget(readMail);
143 setCaption( tr( "Read Mail" ) );
144}
145
146void MailItWindow::updateMailView(Email *mail)
147{
148 if (viewingMail) {
149 readMail->mailUpdated(mail);
150 }
151}
152
153void MailItWindow::updateCaption(const QString &newCaption)
154{
155 currentCaption = newCaption;
156 setCaption(tr(currentCaption));
157}
158
159void MailItWindow::setDocument(const QString &_address)
160{
161 // strip leading 'mailto:'
162 QString address = _address;
163 if (address.startsWith("mailto:"))
164 address = address.mid(6);
165
166 compose();
167 writeMail->setRecipient(address);
168}
diff --git a/noncore/net/mailit/mailitwindow.h b/noncore/net/mailit/mailitwindow.h
deleted file mode 100644
index 11e56b9..0000000
--- a/noncore/net/mailit/mailitwindow.h
+++ b/dev/null
@@ -1,65 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MailItWindow_H
21#define MailItWindow_H
22
23#include <qmainwindow.h>
24#include <qwidgetstack.h>
25#include <qevent.h>
26//#include <qlayout.h>
27#include "emailclient.h"
28#include "writemail.h"
29#include "readmail.h"
30#include "addresslist.h"
31
32class MailItWindow: public QMainWindow
33{
34 Q_OBJECT
35public:
36 static QString appName() { return QString::fromLatin1("mailit"); }
37 MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
38 ~MailItWindow();
39
40signals:
41public slots:
42 void compose();
43 void composeReply(Email &, bool&);
44 void composeForward(Email &);
45 void showEmailClient();
46 void viewMail(QListView *, Email *mail);
47 void updateMailView(Email *mail);
48 void closeEvent(QCloseEvent *e);
49 void updateCaption(const QString &);
50 void setDocument(const QString &);
51 /*void reply(Email&);
52 void replyAll(Email&);
53 void forward(Email&);
54 void remove(Email&);*/
55
56private:
57 EmailClient *emailClient;
58 WriteMail *writeMail;
59 ReadMail *readMail;
60 QWidgetStack *views;
61 QString currentCaption;
62 bool viewingMail;
63};
64
65#endif
diff --git a/noncore/net/mailit/maillist.cpp b/noncore/net/mailit/maillist.cpp
deleted file mode 100644
index 8c34295..0000000
--- a/noncore/net/mailit/maillist.cpp
+++ b/dev/null
@@ -1,131 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "maillist.h"
21
22void MailList::clear()
23{
24 sortedList.setAutoDelete(TRUE);
25 sortedList.clear();
26 currentPos = 0;
27}
28
29int MailList::count()
30{
31 return sortedList.count();
32}
33
34int* MailList::first()
35{
36 dList *mPtr;
37
38 if (sortedList.count() == 0)
39 return NULL;
40
41 mPtr = sortedList.at(0);
42 currentPos = 1;
43 return &(mPtr->serverId);
44}
45
46int* MailList::next()
47{
48 dList *mPtr;
49
50 if ( (currentPos) >= sortedList.count())
51 return NULL;
52
53 mPtr = sortedList.at(currentPos);
54 currentPos++;
55 return &(mPtr->serverId);
56}
57
58void MailList::sizeInsert(int serverId, uint size)
59{
60 dList *tempPtr;
61 int x;
62
63 dList *newEntry = new dList;
64 newEntry->serverId = serverId;
65 newEntry->size = size;
66
67 for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) {
68 if (newEntry->size < tempPtr->size) {
69 x = sortedList.at();
70 sortedList.insert(x, newEntry);
71 return;
72 }
73 }
74 sortedList.append(newEntry);
75}
76
77void MailList::moveFront(int serverId, uint/* size*/)
78{
79 dList *currentPtr;
80 uint tempPos;
81 QString temp;
82
83 tempPos = currentPos;
84 if ( tempPos >= sortedList.count() )
85 return;
86 currentPtr = sortedList.at(tempPos);
87 while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
88 tempPos++;
89 currentPtr = sortedList.at(tempPos);
90 }
91
92 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
93 temp.setNum(currentPtr->serverId);
94 qWarning("moved to front, message: " + temp);
95
96 dList *itemPtr = sortedList.take(tempPos);
97 sortedList.insert(currentPos, itemPtr);
98 }
99
100}
101
102//only works if mail is not already in download
103bool MailList::remove(int serverId, uint /*size*/)
104{
105 dList *currentPtr;
106 uint tempPos;
107 QString temp;
108
109 tempPos = currentPos;
110 if ( tempPos >=sortedList.count() )
111 return FALSE;
112 currentPtr = sortedList.at(tempPos);
113 while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
114 tempPos++;
115 currentPtr = sortedList.at(tempPos);
116 }
117
118 if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
119 temp.setNum(currentPtr->serverId);
120 qWarning("deleted message: " + temp);
121 sortedList.remove(tempPos);
122
123 return TRUE;
124 }
125 return FALSE;
126}
127
128void MailList::insert(int /*pos*/, int /*serverId*/, uint/* size*/)
129{
130// sortedList.insert(pos, mPtr);
131}
diff --git a/noncore/net/mailit/maillist.h b/noncore/net/mailit/maillist.h
deleted file mode 100644
index ec996df..0000000
--- a/noncore/net/mailit/maillist.h
+++ b/dev/null
@@ -1,50 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MAILLIST_H
21#define MAILLIST_H
22
23#include <qobject.h>
24#include <qlist.h>
25
26struct dList{
27 int serverId;
28 uint size;
29};
30
31class MailList : public QObject
32{
33 Q_OBJECT
34
35public:
36 void clear();
37 int count();
38 int* first();
39 int* next();
40 void sizeInsert(int serverId, uint size);
41 void moveFront(int serverId, uint size);
42 bool remove(int serverId, uint size);
43 void insert(int pos, int serverId, uint size);
44
45private:
46 QList<dList> sortedList;
47 uint currentPos;
48};
49
50#endif
diff --git a/noncore/net/mailit/main.cpp b/noncore/net/mailit/main.cpp
deleted file mode 100644
index 71f8877..0000000
--- a/noncore/net/mailit/main.cpp
+++ b/dev/null
@@ -1,25 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qpe/qpeapplication.h>
21#include "mailitwindow.h"
22
23#include <opie/oapplicationfactory.h>
24
25OPIE_EXPORT_APP( OApplicationFactory<MailItWindow> ) \ No newline at end of file
diff --git a/noncore/net/mailit/md5.c b/noncore/net/mailit/md5.c
deleted file mode 100644
index 611f151..0000000
--- a/noncore/net/mailit/md5.c
+++ b/dev/null
@@ -1,251 +0,0 @@
1/*
2 * This code implements the MD5 message-digest algorithm.
3 * The algorithm is due to Ron Rivest. This code was
4 * written by Colin Plumb in 1993, no copyright is claimed.
5 * This code is in the public domain; do with it what you wish.
6 *
7 * Equivalent code is available from RSA Data Security, Inc.
8 * This code has been tested against that, and is equivalent,
9 * except that you don't need to include two pages of legalese
10 * with every copy.
11 *
12 * To compute the message digest of a chunk of bytes, declare an
13 * MD5Context structure, pass it to MD5Init, call MD5Update as
14 * needed on buffers full of bytes, and then call MD5Final, which
15 * will fill a supplied 16-byte array with the digest.
16 *
17 * Changed so as no longer to depend on Colin Plumb's `usual.h' header
18 * definitions; now uses stuff from dpkg's config.h.
19 * - Ian Jackson <ijackson@nyx.cs.du.edu>.
20 * Still in the public domain.
21 *
22 * md5_buffer added by Steven Fuller
23 * Still in the public domain.
24 */
25
26 #include <string.h> /* for memcpy() */
27
28#include "md5.h"
29
30#ifdef WORDS_BIGENDIAN
31void
32byteSwap(UWORD32 *buf, unsigned words)
33{
34 md5byte *p = (md5byte *)buf;
35
36 do {
37 *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
38 ((unsigned)p[1] << 8 | p[0]);
39 p += 4;
40 } while (--words);
41}
42#else
43#define byteSwap(buf,words)
44#endif
45
46/* md5_buffer frontend added for AvP */
47void md5_buffer(char const *buffer, unsigned int len, char *digest)
48{
49 struct MD5Context md5c;
50
51 MD5Init(&md5c);
52 MD5Update(&md5c, (md5byte const *)buffer, len);
53 MD5Final((md5byte *)digest, &md5c);
54 }
55
56/*
57 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
58 * initialization constants.
59 */
60void
61MD5Init(struct MD5Context *ctx)
62{
63 ctx->buf[0] = 0x67452301;
64 ctx->buf[1] = 0xefcdab89;
65 ctx->buf[2] = 0x98badcfe;
66 ctx->buf[3] = 0x10325476;
67
68 ctx->bytes[0] = 0;
69 ctx->bytes[1] = 0;
70}
71
72/*
73 * Update context to reflect the concatenation of another buffer full
74 * of bytes.
75 */
76void
77MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
78{
79 UWORD32 t;
80
81 /* Update byte count */
82
83 t = ctx->bytes[0];
84 if ((ctx->bytes[0] = t + len) < t)
85 ctx->bytes[1]++;/* Carry from low to high */
86
87 t = 64 - (t & 0x3f);/* Space available in ctx->in (at least 1) */
88 if (t > len) {
89 memcpy((md5byte *)ctx->in + 64 - t, buf, len);
90 return;
91 }
92 /* First chunk is an odd size */
93 memcpy((md5byte *)ctx->in + 64 - t, buf, t);
94 byteSwap(ctx->in, 16);
95 MD5Transform(ctx->buf, ctx->in);
96 buf += t;
97 len -= t;
98
99 /* Process data in 64-byte chunks */
100 while (len >= 64) {
101 memcpy(ctx->in, buf, 64);
102 byteSwap(ctx->in, 16);
103 MD5Transform(ctx->buf, ctx->in);
104 buf += 64;
105 len -= 64;
106 }
107
108 /* Handle any remaining bytes of data. */
109 memcpy(ctx->in, buf, len);
110}
111
112/*
113 * Final wrapup - pad to 64-byte boundary with the bit pattern
114 * 1 0* (64-bit count of bits processed, MSB-first)
115 */
116void
117MD5Final(md5byte digest[16], struct MD5Context *ctx)
118{
119 int count = ctx->bytes[0] & 0x3f;/* Number of bytes in ctx->in */
120 md5byte *p = (md5byte *)ctx->in + count;
121
122 /* Set the first char of padding to 0x80. There is always room. */
123 *p++ = 0x80;
124
125 /* Bytes of padding needed to make 56 bytes (-8..55) */
126 count = 56 - 1 - count;
127
128 if (count < 0) {/* Padding forces an extra block */
129 memset(p, 0, count + 8);
130 byteSwap(ctx->in, 16);
131 MD5Transform(ctx->buf, ctx->in);
132 p = (md5byte *)ctx->in;
133 count = 56;
134 }
135 memset(p, 0, count);
136 byteSwap(ctx->in, 14);
137
138 /* Append length in bits and transform */
139 ctx->in[14] = ctx->bytes[0] << 3;
140 ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
141 MD5Transform(ctx->buf, ctx->in);
142
143 byteSwap(ctx->buf, 4);
144 memcpy(digest, ctx->buf, 16);
145 memset(ctx, 0, sizeof(ctx));/* In case it's sensitive */
146}
147
148#ifndef ASM_MD5
149
150/* The four core functions - F1 is optimized somewhat */
151
152/* #define F1(x, y, z) (x & y | ~x & z) */
153#define F1(x, y, z) (z ^ (x & (y ^ z)))
154#define F2(x, y, z) F1(z, x, y)
155#define F3(x, y, z) (x ^ y ^ z)
156#define F4(x, y, z) (y ^ (x | ~z))
157
158/* This is the central step in the MD5 algorithm. */
159#define MD5STEP(f,w,x,y,z,in,s) \
160 (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
161
162/*
163 * The core of the MD5 algorithm, this alters an existing MD5 hash to
164 * reflect the addition of 16 longwords of new data. MD5Update blocks
165 * the data and converts bytes into longwords for this routine.
166 */
167void
168MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
169{
170 register UWORD32 a, b, c, d;
171
172 a = buf[0];
173 b = buf[1];
174 c = buf[2];
175 d = buf[3];
176
177 MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
178 MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
179 MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
180 MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
181 MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
182 MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
183 MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
184 MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
185 MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
186 MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
187 MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
188 MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
189 MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
190 MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
191 MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
192 MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
193
194 MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
195 MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
196 MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
197 MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
198 MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
199 MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
200 MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
201 MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
202 MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
203 MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
204 MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
205 MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
206 MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
207 MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
208 MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
209 MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
210
211 MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
212 MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
213 MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
214 MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
215 MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
216 MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
217 MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
218 MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
219 MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
220 MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
221 MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
222 MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
223 MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
224 MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
225 MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
226 MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
227
228 MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
229 MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
230 MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
231 MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
232 MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
233 MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
234 MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
235 MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
236 MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
237 MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
238 MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
239 MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
240 MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
241 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
242 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
243 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
244
245 buf[0] += a;
246 buf[1] += b;
247 buf[2] += c;
248 buf[3] += d;
249}
250
251#endif
diff --git a/noncore/net/mailit/md5.h b/noncore/net/mailit/md5.h
deleted file mode 100644
index 7e22494..0000000
--- a/noncore/net/mailit/md5.h
+++ b/dev/null
@@ -1,55 +0,0 @@
1/*
2 * This is the header file for the MD5 message-digest algorithm.
3 * The algorithm is due to Ron Rivest. This code was
4 * written by Colin Plumb in 1993, no copyright is claimed.
5 * This code is in the public domain; do with it what you wish.
6 *
7 * Equivalent code is available from RSA Data Security, Inc.
8 * This code has been tested against that, and is equivalent,
9 * except that you don't need to include two pages of legalese
10 * with every copy.
11 *
12 * To compute the message digest of a chunk of bytes, declare an
13 * MD5Context structure, pass it to MD5Init, call MD5Update as
14 * needed on buffers full of bytes, and then call MD5Final, which
15 * will fill a supplied 16-byte array with the digest.
16 *
17 * Changed so as no longer to depend on Colin Plumb's `usual.h'
18 * header definitions; now uses stuff from dpkg's config.h
19 * - Ian Jackson <ijackson@nyx.cs.du.edu>.
20 * Still in the public domain.
21 *
22 * md5_buffer added by Steven Fuller
23 * Still in the public domain.
24 */
25
26#ifndef MD5_H
27#define MD5_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33typedef unsigned int UWORD32;
34
35#define md5byte unsigned char
36
37struct MD5Context {
38 UWORD32 buf[4];
39 UWORD32 bytes[2];
40 UWORD32 in[16];
41};
42
43void MD5Init(struct MD5Context *context);
44void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
45void MD5Final(unsigned char digest[16], struct MD5Context *context);
46void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
47
48/* md5_buffer frontend added for AvP */
49void md5_buffer(char const *buffer, unsigned int len, char *digest);
50
51#ifdef __cplusplus
52};
53#endif
54
55#endif /* !MD5_H */
diff --git a/noncore/net/mailit/opie-mailit.control b/noncore/net/mailit/opie-mailit.control
deleted file mode 100644
index 3789016..0000000
--- a/noncore/net/mailit/opie-mailit.control
+++ b/dev/null
@@ -1,9 +0,0 @@
1Package: opie-mailit
2Files: plugins/application/libmailit.so* bin/mailit apps/1Pim/mailit.desktop pics/mailit
3Priority: optional
4Section: opie/pim
5Maintainer: L.J. Potter <llornkcor@handhelds.org>
6Architecture: arm
7Version: $QPE_VERSION$EXTRAVERSION
8Description: EMail
9 A simple POP3 email client for the Opie environment.
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
deleted file mode 100644
index 1df6b2b..0000000
--- a/noncore/net/mailit/popclient.cpp
+++ b/dev/null
@@ -1,332 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "popclient.h"
21#include "emailhandler.h"
22//#define APOP_TEST
23
24extern "C" {
25#include "md5.h"
26}
27
28#include <qcstring.h>
29
30PopClient::PopClient()
31{
32
33 socket = new QSocket(this, "popClient");
34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
37
38 stream = new QTextStream(socket);
39
40 receiving = FALSE;
41 synchronize = FALSE;
42 lastSync = 0;
43 headerLimit = 0;
44 mailList = 0;
45 preview = FALSE;
46}
47
48PopClient::~PopClient()
49{
50 delete socket;
51 delete stream;
52}
53
54void PopClient::newConnection(const QString &target, int port)
55{
56 if (receiving) {
57 qWarning("socket in use, connection refused");
58 return;
59 }
60
61 status = Init;
62
63 socket->connectToHost(target, port);
64 receiving = TRUE;
65 //selected = FALSE;
66
67 emit updateStatus(tr("DNS lookup"));
68}
69
70void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
71{
72 popUserName = popUser;
73 popPassword = popPasswd;
74}
75
76void PopClient::setSynchronize(int lastCount)
77{
78 synchronize = TRUE;
79 lastSync = lastCount;
80}
81
82void PopClient::removeSynchronize()
83{
84 synchronize = FALSE;
85 lastSync = 0;
86}
87
88void PopClient::headersOnly(bool headers, int limit)
89{
90 preview = headers;
91 headerLimit = limit;
92}
93
94void PopClient::setSelectedMails(MailList *list)
95{
96 selected = TRUE;
97 mailList = list;
98}
99
100void PopClient::connectionEstablished()
101{
102 emit updateStatus(tr("Connection established"));
103}
104
105void PopClient::errorHandling(int status)
106{
107 errorHandlingWithMsg( status, QString::null );
108}
109void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
110{
111 emit updateStatus(tr("Error Occured"));
112 emit errorOccurred(status, Msg);
113 socket->close();
114 receiving = FALSE;
115}
116
117void PopClient::incomingData()
118{
119 QString response, temp, temp2, timeStamp;
120 QString md5Source;
121 int start, end;
122// char *md5Digest;
123 char md5Digest[16];
124// if ( !socket->canReadLine() )
125// return;
126
127
128 response = socket->readLine();
129
130 switch(status) {
131 //logging in
132 case Init: {
133#ifdef APOP_TEST
134 start = response.find('<',0);
135 end = response.find('>', start);
136 if( start >= 0 && end > start )
137 {
138 timeStamp = response.mid( start , end - start + 1);
139 md5Source = timeStamp + popPassword;
140
141 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
142
143 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
144 {
145 printf("%x", md5Digest[j]);
146 }
147 printf("\n");
148// qDebug(md5Digest);
149 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
150 // qDebug("%s", stream);
151 status = Stat;
152 }
153 else
154#endif
155 {
156 timeStamp = "";
157 *stream << "USER " << popUserName << "\r\n";
158 status = Pass;
159 }
160
161 break;
162 }
163
164 case Pass: {
165 *stream << "PASS " << popPassword << "\r\n";
166 status = Stat;
167
168 break;
169 }
170 //ask for number of messages
171 case Stat: {
172 if (response[0] == '+') {
173 *stream << "STAT" << "\r\n";
174 status = Mcnt;
175 } else errorHandlingWithMsg(ErrLoginFailed, response);
176 break;
177 }
178 //get count of messages, eg "+OK 4 900.." -> int 4
179 case Mcnt: {
180 if (response[0] == '+') {
181 temp = response.replace(0, 4, "");
182 int x = temp.find(" ", 0);
183 temp.truncate((uint) x);
184 newMessages = temp.toInt();
185 messageCount = 1;
186 status = List;
187
188 if (synchronize) {
189 //messages deleted from server, reload all
190 if (newMessages < lastSync)
191 lastSync = 0;
192 messageCount = 1;
193 }
194
195 if (selected && mailList ) {
196 int *ptr = mailList->first();
197 if (ptr != 0) {
198 newMessages++; //to ensure no early jumpout
199 messageCount = *ptr;
200 } else newMessages = 0;
201 }
202
203 } else errorHandlingWithMsg(ErrUnknownResponse, response);
204 }
205 //Read message number x, count upwards to messageCount
206 case List: {
207 if (messageCount <= newMessages) {
208 *stream << "LIST " << messageCount << "\r\n";
209 status = Size;
210 temp2.setNum(newMessages - lastSync);
211 temp.setNum(messageCount - lastSync);
212 if (!selected) {
213 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
214 } else {
215 //completing a previously closed transfer
216 /* if ( (messageCount - lastSync) <= 0) {
217 temp.setNum(messageCount);
218 emit updateStatus(tr("Previous message ") + temp);
219 } else {*/
220 emit updateStatus(tr("Completing message ") + temp);
221 //}
222 }
223 break;
224 } else {
225 emit updateStatus(tr("No new Messages"));
226 status = Quit;
227 }
228 }
229 //get size of message, eg "500 characters in message.." -> int 500
230 case Size: {
231 if (status != Quit) { //because of idiotic switch
232 if (response[0] == '+') {
233 temp = response.replace(0, 4, "");
234 int x = temp.find(" ", 0);
235 temp = temp.right(temp.length() - ((uint) x + 1) );
236 mailSize = temp.toInt();
237 emit currentMailSize(mailSize);
238
239 status = Retr;
240 } else {
241 //qWarning(response);
242 errorHandlingWithMsg(ErrUnknownResponse, response);
243 }
244 }
245 }
246 //Read message number x, count upwards to messageCount
247 case Retr: {
248 if (status != Quit) {
249 if ((selected)||(mailSize <= headerLimit))
250 {
251 *stream << "RETR " << messageCount << "\r\n";
252 } else { //only header
253 *stream << "TOP " << messageCount << " 0\r\n";
254 }
255 messageCount++;
256 status = Ignore;
257 break;
258 } }
259 case Ignore: {
260 if (status != Quit) { //because of idiotic switch
261 if (response[0] == '+') {
262 message = "";
263 status = Read;
264 if (!socket->canReadLine()) //sync. problems
265 break;
266 response = socket->readLine();
267 } else errorHandlingWithMsg(ErrUnknownResponse, response);
268 }
269 }
270 //add all incoming lines to body. When size is reached, send
271 //message, and go back to read new message
272 case Read: {
273 if (status != Quit) { //because of idiotic switch
274 message += response;
275 while ( socket->canReadLine() ) {
276 response = socket->readLine();
277 message += response;
278 }
279 emit downloadedSize(message.length());
280 int x = message.find("\r\n.\r\n",-5);
281 if (x == -1) {
282 break;
283 } else { //message reach entire size
284 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
285 {
286 emit newMessage(message, messageCount-1, mailSize, TRUE);
287 } else { //incomplete mail downloaded
288 emit newMessage(message, messageCount-1, mailSize, FALSE);
289 }
290
291 if ((messageCount > newMessages)||(selected)) //last message ?
292 {
293 status = Quit;
294 if (selected) { //grab next from queue
295 newMessages--;
296 status = Quit;
297 }
298 }
299 else
300 {
301 *stream << "LIST " << messageCount << "\r\n";
302 status = Size;
303 temp2.setNum(newMessages - lastSync);
304 temp.setNum(messageCount - lastSync);
305 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
306
307 break;
308 }
309 }
310 }
311 if (status != Quit)
312 break;
313 }
314 case Quit: {
315 *stream << "Quit\r\n";
316 status = Done;
317 int newM = newMessages - lastSync;
318 if (newM > 0) {
319 temp.setNum(newM);
320 emit updateStatus(temp + tr(" new messages"));
321 } else {
322 emit updateStatus(tr("No new messages"));
323 }
324
325 socket->close();
326 receiving = FALSE;
327 emit mailTransfered(newM);
328 break;
329 }
330 }
331
332}
diff --git a/noncore/net/mailit/popclient.h b/noncore/net/mailit/popclient.h
deleted file mode 100644
index 6774ceb..0000000
--- a/noncore/net/mailit/popclient.h
+++ b/dev/null
@@ -1,77 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef PopClient_H
21#define PopClient_H
22
23#include <stdio.h>
24#include <qsocket.h>
25#include <qstring.h>
26#include <qobject.h>
27#include <qtextstream.h>
28#include <qlist.h>
29#include "maillist.h"
30
31class PopClient: public QObject
32{
33 Q_OBJECT
34
35public:
36 PopClient();
37 ~PopClient();
38 void newConnection(const QString &target, int port);
39 void setAccount(const QString &popUser, const QString &popPasswd);
40 void setSynchronize(int lastCount);
41 void removeSynchronize();
42 void headersOnly(bool headers, int limit);
43 void setSelectedMails(MailList *list);
44
45signals:
46 void newMessage(const QString &, int, uint, bool);
47 void errorOccurred(int status, const QString & Msg );
48 void updateStatus(const QString &);
49 void mailTransfered(int);
50 void mailboxSize(int);
51 void currentMailSize(int);
52 void downloadedSize(int);
53
54public slots:
55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & );
57
58protected slots:
59 void connectionEstablished();
60 void incomingData();
61
62private:
63 QSocket *socket;
64 QTextStream *stream;
65 enum transferStatus
66 {
67 Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks,
68 Quit, Done, Ignore
69 };
70 int status, lastSync;
71 int messageCount, newMessages, mailSize, headerLimit;
72 bool receiving, synchronize, preview, selected;
73 QString popUserName, popPassword, message;
74 MailList *mailList;
75};
76
77#endif
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp
deleted file mode 100644
index 1682675..0000000
--- a/noncore/net/mailit/readmail.cpp
+++ b/dev/null
@@ -1,399 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "readmail.h"
21#include <qimage.h>
22#include <qwhatsthis.h>
23#include <qmime.h>
24#include <qaction.h>
25#include <qpopupmenu.h>
26#include <qpe/resource.h>
27
28ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl )
29 : QMainWindow(parent, name, fl)
30{
31 plainTxt = FALSE;
32
33 init();
34 viewAtt = new ViewAtt(0, "View Attatchments");
35}
36
37ReadMail::~ReadMail()
38{
39 delete emailView->mimeSourceFactory();
40 delete viewAtt;
41}
42
43void ReadMail::init()
44{
45 setToolBarsMovable(FALSE);
46
47 QPopupMenu* mailaction=new QPopupMenu(this);
48
49 bar = new QToolBar(this);
50 bar->setHorizontalStretchable( TRUE );
51
52 menu = new QMenuBar( bar );
53
54 viewMenu = new QPopupMenu(menu);
55 menu->insertItem( tr( "&View" ), viewMenu);
56
57 mailMenu = new QPopupMenu(menu);
58 menu->insertItem( tr( "&Mail" ), mailMenu);
59
60 bar = new QToolBar(this);
61
62 downloadButton = new QAction( tr( "Download" ), Resource::loadPixmap( "mailit/download" ),QString::null, 0, this, 0 );
63 connect(downloadButton, SIGNAL(activated()), this, SLOT(download()) );
64 downloadButton->setWhatsThis(tr("Click here to download the selected mail"));
65
66
67 previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 );
68 connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) );
69 previousButton->addTo(bar);
70 previousButton->addTo(viewMenu);
71 previousButton->setWhatsThis(tr("Read the previous mail in the list"));
72
73 nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
74 connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) );
75 nextButton->addTo(bar);
76 nextButton->addTo(viewMenu);
77 previousButton->setWhatsThis(tr("Read the next mail in the list"));
78
79 attachmentButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 );
80 connect( attachmentButton, SIGNAL( activated() ), this,
81 SLOT( viewAttachments() ) );
82 attachmentButton->addTo(bar);
83 attachmentButton->addTo(viewMenu);
84 attachmentButton->setWhatsThis(tr("Click here to add attachments to your mail"));
85
86 plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE);
87 connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) );
88 plainTextButton->addTo(bar);
89 plainTextButton->addTo(viewMenu);
90 plainTextButton->setWhatsThis(tr("The mail view has 2 modes:\n"
91 "<LI><B>RichText</B> shows the mail as HTML with reach features (no standard line breaks)</LI>"
92 "<LI><B>Plain</B> shows the mail as standard plain text</LI>"
93 "Click here to switch between those view modes" ));
94
95 //reply dependant on viewing inbox
96 replyButton = new QToolButton(Resource::loadPixmap("mailit/reply"),tr("reply"),tr("reply to mail"), this,SLOT(reply()),bar);
97 QWhatsThis::add(replyButton,tr("Click here to reply to the selected mail\nPress and hold for more options."));
98 replyButton->setPopup(mailaction);
99
100 replyAllButton = new QAction( tr( "Reply all" ), Resource::loadPixmap( "mailit/reply" ),QString::null, 0, this, 0 );
101 connect(replyAllButton, SIGNAL(activated()), this, SLOT(replyAll()));
102 replyAllButton->setWhatsThis(tr("Click here to reply to the selected mail to CC: addresses also"));
103 replyAllButton->addTo(mailaction);
104
105 forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ),
106 QString::null, 0, this, 0 );
107 connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()));
108 forwardButton->setWhatsThis(tr("Click here to forward the selected mail"));
109 forwardButton->addTo(mailaction);
110
111
112 deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 );
113 connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) );
114 deleteButton->addTo(bar);
115 deleteButton->addTo(mailMenu);
116 deleteButton->setWhatsThis(tr("Click here to remove the selected mail"));
117
118 viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close()));
119
120 emailView = new QTextView( this, "emailView" );
121
122 setCentralWidget(emailView);
123
124 mime = new QMimeSourceFactory();
125 emailView->setMimeSourceFactory(mime);
126}
127
128void ReadMail::updateView()
129{
130 Enclosure *ePtr;
131 QString mailStringSize;
132 QString text, temp;
133
134 mail->read = TRUE; //mark as read
135 inbox = mail->received;
136
137 replyButton->setEnabled(false);
138 /*replyButton->removeFrom(bar);
139 forwardButton->removeFrom(mailMenu);
140 forwardButton->removeFrom(bar);*/
141 downloadButton->removeFrom(bar);
142
143 //downloadButton->setEnabled(!mail->downloaded);
144
145
146 if (inbox == TRUE) {
147 replyButton->setEnabled(true);
148 /*replyButton->addTo(mailMenu);
149 forwardButton->addTo(bar);
150 forwardButton->addTo(mailMenu);*/
151
152
153 if (!mail->downloaded) {
154
155 downloadButton->addTo(bar);
156
157 //report currently viewed mail so that it will be
158 //placed first in the queue of new mails to download
159 emit viewingMail(mail);
160
161 double mailSize = (double) mail->size;
162 if (mailSize < 1024) {
163 mailStringSize.setNum(mailSize);
164 mailStringSize += " Bytes";
165 } else if (mailSize < 1024*1024) {
166 mailStringSize.setNum( (mailSize / 1024), 'g', 2 );
167 mailStringSize += " Kb";
168 } else {
169 mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3);
170 mailStringSize += " Mb";
171 }
172 }
173 }
174
175 QMimeSourceFactory *mime = emailView->mimeSourceFactory();
176
177 if (! plainTxt) { //use RichText, inline pics etc.
178 emailView->setTextFormat(QTextView::RichText);
179 text = "<b><big><center><font color=\"blue\">" + mail->subject
180 +"</font></center></big></b><br>";
181 text += "<b>From: </b>" + mail->from + " <i>" +
182 mail->fromMail + "</i><br>";
183
184 text +="<b>To: </b>";
185 for (QStringList::Iterator it = mail->recipients.begin();
186 it != mail->recipients.end(); ++it ) {
187 text += *it + " ";
188 }
189
190 text +="<br><b>CC: </b>";
191 for (QStringList::Iterator it = mail->carbonCopies.begin();
192 it != mail->carbonCopies.end(); ++it ) {
193 text += *it + " ";
194 }
195
196 text += "<br>" + mail->date;
197
198 if (mail->files.count() > 0) {
199 text += "<br><b>Attatchments: </b>";
200
201 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
202 text += ePtr->originalName + " ";
203 }
204 text += "<hr><br>" + mail->body;
205
206 if (inbox) {
207 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
208
209 text += "<br><hr><b>Attatchment: </b>" +
210 ePtr->originalName + "<hr>";
211
212 if (ePtr->contentType == "TEXT") {
213 QFile f(ePtr->path + ePtr->name);
214
215 if (f.open(IO_ReadOnly) ) {
216 QTextStream t(&f);
217 temp = t.read();
218 text += temp + "<br>";
219 f.close();
220 } else {
221 text += "<b>Could not locate file</b><br>";
222 }
223
224 }
225 if (ePtr->contentType == "IMAGE") {
226 // temp.setNum(emailView->width());//get display width
227 // text += "<img width=" + temp +" src =""" +
228 // ePtr->originalName + """> </img>";
229 text += "<img src =""" +
230 ePtr->originalName + """> </img>";
231 mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) ));
232 }
233 }
234 }
235 } else {
236 if (mail->downloaded || !inbox) {
237 text += "<hr><br>" + mail->body;
238 } else {
239 text += "<hr><br><b> Awaiting download </b><br>";
240 text += "Size of mail: " + mailStringSize;
241 }
242 }
243 emailView->setText(text);
244 } else { // show plain txt mail
245 emailView->setTextFormat(QTextView::PlainText);
246 text = "Subject: " + mail->subject + "\n";
247 text += "From: " + mail->from + " " + mail->fromMail + "\n";
248 text += "To: ";
249 for (QStringList::Iterator it = mail->recipients.begin();
250 it != mail->recipients.end(); ++it ) {
251 text += *it + " ";
252 }
253
254 text += "\nCC: ";
255 for (QStringList::Iterator it = mail->carbonCopies.begin();
256 it != mail->carbonCopies.end(); ++it ) {
257 text += *it + " ";
258 }
259
260
261 text += "\nDate: " + mail->date + "\n";
262 if (mail->files.count() > 0) {
263 text += "Attatchments: ";
264 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
265 text += ePtr->originalName + " ";
266 }
267 text += "\n\n";
268 } else text += "\n";
269
270 if (!inbox) {
271 text += mail->body;
272 } else if (mail->downloaded) {
273 text += mail->bodyPlain;
274 } else {
275 text += "\nAwaiting download\n";
276 text += "Size of mail: " + mailStringSize;
277 }
278
279 emailView->setText(text);
280 }
281
282 if (mail->files.count() == 0)
283 attachmentButton->setEnabled(FALSE);
284 else attachmentButton->setEnabled(TRUE);
285
286 setCaption("Examining mail: " + mail->subject);
287}
288
289//update view with current EmailListItem (item)
290void ReadMail::update(QListView *thisView, Email *mailIn)
291{
292 view = thisView;
293 item = (EmailListItem *) view->selectedItem();
294 mail = mailIn;
295 updateView();
296 updateButtons();
297}
298
299void ReadMail::mailUpdated(Email *mailIn)
300{
301 if (mailIn == mail) {
302 updateView();
303 } else {
304 updateButtons();
305 }
306}
307
308void ReadMail::close()
309{
310 emit cancelView();
311}
312
313//gets next item in listview, exits if there is no next
314void ReadMail::next()
315{
316 item = (EmailListItem *) item->nextSibling();
317 if (item != NULL) {
318 mail = item->getMail();
319 updateView();
320 }
321 updateButtons();
322}
323
324//gets previous item in listview, exits if there is no previous
325void ReadMail::previous()
326{
327 item = (EmailListItem *) item->itemAbove();
328 if (item != NULL) {
329 mail = item->getMail();
330 updateView();
331 }
332 updateButtons();
333}
334
335//deletes item, tries bringing up next or previous, exits if unsucessful
336void ReadMail::deleteItem()
337{
338 EmailListItem *temp = item;
339 temp = (EmailListItem *) item->nextSibling();//trybelow
340 if (temp == NULL)
341 temp = (EmailListItem *) item->itemAbove(); //try above
342
343 emit removeItem(item, inbox);
344
345 item = temp;
346 if (item != NULL) { //more items in list
347 mail = item->getMail();
348 updateView();
349 updateButtons();
350 } else close(); //no more items to see
351}
352
353void ReadMail::updateButtons()
354{
355 EmailListItem *temp;
356
357 temp = item;
358 if ((EmailListItem *) temp->nextSibling() == NULL)
359 nextButton->setEnabled(FALSE);
360 else nextButton->setEnabled(TRUE);
361
362 temp = item;
363 if ((EmailListItem *) temp->itemAbove() == NULL)
364 previousButton->setEnabled(FALSE);
365 else previousButton->setEnabled(TRUE);
366}
367
368void ReadMail::shiftText()
369{
370 plainTxt = ! plainTxt;
371 updateView();
372}
373
374void ReadMail::viewAttachments()
375{
376 viewAtt->update(mail, inbox);
377 viewAtt->showMaximized();
378}
379
380void ReadMail::reply()
381{
382 emit replyRequested(*mail, (bool&)FALSE);
383}
384
385void ReadMail::replyAll()
386{
387 emit replyRequested(*mail, (bool&)TRUE);
388}
389
390void ReadMail::forward()
391{
392 emit forwardRequested(*mail);
393}
394
395void ReadMail::download()
396{
397 emit download(mail);
398}
399
diff --git a/noncore/net/mailit/readmail.h b/noncore/net/mailit/readmail.h
deleted file mode 100644
index 6700595..0000000
--- a/noncore/net/mailit/readmail.h
+++ b/dev/null
@@ -1,95 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef READMAIL_H
21#define READMAIL_H
22
23#include <qaction.h>
24#include <qmainwindow.h>
25#include <qmenubar.h>
26#include <qpopupmenu.h>
27#include <qlabel.h>
28#include <qlistview.h>
29#include <qlayout.h>
30#include <qtextview.h>
31#include <qtoolbutton.h>
32
33#include "emailhandler.h"
34#include "emaillistitem.h"
35#include "viewatt.h"
36
37class ReadMail : public QMainWindow
38{
39 Q_OBJECT
40
41public:
42 ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
43 ~ReadMail();
44 void update(QListView *thisView, Email *mailIn);
45 void updateView();
46 void mailUpdated(Email *mailIn);
47
48signals:
49 void cancelView();
50 void replyRequested(Email &, bool &);
51 void forwardRequested(Email&);
52 void removeItem(EmailListItem *, bool &);
53 void viewingMail(Email *);
54 void download (Email*);
55
56public slots:
57 void close();
58 void next();
59 void previous();
60 void deleteItem();
61 void shiftText();
62 void viewAttachments();
63 void reply();
64 void replyAll();
65 void forward();
66 void download();
67
68private:
69 void init();
70 void updateButtons();
71
72private:
73 QListView *view;
74 EmailListItem *item;
75 bool plainTxt, inbox;
76 Email *mail;
77 ViewAtt *viewAtt;
78
79 QToolBar *bar;
80 QMenuBar *menu;
81 QPopupMenu *viewMenu, *mailMenu;
82 QAction *deleteButton;
83 QMimeSourceFactory *mime;
84 QAction *plainTextButton;
85 QAction *nextButton;
86 QTextView *emailView;
87 QAction *attachmentButton;
88 QAction *previousButton;
89 QToolButton *replyButton;
90 QAction *forwardButton;
91 QAction *replyAllButton;
92 QAction *downloadButton;
93};
94
95#endif // READMAIL_H
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
deleted file mode 100644
index 51ca50b..0000000
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/dev/null
@@ -1,170 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "smtpclient.h"
21#include "emailhandler.h"
22
23SmtpClient::SmtpClient()
24{
25 socket = new QSocket(this, "smtpClient");
26 stream = new QTextStream(socket);
27 mailList.setAutoDelete(TRUE);
28
29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32
33 sending = FALSE;
34}
35
36SmtpClient::~SmtpClient()
37{
38 delete socket;
39 delete stream;
40}
41
42void SmtpClient::newConnection(const QString &target, int port)
43{
44 if (sending) {
45 qWarning("socket in use, connection refused");
46 return;
47 }
48
49 status = Init;
50 sending = TRUE;
51 socket->connectToHost(target, port);
52
53 emit updateStatus(tr("DNS lookup"));
54}
55
56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{
58 RawEmail *mail = new RawEmail;
59
60 mail->from = from;
61 mail->subject = subject;
62 mail->to = to;
63 mail->body = body;
64
65 mailList.append(mail);
66}
67
68void SmtpClient::connectionEstablished()
69{
70 emit updateStatus(tr("Connection established"));
71
72}
73
74void SmtpClient::errorHandling(int status)
75{
76 errorHandlingWithMsg( status, QString::null );
77}
78
79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
80{
81 emit errorOccurred(status, EMsg );
82 socket->close();
83 mailList.clear();
84 sending = FALSE;
85}
86
87void SmtpClient::incomingData()
88{
89 QString response;
90
91 if (!socket->canReadLine())
92 return;
93
94 response = socket->readLine();
95 switch(status) {
96 case Init: {
97 if (response[0] == '2') {
98 status = From;
99 mailPtr = mailList.first();
100 *stream << "HELO there\r\n";
101 } else errorHandlingWithMsg(ErrUnknownResponse,response);
102 break;
103 }
104 case From: {
105 if (response[0] == '2') {
106 qDebug(mailPtr->from);
107 *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
108 status = Recv;
109 } else errorHandlingWithMsg(ErrUnknownResponse, response );
110 break;
111 }
112 case Recv: {
113 if (response[0] == '2') {
114 it = mailPtr->to.begin();
115 if (it == NULL) {
116 errorHandlingWithMsg(ErrUnknownResponse,response);
117 }
118 *stream << "RCPT TO: " << *it << "\r\n";
119 status = MRcv;
120 } else errorHandlingWithMsg(ErrUnknownResponse,response);
121 break;
122 }
123 case MRcv: {
124 if (response[0] == '2') {
125 it++;
126 if ( it != mailPtr->to.end() ) {
127 *stream << "RCPT TO: " << *it << "\r\n";
128 break;
129 } else {
130 status = Data;
131 }
132 } else errorHandlingWithMsg(ErrUnknownResponse,response);
133 }
134 case Data: {
135 if (response[0] == '2') {
136 *stream << "DATA\r\n";
137 status = Body;
138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
139
140 } else errorHandlingWithMsg(ErrUnknownResponse,response);
141 break;
142 }
143 case Body: {
144 if (response[0] == '3') {
145 *stream << mailPtr->body << "\r\n.\r\n";
146 mailPtr = mailList.next();
147 if (mailPtr != NULL) {
148 status = From;
149 } else {
150 status = Quit;
151 }
152 } else errorHandlingWithMsg(ErrUnknownResponse,response);
153 break;
154 }
155 case Quit: {
156 if (response[0] == '2') {
157 *stream << "QUIT\r\n";
158 status = Done;
159 QString temp;
160 temp.setNum(mailList.count());
161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
162 emit mailSent();
163 mailList.clear();
164 sending = FALSE;
165 socket->close();
166 } else errorHandlingWithMsg(ErrUnknownResponse,response);
167 break;
168 }
169 }
170}
diff --git a/noncore/net/mailit/smtpclient.h b/noncore/net/mailit/smtpclient.h
deleted file mode 100644
index 554ba3f..0000000
--- a/noncore/net/mailit/smtpclient.h
+++ b/dev/null
@@ -1,76 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef SmtpClient_H
21#define SmtpClient_H
22
23//#include <stdio.h>
24#include <qsocket.h>
25#include <qstring.h>
26#include <qobject.h>
27#include <qtextstream.h>
28#include <qstringlist.h>
29#include <qlist.h>
30
31struct RawEmail
32{
33 QString from;
34 QString subject;
35 QStringList to;
36 QString body;
37};
38
39class SmtpClient: public QObject
40{
41 Q_OBJECT
42
43public:
44 SmtpClient();
45 ~SmtpClient();
46 void newConnection(const QString &target, int port);
47 void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
48
49signals:
50 void errorOccurred(int, const QString & LR );
51 void updateStatus(const QString &);
52 void mailSent();
53
54public slots:
55 void errorHandling(int);
56 void errorHandlingWithMsg(int, const QString & LastResponse );
57
58protected slots:
59 void connectionEstablished();
60 void incomingData();
61
62private:
63 QSocket *socket;
64 QTextStream *stream;
65 enum transferStatus
66 {
67 Init, From, Recv, MRcv, Data, Body, Quit, Done
68 };
69 int status;
70 QList<RawEmail> mailList;
71 RawEmail *mailPtr;
72 bool sending;
73 QStringList::Iterator it;
74};
75
76#endif
diff --git a/noncore/net/mailit/textparser.cpp b/noncore/net/mailit/textparser.cpp
deleted file mode 100644
index e5c9f7c..0000000
--- a/noncore/net/mailit/textparser.cpp
+++ b/dev/null
@@ -1,304 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "textparser.h"
21
22TextParser::TextParser(const QString &in, const QString &lineBreak)
23{
24 data = in;
25 lineSep = lineBreak;
26
27 init();
28 createSeparators();
29 split();
30}
31
32TextParser::TextParser(const QString &in, const QString &lineBreak, const QString &sep)
33{
34 data = in;
35 lineSep = lineBreak;
36
37 init();
38 separators = sep;
39 split();
40}
41
42void TextParser::init()
43{
44 lineCount = 0;
45 linePos = 0;
46 totalElmCount = 0;
47 separatorPos = -1; //not initialized
48 wordPos = -1; //not initialized
49 sepAtLine = 0;
50 sepAtPosElm = -1; //such that nextSep equals 0
51 wordAtLine = 0;
52 wordAtPosElm = -1; //such that nextWord equals 0
53 atLine = 0;
54 atPosElm = 0;
55}
56
57void TextParser::createSeparators()
58{
59 separators = " @#,.:;<>*/(){}|'?-+=_";
60}
61
62/* Returns pos of given search criteria, -1 if not found */
63int TextParser::find(const QString &target, QChar sep, int pos, bool upperCase)
64{
65
66 t_splitElm parsstr;
67 QString pString, pTarget;
68 pTarget = target;
69 int atLine = 0, atPosElm = 0;
70
71 getLineReference(pos,&atLine,&atPosElm);
72
73 for (int x = pos; x < totalElmCount; x++)
74 {
75 parsstr=splitDone[atLine].elm[atPosElm++];
76
77 if (upperCase)
78 {
79 pString=parsstr.str.upper();
80 pTarget=pTarget.upper();
81 }
82 else
83 {
84 pString=parsstr.str;
85 }
86 if ((pString == pTarget) && (parsstr.separator == sep))
87 {
88 return x;
89 }
90 if (atPosElm >= splitDone[atLine].elmCount)
91 { //new Line
92 atLine++;
93 atPosElm = 0;
94 }
95 }
96 return -1;
97}
98
99int TextParser::elmCount()
100{
101 return totalElmCount;
102}
103
104QChar TextParser::separatorAt(int pos)
105{
106 if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1)
107 return QChar::null;
108
109 separatorPos = pos;
110 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
111}
112
113QChar TextParser::nextSeparator()
114{
115 sepAtPosElm++;
116 if (splitDone[sepAtLine].elmCount <= sepAtPosElm) {
117 sepAtLine++;
118 sepAtPosElm = 0;
119 }
120
121 separatorPos++;
122 return splitDone[sepAtLine].elm[sepAtPosElm].separator;
123}
124
125bool TextParser::hasNextSeparator()
126{
127 return ((separatorPos+1) < totalElmCount);
128}
129
130QString TextParser::wordAt(int pos)
131{
132 if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1)
133 return NULL;
134
135 wordPos = pos;
136 return splitDone[wordAtLine].elm[wordAtPosElm].str;
137}
138
139QString TextParser::nextWord()
140{
141 wordAtPosElm++;
142 if (splitDone[wordAtLine].elmCount <= wordAtPosElm) {
143 wordAtLine++;
144 wordAtPosElm = 0;
145 }
146
147 wordPos++;
148 return splitDone[wordAtLine].elm[wordAtPosElm].str;
149}
150
151bool TextParser::hasNextWord()
152{
153 return ((wordPos + 1) < totalElmCount);
154}
155
156QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false)
157{
158 QString returnStr = wordAt(*pos);
159 QChar chr = separatorAt(*pos);
160 QString s;
161
162 if (returnStr == "")
163 return "";
164 if (chr == stop)
165 return returnStr;
166
167 if (!lineEnd) {
168 while ((chr != stop) && hasNextWord()) {
169 returnStr.append(chr);
170 returnStr += nextWord();
171 chr = nextSeparator();
172 }
173 } else { //copy from pos to end of line
174 getLineReference(*pos, &atLine, &atPosElm);
175 returnStr = "";
176 while (atPosElm < splitDone[atLine].elmCount) {
177 if (splitDone[atLine].elm[atPosElm].str != "") {
178 returnStr += splitDone[atLine].elm[atPosElm].str;
179 }
180 chr = splitDone[atLine].elm[atPosElm].separator;
181 if (!chr.isNull() && (int) chr != 0) {
182 returnStr.append(splitDone[atLine].elm[atPosElm].separator);
183 }
184 atPosElm++;
185 }
186 }
187
188 *pos = wordPos;
189 return returnStr;
190}
191
192QString TextParser::getNextLine()
193{
194 atLine++;
195 atPosElm = 0;
196 if (atLine < lineCount)
197 return splitDone[atLine].str;
198 return "";
199}
200
201bool TextParser::hasNextLine()
202{
203 if (atLine+1 < lineCount)
204 return TRUE;;
205 return FALSE;
206}
207
208int TextParser::endLinePos(int pos)
209{
210 if ( (getLineReference(pos, &atLine, &atPosElm)) == -1)
211 return -1;
212
213 return (pos + (splitDone[atLine].elmCount - atPosElm) + 1);
214}
215
216int TextParser::getLineReference(int pos, int *line, int *inLinePos)
217{
218 int currentPos = 0;
219
220 for (int x = 0; x < lineCount; x++) {
221 if ( currentPos + splitDone[x].elmCount > pos) {
222 *line = x;
223 *inLinePos = pos - currentPos;
224 return 0; //pos found okay
225 }
226 currentPos += splitDone[x].elmCount;
227 }
228 return -1; //no reference found
229}
230
231void TextParser::split()
232{
233 t_splitLine newLine;
234
235 while ((uint) linePos < data.length()) {
236 newLine = nextLine();
237 splitDone[lineCount] = splitLine(newLine);
238 totalElmCount += splitDone[lineCount].elmCount;
239 lineCount++;
240 }
241}
242
243t_splitLine TextParser::splitLine(t_splitLine line)
244{
245 uint pos = 0;
246 uint elmCount = 0;
247 t_splitLine tempLine = line;
248
249 tempLine.str = line.str.simplifyWhiteSpace();
250 tempLine.elm[0].str = "";
251 while ( pos < line.str.length() ) {
252 if ( isSeparator(tempLine.str[pos]) ) {
253 tempLine.elm[elmCount].separator = tempLine.str[pos];
254 elmCount++;
255 pos++;
256 while (tempLine.str[pos] == ' ')
257 pos++;
258 if (pos > line.str.length())
259 elmCount--;
260 tempLine.elm[elmCount].str = "";
261 } else {
262 if (!tempLine.str[pos].isNull())
263 tempLine.elm[elmCount].str += tempLine.str[pos];
264 pos++;
265 }
266 }
267
268 tempLine.elmCount = elmCount + 1;
269 return tempLine;
270}
271
272bool TextParser::isSeparator(QChar chr)
273{
274 for (uint x = 0; x < separators.length(); x++) {
275 if (chr == separators[x])
276 return true;
277 }
278 return false;
279}
280
281t_splitLine TextParser::nextLine()
282{
283 int newLinePos;
284 t_splitLine lineType;
285
286 newLinePos = data.find(lineSep, linePos);
287
288 lineType.lineType = NewLine;
289 lineType.str = "";
290
291 if (newLinePos == -1) {
292 newLinePos = data.length();
293 lineType.lineType = LastLine;
294 }
295
296 for (int x = linePos; x < newLinePos; x++)
297 lineType.str += data[x];
298
299 linePos = newLinePos;
300 if ((uint) linePos < data.length()) //if not EOF, add length of lineSep
301 linePos += lineSep.length();
302
303 return lineType;
304}
diff --git a/noncore/net/mailit/textparser.h b/noncore/net/mailit/textparser.h
deleted file mode 100644
index 03bb6d5..0000000
--- a/noncore/net/mailit/textparser.h
+++ b/dev/null
@@ -1,85 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qobject.h>
21#include <qstring.h>
22
23#ifndef TEXTPARSER_H
24#define TEXTPARSER_H
25
26enum t_strType { Word, Number};
27enum t_lineType {NewLine, LastLine};
28
29const uint MAX_ELEMENTS = 200; //Should be dynamic
30const uint MAX_LINES = 500; //Should be dynamic
31
32struct t_splitElm
33{
34 QChar separator;
35 int strType;
36 QString str;
37};
38
39struct t_splitLine
40{
41 t_lineType lineType;
42 QString str; //a bit redundant...
43 t_splitElm elm[MAX_ELEMENTS];
44 int elmCount;
45};
46
47class TextParser: public QObject
48{
49 Q_OBJECT
50
51public:
52 TextParser(const QString &in, const QString &lineBreak);
53 TextParser(const QString &in, const QString &lineBreak, const QString &sep);
54 int find(const QString &target, QChar sep, int pos, bool upperCase);
55 int elmCount();
56 QChar separatorAt(int pos);
57 QChar nextSeparator();
58 bool hasNextSeparator();
59 QString wordAt(int pos);
60 QString nextWord();
61 bool hasNextWord();
62 QString getString(int *pos, QChar stop, bool lineEnd);
63 QString getNextLine();
64 bool hasNextLine();
65 int endLinePos(int pos);
66
67private:
68 void init();
69 void createSeparators();
70 t_splitLine nextLine();
71 void split();
72 t_splitLine splitLine(t_splitLine line);
73 bool isSeparator(QChar chr);
74 t_splitLine splitDone[MAX_LINES];
75 int getLineReference(int pos, int *line, int *inLinePos);
76
77 int lineCount, linePos, totalElmCount;
78 int separatorPos, wordPos;
79 QString data, separators, lineSep;
80 int sepAtLine, sepAtPosElm;
81 int wordAtLine, wordAtPosElm;
82 int atLine, atPosElm;
83};
84
85#endif
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp
deleted file mode 100644
index 3515ba5..0000000
--- a/noncore/net/mailit/viewatt.cpp
+++ b/dev/null
@@ -1,121 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qpe/resource.h>
21#include "viewatt.h"
22#include <qwhatsthis.h>
23#include <qpe/applnk.h>
24#include <qpe/mimetype.h>
25
26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
27 : QMainWindow(parent, name, f)
28{
29 setCaption(tr("Exploring attatchments"));
30
31 setToolBarsMovable( FALSE );
32 bar = new QToolBar(this);
33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
36
37 listView = new QListView(this, "AttView");
38 listView->addColumn( tr("Attatchment") );
39 listView->addColumn( tr("Type") );
40 listView->addColumn( tr("Installed") );
41 setCentralWidget(listView);
42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
43}
44
45void ViewAtt::update(Email *mailIn, bool inbox)
46{
47 QListViewItem *item;
48 Enclosure *ePtr;
49
50
51
52 listView->clear();
53 if (inbox) {
54 bar->clear();
55 installButton->addTo( bar );
56 bar->show();
57 } else {
58 bar->hide();
59 }
60
61 mail = mailIn;
62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
63
64 QString isInstalled = tr("No");
65 if (ePtr->installed)
66 isInstalled = tr("Yes");
67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
68
69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
70
71 MimeType mt(mtypeDef);
72
73 item->setPixmap(0, mt.pixmap());
74
75 /*
76 if (ePtr->contentType == "TEXT") {
77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
78 actions->addTo(bar);
79 }
80 if (ePtr->contentType == "AUDIO") {
81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
82 actions->addTo(bar);
83 item->setPixmap(0, Resource::loadPixmap("play"));
84 }
85 if (ePtr->contentType == "IMAGE") {
86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
87 actions->addTo(bar);
88 item->setPixmap(0, Resource::loadPixmap("pixmap"));
89 }*/
90 }
91}
92
93void ViewAtt::install()
94{
95 Enclosure *ePtr, *selPtr;
96 QListViewItem *item;
97 QString filename;
98 DocLnk d;
99
100 item = listView->selectedItem();
101 if (item != NULL) {
102 filename = item->text(0);
103 selPtr = NULL;
104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
105 if (ePtr->originalName == filename)
106 selPtr = ePtr;
107 }
108
109 if (selPtr == NULL) {
110 qWarning("Internal error, file is not installed to documents");
111 return;
112 }
113
114 d.setName(selPtr->originalName);
115 d.setFile(selPtr->path + selPtr->name);
116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
117 d.writeLink();
118 selPtr->installed = TRUE;
119 item->setText(2, tr("Yes"));
120 }
121}
diff --git a/noncore/net/mailit/viewatt.h b/noncore/net/mailit/viewatt.h
deleted file mode 100644
index 9e43407..0000000
--- a/noncore/net/mailit/viewatt.h
+++ b/dev/null
@@ -1,46 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef VIEWATT_H
21#define VIEWATT_H
22
23#include <qmainwindow.h>
24#include <qtoolbar.h>
25#include <qaction.h>
26#include <qlistview.h>
27#include "emailhandler.h"
28
29class ViewAtt : public QMainWindow
30{
31 Q_OBJECT
32
33public:
34 ViewAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35 void update(Email *mailIn, bool inbox);
36
37public slots:
38 void install();
39
40private:
41 QListView *listView;
42 QToolBar *bar;
43 QAction *installButton, *actions;
44 Email *mail;
45};
46#endif
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp
deleted file mode 100644
index 26b9660..0000000
--- a/noncore/net/mailit/writemail.cpp
+++ b/dev/null
@@ -1,402 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qmessagebox.h>
21#include <qwhatsthis.h>
22#include "writemail.h"
23#include <qpe/resource.h>
24
25WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl )
26{
27 showingAddressList = FALSE;
28 init();
29
30 addAtt = new AddAtt(0, "Add Attachments");
31}
32
33WriteMail::~WriteMail()
34{
35 delete addAtt;
36}
37
38void WriteMail::setAddressList(AddressList *list)
39{
40 AContact *cPtr;
41
42 addressList = list;
43
44 addressView->clear();
45 QList<AContact> *cListPtr = addressList->getContactList();
46 QListViewItem *item;
47 for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) {
48 item = new QListViewItem(addressView, cPtr->name, cPtr->email);
49 }
50}
51
52void WriteMail::init()
53{
54 setToolBarsMovable(FALSE);
55
56 bar = new QToolBar(this);
57 bar->setHorizontalStretchable( TRUE );
58
59 menu = new QMenuBar( bar );
60
61 mailMenu = new QPopupMenu(menu);
62 menu->insertItem( tr( "&Mail" ), mailMenu);
63 addMenu = new QPopupMenu(menu);
64 menu->insertItem( tr( "&Add" ), addMenu);
65
66 bar = new QToolBar(this);
67 attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0);
68 attachButton->addTo(bar);
69 attachButton->addTo(addMenu);
70 connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) );
71 attachButton->setWhatsThis(tr("Click here to attach files to your mail"));
72
73 confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0);
74 confirmButton->addTo(bar);
75 confirmButton->addTo(mailMenu);
76 connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) );
77 confirmButton->setWhatsThis(tr("This button puts your mail in the send queue"));
78
79 newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
80 newButton->addTo(mailMenu);
81 connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
82 newButton->setWhatsThis(tr("Click here to create a new mail"));
83
84 widget = new QWidget(this, "widget");
85 grid = new QGridLayout( widget );
86
87 recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
88 recipientsBox->insertItem( tr( "To:" ) );
89 recipientsBox->insertItem( tr( "CC:" ) );
90 recipientsBox->setCurrentItem(0);
91 grid->addWidget( recipientsBox, 0, 0 );
92 connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int)));
93
94 subjetLabel = new QLabel( widget, "subjetLabel" );
95 subjetLabel->setText( tr( "Subject:" ) );
96
97 grid->addWidget( subjetLabel, 1, 0 );
98
99 ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
100 ToolButton13_2->setText( tr( "..." ) );
101 grid->addWidget( ToolButton13_2, 1, 2 );
102
103 subjectInput = new QLineEdit( widget, "subjectInput" );
104 grid->addWidget( subjectInput, 1, 1 );
105 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here"));
106
107 toInput = new QLineEdit( widget, "toInput" );
108 grid->addWidget( toInput, 0, 1 );
109 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here"));
110
111 ccInput = new QLineEdit( widget, "ccInput" );
112 ccInput->hide();
113 grid->addWidget( ccInput, 0, 1 );
114 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here"));
115
116 addressButton = new QToolButton( widget, "addressButton" );
117 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
118 addressButton->setToggleButton(TRUE);
119 grid->addWidget( addressButton, 0, 2 );
120 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
121 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your Opie addressbook"));
122
123 emailInput = new QMultiLineEdit( widget, "emailInput" );
124 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
125 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here"));
126
127 addressView = new QListView( widget, "addressView");
128 addressView->addColumn(tr("Name"));
129 addressView->addColumn(tr("EMail") );
130 addressView->setAllColumnsShowFocus(TRUE);
131 addressView->setMultiSelection(TRUE);
132 addressView->hide();
133 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
134 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list"));
135
136 okButton = new QToolButton(bar, "ok");
137 okButton->setPixmap( Resource::loadPixmap("enter") );
138 okButton->hide();
139 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
140 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here"));
141
142 setCentralWidget(widget);
143}
144
145void WriteMail::reject()
146{
147 emit cancelMail();
148}
149
150void WriteMail::accept()
151{
152 QStringList attachedFiles, attachmentsType;
153 int idCount = 0;
154
155 if (toInput->text() == "")
156 {
157 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n"));
158 return;
159 }
160
161 if (! getRecipients(false) )
162 {
163 QMessageBox::warning(this,tr("Incorrect recipient separator"),
164 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
165 return;
166 }
167
168 if ((ccInput->text()!="") && (! getRecipients(true) ))
169 {
170 QMessageBox::warning(this,tr("Incorrect carbon copy separator"),
171 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
172 return;
173 }
174
175 mail.subject = subjectInput->text();
176 mail.body = emailInput->text();
177 mail.sent = false;
178 mail.received = false;
179
180 mail.rawMail = "To: ";
181
182 for (QStringList::Iterator it = mail.recipients.begin();
183 it != mail.recipients.end(); ++it) {
184
185 mail.rawMail += (*it);
186 mail.rawMail += ",\n";
187 }
188
189 mail.rawMail.truncate(mail.rawMail.length()-2);
190
191 mail.rawMail += "\nCC: ";
192
193 for (QStringList::Iterator it = mail.carbonCopies.begin();
194 it != mail.carbonCopies.end(); ++it) {
195
196 mail.rawMail += (*it);
197 mail.rawMail += ",\n";
198 }
199
200 mail.rawMail += mail.from;
201 mail.rawMail += "\nSubject: ";
202 mail.rawMail += mail.subject;
203 mail.rawMail += "\n\n";
204
205 attachedFiles = addAtt->returnattachedFiles();
206 attachmentsType = addAtt->returnFileTypes();
207
208 QStringList::Iterator itType = attachmentsType.begin();
209
210 Enclosure e;
211 for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) {
212 e.id = idCount;
213 e.originalName = (*it).latin1();
214 e.contentType = (*itType).latin1();
215 e.contentAttribute = (*itType).latin1();
216 e.saved = TRUE;
217 mail.addEnclosure(&e);
218
219 itType++;
220 idCount++;
221 }
222 mail.rawMail += mail.body;
223 mail.rawMail += "\n";
224 mail.rawMail += ".\n";
225 emit sendMailRequested(mail);
226 addAtt->clear();
227}
228
229void WriteMail::getAddress()
230{
231 showingAddressList = !showingAddressList;
232
233 if (showingAddressList) {
234 emailInput->hide();
235 addressView->show();
236 okButton->show();
237
238 } else {
239 addressView->hide();
240 okButton->hide();
241 emailInput->show();
242 }
243}
244
245void WriteMail::attachFile()
246{
247 addAtt->showMaximized();
248}
249
250void WriteMail::reply(Email replyMail, bool replyAll)
251{
252 int pos;
253 QString ccRecipients;
254
255 mail = replyMail;
256 mail.files.clear();
257
258 toInput->setText(mail.fromMail);
259
260 if (replyAll)
261 {
262 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it)
263 {
264 ccRecipients.append(*it);
265 ccRecipients.append(";");
266 }
267 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end
268 ccInput->setText(ccRecipients);
269 }
270 else ccInput->clear();
271
272 subjectInput->setText(tr("Re: ") + mail.subject);
273
274 QString citation=mail.fromMail;
275 citation.append(tr(" wrote on "));
276 citation.append(mail.date);
277 citation.append(":\n");
278
279
280 //mail.body.insert(0,tr("On"));
281 pos = 0;
282 mail.body.insert(pos, ">");
283 while (pos != -1) {
284 pos = mail.body.find('\n', pos);
285 if (pos != -1)
286 mail.body.insert(++pos, ">");
287 }
288 mail.body.insert(0,citation);
289 emailInput->setText(mail.body);
290}
291
292void WriteMail::forward(Email forwMail)
293{
294 // int pos=0;
295
296 QString fwdBody=tr("======forwarded message from ");
297 fwdBody.append(forwMail.fromMail);
298 fwdBody.append(tr(" starts======\n\n"));
299
300 mail=forwMail;
301 toInput->setText("");
302 ccInput->setText("");
303 subjectInput->setText(tr("FWD: ") + mail.subject);
304
305 fwdBody+=mail.body;
306 fwdBody+=QString(tr("======end of forwarded message======\n\n"));
307
308 emailInput->setText(fwdBody);
309}
310
311bool WriteMail::getRecipients(bool ccField)
312{
313 QString str, temp;
314 int pos = 0;
315
316 if (ccField)
317 {
318 mail.carbonCopies.clear();
319 temp = ccInput->text();
320 }
321 else
322 {
323 mail.recipients.clear();
324 temp=toInput->text() ;
325 }
326
327 while ( (pos = temp.find(';')) != -1) {
328 str = temp.left(pos).stripWhiteSpace();
329 temp = temp.right(temp.length() - (pos + 1));
330 if ( str.find('@') == -1)
331 return false;
332 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str);
333 //addressList->addContact(str, "");
334 }
335 temp = temp.stripWhiteSpace();
336 if ( temp.find('@') == -1)
337 return false;
338 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp);
339 //addressList->addContact(temp, "");
340
341 return TRUE;
342}
343
344void WriteMail::addRecipients()
345{
346 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
347}
348
349void WriteMail::addRecipients(bool ccField)
350{
351 QString recipients = "";
352
353 mail.recipients.clear();
354
355 QListViewItem *item = addressView->firstChild();
356 while (item != NULL) {
357 if ( item->isSelected() ) {
358 if (recipients == "") {
359 recipients = item->text(1);
360 } else {
361 recipients += "; " + item->text(1);
362 }
363 }
364 item = item->nextSibling();
365 }
366
367 ccField ? ccInput->setText(recipients):toInput->setText(recipients);
368
369 addressView->hide();
370 okButton->hide();
371 emailInput->show();
372 addressButton->setOn(FALSE);
373 showingAddressList = !showingAddressList;
374}
375
376void WriteMail::changeRecipients(int selection)
377{
378 if (selection==0)
379 {
380 toInput->show();
381 ccInput->hide();
382 }
383 else if (selection==1)
384 {
385 toInput->hide();
386 ccInput->show();
387 }
388}
389
390void WriteMail::setRecipient(const QString &recipient)
391{
392 toInput->setText(recipient);
393}
394
395void WriteMail::newMail()
396{
397 toInput->clear();
398 ccInput->clear();
399 subjectInput->clear();
400 emailInput->clear();
401 setAddressList(addressList);
402}
diff --git a/noncore/net/mailit/writemail.h b/noncore/net/mailit/writemail.h
deleted file mode 100644
index 921f27e..0000000
--- a/noncore/net/mailit/writemail.h
+++ b/dev/null
@@ -1,96 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef WRITEMAIL_H
21#define WRITEMAIL_H
22
23#include <qmainwindow.h>
24#include <qaction.h>
25#include <qlabel.h>
26#include <qtoolbar.h>
27#include <qtoolbutton.h>
28#include <qmenubar.h>
29#include <qlayout.h>
30#include <qlineedit.h>
31#include <qmultilineedit.h>
32#include <qlistview.h>
33#include <qcombobox.h>
34
35#include "emailhandler.h"
36#include "addresslist.h"
37#include "addatt.h"
38
39class WriteMail : public QMainWindow
40{
41 Q_OBJECT
42
43public:
44 WriteMail( QWidget* parent, const char* name, WFlags fl = 0 );
45 ~WriteMail();
46 void reply(Email replyMail, bool replyAll);
47 void setRecipient(const QString &recipient);
48 void setAddressList(AddressList *list);
49 void forward(Email forwMail);
50
51signals:
52 void sendMailRequested(const Email &mail);
53 void cancelMail();
54
55
56public slots:
57 void getAddress();
58 void attachFile();
59 void addRecipients();
60 void newMail();
61 void accept();
62 void reject();
63 void changeRecipients(int);
64
65private:
66 bool getRecipients(bool);
67 void init();
68 void addRecipients(bool);
69
70 Email mail;
71 AddAtt *addAtt;
72 AddressList *addressList;
73 bool showingAddressList;
74
75 QToolBar *bar;
76 QMenuBar *menu;
77 QPopupMenu *addMenu, *mailMenu;
78 QListView *addressView;
79
80 QToolButton *okButton;
81 QWidget *widget;
82 QAction *attachButton;
83 QAction *confirmButton;
84 QAction *newButton;
85 QLabel* subjetLabel;
86 QToolButton* ToolButton13_2;
87 QComboBox* recipientsBox;
88 QLineEdit *subjectInput;
89 QLineEdit *toInput;
90 QLineEdit *ccInput;
91 QToolButton* addressButton;
92 QMultiLineEdit* emailInput;
93 QGridLayout* grid;
94};
95
96#endif // WRITEMAIL_H
diff --git a/packages b/packages
index c4eaf66..ae84e97 100644
--- a/packages
+++ b/packages
@@ -95,3 +95,3 @@ CONFIG_MAIL3 noncore/net/mail mail.pro
95CONFIG_MAILAPPLET noncore/net/mail/taskbarapplet taskbarapplet.pro 95CONFIG_MAILAPPLET noncore/net/mail/taskbarapplet taskbarapplet.pro
96 CONFIG_MAILIT noncore/net/mailit mailit.pro 96 CONFIG_MAILIT noncore/unsupported/mailit mailit.pro
97CONFIG_MAIN_TAB_EXAMPLE examples/main-tab example.pro 97CONFIG_MAIN_TAB_EXAMPLE examples/main-tab example.pro