author | groucho <groucho> | 2003-04-24 11:19:11 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-24 11:19:11 (UTC) |
commit | 9671975e21266e3bfa6f3c793a3278b67cea34b7 (patch) (unidiff) | |
tree | 876c77939cfd0e00fc844b1b5af09b2978564a6d | |
parent | 51e782b9658de61dc02579e115a9c62f396609a3 (diff) | |
download | opie-9671975e21266e3bfa6f3c793a3278b67cea34b7.zip opie-9671975e21266e3bfa6f3c793a3278b67cea34b7.tar.gz opie-9671975e21266e3bfa6f3c793a3278b67cea34b7.tar.bz2 |
- reworked size filtering
- started reworking offline download
- better tab focus switching
- Hello "Whats this" capability
- Fixed parsing of To: header files (no more Delivered-To: and Reply-To: matches)
- Good bye Settings.txt, hello Config Objects and encrypted passwords
- Translation improvements (added trs)
- Parser optimizations
30 files changed, 488 insertions, 512 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp index d268f1f..daefac6 100644 --- a/noncore/net/mailit/addatt.cpp +++ b/noncore/net/mailit/addatt.cpp | |||
@@ -1,224 +1,224 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include "addatt.h" | 25 | #include "addatt.h" |
26 | 26 | ||
27 | FileItem::FileItem(QListView *parent, DocLnk* dl) | 27 | FileItem::FileItem(QListView *parent, DocLnk* dl) |
28 | : QListViewItem(parent) | 28 | : QListViewItem(parent) |
29 | { | 29 | { |
30 | /*file = fileInfo; | 30 | /*file = fileInfo; |
31 | type = fileType;*/ | 31 | type = fileType;*/ |
32 | 32 | ||
33 | doclnk=dl; | 33 | doclnk=dl; |
34 | 34 | ||
35 | setText(0, doclnk->name()); | 35 | setText(0, doclnk->name()); |
36 | 36 | ||
37 | /*if (fileType == "Picture") { | 37 | /*if (fileType == "Picture") { |
38 | setPixmap(0, Resource::loadPixmap("pixmap")); | 38 | setPixmap(0, Resource::loadPixmap("pixmap")); |
39 | } else if (fileType == "Document") { | 39 | } else if (fileType == "Document") { |
40 | setPixmap(0, Resource::loadPixmap("txt")); | 40 | setPixmap(0, Resource::loadPixmap("txt")); |
41 | } else if (fileType == "Sound") { | 41 | } else if (fileType == "Sound") { |
42 | setPixmap(0, Resource::loadPixmap("play")); | 42 | setPixmap(0, Resource::loadPixmap("play")); |
43 | } else if (fileType == "Movie") { | 43 | } else if (fileType == "Movie") { |
44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | 44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); |
45 | } else if (fileType == "File") { | 45 | } else if (fileType == "File") { |
46 | setPixmap(0, Resource::loadPixmap("exec")); | 46 | setPixmap(0, Resource::loadPixmap("exec")); |
47 | }*/ | 47 | }*/ |
48 | } | 48 | } |
49 | 49 | ||
50 | FileItem::~FileItem() | 50 | FileItem::~FileItem() |
51 | { | 51 | { |
52 | if (doclnk!=NULL) delete doclnk; | 52 | if (doclnk!=NULL) delete doclnk; |
53 | doclnk=NULL; | 53 | doclnk=NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | 56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) |
57 | : QDialog(parent, name, f) | 57 | : QDialog(parent, name, f) |
58 | { | 58 | { |
59 | setCaption("Adding attatchments"); | 59 | setCaption("Adding attachments"); |
60 | 60 | ||
61 | QGridLayout *top = new QGridLayout(this, 1,1 ); | 61 | QGridLayout *top = new QGridLayout(this, 1,1 ); |
62 | 62 | ||
63 | QHBox *buttons=new QHBox(this); | 63 | QHBox *buttons=new QHBox(this); |
64 | /*fileCategoryButton = new QPushButton(this);*/ | 64 | /*fileCategoryButton = new QPushButton(this);*/ |
65 | attatchButton = new QPushButton(tr("Attatch..."), buttons); | 65 | attachButton = new QPushButton(tr("attach..."), buttons); |
66 | removeButton = new QPushButton(tr("Remove"), buttons); | 66 | removeButton = new QPushButton(tr("Remove"), buttons); |
67 | 67 | ||
68 | /*fileCategories = new QPopupMenu(fileCategoryButton); | 68 | /*fileCategories = new QPopupMenu(fileCategoryButton); |
69 | fileCategoryButton->setPopup(fileCategories); | 69 | fileCategoryButton->setPopup(fileCategories); |
70 | fileCategories->insertItem("Document"); | 70 | fileCategories->insertItem("Document"); |
71 | fileCategories->insertItem("Picture"); | 71 | fileCategories->insertItem("Picture"); |
72 | fileCategories->insertItem("Sound"); | 72 | fileCategories->insertItem("Sound"); |
73 | fileCategories->insertItem("Movie"); | 73 | fileCategories->insertItem("Movie"); |
74 | fileCategories->insertItem("File"); | 74 | fileCategories->insertItem("File"); |
75 | 75 | ||
76 | fileCategoryButton->setText("Document"); | 76 | fileCategoryButton->setText("Document"); |
77 | top->addWidget(fileCategoryButton, 0, 0);*/ | 77 | top->addWidget(fileCategoryButton, 0, 0);*/ |
78 | 78 | ||
79 | 79 | ||
80 | top->addWidget(buttons,1,0); | 80 | top->addWidget(buttons,1,0); |
81 | //buttons->addWidget(attatchButton,0,0); | 81 | //buttons->addWidget(attachButton,0,0); |
82 | //buttons->addWidget(removeButton,0,1); | 82 | //buttons->addWidget(removeButton,0,1); |
83 | 83 | ||
84 | //connect(fileCategories, SIGNAL(activated(int)), this, | 84 | //connect(fileCategories, SIGNAL(activated(int)), this, |
85 | //SLOT(fileCategorySelected(int)) );*/ | 85 | //SLOT(fileCategorySelected(int)) );*/ |
86 | connect(attatchButton, SIGNAL(clicked()), this, | 86 | connect(attachButton, SIGNAL(clicked()), this, |
87 | SLOT(addAttatchment()) ); | 87 | SLOT(addattachment()) ); |
88 | connect(removeButton, SIGNAL(clicked()), this, | 88 | connect(removeButton, SIGNAL(clicked()), this, |
89 | SLOT(removeAttatchment()) ); | 89 | SLOT(removeattachment()) ); |
90 | 90 | ||
91 | /*listView = new QListView(this, "AttView"); | 91 | /*listView = new QListView(this, "AttView"); |
92 | listView->addColumn("Documents");* | 92 | listView->addColumn("Documents");* |
93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | 93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, |
94 | SLOT(addAttatchment()) );*/ | 94 | SLOT(addattachment()) );*/ |
95 | 95 | ||
96 | 96 | ||
97 | attView = new QListView(this, "Selected"); | 97 | attView = new QListView(this, "Selected"); |
98 | attView->addColumn(tr("Attached")); | 98 | attView->addColumn(tr("Attached")); |
99 | attView->addColumn(tr("File type")); | 99 | attView->addColumn(tr("File type")); |
100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | 100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, |
101 | SLOT(removeAttatchment()) ); | 101 | SLOT(removeattachment()) ); |
102 | 102 | ||
103 | //top->addWidget(ofs, 0,0); | 103 | //top->addWidget(ofs, 0,0); |
104 | top->addWidget(attView, 0,0); | 104 | top->addWidget(attView, 0,0); |
105 | 105 | ||
106 | clear(); | 106 | clear(); |
107 | 107 | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | void AddAtt::clear() | 111 | void AddAtt::clear() |
112 | { | 112 | { |
113 | attView->clear(); | 113 | attView->clear(); |
114 | //getFiles(); | 114 | //getFiles(); |
115 | modified = FALSE; | 115 | modified = FALSE; |
116 | } | 116 | } |
117 | 117 | ||
118 | /*void AddAtt::fileCategorySelected(int id) | 118 | /*void AddAtt::fileCategorySelected(int id) |
119 | { | 119 | { |
120 | fileCategoryButton->setText(fileCategories->text(id)); | 120 | fileCategoryButton->setText(fileCategories->text(id)); |
121 | getFiles(); | 121 | getFiles(); |
122 | }*/ | 122 | }*/ |
123 | 123 | ||
124 | void AddAtt::addAttatchment() | 124 | void AddAtt::addattachment() |
125 | { | 125 | { |
126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); | 126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); |
127 | 127 | ||
128 | ofs.showMaximized(); | 128 | ofs.showMaximized(); |
129 | 129 | ||
130 | if (ofs.exec()==QDialog::Accepted) | 130 | if (ofs.exec()==QDialog::Accepted) |
131 | { | 131 | { |
132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); | 132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); |
133 | FileItem* fi=new FileItem(attView,dl); | 133 | FileItem* fi=new FileItem(attView,dl); |
134 | fi->setPixmap(0,dl->pixmap()); | 134 | fi->setPixmap(0,dl->pixmap()); |
135 | fi->setText(1,dl->type()); | 135 | fi->setText(1,dl->type()); |
136 | attView->insertItem(fi); | 136 | attView->insertItem(fi); |
137 | modified = TRUE; | 137 | modified = TRUE; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void AddAtt::removeAttatchment() | 141 | void AddAtt::removeattachment() |
142 | { | 142 | { |
143 | if (attView->selectedItem() != NULL) | 143 | if (attView->selectedItem() != NULL) |
144 | { | 144 | { |
145 | attView->takeItem(attView->selectedItem()); | 145 | attView->takeItem(attView->selectedItem()); |
146 | } | 146 | } |
147 | modified = TRUE; | 147 | modified = TRUE; |
148 | } | 148 | } |
149 | 149 | ||
150 | void AddAtt::reject() | 150 | void AddAtt::reject() |
151 | { | 151 | { |
152 | if (modified) { | 152 | if (modified) { |
153 | attView->clear(); | 153 | attView->clear(); |
154 | modified = FALSE; | 154 | modified = FALSE; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void AddAtt::accept() | 158 | void AddAtt::accept() |
159 | { | 159 | { |
160 | modified = FALSE; | 160 | modified = FALSE; |
161 | hide(); | 161 | hide(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void AddAtt::getFiles() | 164 | void AddAtt::getFiles() |
165 | { | 165 | { |
166 | QString path, selected; | 166 | QString path, selected; |
167 | 167 | ||
168 | /*listView->clear(); | 168 | /*listView->clear(); |
169 | 169 | ||
170 | selected = fileCategoryButton->text(); | 170 | selected = fileCategoryButton->text(); |
171 | if (selected == "Picture") { | 171 | if (selected == "Picture") { |
172 | path = "../pics/"; | 172 | path = "../pics/"; |
173 | } else if (selected == "Document") { | 173 | } else if (selected == "Document") { |
174 | path = "" ; //sub-dirs not decided | 174 | path = "" ; //sub-dirs not decided |
175 | } else if (selected == "Sound") { | 175 | } else if (selected == "Sound") { |
176 | path = "../sounds/"; //sub-dirs not decided | 176 | path = "../sounds/"; //sub-dirs not decided |
177 | } else if (selected == "Movie") { | 177 | } else if (selected == "Movie") { |
178 | path = ""; //sub-dirs not decided | 178 | path = ""; //sub-dirs not decided |
179 | } else if (selected == "File") { | 179 | } else if (selected == "File") { |
180 | path = ""; //sub-dirs not decided | 180 | path = ""; //sub-dirs not decided |
181 | } | 181 | } |
182 | 182 | ||
183 | dir = new QDir(path); | 183 | dir = new QDir(path); |
184 | dir->setFilter(QDir::Files); | 184 | dir->setFilter(QDir::Files); |
185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | 185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); |
186 | 186 | ||
187 | QFileInfoListIterator it(*dirInfoList); // create list iterator | 187 | QFileInfoListIterator it(*dirInfoList); // create list iterator |
188 | 188 | ||
189 | while ( (fi=it.current()) ) { // for each file... | 189 | while ( (fi=it.current()) ) { // for each file... |
190 | item = new FileItem(lis+ütView, *fi, selected); | 190 | item = new FileItem(lis+ütView, *fi, selected); |
191 | ++it; // goto next list element | 191 | ++it; // goto next list element |
192 | }*/ | 192 | }*/ |
193 | } | 193 | } |
194 | 194 | ||
195 | QStringList AddAtt::returnAttatchedFiles() | 195 | QStringList AddAtt::returnattachedFiles() |
196 | { | 196 | { |
197 | QFileInfo info; | 197 | QFileInfo info; |
198 | QStringList list; | 198 | QStringList list; |
199 | 199 | ||
200 | item = (FileItem *) attView->firstChild(); | 200 | item = (FileItem *) attView->firstChild(); |
201 | 201 | ||
202 | 202 | ||
203 | while (item != NULL) { | 203 | while (item != NULL) { |
204 | DocLnk* dl=item->getDocLnk(); | 204 | DocLnk* dl=item->getDocLnk(); |
205 | list+=dl->file(); | 205 | list+=dl->file(); |
206 | /*info = item->getFileInfo(); | 206 | /*info = item->getFileInfo(); |
207 | list += info.filePath();*/ | 207 | list += info.filePath();*/ |
208 | item = (FileItem *) item->nextSibling(); | 208 | item = (FileItem *) item->nextSibling(); |
209 | } | 209 | } |
210 | return list; | 210 | return list; |
211 | } | 211 | } |
212 | 212 | ||
213 | QStringList AddAtt::returnFileTypes() | 213 | QStringList AddAtt::returnFileTypes() |
214 | { | 214 | { |
215 | QStringList list; | 215 | QStringList list; |
216 | 216 | ||
217 | item = (FileItem *) attView->firstChild(); | 217 | item = (FileItem *) attView->firstChild(); |
218 | 218 | ||
219 | while (item != NULL) { | 219 | while (item != NULL) { |
220 | list += item->getDocLnk()->type(); | 220 | list += item->getDocLnk()->type(); |
221 | item = (FileItem *) item->nextSibling(); | 221 | item = (FileItem *) item->nextSibling(); |
222 | } | 222 | } |
223 | return list; | 223 | return list; |
224 | } | 224 | } |
diff --git a/noncore/net/mailit/addatt.h b/noncore/net/mailit/addatt.h index fcf3279..a365947 100644 --- a/noncore/net/mailit/addatt.h +++ b/noncore/net/mailit/addatt.h | |||
@@ -1,76 +1,76 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef ADDATT_H | 20 | #ifndef ADDATT_H |
21 | #define ADDATT_H | 21 | #define ADDATT_H |
22 | 22 | ||
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <opie/ofiledialog.h> | 30 | #include <opie/ofiledialog.h> |
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | 32 | ||
33 | class FileItem : public QListViewItem | 33 | class FileItem : public QListViewItem |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); | 36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); |
37 | FileItem(QListView*, DocLnk*); | 37 | FileItem(QListView*, DocLnk*); |
38 | ~FileItem(); | 38 | ~FileItem(); |
39 | DocLnk* getDocLnk() {return doclnk;} | 39 | DocLnk* getDocLnk() {return doclnk;} |
40 | 40 | ||
41 | 41 | ||
42 | private: | 42 | private: |
43 | DocLnk* doclnk; | 43 | DocLnk* doclnk; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | class AddAtt : public QDialog | 46 | class AddAtt : public QDialog |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | 49 | ||
50 | public: | 50 | public: |
51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
52 | QStringList returnAttatchedFiles(); | 52 | QStringList returnattachedFiles(); |
53 | QStringList returnFileTypes(); | 53 | QStringList returnFileTypes(); |
54 | void getFiles(); | 54 | void getFiles(); |
55 | void clear(); | 55 | void clear(); |
56 | 56 | ||
57 | 57 | ||
58 | public slots: | 58 | public slots: |
59 | //void fileCategorySelected(int); | 59 | //void fileCategorySelected(int); |
60 | void addAttatchment(); | 60 | void addattachment(); |
61 | void removeAttatchment(); | 61 | void removeattachment(); |
62 | void reject(); | 62 | void reject(); |
63 | void accept(); | 63 | void accept(); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | FileItem* item; | 66 | FileItem* item; |
67 | QListView *attView; | 67 | QListView *attView; |
68 | QPushButton *attatchButton, *removeButton; | 68 | QPushButton *attachButton, *removeButton; |
69 | QPopupMenu *fileCategories; | 69 | QPopupMenu *fileCategories; |
70 | bool modified; | 70 | bool modified; |
71 | //QFileInfo *fi; | 71 | //QFileInfo *fi; |
72 | 72 | ||
73 | OFileDialog* ofs; | 73 | OFileDialog* ofs; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | #endif | 76 | #endif |
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp index 8d9ab91..7d60ebf 100644 --- a/noncore/net/mailit/addresslist.cpp +++ b/noncore/net/mailit/addresslist.cpp | |||
@@ -1,161 +1,161 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #include <opie/ocontactaccess.h> | 22 | #include <opie/ocontactaccess.h> |
23 | #include <opie/ocontact.h> | 23 | #include <opie/ocontact.h> |
24 | 24 | ||
25 | #include "addresslist.h" | 25 | #include "addresslist.h" |
26 | 26 | ||
27 | AddressList::AddressList() | 27 | AddressList::AddressList() |
28 | { | 28 | { |
29 | addresses.setAutoDelete(TRUE); | 29 | addresses.setAutoDelete(TRUE); |
30 | read(); | 30 | read(); |
31 | dirty = FALSE; | 31 | dirty = FALSE; |
32 | } | 32 | } |
33 | 33 | ||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void AddressList::addContact(QString email, QString name) |
40 | { | 40 | { |
41 | //skip if not a valid email address, | 41 | //skip if not a valid email address, |
42 | if (email.find( '@') == -1) | 42 | if (email.find( '@') == -1) |
43 | return; | 43 | return; |
44 | 44 | ||
45 | if ( ! containsEmail(email) ) { | 45 | if ( ! containsEmail(email) ) { |
46 | Contact *in = new Contact; | 46 | Contact *in = new Contact; |
47 | in->email = email; | 47 | in->email = email; |
48 | in->name = name; | 48 | in->name = name; |
49 | addresses.append(in); | 49 | addresses.append(in); |
50 | dirty = TRUE; | 50 | dirty = TRUE; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(QString email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(QString name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString AddressList::getNameByEmail(QString email) |
65 | { | 65 | { |
66 | int pos = getEmailRef(email); | 66 | int pos = getEmailRef(email); |
67 | if (pos != -1) { | 67 | if (pos != -1) { |
68 | Contact *ptr = addresses.at(pos); | 68 | Contact *ptr = addresses.at(pos); |
69 | return ptr->name; | 69 | return ptr->name; |
70 | } | 70 | } |
71 | 71 | ||
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | 74 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString AddressList::getEmailByName(QString name) |
76 | { | 76 | { |
77 | int pos = getNameRef(name); | 77 | int pos = getNameRef(name); |
78 | if (pos != -1) { | 78 | if (pos != -1) { |
79 | Contact *ptr = addresses.at(pos); | 79 | Contact *ptr = addresses.at(pos); |
80 | return ptr->email; | 80 | return ptr->email; |
81 | } | 81 | } |
82 | 82 | ||
83 | return NULL; | 83 | return NULL; |
84 | } | 84 | } |
85 | 85 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int AddressList::getEmailRef(QString email) |
87 | { | 87 | { |
88 | int pos = 0; | 88 | int pos = 0; |
89 | Contact *ptr; | 89 | Contact *ptr; |
90 | 90 | ||
91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
92 | if (ptr->email == email) | 92 | if (ptr->email == email) |
93 | return pos; | 93 | return pos; |
94 | pos++; | 94 | pos++; |
95 | } | 95 | } |
96 | return -1; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int AddressList::getNameRef(QString name) |
100 | { | 100 | { |
101 | int pos = 0; | 101 | int pos = 0; |
102 | Contact *ptr; | 102 | Contact *ptr; |
103 | 103 | ||
104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
105 | if (ptr->name == name) | 105 | if (ptr->name == name) |
106 | return pos; | 106 | return pos; |
107 | pos++; | 107 | pos++; |
108 | } | 108 | } |
109 | return -1; | 109 | return -1; |
110 | } | 110 | } |
111 | 111 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void AddressList::read() |
118 | { | 118 | { |
119 | OContactAccess::List::Iterator it; | 119 | OContactAccess::List::Iterator it; |
120 | 120 | ||
121 | QString lineEmail, lineName, email, name; | 121 | QString lineEmail, lineName, email, name; |
122 | OContactAccess m_contactdb("mailit"); | 122 | OContactAccess m_contactdb("mailit"); |
123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
124 | //OContact* oc; | 124 | //OContact* oc;(*it).defaultEmail() |
125 | 125 | ||
126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
127 | { | 127 | { |
128 | //oc=(OContact*) it; | 128 | //oc=(OContact*) it; |
129 | if ((*it).defaultEmail().length()!=0) | 129 | if ((*it).defaultEmail().length()!=0) |
130 | addContact((*it).defaultEmail(),(*it).fileAs()); | 130 | addContact((*it).defaultEmail(),(*it).fileAs()); |
131 | } | 131 | } |
132 | 132 | ||
133 | /*if (! f.open(IO_ReadOnly) ) | 133 | /*if (! f.open(IO_ReadOnly) ) |
134 | return; | 134 | return; |
135 | 135 | ||
136 | QTextStream stream(&f); | 136 | QTextStream stream(&f); |
137 | 137 | ||
138 | while (! stream.atEnd() ) { | 138 | while (! stream.atEnd() ) { |
139 | lineEmail = stream.readLine(); | 139 | lineEmail = stream.readLine(); |
140 | if (! stream.atEnd() ) | 140 | if (! stream.atEnd() ) |
141 | lineName = stream.readLine(); | 141 | lineName = stream.readLine(); |
142 | else return; | 142 | else return; |
143 | 143 | ||
144 | email = getRightString(lineEmail); | 144 | email = getRightString(lineEmail); |
145 | name = getRightString(lineName); | 145 | name = getRightString(lineName); |
146 | addContact(email, name); | 146 | addContact(email, name); |
147 | } | 147 | } |
148 | f.close();*/ | 148 | f.close();*/ |
149 | } | 149 | } |
150 | 150 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString AddressList::getRightString(QString in) |
152 | { | 152 | { |
153 | QString out = ""; | 153 | QString out = ""; |
154 | 154 | ||
155 | int pos = in.find('='); | 155 | int pos = in.find('='); |
156 | if (pos != -1) { | 156 | if (pos != -1) { |
157 | out = in.mid(pos+1).stripWhiteSpace(); | 157 | out = in.mid(pos+1).stripWhiteSpace(); |
158 | } | 158 | } |
159 | return out; | 159 | return out; |
160 | } | 160 | } |
161 | 161 | ||
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index ad1e0b4..23059cf 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -1,1004 +1,981 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qwhatsthis.h> | ||
26 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
27 | #include "emailclient.h" | 28 | #include "emailclient.h" |
28 | 29 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 30 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 31 | { |
31 | return dupl( (MailAccount *) d); | 32 | return dupl( (MailAccount *) d); |
32 | } | 33 | } |
33 | 34 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 35 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 36 | { |
36 | ac = new MailAccount(*in); | 37 | ac = new MailAccount(*in); |
37 | return ac; | 38 | return ac; |
38 | } | 39 | } |
39 | 40 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 41 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 42 | : QMainWindow( parent, name, fl ) |
42 | { | 43 | { |
43 | emailHandler = new EmailHandler(); | 44 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList(); | 45 | addressList = new AddressList(); |
45 | 46 | ||
46 | sending = FALSE; | 47 | sending = FALSE; |
47 | receiving = FALSE; | 48 | receiving = FALSE; |
48 | previewingMail = FALSE; | 49 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 50 | mailIdCount = 1; |
50 | accountIdCount = 1; | 51 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 52 | allAccounts = FALSE; |
52 | 53 | ||
53 | init(); | 54 | init(); |
54 | 55 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 56 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 57 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 58 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 59 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 60 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 61 | SLOT(popError(int)) ); |
61 | 62 | ||
62 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 63 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 64 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | 65 | ||
65 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | 66 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); |
66 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | 67 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); |
67 | 68 | ||
68 | 69 | ||
69 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 70 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
70 | SLOT(mailArrived(const Email &, bool)) ); | 71 | SLOT(mailArrived(const Email &, bool)) ); |
71 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 72 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
72 | SLOT(allMailArrived(int)) ); | 73 | SLOT(allMailArrived(int)) ); |
73 | 74 | ||
74 | mailconf = new Config("mailit"); | 75 | mailconf = new Config("mailit"); |
75 | //In case Synchronize is not defined in settings.txt | 76 | //In case Synchronize is not defined in settings.txt |
76 | 77 | ||
77 | readSettings(); | 78 | readSettings(); |
78 | 79 | ||
79 | updateAccounts(); | 80 | updateAccounts(); |
80 | 81 | ||
81 | lineShift = "\n"; | 82 | lineShift = "\n"; |
82 | readMail(); | 83 | readMail(); |
83 | lineShift = "\r\n"; | 84 | lineShift = "\r\n"; |
84 | 85 | ||
86 | mailboxView->setCurrentTab(0); //ensure that inbox has focus | ||
85 | } | 87 | } |
86 | 88 | ||
87 | 89 | ||
88 | EmailClient::~EmailClient() | 90 | EmailClient::~EmailClient() |
89 | { | 91 | { |
90 | //needs to be moved from destructor to closewindow event | 92 | //needs to be moved from destructor to closewindow event |
91 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 93 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
92 | //does not currently work. Defining outbox in the same | 94 | //does not currently work. Defining outbox in the same |
93 | //format as inbox is not a good solution as they have | 95 | //format as inbox is not a good solution as they have |
94 | //different properties | 96 | //different properties |
95 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 97 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
96 | saveSettings(); | 98 | saveSettings(); |
97 | 99 | ||
98 | mailconf->write(); | 100 | mailconf->write(); |
99 | delete mailconf; | 101 | delete mailconf; |
100 | 102 | ||
101 | } | 103 | } |
102 | 104 | ||
103 | void EmailClient::init() | 105 | void EmailClient::init() |
104 | { | 106 | { |
105 | statusBar = new QStatusBar(this); | 107 | statusBar = new QStatusBar(this); |
106 | statusBar->setSizeGripEnabled(FALSE); | 108 | statusBar->setSizeGripEnabled(FALSE); |
107 | 109 | ||
108 | status1Label = new QLabel( tr("Idle"), statusBar); | 110 | status1Label = new QLabel( tr("Idle"), statusBar); |
109 | status2Label = new QLabel("", statusBar); | 111 | status2Label = new QLabel("", statusBar); |
110 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 112 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
111 | status2Label, SLOT(setText(const QString &)) ); | 113 | status2Label, SLOT(setText(const QString &)) ); |
112 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 114 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
113 | status2Label, SLOT(setText(const QString &)) ); | 115 | status2Label, SLOT(setText(const QString &)) ); |
114 | 116 | ||
115 | progressBar = new QProgressBar(statusBar); | 117 | progressBar = new QProgressBar(statusBar); |
118 | |||
116 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 119 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
117 | this, SLOT(setTotalSize(int)) ); | 120 | this, SLOT(setTotalSize(int)) ); |
118 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 121 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
119 | this, SLOT(setMailSize(int)) ); | 122 | this, SLOT(setMailSize(int)) ); |
120 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 123 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
121 | this, SLOT(setDownloadedSize(int)) ); | 124 | this, SLOT(setDownloadedSize(int)) ); |
122 | 125 | ||
123 | statusBar->addWidget(status1Label); | 126 | statusBar->addWidget(status1Label); |
124 | statusBar->addWidget(progressBar); | 127 | statusBar->addWidget(progressBar); |
125 | statusBar->addWidget(status2Label); | 128 | statusBar->addWidget(status2Label); |
126 | 129 | ||
127 | setToolBarsMovable(FALSE); | 130 | setToolBarsMovable(FALSE); |
128 | 131 | ||
129 | bar = new QToolBar(this); | 132 | bar = new QToolBar(this); |
133 | QWhatsThis::add(bar,tr("Main operation toolbar")); | ||
130 | bar->setHorizontalStretchable( TRUE ); | 134 | bar->setHorizontalStretchable( TRUE ); |
131 | 135 | ||
132 | mb = new QMenuBar( bar ); | 136 | mb = new QMenuBar( bar ); |
133 | 137 | ||
134 | QPopupMenu *mail = new QPopupMenu(mb); | 138 | QPopupMenu *mail = new QPopupMenu(mb); |
135 | mb->insertItem( tr( "&Mail" ), mail); | 139 | mb->insertItem( tr( "&Mail" ), mail); |
136 | 140 | ||
137 | QPopupMenu *configure = new QPopupMenu(mb); | 141 | QPopupMenu *configure = new QPopupMenu(mb); |
138 | mb->insertItem( tr( "Accounts" ), configure); | 142 | mb->insertItem( tr( "Accounts" ), configure); |
139 | 143 | ||
140 | selectAccountMenu = new QPopupMenu(mb); | 144 | selectAccountMenu = new QPopupMenu(mb); |
141 | editAccountMenu = new QPopupMenu(mb); | 145 | editAccountMenu = new QPopupMenu(mb); |
142 | deleteAccountMenu = new QPopupMenu(mb); | 146 | deleteAccountMenu = new QPopupMenu(mb); |
143 | 147 | ||
144 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 148 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
145 | configure->insertItem(tr("Edit account"), editAccountMenu); | 149 | configure->insertItem(tr("Edit account"), editAccountMenu); |
146 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 150 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
147 | 151 | ||
148 | bar = new QToolBar(this); | 152 | bar = new QToolBar(this); |
149 | 153 | ||
150 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); | 154 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
151 | //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); | 155 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); |
152 | // setAccountButton->addTo(bar); | 156 | |
153 | //setAccountButton->addTo(mail); | ||
154 | |||
155 | /*idCount = 0; | ||
156 | |||
157 | for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; | ||
158 | accountPtr = accountList.next()) { | ||
159 | |||
160 | selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); | ||
161 | idCount++; | ||
162 | }*/ | ||
163 | getMailButton->setPopup(selectAccountMenu); | 157 | getMailButton->setPopup(selectAccountMenu); |
164 | 158 | ||
165 | |||
166 | /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | ||
167 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | ||
168 | getMailButton->addTo(bar);*/ | ||
169 | //getMailButton->addTo(mail); | ||
170 | |||
171 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 159 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
172 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 160 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
173 | sendMailButton->addTo(bar); | 161 | sendMailButton->addTo(bar); |
174 | sendMailButton->addTo(mail); | 162 | sendMailButton->addTo(mail); |
163 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); | ||
175 | 164 | ||
176 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 165 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
177 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 166 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
178 | composeButton->addTo(bar); | 167 | composeButton->addTo(bar); |
179 | composeButton->addTo(mail); | 168 | composeButton->addTo(mail); |
169 | composeButton->setWhatsThis("Compose a new mail"); | ||
180 | 170 | ||
181 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 171 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
182 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 172 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
183 | cancelButton->addTo(mail); | 173 | cancelButton->addTo(mail); |
184 | cancelButton->addTo(bar); | 174 | cancelButton->addTo(bar); |
185 | cancelButton->setEnabled(FALSE); | 175 | cancelButton->setEnabled(FALSE); |
176 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); | ||
177 | |||
186 | 178 | ||
187 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 179 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
188 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 180 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
189 | deleteButton->addTo(bar); | 181 | deleteButton->addTo(bar); |
182 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); | ||
190 | 183 | ||
191 | mailboxView = new OTabWidget( this, "mailboxView" ); | 184 | mailboxView = new OTabWidget( this, "mailboxView" ); |
192 | 185 | ||
193 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 186 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
194 | grid_2 = new QGridLayout( widget ); | 187 | grid_2 = new QGridLayout( widget ); |
195 | // grid_2->setSpacing(6); | 188 | // grid_2->setSpacing(6); |
196 | // grid_2->setMargin( 11 ); | 189 | // grid_2->setMargin( 11 ); |
197 | 190 | ||
198 | inboxView = new QListView( widget, "inboxView" ); | 191 | inboxView = new QListView( widget, "inboxView" ); |
199 | inboxView->addColumn( tr( "From" ) ); | 192 | inboxView->addColumn( tr( "From" ) ); |
200 | inboxView->addColumn( tr( "Subject" ) ); | 193 | inboxView->addColumn( tr( "Subject" ) ); |
201 | inboxView->addColumn( tr( "Date" ) ); | 194 | inboxView->addColumn( tr( "Date" ) ); |
202 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 195 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
203 | inboxView->setAllColumnsShowFocus(TRUE); | 196 | inboxView->setAllColumnsShowFocus(TRUE); |
197 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n It keeps the fetched mail which can be viewed by double clicking the entry.\n" | ||
198 | " A blue attachment icon shows whether this mail has attachments.")); | ||
204 | 199 | ||
205 | grid_2->addWidget( inboxView, 2, 0 ); | 200 | grid_2->addWidget( inboxView, 2, 0 ); |
206 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 201 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
207 | 202 | ||
208 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 203 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
209 | grid_3 = new QGridLayout( widget_2 ); | 204 | grid_3 = new QGridLayout( widget_2 ); |
210 | // grid_3->setSpacing(6); | 205 | // grid_3->setSpacing(6); |
211 | // grid_3->setMargin( 11 ); | 206 | // grid_3->setMargin( 11 ); |
212 | 207 | ||
213 | outboxView = new QListView( widget_2, "outboxView" ); | 208 | outboxView = new QListView( widget_2, "outboxView" ); |
214 | outboxView->addColumn( tr( "To" ) ); | 209 | outboxView->addColumn( tr( "To" ) ); |
215 | outboxView->addColumn( tr( "Subject" ) ); | 210 | outboxView->addColumn( tr( "Subject" ) ); |
216 | outboxView->setAllColumnsShowFocus(TRUE); | 211 | outboxView->setAllColumnsShowFocus(TRUE); |
217 | 212 | ||
213 | QWhatsThis::add(outboxView,QWidget::tr("This is the oubox view.\n It keeps the queued mails to send which can be reviewed by double clicking the entry.")); | ||
218 | grid_3->addWidget( outboxView, 0, 0 ); | 214 | grid_3->addWidget( outboxView, 0, 0 ); |
219 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 215 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
220 | 216 | ||
221 | setCentralWidget(mailboxView); | 217 | setCentralWidget(mailboxView); |
222 | 218 | ||
223 | mailboxView->setCurrentTab(0); | ||
224 | } | 219 | } |
225 | 220 | ||
226 | void EmailClient::compose() | 221 | void EmailClient::compose() |
227 | { | 222 | { |
228 | emit composeRequested(); | 223 | emit composeRequested(); |
229 | } | 224 | } |
230 | 225 | ||
231 | void EmailClient::cancel() | 226 | void EmailClient::cancel() |
232 | { | 227 | { |
233 | emailHandler->cancel(); | 228 | emailHandler->cancel(); |
234 | } | 229 | } |
235 | 230 | ||
236 | AddressList* EmailClient::getAdrListRef() | 231 | AddressList* EmailClient::getAdrListRef() |
237 | { | 232 | { |
238 | return addressList; | 233 | return addressList; |
239 | } | 234 | } |
240 | 235 | ||
241 | //this needs to be rewritten to syncronize with outboxView | 236 | //this needs to be rewritten to syncronize with outboxView |
242 | void EmailClient::enqueMail(const Email &mail) | 237 | void EmailClient::enqueMail(const Email &mail) |
243 | { | 238 | { |
244 | if (accountList.count() == 0) { | 239 | if (accountList.count() == 0) { |
245 | QMessageBox::warning(qApp->activeWindow(), | 240 | QMessageBox::warning(qApp->activeWindow(), |
246 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 241 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
247 | return; | 242 | return; |
248 | } | 243 | } |
249 | 244 | ||
250 | if (accountList.count() > 0) { | 245 | if (accountList.count() > 0) { |
251 | currentAccount = accountList.first(); | 246 | currentAccount = accountList.first(); |
252 | qWarning("using account " + currentAccount->name); | 247 | qWarning("using account " + currentAccount->name); |
253 | } | 248 | } |
254 | 249 | ||
255 | Email addMail = mail; | 250 | Email addMail = mail; |
256 | addMail.from = currentAccount->name; | 251 | addMail.from = currentAccount->name; |
257 | addMail.fromMail = currentAccount->emailAddress; | 252 | addMail.fromMail = currentAccount->emailAddress; |
258 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 253 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
259 | item = new EmailListItem(outboxView, addMail, false); | 254 | item = new EmailListItem(outboxView, addMail, false); |
260 | 255 | ||
261 | mailboxView->setCurrentTab(1); | 256 | mailboxView->setCurrentTab(1); |
262 | 257 | ||
263 | } | 258 | } |
264 | 259 | ||
265 | void EmailClient::sendQuedMail() | 260 | void EmailClient::sendQuedMail() |
266 | { | 261 | { |
267 | int count = 0; | 262 | int count = 0; |
268 | 263 | ||
269 | if (accountList.count() == 0) { | 264 | if (accountList.count() == 0) { |
270 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 265 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
271 | return; | 266 | return; |
272 | } | 267 | } |
273 | //traverse listview, find messages to send | 268 | //traverse listview, find messages to send |
274 | if (! sending) { | 269 | if (! sending) { |
275 | item = (EmailListItem *) outboxView->firstChild(); | 270 | item = (EmailListItem *) outboxView->firstChild(); |
276 | if (item != NULL) { | 271 | if (item != NULL) { |
277 | while (item != NULL) { | 272 | while (item != NULL) { |
278 | quedMessages.append(item->getMail()); | 273 | quedMessages.append(item->getMail()); |
279 | item = (EmailListItem *) item->nextSibling(); | 274 | item = (EmailListItem *) item->nextSibling(); |
280 | count++; | 275 | count++; |
281 | } | 276 | } |
282 | setMailAccount(); | 277 | setMailAccount(); |
283 | emailHandler->sendMail(&quedMessages); | 278 | emailHandler->sendMail(&quedMessages); |
284 | sending = TRUE; | 279 | sending = TRUE; |
285 | sendMailButton->setEnabled(FALSE); | 280 | sendMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 281 | cancelButton->setEnabled(TRUE); |
287 | } else { | 282 | } else { |
288 | qWarning("sendQuedMail(): no messages to send"); | 283 | qWarning("sendQuedMail(): no messages to send"); |
289 | } | 284 | } |
290 | } | 285 | } |
291 | } | 286 | } |
292 | 287 | ||
293 | void EmailClient::setMailAccount() | 288 | void EmailClient::setMailAccount() |
294 | { | 289 | { |
295 | emailHandler->setAccount(*currentAccount); | 290 | emailHandler->setAccount(*currentAccount); |
296 | } | 291 | } |
297 | 292 | ||
298 | void EmailClient::mailSent() | 293 | void EmailClient::mailSent() |
299 | { | 294 | { |
300 | sending = FALSE; | 295 | sending = FALSE; |
301 | sendMailButton->setEnabled(TRUE); | 296 | sendMailButton->setEnabled(TRUE); |
302 | 297 | ||
303 | quedMessages.clear(); | 298 | quedMessages.clear(); |
304 | outboxView->clear(); //should be moved to an sentBox | 299 | outboxView->clear(); //should be moved to an sentBox |
305 | } | 300 | } |
306 | 301 | ||
307 | void EmailClient::getNewMail() { | 302 | void EmailClient::getNewMail() { |
308 | 303 | ||
309 | if (accountList.count() == 0) { | 304 | if (accountList.count() == 0) { |
310 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 305 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
311 | "You must create an account", "OK\n"); | 306 | "You must create an account", "OK\n"); |
312 | return; | 307 | return; |
313 | } | 308 | } |
314 | 309 | ||
315 | setMailAccount(); | 310 | setMailAccount(); |
316 | 311 | ||
317 | receiving = TRUE; | 312 | receiving = TRUE; |
318 | previewingMail = TRUE; | 313 | previewingMail = TRUE; |
319 | getMailButton->setEnabled(FALSE); | 314 | getMailButton->setEnabled(FALSE); |
320 | cancelButton->setEnabled(TRUE); | 315 | cancelButton->setEnabled(TRUE); |
321 | selectAccountMenu->setEnabled(FALSE); | 316 | selectAccountMenu->setEnabled(FALSE); |
322 | 317 | ||
323 | status1Label->setText(currentAccount->accountName + " headers"); | 318 | status1Label->setText(currentAccount->accountName + " headers"); |
324 | progressBar->reset(); | 319 | progressBar->reset(); |
325 | 320 | ||
326 | //get any previous mails not downloaded and add to queue | 321 | //get any previous mails not downloaded and add to queue |
327 | /* mailDownloadList.clear(); | 322 | mailDownloadList.clear(); |
328 | Email *mailPtr; | 323 | Email *mailPtr; |
329 | item = (EmailListItem *) inboxView->firstChild(); | 324 | item = (EmailListItem *) inboxView->firstChild(); |
330 | while (item != NULL) { | 325 | while (item != NULL) { |
331 | mailPtr = item->getMail(); | 326 | mailPtr = item->getMail(); |
332 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 327 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
333 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 328 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
334 | } | 329 | } |
335 | item = (EmailListItem *) item->nextSibling(); | 330 | item = (EmailListItem *) item->nextSibling(); |
336 | }*/ | 331 | } |
337 | 332 | ||
338 | emailHandler->getMailHeaders(); | 333 | emailHandler->getMailHeaders(); |
334 | |||
339 | } | 335 | } |
340 | 336 | ||
341 | void EmailClient::getAllNewMail() | 337 | void EmailClient::getAllNewMail() |
342 | { | 338 | { |
343 | allAccounts = TRUE; | 339 | allAccounts = TRUE; |
344 | currentAccount = accountList.first(); | 340 | currentAccount = accountList.first(); |
345 | getNewMail(); | 341 | getNewMail(); |
346 | } | 342 | } |
347 | 343 | ||
348 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 344 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
349 | { | 345 | { |
350 | Enclosure *ePtr; | 346 | Enclosure *ePtr; |
351 | Email newMail; | 347 | Email newMail; |
352 | int thisMailId; | 348 | int thisMailId; |
353 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 349 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
354 | |||
355 | mailconf->setGroup(newMail.id); | 350 | mailconf->setGroup(newMail.id); |
356 | 351 | ||
357 | if (fromDisk) { | 352 | if (fromDisk) |
353 | { | ||
358 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 354 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
359 | newMail.size = mailconf->readNumEntry("size"); | 355 | newMail.size = mailconf->readNumEntry("size"); |
360 | newMail.serverId = mailconf->readNumEntry("serverid"); | 356 | newMail.serverId = mailconf->readNumEntry("serverid"); |
361 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 357 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
362 | } else { //mail arrived from server | 358 | } |
359 | else | ||
360 | { //mail arrived from server | ||
363 | newMail.serverId = mail.serverId; | 361 | newMail.serverId = mail.serverId; |
364 | newMail.size = mail.size; | 362 | newMail.size = mail.size; |
365 | newMail.downloaded = mail.downloaded; | 363 | newMail.downloaded = mail.downloaded; |
366 | 364 | ||
367 | newMail.fromAccountId = currentAccount->id; | 365 | newMail.fromAccountId = currentAccount->id; |
368 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 366 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
369 | } | 367 | } |
370 | 368 | ||
371 | //add if read or not | 369 | //add if read or not |
372 | newMail.read = mailconf->readBoolEntry("mailread"); | 370 | newMail.read = mailconf->readBoolEntry("mailread"); |
373 | 371 | ||
374 | //check if new mail | 372 | //check if new mail |
375 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 373 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
376 | thisMailId = mailIdCount; | 374 | thisMailId = mailIdCount; |
377 | mailIdCount++; | 375 | mailIdCount++; |
378 | 376 | ||
379 | //set server count, so that if the user aborts, the new | 377 | //set server count, so that if the user aborts, the new |
380 | //header is not reloaded | 378 | //header is not reloaded |
381 | if (currentAccount->synchronize) | 379 | if ((currentAccount)&&(currentAccount->synchronize)) |
382 | currentAccount->lastServerMailCount++; | 380 | currentAccount->lastServerMailCount++; |
383 | 381 | ||
384 | mailconf->writeEntry("internalmailid", thisMailId); | 382 | mailconf->writeEntry("internalmailid", thisMailId); |
385 | mailconf->writeEntry("downloaded", newMail.downloaded); | 383 | mailconf->writeEntry("downloaded", newMail.downloaded); |
386 | mailconf->writeEntry("size", (int) newMail.size); | 384 | mailconf->writeEntry("size", (int) newMail.size); |
387 | mailconf->writeEntry("serverid", newMail.serverId); | 385 | mailconf->writeEntry("serverid", newMail.serverId); |
388 | 386 | ||
389 | addressList->addContact(newMail.fromMail, newMail.from); | 387 | //addressList->addContact(newMail.fromMail, newMail.from); |
390 | } else if (!fromDisk) { //body to header arrived | ||
391 | mailconf->writeEntry("downloaded", TRUE); | ||
392 | } | 388 | } |
389 | |||
390 | mailconf->writeEntry("downloaded", newMail.downloaded); | ||
391 | |||
393 | QString stringMailId; | 392 | QString stringMailId; |
394 | stringMailId.setNum(thisMailId); | 393 | stringMailId.setNum(thisMailId); |
395 | //se if any attatchments needs to be stored | 394 | //see if any attatchments needs to be stored |
395 | |||
396 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 396 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
397 | QString stringId; | 397 | QString stringId; |
398 | stringId.setNum(ePtr->id); | 398 | stringId.setNum(ePtr->id); |
399 | 399 | ||
400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
401 | if (id != ePtr->id) { //new entry | 401 | if (id != ePtr->id) { //new entry |
402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
407 | mailconf->writeEntry("installed_" + stringId, FALSE); | 407 | mailconf->writeEntry("installed_" + stringId, FALSE); |
408 | 408 | ||
409 | ePtr->name = stringMailId + "_" + stringId; | 409 | ePtr->name = stringMailId + "_" + stringId; |
410 | ePtr->path = getPath(TRUE); | 410 | ePtr->path = getPath(TRUE); |
411 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 411 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
412 | ePtr->saved = TRUE; | 412 | ePtr->saved = TRUE; |
413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
415 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 415 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
416 | } else { | 416 | } else { |
417 | ePtr->saved = FALSE; | 417 | ePtr->saved = FALSE; |
418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
419 | } | 419 | } |
420 | } else { | 420 | } else { |
421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
423 | if (ePtr->saved) { | 423 | if (ePtr->saved) { |
424 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 424 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
425 | ePtr->path = mailconf->readEntry("path_" + stringId); | 425 | ePtr->path = mailconf->readEntry("path_" + stringId); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if (!previewingMail && !fromDisk) { | 429 | |
430 | bool found=false; | ||
431 | |||
432 | if (!fromDisk) | ||
433 | { | ||
434 | |||
430 | Email *mailPtr; | 435 | Email *mailPtr; |
431 | item = (EmailListItem *) inboxView->firstChild(); | 436 | item = (EmailListItem *) inboxView->firstChild(); |
432 | while (item != NULL) { | 437 | while ((item != NULL)&&(!found)) |
438 | { | ||
433 | mailPtr = item->getMail(); | 439 | mailPtr = item->getMail(); |
434 | if (mailPtr->id == newMail.id) { | 440 | if (mailPtr->id == newMail.id) { |
435 | item->setMail(newMail); | 441 | item->setMail(newMail); |
436 | emit mailUpdated(item->getMail()); | 442 | emit mailUpdated(item->getMail()); |
443 | found = true; | ||
437 | } | 444 | } |
438 | item = (EmailListItem *) item->nextSibling(); | 445 | item = (EmailListItem *) item->nextSibling(); |
439 | } | 446 | } |
440 | } else { | ||
441 | item = new EmailListItem(inboxView, newMail, TRUE); | ||
442 | if (!newMail.downloaded) | ||
443 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | ||
444 | } | 447 | } |
448 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); | ||
449 | |||
450 | /*if (!newMail.downloaded) | ||
451 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ | ||
445 | 452 | ||
446 | mailboxView->setCurrentTab(0); | 453 | mailboxView->setCurrentTab(0); |
447 | 454 | ||
448 | } | 455 | } |
449 | 456 | ||
450 | void EmailClient::allMailArrived(int count) | 457 | void EmailClient::allMailArrived(int count) |
451 | { | 458 | { |
452 | // not previewing means all mailtransfer has been done | 459 | // not previewing means all mailtransfer has been done |
453 | if (!previewingMail) { | 460 | /*if (!previewingMail) {*/ |
454 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 461 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
455 | emit newCaption("Mailit - " + currentAccount->accountName); | 462 | emit newCaption("Mailit - " + currentAccount->accountName); |
456 | getNewMail(); | 463 | getNewMail(); |
457 | return; | 464 | return; |
458 | } else { | 465 | } else { |
459 | allAccounts = FALSE; | 466 | allAccounts = FALSE; |
460 | receiving = FALSE; | 467 | receiving = FALSE; |
461 | getMailButton->setEnabled(TRUE); | 468 | getMailButton->setEnabled(TRUE); |
462 | cancelButton->setEnabled(FALSE); | 469 | cancelButton->setEnabled(FALSE); |
463 | selectAccountMenu->setEnabled(TRUE); | 470 | selectAccountMenu->setEnabled(TRUE); |
464 | status1Label->setText("Idle"); | 471 | status1Label->setText("Idle"); |
465 | 472 | ||
466 | progressBar->reset(); | 473 | progressBar->reset(); |
467 | return; | 474 | return; |
468 | } | 475 | } |
469 | } | 476 | //} |
470 | 477 | ||
471 | // all headers downloaded from server, start downloading remaining mails | 478 | // all headers downloaded from server, start downloading remaining mails |
472 | previewingMail = FALSE; | 479 | previewingMail = FALSE; |
473 | status1Label->setText(currentAccount->accountName); | 480 | status1Label->setText(currentAccount->accountName); |
474 | progressBar->reset(); | 481 | progressBar->reset(); |
475 | 482 | ||
476 | emailHandler->getMailByList(&mailDownloadList); | 483 | //emailHandler->getMailByList(&mailDownloadList); |
477 | 484 | ||
478 | mailboxView->setCurrentTab(0); | 485 | mailboxView->setCurrentTab(0); |
479 | } | 486 | } |
480 | 487 | ||
481 | void EmailClient::moveMailFront(Email *mailPtr) | 488 | void EmailClient::moveMailFront(Email *mailPtr) |
482 | { | 489 | { |
483 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 490 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
484 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 491 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
485 | } | 492 | } |
486 | } | 493 | } |
487 | 494 | ||
488 | void EmailClient::smtpError(int code) | 495 | void EmailClient::smtpError(int code) |
489 | { | 496 | { |
490 | QString temp; | 497 | QString temp; |
491 | 498 | ||
492 | if (code == ErrUnknownResponse) | 499 | if (code == ErrUnknownResponse) |
493 | temp = "Unknown response from server"; | 500 | temp = "Unknown response from server"; |
494 | 501 | ||
495 | if (code == QSocket::ErrHostNotFound) | 502 | if (code == QSocket::ErrHostNotFound) |
496 | temp = "host not found"; | 503 | temp = "host not found"; |
497 | if (code == QSocket::ErrConnectionRefused) | 504 | if (code == QSocket::ErrConnectionRefused) |
498 | temp = "connection refused"; | 505 | temp = "connection refused"; |
499 | if (code == QSocket::ErrSocketRead) | 506 | if (code == QSocket::ErrSocketRead) |
500 | temp = "socket packet error"; | 507 | temp = "socket packet error"; |
501 | 508 | ||
502 | if (code != ErrCancel) { | 509 | if (code != ErrCancel) { |
503 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 510 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
504 | } else { | 511 | } else { |
505 | status2Label->setText("Aborted by user"); | 512 | status2Label->setText("Aborted by user"); |
506 | } | 513 | } |
507 | 514 | ||
508 | sending = FALSE; | 515 | sending = FALSE; |
509 | sendMailButton->setEnabled(TRUE); | 516 | sendMailButton->setEnabled(TRUE); |
510 | cancelButton->setEnabled(FALSE); | 517 | cancelButton->setEnabled(FALSE); |
511 | quedMessages.clear(); | 518 | quedMessages.clear(); |
512 | } | 519 | } |
513 | 520 | ||
514 | void EmailClient::popError(int code) | 521 | void EmailClient::popError(int code) |
515 | { | 522 | { |
516 | QString temp; | 523 | QString temp; |
517 | 524 | ||
518 | if (code == ErrUnknownResponse) | 525 | if (code == ErrUnknownResponse) |
519 | temp = "Unknown response from server"; | 526 | temp = "Unknown response from server"; |
520 | if (code == ErrLoginFailed) | 527 | if (code == ErrLoginFailed) |
521 | temp = "Login failed\nCheck user name and password"; | 528 | temp = "Login failed\nCheck user name and password"; |
522 | 529 | ||
523 | if (code == QSocket::ErrHostNotFound) | 530 | if (code == QSocket::ErrHostNotFound) |
524 | temp = "host not found"; | 531 | temp = "host not found"; |
525 | if (code == QSocket::ErrConnectionRefused) | 532 | if (code == QSocket::ErrConnectionRefused) |
526 | temp = "connection refused"; | 533 | temp = "connection refused"; |
527 | if (code == QSocket::ErrSocketRead) | 534 | if (code == QSocket::ErrSocketRead) |
528 | temp = "socket packet error"; | 535 | temp = "socket packet error"; |
529 | 536 | ||
530 | if (code != ErrCancel) { | 537 | if (code != ErrCancel) { |
531 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 538 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
532 | } else { | 539 | } else { |
533 | status2Label->setText("Aborted by user"); | 540 | status2Label->setText("Aborted by user"); |
534 | } | 541 | } |
535 | 542 | ||
536 | receiving = FALSE; | 543 | receiving = FALSE; |
537 | getMailButton->setEnabled(TRUE); | 544 | getMailButton->setEnabled(TRUE); |
538 | cancelButton->setEnabled(FALSE); | 545 | cancelButton->setEnabled(FALSE); |
539 | selectAccountMenu->setEnabled(TRUE); | 546 | selectAccountMenu->setEnabled(TRUE); |
540 | } | 547 | } |
541 | 548 | ||
542 | void EmailClient::inboxItemSelected() | 549 | void EmailClient::inboxItemSelected() |
543 | { | 550 | { |
544 | killTimer(timerID); | 551 | //killTimer(timerID); |
545 | 552 | ||
546 | item = (EmailListItem*) inboxView->selectedItem(); | 553 | item = (EmailListItem*) inboxView->selectedItem(); |
547 | if (item != NULL) { | 554 | if (item != NULL) { |
548 | emit viewEmail(inboxView, item->getMail()); | 555 | emit viewEmail(inboxView, item->getMail()); |
549 | } | 556 | } |
550 | } | 557 | } |
551 | 558 | ||
552 | void EmailClient::outboxItemSelected() | 559 | void EmailClient::outboxItemSelected() |
553 | { | 560 | { |
554 | killTimer(timerID); | 561 | //killTimer(timerID); |
555 | 562 | ||
556 | item = (EmailListItem*) outboxView->selectedItem(); | 563 | item = (EmailListItem*) outboxView->selectedItem(); |
557 | if (item != NULL) { | 564 | if (item != NULL) { |
558 | emit viewEmail(outboxView, item->getMail()); | 565 | emit viewEmail(outboxView, item->getMail()); |
559 | } | 566 | } |
560 | 567 | ||
561 | } | 568 | } |
562 | 569 | ||
563 | void EmailClient::readMail() | 570 | void EmailClient::readMail() |
564 | { | 571 | { |
565 | Email mail; | 572 | Email mail; |
566 | int start, stop; | 573 | int start, stop; |
567 | QString s, del; | 574 | QString s, del; |
568 | 575 | ||
569 | QFile f(getPath(FALSE) + "inbox.txt"); | 576 | QFile f(getPath(FALSE) + "inbox.txt"); |
570 | // QFileInfo fi(f); | 577 | |
571 | //qDebug( f.name()); | ||
572 | |||
573 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 578 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
574 | QTextStream t( &f ); // use a text stream | 579 | QTextStream t( &f ); // use a text stream |
575 | s = t.read(); | 580 | s = t.read(); |
576 | f.close(); | 581 | f.close(); |
577 | 582 | ||
578 | start = 0; | 583 | start = 0; |
579 | del = "\n.\n"; | 584 | del = "\n.\n"; |
580 | while ((uint) start < s.length()) { | 585 | while ((uint) start < s.length()) { |
581 | stop = s.find(del, start); | 586 | stop = s.find(del, start); |
582 | if (stop == -1) | 587 | if (stop == -1) |
583 | stop = s.length() - del.length(); | 588 | stop = s.length() - del.length(); |
584 | 589 | ||
585 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 590 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
586 | start = stop + del.length(); | 591 | start = stop + del.length(); |
587 | mailArrived(mail, TRUE); | 592 | mailArrived(mail, TRUE); |
588 | } | 593 | } |
589 | } | 594 | } |
590 | 595 | ||
591 | QFile fo(getPath(FALSE) + "outbox.txt"); | 596 | QFile fo(getPath(FALSE) + "outbox.txt"); |
592 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 597 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
593 | QTextStream t( &fo ); // use a text stream | 598 | QTextStream t( &fo ); // use a text stream |
594 | s = t.read(); | 599 | s = t.read(); |
595 | fo.close(); | 600 | fo.close(); |
596 | 601 | ||
597 | start = 0; | 602 | start = 0; |
598 | del = "\n.\n"; | 603 | del = "\n.\n"; |
599 | while ((uint) start < s.length()) { | 604 | while ((uint) start < s.length()) { |
600 | stop = s.find(del, start); | 605 | stop = s.find(del, start); |
601 | if (stop == -1) | 606 | if (stop == -1) |
602 | stop = s.length() - del.length(); | 607 | stop = s.length() - del.length(); |
603 | 608 | ||
604 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 609 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
605 | start = stop + del.length(); | 610 | start = stop + del.length(); |
606 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 611 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
607 | mail.sent = false; | 612 | mail.sent = false; |
608 | mail.received = false; | 613 | mail.received = false; |
609 | enqueMail(mail); | 614 | enqueMail(mail); |
610 | 615 | ||
611 | } | 616 | } |
612 | } | 617 | } |
613 | } | 618 | } |
614 | 619 | ||
615 | void EmailClient::saveMail(QString fileName, QListView *view) | 620 | void EmailClient::saveMail(QString fileName, QListView *view) |
616 | { | 621 | { |
617 | QFile f(fileName); | 622 | QFile f(fileName); |
618 | Email *mail; | 623 | Email *mail; |
619 | 624 | ||
620 | if (! f.open(IO_WriteOnly) ) { | 625 | if (! f.open(IO_WriteOnly) ) { |
621 | qWarning("could not open file"); | 626 | qWarning("could not open file"); |
622 | return; | 627 | return; |
623 | } | 628 | } |
624 | item = (EmailListItem *) view->firstChild(); | 629 | item = (EmailListItem *) view->firstChild(); |
625 | //qDebug (QString("Write : ") ); | ||
626 | QTextStream t(&f); | 630 | QTextStream t(&f); |
627 | while (item != NULL) { | 631 | while (item != NULL) { |
628 | mail = item->getMail(); | 632 | mail = item->getMail(); |
629 | //qDebug(mail->rawMail); | ||
630 | //qDebug(mail->recipients.first()); | ||
631 | t << mail->rawMail; | 633 | t << mail->rawMail; |
632 | 634 | ||
633 | mailconf->setGroup(mail->id); | 635 | mailconf->setGroup(mail->id); |
634 | mailconf->writeEntry("mailread", mail->read); | 636 | mailconf->writeEntry("mailread", mail->read); |
635 | 637 | ||
636 | item = (EmailListItem *) item->nextSibling(); | 638 | item = (EmailListItem *) item->nextSibling(); |
637 | } | 639 | } |
638 | f.close(); | 640 | f.close(); |
639 | } | 641 | } |
640 | 642 | ||
641 | //paths for mailit, is settings, inbox, enclosures | 643 | //paths for mailit, is settings, inbox, enclosures |
642 | QString EmailClient::getPath(bool enclosurePath) | 644 | QString EmailClient::getPath(bool enclosurePath) |
643 | { | 645 | { |
644 | QString basePath = "qtmail"; | 646 | QString basePath = "qtmail"; |
645 | QString enclosures = "enclosures"; | 647 | QString enclosures = "enclosures"; |
646 | 648 | ||
647 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 649 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
648 | if ( !dir.exists() ) | 650 | if ( !dir.exists() ) |
649 | dir.mkdir( dir.path() ); | 651 | dir.mkdir( dir.path() ); |
650 | 652 | ||
651 | if (enclosurePath) { | 653 | if (enclosurePath) { |
652 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 654 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
653 | 655 | ||
654 | if ( !dir.exists() ) | 656 | if ( !dir.exists() ) |
655 | dir.mkdir( dir.path() ); | 657 | dir.mkdir( dir.path() ); |
656 | 658 | ||
657 | return (dir.path() + "/"); | 659 | return (dir.path() + "/"); |
658 | 660 | ||
659 | } | 661 | } |
660 | return (dir.path() + "/"); | 662 | return (dir.path() + "/"); |
661 | } | 663 | } |
662 | 664 | ||
663 | void EmailClient::readSettings() | 665 | void EmailClient::readSettings() |
664 | { | 666 | { |
665 | TextParser *p; | 667 | int y,acc_count, accountPos=0; |
666 | QString s; | ||
667 | int pos, accountPos, y; | ||
668 | QFile f( getPath(FALSE) + "settings.txt"); | ||
669 | |||
670 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
671 | QTextStream t( &f ); // use a text stream | ||
672 | s = t.read(); | ||
673 | f.close(); | ||
674 | 668 | ||
675 | p = new TextParser(s, "\n"); | 669 | mailconf->setGroup("mailitglobal"); |
676 | 670 | acc_count=mailconf->readNumEntry("Accounts",0); | |
677 | accountPos = 0; | ||
678 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | ||
679 | accountPos++; | ||
680 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | ||
681 | account.accountName = p->getString(& ++pos, 'z', TRUE); | ||
682 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | ||
683 | account.name = p->getString(& ++pos, 'z', TRUE); | ||
684 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | ||
685 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | ||
686 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | ||
687 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | ||
688 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | ||
689 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | ||
690 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | ||
691 | account.popServer = p->getString(& ++pos, 'z', TRUE); | ||
692 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | ||
693 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | ||
694 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | ||
695 | s = p->getString(& ++pos, 'z', TRUE); | ||
696 | account.id = s.toInt(); | ||
697 | } | ||
698 | 671 | ||
672 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) | ||
673 | { | ||
674 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... | ||
675 | account.accountName = mailconf->readEntry("AccName",""); | ||
676 | account.name = mailconf->readEntry("UserName",""); | ||
677 | account.emailAddress = mailconf->readEntry("Email",""); | ||
678 | account.popUserName = mailconf->readEntry("POPUser",""); | ||
679 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); | ||
680 | account.popServer = mailconf->readEntry("POPServer",""); | ||
681 | account.smtpServer = mailconf->readEntry("SMTPServer",""); | ||
682 | account.id = mailconf->readNumEntry("AccountId",0); | ||
683 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); | ||
699 | account.lastServerMailCount = 0; | 684 | account.lastServerMailCount = 0; |
700 | account.synchronize = FALSE; | 685 | account.synchronize = FALSE; |
701 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 686 | |
702 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 687 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); |
703 | account.synchronize = TRUE; | 688 | if (account.synchronize) |
704 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 689 | { |
705 | s = p->getString(& ++pos, 'z', TRUE); | 690 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); |
706 | account.lastServerMailCount = s.toInt(); | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | |||
711 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | ||
712 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | ||
713 | } | 691 | } |
714 | |||
715 | 692 | ||
716 | accountList.append(&account); | 693 | accountList.append(&account); |
717 | } | 694 | } |
718 | delete p; | 695 | |
719 | } | ||
720 | mailconf->setGroup("mailitglobal"); | 696 | mailconf->setGroup("mailitglobal"); |
721 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 697 | |
698 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) | ||
699 | { | ||
722 | mailIdCount = y; | 700 | mailIdCount = y; |
723 | } | 701 | } |
724 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 702 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) |
703 | { | ||
725 | accountIdCount = y; | 704 | accountIdCount = y; |
726 | } | 705 | } |
727 | } | 706 | } |
728 | 707 | ||
729 | void EmailClient::saveSettings() | 708 | void EmailClient::saveSettings() |
730 | { | 709 | { |
731 | 710 | int acc_count=0; | |
732 | QString temp; | ||
733 | QFile f( getPath(FALSE) + "settings.txt"); | ||
734 | MailAccount *accountPtr; | 711 | MailAccount *accountPtr; |
735 | 712 | ||
736 | if (! f.open(IO_WriteOnly) ) { | 713 | |
737 | qWarning("could not save settings file"); | 714 | if (!mailconf) |
715 | { | ||
716 | qWarning("could not save settings"); | ||
738 | return; | 717 | return; |
739 | } | 718 | } |
740 | QTextStream t(&f); | ||
741 | t << "#Settings for OPIE Mailit program\n"; | ||
742 | 719 | ||
743 | for (accountPtr = accountList.first(); accountPtr != 0; | 720 | for (accountPtr = accountList.first(); accountPtr != 0; |
744 | accountPtr = accountList.next()) { | 721 | accountPtr = accountList.next()) |
745 | 722 | { | |
746 | t << "accountStart;\n"; | 723 | mailconf->setGroup("Account_"+QString::number(++acc_count)); |
747 | t << "AccountName: " + accountPtr->accountName + "\n"; | 724 | mailconf->writeEntry("AccName",accountPtr->accountName ); |
748 | t << "Name: " + accountPtr->name + "\n"; | 725 | mailconf->writeEntry("UserName",accountPtr->name); |
749 | t << "Email: " + accountPtr->emailAddress + "\n"; | 726 | mailconf->writeEntry("Email",accountPtr->emailAddress); |
750 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 727 | mailconf->writeEntry("POPUser",accountPtr->popUserName); |
751 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 728 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); |
752 | t << "POPServer: " + accountPtr->popServer + "\n"; | 729 | mailconf->writeEntry("POPServer",accountPtr->popServer); |
753 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 730 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); |
754 | t << "AccountId: " << accountPtr->id << "\n"; | 731 | mailconf->writeEntry("AccountId",accountPtr->id); |
755 | if (accountPtr->synchronize) { | 732 | if (accountPtr->synchronize) |
756 | t << "Synchronize: Yes\n"; | 733 | { |
757 | t << "LastServerMailCount: "; | 734 | mailconf->writeEntry("Synchronize","Yes"); |
758 | t << accountPtr->lastServerMailCount << "\n"; | 735 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); |
759 | } else { | 736 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); |
760 | t << "Synchronize: No\n"; | 737 | } |
738 | else | ||
739 | { | ||
740 | mailconf->writeEntry("Synchronize", "No"); | ||
761 | } | 741 | } |
762 | t << "SyncLimit: "; | ||
763 | t << accountPtr->syncLimit << "\n"; | ||
764 | t << "accountEnd;\n"; | ||
765 | } | 742 | } |
766 | f.close(); | ||
767 | 743 | ||
768 | mailconf->setGroup("mailitglobal"); | 744 | mailconf->setGroup("mailitglobal"); |
745 | mailconf->writeEntry("Accounts",acc_count); | ||
769 | mailconf->writeEntry("mailidcount", mailIdCount); | 746 | mailconf->writeEntry("mailidcount", mailIdCount); |
770 | mailconf->writeEntry("accountidcount", accountIdCount); | 747 | mailconf->writeEntry("accountidcount", accountIdCount); |
771 | } | 748 | } |
772 | 749 | ||
773 | void EmailClient::selectAccount(int id) | 750 | void EmailClient::selectAccount(int id) |
774 | { | 751 | { |
775 | if (accountList.count() > 0) { | 752 | if (accountList.count() > 0) { |
776 | currentAccount = accountList.at(id); | 753 | currentAccount = accountList.at(id); |
777 | emit newCaption("Mailit - " + currentAccount->accountName); | 754 | emit newCaption("Mailit - " + currentAccount->accountName); |
778 | getNewMail(); | 755 | getNewMail(); |
779 | } else { | 756 | } else { |
780 | emit newCaption("Mailit ! No account defined"); | 757 | emit newCaption("Mailit ! No account defined"); |
781 | } | 758 | } |
782 | } | 759 | } |
783 | 760 | ||
784 | void EmailClient::editAccount(int id) | 761 | void EmailClient::editAccount(int id) |
785 | { | 762 | { |
786 | MailAccount *newAccount; | 763 | MailAccount *newAccount; |
787 | 764 | ||
788 | editAccountView = new EditAccount(this, "account", TRUE); | 765 | editAccountView = new EditAccount(this, "account", TRUE); |
789 | if (id == newAccountId) { //new account | 766 | if (id == newAccountId) { //new account |
790 | newAccount = new MailAccount; | 767 | newAccount = new MailAccount; |
791 | editAccountView->setAccount(newAccount); | 768 | editAccountView->setAccount(newAccount); |
792 | } else { | 769 | } else { |
793 | newAccount = accountList.at(id); | 770 | newAccount = accountList.at(id); |
794 | editAccountView->setAccount(newAccount, FALSE); | 771 | editAccountView->setAccount(newAccount, FALSE); |
795 | } | 772 | } |
796 | 773 | ||
797 | editAccountView->showMaximized(); | 774 | editAccountView->showMaximized(); |
798 | editAccountView->exec(); | 775 | editAccountView->exec(); |
799 | 776 | ||
800 | if (editAccountView->result() == QDialog::Accepted) { | 777 | if (editAccountView->result() == QDialog::Accepted) { |
801 | if (id == newAccountId) { | 778 | if (id == newAccountId) { |
802 | newAccount->id = accountIdCount; | 779 | newAccount->id = accountIdCount; |
803 | accountIdCount++; | 780 | accountIdCount++; |
804 | accountList.append(newAccount); | 781 | accountList.append(newAccount); |
805 | updateAccounts(); | 782 | updateAccounts(); |
806 | } else { | 783 | } else { |
807 | updateAccounts(); | 784 | updateAccounts(); |
808 | } | 785 | } |
809 | } | 786 | } |
810 | 787 | ||
811 | delete editAccountView; | 788 | delete editAccountView; |
812 | } | 789 | } |
813 | 790 | ||
814 | void EmailClient::deleteAccount(int id) | 791 | void EmailClient::deleteAccount(int id) |
815 | { | 792 | { |
816 | MailAccount *newAccount; | 793 | MailAccount *newAccount; |
817 | QString message; | 794 | QString message; |
818 | 795 | ||
819 | newAccount = accountList.at(id); | 796 | newAccount = accountList.at(id); |
820 | message = "Delete account:\n" + newAccount->accountName; | 797 | message = "Delete account:\n" + newAccount->accountName; |
821 | switch( QMessageBox::warning( this, "Mailit", message, | 798 | switch( QMessageBox::warning( this, "Mailit", message, |
822 | "Yes", "No", 0, 0, 1 ) ) { | 799 | "Yes", "No", 0, 0, 1 ) ) { |
823 | 800 | ||
824 | case 0: accountList.remove(id); | 801 | case 0: accountList.remove(id); |
825 | updateAccounts(); | 802 | updateAccounts(); |
826 | break; | 803 | break; |
827 | case 1: | 804 | case 1: |
828 | break; | 805 | break; |
829 | } | 806 | } |
830 | } | 807 | } |
831 | 808 | ||
832 | void EmailClient::updateAccounts() | 809 | void EmailClient::updateAccounts() |
833 | { | 810 | { |
834 | MailAccount *accountPtr; | 811 | MailAccount *accountPtr; |
835 | 812 | ||
836 | //rebuild menus, clear all first | 813 | //rebuild menus, clear all first |
837 | editAccountMenu->clear(); | 814 | editAccountMenu->clear(); |
838 | selectAccountMenu->clear(); | 815 | selectAccountMenu->clear(); |
839 | deleteAccountMenu->clear(); | 816 | deleteAccountMenu->clear(); |
840 | 817 | ||
841 | newAccountId = editAccountMenu->insertItem("New", this, | 818 | newAccountId = editAccountMenu->insertItem("New", this, |
842 | SLOT(editAccount(int)) ); | 819 | SLOT(editAccount(int)) ); |
843 | editAccountMenu->insertSeparator(); | 820 | editAccountMenu->insertSeparator(); |
844 | 821 | ||
845 | idCount = 0; | 822 | idCount = 0; |
846 | for (accountPtr = accountList.first(); accountPtr != 0; | 823 | for (accountPtr = accountList.first(); accountPtr != 0; |
847 | accountPtr = accountList.next()) { | 824 | accountPtr = accountList.next()) { |
848 | 825 | ||
849 | editAccountMenu->insertItem(accountPtr->accountName, | 826 | editAccountMenu->insertItem(accountPtr->accountName, |
850 | this, SLOT(editAccount(int)), 0, idCount); | 827 | this, SLOT(editAccount(int)), 0, idCount); |
851 | selectAccountMenu->insertItem(accountPtr->accountName, | 828 | selectAccountMenu->insertItem(accountPtr->accountName, |
852 | this, SLOT(selectAccount(int)), 0, idCount); | 829 | this, SLOT(selectAccount(int)), 0, idCount); |
853 | deleteAccountMenu->insertItem(accountPtr->accountName, | 830 | deleteAccountMenu->insertItem(accountPtr->accountName, |
854 | this, SLOT(deleteAccount(int)), 0, idCount); | 831 | this, SLOT(deleteAccount(int)), 0, idCount); |
855 | idCount++; | 832 | idCount++; |
856 | } | 833 | } |
857 | } | 834 | } |
858 | 835 | ||
859 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 836 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
860 | { | 837 | { |
861 | Email *mPtr; | 838 | Email *mPtr; |
862 | Enclosure *ePtr; | 839 | Enclosure *ePtr; |
863 | 840 | ||
864 | if (inbox) | 841 | if (inbox) |
865 | { | 842 | { |
866 | mPtr = mailItem->getMail(); | 843 | mPtr = mailItem->getMail(); |
867 | 844 | ||
868 | //if mail is in queue for download, remove it from | 845 | //if mail is in queue for download, remove it from |
869 | //queue if possible | 846 | //queue if possible |
870 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 847 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
871 | if ( !mPtr->downloaded ) | 848 | if ( !mPtr->downloaded ) |
872 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 849 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
873 | } | 850 | } |
874 | 851 | ||
875 | mailconf->setGroup(mPtr->id); | 852 | mailconf->setGroup(mPtr->id); |
876 | mailconf->clearGroup(); | 853 | mailconf->clearGroup(); |
877 | 854 | ||
878 | //delete any temporary attatchemnts storing | 855 | //delete any temporary attatchemnts storing |
879 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 856 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
880 | if (ePtr->saved) { | 857 | if (ePtr->saved) { |
881 | QFile::remove( (ePtr->path + ePtr->name) ); | 858 | QFile::remove( (ePtr->path + ePtr->name) ); |
882 | } | 859 | } |
883 | } | 860 | } |
884 | inboxView->takeItem(mailItem); | 861 | inboxView->takeItem(mailItem); |
885 | } | 862 | } |
886 | else | 863 | else |
887 | { | 864 | { |
888 | outboxView->takeItem(mailItem); | 865 | outboxView->takeItem(mailItem); |
889 | } | 866 | } |
890 | } | 867 | } |
891 | 868 | ||
892 | void EmailClient::setMailSize(int size) | 869 | void EmailClient::setMailSize(int size) |
893 | { | 870 | { |
894 | progressBar->reset(); | 871 | progressBar->reset(); |
895 | progressBar->setTotalSteps(size); | 872 | progressBar->setTotalSteps(size); |
896 | } | 873 | } |
897 | 874 | ||
898 | void EmailClient::setTotalSize(int size) | 875 | void EmailClient::setTotalSize(int size) |
899 | { | 876 | { |
900 | 877 | ||
901 | } | 878 | } |
902 | 879 | ||
903 | void EmailClient::setDownloadedSize(int size) | 880 | void EmailClient::setDownloadedSize(int size) |
904 | { | 881 | { |
905 | int total = progressBar->totalSteps(); | 882 | int total = progressBar->totalSteps(); |
906 | 883 | ||
907 | if (size < total) { | 884 | if (size < total) { |
908 | progressBar->setProgress(size); | 885 | progressBar->setProgress(size); |
909 | } else { | 886 | } else { |
910 | progressBar->setProgress(total); | 887 | progressBar->setProgress(total); |
911 | } | 888 | } |
912 | } | 889 | } |
913 | 890 | ||
914 | void EmailClient::deleteItem() | 891 | void EmailClient::deleteItem() |
915 | { | 892 | { |
916 | bool inbox=mailboxView->currentTab()==0; | 893 | bool inbox=mailboxView->currentTab()==0; |
917 | 894 | ||
918 | EmailListItem* eli; | 895 | EmailListItem* eli; |
919 | 896 | ||
920 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); | 897 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); |
921 | 898 | ||
922 | if (eli) | 899 | if (eli) |
923 | deleteMail(eli,(bool&)inbox); | 900 | deleteMail(eli,(bool&)inbox); |
924 | } | 901 | } |
925 | 902 | ||
926 | void EmailClient::inboxItemPressed() | 903 | void EmailClient::inboxItemPressed() |
927 | { | 904 | { |
928 | //timerID=startTimer(500); | 905 | //timerID=startTimer(500); |
929 | } | 906 | } |
930 | 907 | ||
931 | void EmailClient::inboxItemReleased() | 908 | void EmailClient::inboxItemReleased() |
932 | { | 909 | { |
933 | //killTimer(timerID); | 910 | //killTimer(timerID); |
934 | } | 911 | } |
935 | 912 | ||
936 | void EmailClient::timerEvent(QTimerEvent *e) | 913 | void EmailClient::timerEvent(QTimerEvent *e) |
937 | { | 914 | { |
938 | /*killTimer(timerID); | 915 | /*killTimer(timerID); |
939 | 916 | ||
940 | 917 | ||
941 | QPopupMenu *action = new QPopupMenu(this); | 918 | QPopupMenu *action = new QPopupMenu(this); |
942 | 919 | ||
943 | int reply=0; | 920 | int reply=0; |
944 | 921 | ||
945 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | 922 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); |
946 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | 923 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); |
947 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | 924 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); |
948 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | 925 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); |
949 | 926 | ||
950 | action->exec(QCursor::pos()); | 927 | action->exec(QCursor::pos()); |
951 | 928 | ||
952 | if (action) delete action; | 929 | if (action) delete action; |
953 | */ | 930 | */ |
954 | } | 931 | } |
955 | 932 | ||
956 | Email* EmailClient::getCurrentMail() | 933 | Email* EmailClient::getCurrentMail() |
957 | { | 934 | { |
958 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 935 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
959 | if (eli!=NULL) | 936 | if (eli!=NULL) |
960 | return eli->getMail(); | 937 | return eli->getMail(); |
961 | else | 938 | else |
962 | return NULL; | 939 | return NULL; |
963 | } | 940 | } |
964 | 941 | ||
965 | /* | 942 | /* |
966 | void EmailClient::reply() | 943 | void EmailClient::reply() |
967 | { | 944 | { |
968 | Email* mail=getCurrentMail(); | 945 | Email* mail=getCurrentMail(); |
969 | 946 | ||
970 | if (mail!=NULL) | 947 | if (mail!=NULL) |
971 | { | 948 | { |
972 | emit reply(*mail); | 949 | emit reply(*mail); |
973 | } | 950 | } |
974 | } | 951 | } |
975 | 952 | ||
976 | void EmailClient::replyAll() | 953 | void EmailClient::replyAll() |
977 | { | 954 | { |
978 | Email* mail=getCurrentMail(); | 955 | Email* mail=getCurrentMail(); |
979 | 956 | ||
980 | if (mail!=NULL) | 957 | if (mail!=NULL) |
981 | { | 958 | { |
982 | emit replyAll(*mail); | 959 | emit replyAll(*mail); |
983 | } | 960 | } |
984 | } | 961 | } |
985 | 962 | ||
986 | void EmailClient::forward() | 963 | void EmailClient::forward() |
987 | { | 964 | { |
988 | Email* mail=getCurrentMail(); | 965 | Email* mail=getCurrentMail(); |
989 | 966 | ||
990 | if (mail!=NULL) | 967 | if (mail!=NULL) |
991 | { | 968 | { |
992 | emit reply(*mail); | 969 | emit reply(*mail); |
993 | } | 970 | } |
994 | } | 971 | } |
995 | 972 | ||
996 | void EmailClient::remove() | 973 | void EmailClient::remove() |
997 | { | 974 | { |
998 | Email* mail=getCurrentMail(); | 975 | Email* mail=getCurrentMail(); |
999 | 976 | ||
1000 | if (mail!=NULL) | 977 | if (mail!=NULL) |
1001 | { | 978 | { |
1002 | emit remove(*mail); | 979 | emit remove(*mail); |
1003 | } | 980 | } |
1004 | }*/ \ No newline at end of file | 981 | }*/ |
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index f6c6d60..b180051 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -1,612 +1,628 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | smtpClient = new SmtpClient(); | 42 | smtpClient = new SmtpClient(); |
43 | popClient = new PopClient(); | 43 | popClient = new PopClient(); |
44 | 44 | ||
45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, | 45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, |
46 | SIGNAL(smtpError(int)) ); | 46 | SIGNAL(smtpError(int)) ); |
47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
49 | SIGNAL(updateSmtpStatus(const QString &)) ); | 49 | SIGNAL(updateSmtpStatus(const QString &)) ); |
50 | 50 | ||
51 | connect(popClient, SIGNAL(errorOccurred(int)), this, | 51 | connect(popClient, SIGNAL(errorOccurred(int)), this, |
52 | SIGNAL(popError(int)) ); | 52 | SIGNAL(popError(int)) ); |
53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
56 | SIGNAL(updatePopStatus(const QString &)) ); | 56 | SIGNAL(updatePopStatus(const QString &)) ); |
57 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 57 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
58 | SIGNAL(mailTransfered(int)) ); | 58 | SIGNAL(mailTransfered(int)) ); |
59 | 59 | ||
60 | 60 | ||
61 | //relaying size information | 61 | //relaying size information |
62 | connect(popClient, SIGNAL(currentMailSize(int)), | 62 | connect(popClient, SIGNAL(currentMailSize(int)), |
63 | this, SIGNAL(currentMailSize(int)) ); | 63 | this, SIGNAL(currentMailSize(int)) ); |
64 | connect(popClient, SIGNAL(downloadedSize(int)), | 64 | connect(popClient, SIGNAL(downloadedSize(int)), |
65 | this, SIGNAL(downloadedSize(int)) ); | 65 | this, SIGNAL(downloadedSize(int)) ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void EmailHandler::sendMail(QList<Email> *mailList) | 68 | void EmailHandler::sendMail(QList<Email> *mailList) |
69 | { | 69 | { |
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | //popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | ||
116 | } else { | ||
117 | popClient->removeSynchronize(); | ||
118 | } | ||
119 | 115 | ||
120 | headers = TRUE; | 116 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 117 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 118 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 119 | } |
124 | 120 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 121 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 122 | { |
127 | if (mailList->count() == 0) { //should not occur though | 123 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 124 | emit mailTransfered(0); |
129 | return; | 125 | return; |
130 | } | 126 | } |
131 | 127 | ||
132 | headers = FALSE; | 128 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 129 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 130 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 131 | popClient->setSelectedMails(mailList); |
136 | } | 132 | } |
137 | 133 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 134 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete) |
139 | { | 135 | { |
140 | Email mail; | 136 | Email mail; |
141 | 137 | ||
142 | mail.rawMail = message; | 138 | mail.rawMail = message; |
143 | mail.serverId = id; | 139 | mail.serverId = id; |
144 | mail.size = size; | 140 | mail.size = size; |
145 | mail.downloaded = complete; | 141 | mail.downloaded = incomplete; |
146 | 142 | ||
147 | emit mailArrived(mail, FALSE); | 143 | emit mailArrived(mail, FALSE); |
148 | } | 144 | } |
149 | 145 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 146 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 147 | { |
152 | QString temp, boundary; | 148 | QString temp, boundary; |
153 | int pos; | 149 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 150 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 151 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 152 | QString fileName, storedName; |
157 | int enclosureId = 0; | 153 | int enclosureId = 0; |
158 | 154 | ||
159 | mail->rawMail = in; | 155 | mail->rawMail = in; |
160 | mail->received = TRUE; | 156 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 157 | mail->files.setAutoDelete(TRUE); |
162 | 158 | ||
163 | temp = lineShift + "." + lineShift; | 159 | temp = lineShift + "." + lineShift; |
164 | 160 | ||
165 | if (in.right(temp.length()) != temp) { | 161 | if (in.right(temp.length()) != temp) { |
166 | mail->rawMail += temp; | 162 | mail->rawMail += temp; |
167 | } | 163 | } |
168 | 164 | ||
169 | 165 | ||
170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 166 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
171 | pos = in.find(delimiter, 0, FALSE); | 167 | pos = in.find(delimiter, 0, FALSE); |
172 | header = in.left(pos); | 168 | header = in.left(pos); |
173 | body = in.right(in.length() - pos - delimiter.length()); | 169 | body = in.right(in.length() - pos - delimiter.length()); |
174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 170 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
175 | body.truncate(body.length()-2); | 171 | body.truncate(body.length()-2); |
176 | 172 | ||
177 | TextParser p(header, lineShift); | 173 | TextParser p(header, lineShift); |
178 | 174 | ||
179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 175 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
180 | pos++; | 176 | pos++; |
181 | if (p.separatorAt(pos) == ' ') { | 177 | if (p.separatorAt(pos) == ' ') { |
182 | mail->from = p.getString(&pos, '<', false); | 178 | mail->from = p.getString(&pos, '<', false); |
183 | mail->from = mail->from.stripWhiteSpace(); | 179 | mail->from = mail->from.stripWhiteSpace(); |
184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 180 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
185 | mail->from = mail->from.left(mail->from.length() - 1); | 181 | mail->from = mail->from.left(mail->from.length() - 1); |
186 | mail->from = mail->from.right(mail->from.length() - 1); | 182 | mail->from = mail->from.right(mail->from.length() - 1); |
187 | } | 183 | } |
188 | pos++; | 184 | pos++; |
185 | |||
189 | mail->fromMail = p.getString(&pos, '>', false); | 186 | mail->fromMail = p.getString(&pos, '>', false); |
190 | } else { | 187 | } else { |
191 | if ((p.separatorAt(pos) == '<') | 188 | if ((p.separatorAt(pos) == '<') |
192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 189 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
193 | pos++; | 190 | pos++; |
194 | pos++; | 191 | pos++; |
195 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 192 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 193 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
197 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 194 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
198 | mail->from=mail->fromMail; | 195 | mail->from=mail->fromMail; |
199 | } | 196 | } |
200 | } | 197 | } |
201 | 198 | ||
202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 199 | pos=0; |
203 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) | 200 | |
201 | //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: | ||
202 | while((pos = p.find("TO",':', pos+1, TRUE))!=-1) | ||
204 | { | 203 | { |
205 | pos++; | 204 | QString rec; |
206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 205 | |
206 | if (p.separatorAt(pos-1)!='-') | ||
207 | { | ||
208 | pos++; | ||
209 | mail->recipients.append(p.getString(&pos, '\r', TRUE)); | ||
210 | } | ||
211 | /*else { | ||
212 | if ((p.separatorAt(pos) == '<')|| (p.separatorAt(pos) == ' ')) //No name.. nasty | ||
213 | pos++; | ||
214 | pos++; | ||
215 | mail->fromMail = p.getString(&pos, 'z', TRUE); | ||
216 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | ||
217 | mail->fromMail.truncate(mail->fromMail.length() - 1); | ||
218 | mail->from=mail->fromMail; | ||
219 | } | ||
220 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | ||
221 | }*/ | ||
207 | } | 222 | } |
208 | 223 | // | |
209 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 224 | //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); |
225 | |||
210 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) | 226 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) |
211 | { | 227 | { |
212 | pos++; | 228 | pos++; |
213 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); | 229 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); |
214 | } | 230 | } |
215 | 231 | ||
216 | |||
217 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 232 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
218 | pos++; | 233 | pos++; |
219 | mail->subject = p.getString(&pos, 'z', TRUE); | 234 | mail->subject = p.getString(&pos, 'z', TRUE); |
220 | } | 235 | } |
236 | |||
221 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 237 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
222 | pos++; | 238 | pos++; |
223 | mail->date = p.getString(&pos, 'z', true); | 239 | mail->date = p.getString(&pos, 'z', TRUE); |
224 | } | 240 | } |
225 | 241 | ||
226 | 242 | ||
227 | 243 | ||
228 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 244 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
229 | pos++; | 245 | pos++; |
230 | if ( (p.wordAt(pos).upper() == "ID") && | 246 | if ( (p.wordAt(pos).upper() == "ID") && |
231 | (p.separatorAt(pos) == ':') ) { | 247 | (p.separatorAt(pos) == ':') ) { |
232 | 248 | ||
233 | id = p.getString(&pos, 'z', TRUE); | 249 | id = p.getString(&pos, 'z', TRUE); |
234 | mail->id = id; | 250 | mail->id = id; |
235 | } | 251 | } |
236 | } | 252 | } |
237 | 253 | ||
238 | pos = 0; | 254 | pos = 0; |
239 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 255 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
240 | pos++; | 256 | pos++; |
241 | if ( (p.wordAt(pos).upper() == "VERSION") && | 257 | if ( (p.wordAt(pos).upper() == "VERSION") && |
242 | (p.separatorAt(pos) == ':') ) { | 258 | (p.separatorAt(pos) == ':') ) { |
243 | pos++; | 259 | pos++; |
244 | if (p.getString(&pos, 'z', true) == "1.0") { | 260 | if (p.getString(&pos, 'z', true) == "1.0") { |
245 | mail->mimeType = 1; | 261 | mail->mimeType = 1; |
246 | } | 262 | } |
247 | } | 263 | } |
248 | } | 264 | } |
249 | 265 | ||
250 | if (mail->mimeType == 1) { | 266 | if (mail->mimeType == 1) { |
251 | boundary = ""; | 267 | boundary = ""; |
252 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 268 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
253 | pos++; | 269 | pos++; |
254 | boundary = p.getString(&pos, 'z', true); | 270 | boundary = p.getString(&pos, 'z', true); |
255 | if (boundary[0] == '"') { | 271 | if (boundary[0] == '"') { |
256 | boundary = boundary.left(boundary.length() - 1); //strip " | 272 | boundary = boundary.left(boundary.length() - 1); //strip " |
257 | boundary = boundary.right(boundary.length() - 1); //strip " | 273 | boundary = boundary.right(boundary.length() - 1); //strip " |
258 | } | 274 | } |
259 | boundary = "--" + boundary; //create boundary field | 275 | boundary = "--" + boundary; //create boundary field |
260 | } | 276 | } |
261 | 277 | ||
262 | if (boundary == "") { //fooled by Mime-Version | 278 | if (boundary == "") { //fooled by Mime-Version |
263 | mail->body = body; | 279 | mail->body = body; |
264 | mail->bodyPlain = body; | 280 | mail->bodyPlain = body; |
265 | return mail; | 281 | return mail; |
266 | } | 282 | } |
267 | 283 | ||
268 | while (body.length() > 0) { | 284 | while (body.length() > 0) { |
269 | pos = body.find(boundary, 0, FALSE); | 285 | pos = body.find(boundary, 0, FALSE); |
270 | pos = body.find(delimiter, pos, FALSE); | 286 | pos = body.find(delimiter, pos, FALSE); |
271 | mimeHeader = body.left(pos); | 287 | mimeHeader = body.left(pos); |
272 | mimeBody = body.right(body.length() - pos - delimiter.length()); | 288 | mimeBody = body.right(body.length() - pos - delimiter.length()); |
273 | TextParser bp(mimeHeader, lineShift); | 289 | TextParser bp(mimeHeader, lineShift); |
274 | 290 | ||
275 | contentType = ""; | 291 | contentType = ""; |
276 | contentAttribute = ""; | 292 | contentAttribute = ""; |
277 | fileName = ""; | 293 | fileName = ""; |
278 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { | 294 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { |
279 | pos++; | 295 | pos++; |
280 | if ( (bp.wordAt(pos).upper() == "TYPE") && | 296 | if ( (bp.wordAt(pos).upper() == "TYPE") && |
281 | (bp.separatorAt(pos) == ':') ) { | 297 | (bp.separatorAt(pos) == ':') ) { |
282 | contentType = bp.nextWord().upper(); | 298 | contentType = bp.nextWord().upper(); |
283 | if (bp.nextSeparator() == '/') | 299 | if (bp.nextSeparator() == '/') |
284 | contentAttribute = bp.nextWord().upper(); | 300 | contentAttribute = bp.nextWord().upper(); |
285 | content = contentType + "/" + contentAttribute; | 301 | content = contentType + "/" + contentAttribute; |
286 | } | 302 | } |
287 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { | 303 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { |
288 | pos++; | 304 | pos++; |
289 | encoding = bp.getString(&pos, 'z', TRUE); | 305 | encoding = bp.getString(&pos, 'z', TRUE); |
290 | } | 306 | } |
291 | 307 | ||
292 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { | 308 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { |
293 | pos++; | 309 | pos++; |
294 | fileName = bp.getString(&pos, 'z', TRUE); | 310 | fileName = bp.getString(&pos, 'z', TRUE); |
295 | fileName = fileName.right(fileName.length() - 1); | 311 | fileName = fileName.right(fileName.length() - 1); |
296 | fileName = fileName.left(fileName.length() - 1); | 312 | fileName = fileName.left(fileName.length() - 1); |
297 | } | 313 | } |
298 | 314 | ||
299 | } | 315 | } |
300 | pos = mimeBody.find(boundary, 0, FALSE); | 316 | pos = mimeBody.find(boundary, 0, FALSE); |
301 | if (pos == -1) //should not occur, malformed mail | 317 | if (pos == -1) //should not occur, malformed mail |
302 | pos = mimeBody.length(); | 318 | pos = mimeBody.length(); |
303 | body = mimeBody.right(mimeBody.length() - pos); | 319 | body = mimeBody.right(mimeBody.length() - pos); |
304 | mimeBody = mimeBody.left(pos); | 320 | mimeBody = mimeBody.left(pos); |
305 | 321 | ||
306 | if (fileName != "") { //attatchments of some type, audio, image etc. | 322 | if (fileName != "") { //attatchments of some type, audio, image etc. |
307 | 323 | ||
308 | Enclosure e; | 324 | Enclosure e; |
309 | e.id = enclosureId; | 325 | e.id = enclosureId; |
310 | e.originalName = fileName; | 326 | e.originalName = fileName; |
311 | e.contentType = contentType; | 327 | e.contentType = contentType; |
312 | e.contentAttribute = contentAttribute; | 328 | e.contentAttribute = contentAttribute; |
313 | e.encoding = encoding; | 329 | e.encoding = encoding; |
314 | e.body = mimeBody; | 330 | e.body = mimeBody; |
315 | e.saved = FALSE; | 331 | e.saved = FALSE; |
316 | mail->addEnclosure(&e); | 332 | mail->addEnclosure(&e); |
317 | enclosureId++; | 333 | enclosureId++; |
318 | 334 | ||
319 | } else if (contentType == "TEXT") { | 335 | } else if (contentType == "TEXT") { |
320 | if (contentAttribute == "PLAIN") { | 336 | if (contentAttribute == "PLAIN") { |
321 | mail->body = mimeBody; | 337 | mail->body = mimeBody; |
322 | mail->bodyPlain = mimeBody; | 338 | mail->bodyPlain = mimeBody; |
323 | } | 339 | } |
324 | if (contentAttribute == "HTML") { | 340 | if (contentAttribute == "HTML") { |
325 | mail->body = mimeBody; | 341 | mail->body = mimeBody; |
326 | } | 342 | } |
327 | } | 343 | } |
328 | } | 344 | } |
329 | } else { | 345 | } else { |
330 | mail->bodyPlain = body; | 346 | mail->bodyPlain = body; |
331 | mail->body = body; | 347 | mail->body = body; |
332 | } | 348 | } |
333 | return TRUE; | 349 | return TRUE; |
334 | } | 350 | } |
335 | 351 | ||
336 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 352 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
337 | { | 353 | { |
338 | QFile f(ePtr->path + ePtr->name); | 354 | QFile f(ePtr->path + ePtr->name); |
339 | char src[4]; | 355 | char src[4]; |
340 | char *destPtr; | 356 | char *destPtr; |
341 | QByteArray buffer; | 357 | QByteArray buffer; |
342 | uint bufCount, pos, decodedCount, size, x; | 358 | uint bufCount, pos, decodedCount, size, x; |
343 | 359 | ||
344 | if (! f.open(IO_WriteOnly) ) { | 360 | if (! f.open(IO_WriteOnly) ) { |
345 | qWarning("could not save: " + ePtr->path + ePtr->name); | 361 | qWarning("could not save: " + ePtr->path + ePtr->name); |
346 | return FALSE; | 362 | return FALSE; |
347 | } | 363 | } |
348 | 364 | ||
349 | if (ePtr->encoding.upper() == "BASE64") { | 365 | if (ePtr->encoding.upper() == "BASE64") { |
350 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 366 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
351 | buffer.resize(size); | 367 | buffer.resize(size); |
352 | bufCount = 0; | 368 | bufCount = 0; |
353 | pos = 0; | 369 | pos = 0; |
354 | destPtr = buffer.data(); | 370 | destPtr = buffer.data(); |
355 | 371 | ||
356 | while (pos < ePtr->body.length()) { | 372 | while (pos < ePtr->body.length()) { |
357 | decodedCount = 4; | 373 | decodedCount = 4; |
358 | x = 0; | 374 | x = 0; |
359 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 375 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
360 | src[x] = ePtr->body[pos].latin1(); | 376 | src[x] = ePtr->body[pos].latin1(); |
361 | pos++; | 377 | pos++; |
362 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 378 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
363 | x--; | 379 | x--; |
364 | x++; | 380 | x++; |
365 | } | 381 | } |
366 | if (x > 1) { | 382 | if (x > 1) { |
367 | decodedCount = parse64base(src, destPtr); | 383 | decodedCount = parse64base(src, destPtr); |
368 | destPtr += decodedCount; | 384 | destPtr += decodedCount; |
369 | bufCount += decodedCount; | 385 | bufCount += decodedCount; |
370 | } | 386 | } |
371 | } | 387 | } |
372 | 388 | ||
373 | buffer.resize(bufCount); //set correct length of file | 389 | buffer.resize(bufCount); //set correct length of file |
374 | f.writeBlock(buffer); | 390 | f.writeBlock(buffer); |
375 | } else { | 391 | } else { |
376 | QTextStream t(&f); | 392 | QTextStream t(&f); |
377 | t << ePtr->body; | 393 | t << ePtr->body; |
378 | } | 394 | } |
379 | return TRUE; | 395 | return TRUE; |
380 | } | 396 | } |
381 | 397 | ||
382 | int EmailHandler::parse64base(char *src, char *bufOut) { | 398 | int EmailHandler::parse64base(char *src, char *bufOut) { |
383 | 399 | ||
384 | char c, z; | 400 | char c, z; |
385 | char li[4]; | 401 | char li[4]; |
386 | int processed; | 402 | int processed; |
387 | 403 | ||
388 | //conversion table withouth table... | 404 | //conversion table withouth table... |
389 | for (int x = 0; x < 4; x++) { | 405 | for (int x = 0; x < 4; x++) { |
390 | c = src[x]; | 406 | c = src[x]; |
391 | 407 | ||
392 | if ( (int) c >= 'A' && (int) c <= 'Z') | 408 | if ( (int) c >= 'A' && (int) c <= 'Z') |
393 | li[x] = (int) c - (int) 'A'; | 409 | li[x] = (int) c - (int) 'A'; |
394 | if ( (int) c >= 'a' && (int) c <= 'z') | 410 | if ( (int) c >= 'a' && (int) c <= 'z') |
395 | li[x] = (int) c - (int) 'a' + 26; | 411 | li[x] = (int) c - (int) 'a' + 26; |
396 | if ( (int) c >= '0' && (int) c <= '9') | 412 | if ( (int) c >= '0' && (int) c <= '9') |
397 | li[x] = (int) c - (int) '0' + 52; | 413 | li[x] = (int) c - (int) '0' + 52; |
398 | if (c == '+') | 414 | if (c == '+') |
399 | li[x] = 62; | 415 | li[x] = 62; |
400 | if (c == '/') | 416 | if (c == '/') |
401 | li[x] = 63; | 417 | li[x] = 63; |
402 | } | 418 | } |
403 | 419 | ||
404 | processed = 1; | 420 | processed = 1; |
405 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 421 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
406 | bufOut[0] <<= 2; | 422 | bufOut[0] <<= 2; |
407 | z = li[1] >> 4; | 423 | z = li[1] >> 4; |
408 | bufOut[0] = bufOut[0] | z; //first byte retrived | 424 | bufOut[0] = bufOut[0] | z; //first byte retrived |
409 | 425 | ||
410 | if (src[2] != '=') { | 426 | if (src[2] != '=') { |
411 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 427 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
412 | bufOut[1] <<= 4; | 428 | bufOut[1] <<= 4; |
413 | z = li[2] >> 2; | 429 | z = li[2] >> 2; |
414 | bufOut[1] = bufOut[1] | z; //second byte retrived | 430 | bufOut[1] = bufOut[1] | z; //second byte retrived |
415 | processed++; | 431 | processed++; |
416 | 432 | ||
417 | if (src[3] != '=') { | 433 | if (src[3] != '=') { |
418 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 434 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
419 | bufOut[2] <<= 6; | 435 | bufOut[2] <<= 6; |
420 | z = li[3]; | 436 | z = li[3]; |
421 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 437 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
422 | processed++; | 438 | processed++; |
423 | } | 439 | } |
424 | } | 440 | } |
425 | return processed; | 441 | return processed; |
426 | } | 442 | } |
427 | 443 | ||
428 | int EmailHandler::encodeMime(Email *mail) | 444 | int EmailHandler::encodeMime(Email *mail) |
429 | { | 445 | { |
430 | 446 | ||
431 | QString fileName, fileType, contentType, newBody, boundary; | 447 | QString fileName, fileType, contentType, newBody, boundary; |
432 | Enclosure *ePtr; | 448 | Enclosure *ePtr; |
433 | 449 | ||
434 | QString userName = mailAccount.name; | 450 | QString userName = mailAccount.name; |
435 | if (userName.length()>0)//only embrace it if there is a user name | 451 | if (userName.length()>0)//only embrace it if there is a user name |
436 | userName += " <" + mailAccount.emailAddress + ">"; | 452 | userName += " <" + mailAccount.emailAddress + ">"; |
437 | 453 | ||
438 | //add standard headers | 454 | //add standard headers |
439 | newBody = "From: " + userName + "\r\nTo: "; | 455 | newBody = "From: " + userName + "\r\nTo: "; |
440 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 456 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
441 | newBody += *it + " "; | 457 | newBody += *it + " "; |
442 | } | 458 | } |
443 | 459 | ||
444 | newBody += "\r\nCC: "; | 460 | newBody += "\r\nCC: "; |
445 | 461 | ||
446 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | 462 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { |
447 | newBody += *it + " "; | 463 | newBody += *it + " "; |
448 | } | 464 | } |
449 | 465 | ||
450 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 466 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
451 | 467 | ||
452 | if (mail->files.count() == 0) { //just a simple mail | 468 | if (mail->files.count() == 0) { //just a simple mail |
453 | newBody += "\r\n" + mail->body; | 469 | newBody += "\r\n" + mail->body; |
454 | mail->rawMail = newBody; | 470 | mail->rawMail = newBody; |
455 | return 0; | 471 | return 0; |
456 | } | 472 | } |
457 | 473 | ||
458 | //Build mime encoded mail | 474 | //Build mime encoded mail |
459 | boundary = "-----4345=next_bound=0495----"; | 475 | boundary = "-----4345=next_bound=0495----"; |
460 | 476 | ||
461 | newBody += "Mime-Version: 1.0\r\n"; | 477 | newBody += "Mime-Version: 1.0\r\n"; |
462 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 478 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
463 | boundary + "\"\r\n\r\n"; | 479 | boundary + "\"\r\n\r\n"; |
464 | 480 | ||
465 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 481 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
466 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 482 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
467 | newBody += mail->body; | 483 | newBody += mail->body; |
468 | 484 | ||
469 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 485 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
470 | fileName = ePtr->originalName; | 486 | fileName = ePtr->originalName; |
471 | fileType = ePtr->contentType; | 487 | fileType = ePtr->contentType; |
472 | QFileInfo fi(fileName); | 488 | QFileInfo fi(fileName); |
473 | 489 | ||
474 | // This specification of contentType is temporary | 490 | // This specification of contentType is temporary |
475 | contentType = ""; | 491 | contentType = ""; |
476 | if (fileType == "Picture") { | 492 | if (fileType == "Picture") { |
477 | contentType = "image/x-image"; | 493 | contentType = "image/x-image"; |
478 | } else if (fileType == "Document") { | 494 | } else if (fileType == "Document") { |
479 | contentType = "text/plain"; | 495 | contentType = "text/plain"; |
480 | } else if (fileType == "Sound") { | 496 | } else if (fileType == "Sound") { |
481 | contentType = "audio/x-wav"; | 497 | contentType = "audio/x-wav"; |
482 | } else if (fileType == "Movie") { | 498 | } else if (fileType == "Movie") { |
483 | contentType = "video/mpeg"; | 499 | contentType = "video/mpeg"; |
484 | } else { | 500 | } else { |
485 | contentType = "application/octet-stream"; | 501 | contentType = "application/octet-stream"; |
486 | } | 502 | } |
487 | 503 | ||
488 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 504 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
489 | newBody += "Content-Type: " + contentType + "; name=\"" + | 505 | newBody += "Content-Type: " + contentType + "; name=\"" + |
490 | fi.fileName() + "\"\r\n"; | 506 | fi.fileName() + "\"\r\n"; |
491 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 507 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
492 | newBody += "Content-Disposition: inline; filename=\"" + | 508 | newBody += "Content-Disposition: inline; filename=\"" + |
493 | fi.fileName() + "\"\r\n\r\n"; | 509 | fi.fileName() + "\"\r\n\r\n"; |
494 | 510 | ||
495 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 511 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
496 | return -1; | 512 | return -1; |
497 | } | 513 | } |
498 | 514 | ||
499 | newBody += "\r\n\r\n--" + boundary + "--"; | 515 | newBody += "\r\n\r\n--" + boundary + "--"; |
500 | mail->rawMail = newBody; | 516 | mail->rawMail = newBody; |
501 | 517 | ||
502 | return 0; | 518 | return 0; |
503 | } | 519 | } |
504 | 520 | ||
505 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 521 | int EmailHandler::encodeFile(QString fileName, QString *toBody) |
506 | { | 522 | { |
507 | char *fileData; | 523 | char *fileData; |
508 | char *dataPtr; | 524 | char *dataPtr; |
509 | QString temp; | 525 | QString temp; |
510 | uint dataSize, count; | 526 | uint dataSize, count; |
511 | QFile f(fileName); | 527 | QFile f(fileName); |
512 | 528 | ||
513 | if (! f.open(IO_ReadOnly) ) { | 529 | if (! f.open(IO_ReadOnly) ) { |
514 | qWarning("could not open file: " + fileName); | 530 | qWarning("could not open file: " + fileName); |
515 | return -1; | 531 | return -1; |
516 | } | 532 | } |
517 | QTextStream s(&f); | 533 | QTextStream s(&f); |
518 | dataSize = f.size(); | 534 | dataSize = f.size(); |
519 | fileData = (char *) malloc(dataSize + 3); | 535 | fileData = (char *) malloc(dataSize + 3); |
520 | s.readRawBytes(fileData, dataSize); | 536 | s.readRawBytes(fileData, dataSize); |
521 | 537 | ||
522 | temp = ""; | 538 | temp = ""; |
523 | dataPtr = fileData; | 539 | dataPtr = fileData; |
524 | count = 0; | 540 | count = 0; |
525 | while (dataSize > 0) { | 541 | while (dataSize > 0) { |
526 | if (dataSize < 3) { | 542 | if (dataSize < 3) { |
527 | encode64base(dataPtr, &temp, dataSize); | 543 | encode64base(dataPtr, &temp, dataSize); |
528 | dataSize = 0; | 544 | dataSize = 0; |
529 | } else { | 545 | } else { |
530 | encode64base(dataPtr, &temp, 3); | 546 | encode64base(dataPtr, &temp, 3); |
531 | dataSize -= 3; | 547 | dataSize -= 3; |
532 | dataPtr += 3; | 548 | dataPtr += 3; |
533 | count += 4; | 549 | count += 4; |
534 | } | 550 | } |
535 | if (count > 72) { | 551 | if (count > 72) { |
536 | count = 0; | 552 | count = 0; |
537 | temp += "\r\n"; | 553 | temp += "\r\n"; |
538 | } | 554 | } |
539 | } | 555 | } |
540 | toBody->append(temp); | 556 | toBody->append(temp); |
541 | 557 | ||
542 | delete(fileData); | 558 | delete(fileData); |
543 | f.close(); | 559 | f.close(); |
544 | return 0; | 560 | return 0; |
545 | } | 561 | } |
546 | 562 | ||
547 | void EmailHandler::encode64base(char *src, QString *dest, int len) | 563 | void EmailHandler::encode64base(char *src, QString *dest, int len) |
548 | { | 564 | { |
549 | QString temp; | 565 | QString temp; |
550 | uchar c; | 566 | uchar c; |
551 | uchar bufOut[4]; | 567 | uchar bufOut[4]; |
552 | 568 | ||
553 | bufOut[0] = src[0]; | 569 | bufOut[0] = src[0]; |
554 | bufOut[0] >>= 2; //Done byte 0 | 570 | bufOut[0] >>= 2; //Done byte 0 |
555 | 571 | ||
556 | bufOut[1] = src[0]; | 572 | bufOut[1] = src[0]; |
557 | bufOut[1] = bufOut[1] & (1 + 2); //mask out top 6 bits | 573 | bufOut[1] = bufOut[1] & (1 + 2); //mask out top 6 bits |
558 | bufOut[1] <<= 4; //copy up 4 places | 574 | bufOut[1] <<= 4; //copy up 4 places |
559 | if (len > 1) { | 575 | if (len > 1) { |
560 | c = src[1]; | 576 | c = src[1]; |
561 | } else { | 577 | } else { |
562 | c = 0; | 578 | c = 0; |
563 | } | 579 | } |
564 | 580 | ||
565 | c = c & (16 + 32 + 64 + 128); | 581 | c = c & (16 + 32 + 64 + 128); |
566 | c >>= 4; | 582 | c >>= 4; |
567 | bufOut[1] = bufOut[1] | c; //Done byte 1 | 583 | bufOut[1] = bufOut[1] | c; //Done byte 1 |
568 | 584 | ||
569 | bufOut[2] = src[1]; | 585 | bufOut[2] = src[1]; |
570 | bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8); | 586 | bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8); |
571 | bufOut[2] <<= 2; | 587 | bufOut[2] <<= 2; |
572 | if (len > 2) { | 588 | if (len > 2) { |
573 | c = src[2]; | 589 | c = src[2]; |
574 | } else { | 590 | } else { |
575 | c = 0; | 591 | c = 0; |
576 | } | 592 | } |
577 | c >>= 6; | 593 | c >>= 6; |
578 | bufOut[2] = bufOut[2] | c; | 594 | bufOut[2] = bufOut[2] | c; |
579 | 595 | ||
580 | bufOut[3] = src[2]; | 596 | bufOut[3] = src[2]; |
581 | bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32); | 597 | bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32); |
582 | 598 | ||
583 | if (len == 1) { | 599 | if (len == 1) { |
584 | bufOut[2] = 64; | 600 | bufOut[2] = 64; |
585 | bufOut[3] = 64; | 601 | bufOut[3] = 64; |
586 | } | 602 | } |
587 | if (len == 2) { | 603 | if (len == 2) { |
588 | bufOut[3] = 64; | 604 | bufOut[3] = 64; |
589 | } | 605 | } |
590 | for (int x = 0; x < 4; x++) { | 606 | for (int x = 0; x < 4; x++) { |
591 | if (bufOut[x] <= 25) | 607 | if (bufOut[x] <= 25) |
592 | bufOut[x] += (uint) 'A'; | 608 | bufOut[x] += (uint) 'A'; |
593 | else if (bufOut[x] >= 26 && bufOut[x] <= 51) | 609 | else if (bufOut[x] >= 26 && bufOut[x] <= 51) |
594 | bufOut[x] += (uint) 'a' - 26; | 610 | bufOut[x] += (uint) 'a' - 26; |
595 | else if (bufOut[x] >= 52 && bufOut[x] <= 61) | 611 | else if (bufOut[x] >= 52 && bufOut[x] <= 61) |
596 | bufOut[x] += (uint) '0' - 52; | 612 | bufOut[x] += (uint) '0' - 52; |
597 | else if (bufOut[x] == 62) | 613 | else if (bufOut[x] == 62) |
598 | bufOut[x] = '+'; | 614 | bufOut[x] = '+'; |
599 | else if (bufOut[x] == 63) | 615 | else if (bufOut[x] == 63) |
600 | bufOut[x] = '/'; | 616 | bufOut[x] = '/'; |
601 | else if (bufOut[x] == 64) | 617 | else if (bufOut[x] == 64) |
602 | bufOut[x] = '='; | 618 | bufOut[x] = '='; |
603 | 619 | ||
604 | dest->append(bufOut[x]); | 620 | dest->append(bufOut[x]); |
605 | } | 621 | } |
606 | } | 622 | } |
607 | 623 | ||
608 | void EmailHandler::cancel() | 624 | void EmailHandler::cancel() |
609 | { | 625 | { |
610 | popClient->errorHandling(ErrCancel); | 626 | popClient->errorHandling(ErrCancel); |
611 | smtpClient->errorHandling(ErrCancel); | 627 | smtpClient->errorHandling(ErrCancel); |
612 | } | 628 | } |
diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp index a325766..b925a1c 100644 --- a/noncore/net/mailit/emaillistitem.cpp +++ b/noncore/net/mailit/emaillistitem.cpp | |||
@@ -1,97 +1,99 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include "emaillistitem.h" | 22 | #include "emaillistitem.h" |
23 | 23 | ||
24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | 24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) |
25 | : QListViewItem(parent) | 25 | : QListViewItem(parent) |
26 | { | 26 | { |
27 | QString temp; | 27 | QString temp; |
28 | 28 | ||
29 | mail = mailIn; | 29 | mail = mailIn; |
30 | 30 | ||
31 | if (inbox) { | 31 | if (inbox) { |
32 | setText(0, mail.from); | 32 | setText(0, mail.from); |
33 | } else { | 33 | } else { |
34 | QStringList::Iterator it = mail.recipients.begin(); | 34 | QStringList::Iterator it = mail.recipients.begin(); |
35 | temp = *it; | 35 | temp = *it; |
36 | if (mail.recipients.count() > 1) | 36 | if (mail.recipients.count() > 1) |
37 | temp += "..."; | 37 | temp += "..."; |
38 | setText(0, temp); | 38 | setText(0, temp); |
39 | } | 39 | } |
40 | setText(1, mail.subject); | 40 | setText(1, mail.subject); |
41 | setText(2,mail.date); | ||
41 | 42 | ||
42 | if (mailIn.files.count()>0) | 43 | if (mailIn.files.count()>0) |
43 | { | 44 | { |
44 | setPixmap(0, Resource::loadPixmap("mailit/attach")); | 45 | setPixmap(0, Resource::loadPixmap("mailit/attach")); |
45 | } | 46 | } |
47 | |||
46 | selected = FALSE; | 48 | selected = FALSE; |
47 | } | 49 | } |
48 | 50 | ||
49 | Email* EmailListItem::getMail() | 51 | Email* EmailListItem::getMail() |
50 | { | 52 | { |
51 | return &mail; | 53 | return &mail; |
52 | } | 54 | } |
53 | 55 | ||
54 | void EmailListItem::setMail(Email newMail) | 56 | void EmailListItem::setMail(Email newMail) |
55 | { | 57 | { |
56 | mail = newMail; | 58 | mail = newMail; |
57 | repaint(); | 59 | repaint(); |
58 | } | 60 | } |
59 | 61 | ||
60 | void EmailListItem::setItemSelected(bool enable) | 62 | void EmailListItem::setItemSelected(bool enable) |
61 | { | 63 | { |
62 | selected = enable; | 64 | selected = enable; |
63 | setSelected(enable); | 65 | setSelected(enable); |
64 | repaint(); | 66 | repaint(); |
65 | } | 67 | } |
66 | 68 | ||
67 | bool EmailListItem::isItemSelected() | 69 | bool EmailListItem::isItemSelected() |
68 | { | 70 | { |
69 | return selected; | 71 | return selected; |
70 | } | 72 | } |
71 | 73 | ||
72 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | 74 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, |
73 | int column, int width, int alignment ) | 75 | int column, int width, int alignment ) |
74 | { | 76 | { |
75 | 77 | ||
76 | QColorGroup _cg( cg ); | 78 | QColorGroup _cg( cg ); |
77 | QColor c = _cg.text(); | 79 | QColor c = _cg.text(); |
78 | 80 | ||
79 | if ( (! mail.read) && (mail.received) ) | 81 | if ( (! mail.read) && (mail.received) ) |
80 | _cg.setColor( QColorGroup::Text, Qt::blue); | 82 | _cg.setColor( QColorGroup::Text, Qt::blue); |
81 | if (!mail.downloaded) | 83 | if (!mail.downloaded) |
82 | _cg.setColor( QColorGroup::Text, Qt::red); | 84 | _cg.setColor( QColorGroup::Text, Qt::red); |
83 | 85 | ||
84 | /*if (selected) { | 86 | /*if (selected) { |
85 | _cg.setColor(QColorGroup::Base, Qt::blue); | 87 | _cg.setColor(QColorGroup::Base, Qt::blue); |
86 | _cg.setColor(QColorGroup::Text, Qt::yellow); | 88 | _cg.setColor(QColorGroup::Text, Qt::yellow); |
87 | if (isSelected()) { | 89 | if (isSelected()) { |
88 | _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); | 90 | _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); |
89 | } else { | 91 | } else { |
90 | _cg.setColor(QColorGroup::Highlight, Qt::blue); | 92 | _cg.setColor(QColorGroup::Highlight, Qt::blue); |
91 | } | 93 | } |
92 | } | 94 | } |
93 | */ | 95 | */ |
94 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 96 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
95 | 97 | ||
96 | _cg.setColor( QColorGroup::Text, c ); | 98 | _cg.setColor( QColorGroup::Text, c ); |
97 | } | 99 | } |
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index ef5fc09..7181adf 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp | |||
@@ -1,165 +1,143 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qwhatsthis.h> | ||
20 | #include "mailitwindow.h" | 21 | #include "mailitwindow.h" |
21 | 22 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 23 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 24 | : QMainWindow(parent, name, WStyle_ContextHelp) |
24 | { | 25 | { |
25 | currentCaption = "Mailit"; | 26 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 27 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 28 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 29 | setCentralWidget(views); |
29 | 30 | QWhatsThis::add(views,tr("Central view area")); | |
30 | emailClient = new EmailClient(views, "client"); | 31 | emailClient = new EmailClient(views, "client"); |
31 | writeMail = new WriteMail(views, "writing"); | 32 | writeMail = new WriteMail(views, "writing"); |
32 | readMail = new ReadMail(views, "reading"); | 33 | readMail = new ReadMail(views, "reading"); |
33 | 34 | ||
34 | views->raiseWidget(emailClient); | 35 | views->raiseWidget(emailClient); |
35 | 36 | ||
36 | connect(emailClient, SIGNAL(composeRequested()), | 37 | connect(emailClient, SIGNAL(composeRequested()), |
37 | this, SLOT(compose()) ); | 38 | this, SLOT(compose()) ); |
38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 39 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
39 | SLOT(viewMail(QListView *, Email *)) ); | 40 | SLOT(viewMail(QListView *, Email *)) ); |
40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 41 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
41 | SLOT(updateMailView(Email *)) ); | 42 | SLOT(updateMailView(Email *)) ); |
42 | 43 | ||
43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 44 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 45 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
45 | SLOT(showEmailClient()) ); | 46 | SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 47 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
47 | SLOT(enqueMail(const Email &)) ); | 48 | SLOT(enqueMail(const Email &)) ); |
48 | 49 | ||
49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 50 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
50 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, | 51 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, |
51 | SLOT(composeReply(Email &, bool&)) ); | 52 | SLOT(composeReply(Email &, bool&)) ); |
52 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | 53 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, |
53 | SLOT(composeForward(Email &)) ); | 54 | SLOT(composeForward(Email &)) ); |
54 | 55 | ||
55 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 56 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
56 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 57 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
57 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 58 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
58 | SLOT(moveMailFront(Email *)) ); | 59 | SLOT(moveMailFront(Email *)) ); |
59 | 60 | ||
60 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 61 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
61 | this, SLOT(updateCaption(const QString &)) ); | 62 | this, SLOT(updateCaption(const QString &)) ); |
62 | viewingMail = FALSE; | 63 | viewingMail = FALSE; |
63 | 64 | ||
64 | } | 65 | } |
65 | 66 | ||
66 | MailItWindow::~MailItWindow() | 67 | MailItWindow::~MailItWindow() |
67 | { | 68 | { |
68 | } | 69 | } |
69 | 70 | ||
70 | void MailItWindow::closeEvent(QCloseEvent *e) | 71 | void MailItWindow::closeEvent(QCloseEvent *e) |
71 | { | 72 | { |
72 | if (views->visibleWidget() == emailClient) { | 73 | if (views->visibleWidget() == emailClient) { |
73 | e->accept(); | 74 | e->accept(); |
74 | } else { | 75 | } else { |
75 | showEmailClient(); | 76 | showEmailClient(); |
76 | } | 77 | } |
77 | } | 78 | } |
78 | 79 | ||
79 | void MailItWindow::compose() | 80 | void MailItWindow::compose() |
80 | { | 81 | { |
81 | viewingMail = FALSE; | 82 | viewingMail = FALSE; |
82 | emailClient->hide(); | 83 | emailClient->hide(); |
83 | readMail->hide(); | 84 | readMail->hide(); |
84 | views->raiseWidget(writeMail); | 85 | views->raiseWidget(writeMail); |
85 | writeMail->setAddressList(emailClient->getAdrListRef()); | 86 | writeMail->setAddressList(emailClient->getAdrListRef()); |
86 | setCaption( tr( "Write mail" ) ); | 87 | setCaption( tr( "Write mail" ) ); |
87 | } | 88 | } |
88 | 89 | ||
89 | void MailItWindow::composeReply(Email &mail, bool& replyAll) | 90 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
90 | { | 91 | { |
91 | compose(); | 92 | compose(); |
92 | writeMail->reply(mail,replyAll) ; | 93 | writeMail->reply(mail,replyAll) ; |
93 | } | 94 | } |
94 | 95 | ||
95 | void MailItWindow::composeForward(Email &mail) | 96 | void MailItWindow::composeForward(Email &mail) |
96 | { | 97 | { |
97 | compose(); | 98 | compose(); |
98 | writeMail->forward(mail) ; | 99 | writeMail->forward(mail) ; |
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
102 | void MailItWindow::showEmailClient() | 103 | void MailItWindow::showEmailClient() |
103 | { | 104 | { |
104 | viewingMail = FALSE; | 105 | viewingMail = FALSE; |
105 | writeMail->hide(); | 106 | writeMail->hide(); |
106 | readMail->hide(); | 107 | readMail->hide(); |
107 | views->raiseWidget(emailClient); | 108 | views->raiseWidget(emailClient); |
108 | setCaption( tr(currentCaption) ); | 109 | setCaption( tr(currentCaption) ); |
109 | } | 110 | } |
110 | 111 | ||
111 | void MailItWindow::viewMail(QListView *view, Email *mail) | 112 | void MailItWindow::viewMail(QListView *view, Email *mail) |
112 | { | 113 | { |
113 | viewingMail = TRUE; | 114 | viewingMail = TRUE; |
114 | emailClient->hide(); | 115 | emailClient->hide(); |
115 | readMail->update(view, mail); | 116 | readMail->update(view, mail); |
116 | views->raiseWidget(readMail); | 117 | views->raiseWidget(readMail); |
117 | setCaption( tr( "Examine mail" ) ); | 118 | setCaption( tr( "Examine mail" ) ); |
118 | } | 119 | } |
119 | 120 | ||
120 | void MailItWindow::updateMailView(Email *mail) | 121 | void MailItWindow::updateMailView(Email *mail) |
121 | { | 122 | { |
122 | if (viewingMail) { | 123 | if (viewingMail) { |
123 | readMail->mailUpdated(mail); | 124 | readMail->mailUpdated(mail); |
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | void MailItWindow::updateCaption(const QString &newCaption) | 128 | void MailItWindow::updateCaption(const QString &newCaption) |
128 | { | 129 | { |
129 | currentCaption = newCaption; | 130 | currentCaption = newCaption; |
130 | setCaption(tr(currentCaption)); | 131 | setCaption(tr(currentCaption)); |
131 | } | 132 | } |
132 | 133 | ||
133 | void MailItWindow::setDocument(const QString &_address) | 134 | void MailItWindow::setDocument(const QString &_address) |
134 | { | 135 | { |
135 | // strip leading 'mailto:' | 136 | // strip leading 'mailto:' |
136 | QString address = _address; | 137 | QString address = _address; |
137 | if (address.startsWith("mailto:")) | 138 | if (address.startsWith("mailto:")) |
138 | address = address.mid(6); | 139 | address = address.mid(6); |
139 | 140 | ||
140 | compose(); | 141 | compose(); |
141 | writeMail->setRecipient(address); | 142 | writeMail->setRecipient(address); |
142 | } | 143 | } |
143 | |||
144 | /*void MailItWindow::reply(Email& mail) | ||
145 | { | ||
146 | qDebug("####EmailClient: 0 reached"); | ||
147 | composeReply(mail,(bool&)FALSE); | ||
148 | } | ||
149 | |||
150 | void MailItWindow::replyAll(Email& mail) | ||
151 | { | ||
152 | qDebug("####EmailClient: 1 reached"); | ||
153 | composeReply(mail,(bool&)TRUE); | ||
154 | } | ||
155 | |||
156 | void MailItWindow::forward(Email& mail) | ||
157 | { | ||
158 | qDebug("####EmailClient: 2 reached"); | ||
159 | } | ||
160 | |||
161 | void MailItWindow::remove(Email&) | ||
162 | { | ||
163 | qDebug("####EmailClient: 3 reached"); | ||
164 | //emit removeItem(eli,(bool&)TRUE); | ||
165 | } */ \ No newline at end of file | ||
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp index f9cc337..67306be 100644 --- a/noncore/net/mailit/popclient.cpp +++ b/noncore/net/mailit/popclient.cpp | |||
@@ -1,375 +1,367 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "popclient.h" | 20 | #include "popclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | //#define APOP_TEST | 22 | //#define APOP_TEST |
23 | 23 | ||
24 | extern "C" { | 24 | extern "C" { |
25 | #include "md5.h" | 25 | #include "md5.h" |
26 | } | 26 | } |
27 | 27 | ||
28 | #include <qcstring.h> | 28 | #include <qcstring.h> |
29 | 29 | ||
30 | PopClient::PopClient() | 30 | PopClient::PopClient() |
31 | { | 31 | { |
32 | socket = new QSocket(this, "popClient"); | 32 | socket = new QSocket(this, "popClient"); |
33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
36 | 36 | ||
37 | stream = new QTextStream(socket); | 37 | stream = new QTextStream(socket); |
38 | 38 | ||
39 | receiving = FALSE; | 39 | receiving = FALSE; |
40 | synchronize = FALSE; | 40 | synchronize = FALSE; |
41 | lastSync = 0; | 41 | lastSync = 0; |
42 | headerLimit = 0; | 42 | headerLimit = 0; |
43 | preview = FALSE; | 43 | preview = FALSE; |
44 | } | 44 | } |
45 | 45 | ||
46 | PopClient::~PopClient() | 46 | PopClient::~PopClient() |
47 | { | 47 | { |
48 | delete socket; | 48 | delete socket; |
49 | delete stream; | 49 | delete stream; |
50 | } | 50 | } |
51 | 51 | ||
52 | void PopClient::newConnection(QString target, int port) | 52 | void PopClient::newConnection(QString target, int port) |
53 | { | 53 | { |
54 | if (receiving) { | 54 | if (receiving) { |
55 | qWarning("socket in use, connection refused"); | 55 | qWarning("socket in use, connection refused"); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | status = Init; | 59 | status = Init; |
60 | 60 | ||
61 | socket->connectToHost(target, port); | 61 | socket->connectToHost(target, port); |
62 | receiving = TRUE; | 62 | receiving = TRUE; |
63 | selected = FALSE; | 63 | selected = FALSE; |
64 | 64 | ||
65 | emit updateStatus("DNS lookup"); | 65 | emit updateStatus("DNS lookup"); |
66 | } | 66 | } |
67 | 67 | ||
68 | void PopClient::setAccount(QString popUser, QString popPasswd) | 68 | void PopClient::setAccount(QString popUser, QString popPasswd) |
69 | { | 69 | { |
70 | popUserName = popUser; | 70 | popUserName = popUser; |
71 | popPassword = popPasswd; | 71 | popPassword = popPasswd; |
72 | } | 72 | } |
73 | 73 | ||
74 | void PopClient::setSynchronize(int lastCount) | 74 | void PopClient::setSynchronize(int lastCount) |
75 | { | 75 | { |
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus(tr("Connection established")); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus(tr("Error Occured")); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void PopClient::incomingData() | 111 | void PopClient::incomingData() |
112 | { | 112 | { |
113 | QString response, temp, temp2, timeStamp; | 113 | QString response, temp, temp2, timeStamp; |
114 | QString md5Source; | 114 | QString md5Source; |
115 | int start, end; | 115 | int start, end; |
116 | // char *md5Digest; | 116 | // char *md5Digest; |
117 | char md5Digest[16]; | 117 | char md5Digest[16]; |
118 | // if ( !socket->canReadLine() ) | 118 | // if ( !socket->canReadLine() ) |
119 | // return; | 119 | // return; |
120 | 120 | ||
121 | response = socket->readLine(); | 121 | response = socket->readLine(); |
122 | //qDebug(response +" %d", status); | ||
123 | 122 | ||
124 | switch(status) { | 123 | switch(status) { |
125 | //logging in | 124 | //logging in |
126 | case Init: { | 125 | case Init: { |
127 | #ifdef APOP_TEST | 126 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 127 | start = response.find('<',0); |
129 | end = response.find('>', start); | 128 | end = response.find('>', start); |
130 | if( start >= 0 && end > start ) | 129 | if( start >= 0 && end > start ) |
131 | { | 130 | { |
132 | timeStamp = response.mid( start , end - start + 1); | 131 | timeStamp = response.mid( start , end - start + 1); |
133 | md5Source = timeStamp + popPassword; | 132 | md5Source = timeStamp + popPassword; |
134 | //qDebug( md5Source); | ||
135 | // for( int i = 0; i < md5Source.length(); i++) { | ||
136 | // buff[i] = (QChar)md5Source[i]; | ||
137 | // } | ||
138 | 133 | ||
139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); | 134 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); |
140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); | ||
141 | |||
142 | // MD5_Init( &ctx); | ||
143 | // MD5_Update( &ctx, buff, sizeof( buff) ); | ||
144 | // MD5_Final( md5Digest, &ctx); | ||
145 | // MD5( buff, md5Source.length(), md5Digest); | ||
146 | 135 | ||
147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) | 136 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) |
148 | { | 137 | { |
149 | printf("%x", md5Digest[j]); | 138 | printf("%x", md5Digest[j]); |
150 | } | 139 | } |
151 | printf("\n"); | 140 | printf("\n"); |
152 | // qDebug(md5Digest); | 141 | // qDebug(md5Digest); |
153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; | 142 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; |
154 | // qDebug("%s", stream); | 143 | // qDebug("%s", stream); |
155 | status = Stat; | 144 | status = Stat; |
156 | } | 145 | } |
157 | else | 146 | else |
158 | #endif | 147 | #endif |
159 | { | 148 | { |
160 | timeStamp = ""; | 149 | timeStamp = ""; |
161 | *stream << "USER " << popUserName << "\r\n"; | 150 | *stream << "USER " << popUserName << "\r\n"; |
162 | status = Pass; | 151 | status = Pass; |
163 | } | 152 | } |
164 | 153 | ||
165 | break; | 154 | break; |
166 | } | 155 | } |
167 | //password shhh. don't tell anyone (implement APOP...) | 156 | |
168 | case Pass: { | 157 | case Pass: { |
169 | *stream << "PASS " << popPassword << "\r\n"; | 158 | *stream << "PASS " << popPassword << "\r\n"; |
170 | status = Stat; | 159 | status = Stat; |
171 | break; | 160 | break; |
172 | } | 161 | } |
173 | //ask for number of messages | 162 | //ask for number of messages |
174 | case Stat: { | 163 | case Stat: { |
175 | if (response[0] == '+') { | 164 | if (response[0] == '+') { |
176 | *stream << "STAT" << "\r\n"; | 165 | *stream << "STAT" << "\r\n"; |
177 | status = Mcnt; | 166 | status = Mcnt; |
178 | } else errorHandling(ErrLoginFailed); | 167 | } else errorHandling(ErrLoginFailed); |
179 | break; | 168 | break; |
180 | } | 169 | } |
181 | //get count of messages, eg "+OK 4 900.." -> int 4 | 170 | //get count of messages, eg "+OK 4 900.." -> int 4 |
182 | case Mcnt: { | 171 | case Mcnt: { |
183 | if (response[0] == '+') { | 172 | if (response[0] == '+') { |
184 | temp = response.replace(0, 4, ""); | 173 | temp = response.replace(0, 4, ""); |
185 | int x = temp.find(" ", 0); | 174 | int x = temp.find(" ", 0); |
186 | temp.truncate((uint) x); | 175 | temp.truncate((uint) x); |
187 | newMessages = temp.toInt(); | 176 | newMessages = temp.toInt(); |
188 | messageCount = 1; | 177 | messageCount = 1; |
189 | status = List; | 178 | status = List; |
190 | 179 | ||
191 | if (synchronize) { | 180 | if (synchronize) { |
192 | //messages deleted from server, reload all | 181 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 182 | if (newMessages < lastSync) |
194 | lastSync = 0; | 183 | lastSync = 0; |
195 | messageCount = 1; | 184 | messageCount = 1; |
196 | } | 185 | } |
197 | 186 | ||
198 | if (selected) { | 187 | if (selected) { |
199 | int *ptr = mailList->first(); | 188 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 189 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 190 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 191 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 192 | } else newMessages = 0; |
204 | } | 193 | } |
205 | } else errorHandling(ErrUnknownResponse); | 194 | } else errorHandling(ErrUnknownResponse); |
206 | } | 195 | } |
207 | //Read message number x, count upwards to messageCount | 196 | //Read message number x, count upwards to messageCount |
208 | case List: { | 197 | case List: { |
209 | if (messageCount <= newMessages) { | 198 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 199 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 200 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 201 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 202 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 203 | if (!selected) { |
215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 204 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 205 | } else { |
217 | //completing a previously closed transfer | 206 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 207 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 208 | temp.setNum(messageCount); |
220 | emit updateStatus(tr("Previous message ") + temp); | 209 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 210 | } else { |
222 | emit updateStatus(tr("Completing message ") + temp); | 211 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 212 | } |
224 | } | 213 | } |
225 | break; | 214 | break; |
226 | } else { | 215 | } else { |
227 | emit updateStatus(tr("No new Messages")); | 216 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 217 | status = Quit; |
229 | } | 218 | } |
230 | } | 219 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 220 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 221 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 222 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 223 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 224 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 225 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 226 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 227 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 228 | emit currentMailSize(mailSize); |
240 | 229 | ||
241 | status = Retr; | 230 | status = Retr; |
242 | } else { | 231 | } else { |
243 | //qWarning(response); | 232 | //qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 233 | errorHandling(ErrUnknownResponse); |
245 | } | 234 | } |
246 | } | 235 | } |
247 | } | 236 | } |
248 | //Read message number x, count upwards to messageCount | 237 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 238 | case Retr: { |
250 | if (status != Quit) { | 239 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 240 | if (mailSize <= headerLimit) |
241 | { | ||
252 | *stream << "RETR " << messageCount << "\r\n"; | 242 | *stream << "RETR " << messageCount << "\r\n"; |
253 | } else { //only header | 243 | } else { //only header |
254 | *stream << "TOP " << messageCount << " 0\r\n"; | 244 | *stream << "TOP " << messageCount << " 0\r\n"; |
255 | } | 245 | } |
256 | messageCount++; | 246 | messageCount++; |
257 | status = Ignore; | 247 | status = Ignore; |
258 | break; | 248 | break; |
259 | } } | 249 | } } |
260 | case Ignore: { | 250 | case Ignore: { |
261 | if (status != Quit) { //because of idiotic switch | 251 | if (status != Quit) { //because of idiotic switch |
262 | if (response[0] == '+') { | 252 | if (response[0] == '+') { |
263 | message = ""; | 253 | message = ""; |
264 | status = Read; | 254 | status = Read; |
265 | if (!socket->canReadLine()) //sync. problems | 255 | if (!socket->canReadLine()) //sync. problems |
266 | break; | 256 | break; |
267 | response = socket->readLine(); | 257 | response = socket->readLine(); |
268 | } else errorHandling(ErrUnknownResponse); | 258 | } else errorHandling(ErrUnknownResponse); |
269 | } | 259 | } |
270 | } | 260 | } |
271 | //add all incoming lines to body. When size is reached, send | 261 | //add all incoming lines to body. When size is reached, send |
272 | //message, and go back to read new message | 262 | //message, and go back to read new message |
273 | case Read: { | 263 | case Read: { |
274 | if (status != Quit) { //because of idiotic switch | 264 | if (status != Quit) { //because of idiotic switch |
275 | message += response; | 265 | message += response; |
276 | while ( socket->canReadLine() ) { | 266 | while ( socket->canReadLine() ) { |
277 | response = socket->readLine(); | 267 | response = socket->readLine(); |
278 | message += response; | 268 | message += response; |
279 | } | 269 | } |
280 | emit downloadedSize(message.length()); | 270 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 271 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 272 | if (x == -1) { |
283 | break; | 273 | break; |
284 | } else { //message reach entire size | 274 | } else { //message reach entire size |
285 | //complete mail downloaded | 275 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 276 | //if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 277 | if ( mailSize <= headerLimit) |
278 | { | ||
279 | emit newMessage(message, messageCount-1, mailSize, TRUE); | ||
288 | } else { //incomplete mail downloaded | 280 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 281 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 282 | } |
291 | if (messageCount > newMessages) //that was the last message | 283 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 284 | status = Quit; |
293 | else { //ask for new message | 285 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 286 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 287 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 288 | if (ptr != 0) { |
297 | messageCount = *ptr; | 289 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 290 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 291 | status = Size; |
300 | //completing a previously closed transfer | 292 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 293 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 294 | temp.setNum(messageCount); |
303 | emit updateStatus(tr("Previous message ") + temp); | 295 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 296 | } else { |
305 | temp.setNum(messageCount - lastSync); | 297 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus(tr("Completing message ") + temp); | 298 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 299 | } |
308 | break; | 300 | break; |
309 | } else { | 301 | } else { |
310 | newMessages--; | 302 | newMessages--; |
311 | status = Quit; | 303 | status = Quit; |
312 | } | 304 | } |
313 | } else { | 305 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 306 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 307 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 308 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 309 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 310 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 311 | ||
320 | break; | 312 | break; |
321 | } | 313 | } |
322 | } | 314 | } |
323 | } | 315 | } |
324 | if (status != Quit) | 316 | if (status != Quit) |
325 | break; | 317 | break; |
326 | } | 318 | } |
327 | } | 319 | } |
328 | case Quit: { | 320 | case Quit: { |
329 | *stream << "Quit\r\n"; | 321 | *stream << "Quit\r\n"; |
330 | status = Done; | 322 | status = Done; |
331 | int newM = newMessages - lastSync; | 323 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 324 | if (newM > 0) { |
333 | temp.setNum(newM); | 325 | temp.setNum(newM); |
334 | emit updateStatus(temp + tr(" new messages")); | 326 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 327 | } else { |
336 | emit updateStatus(tr("No new messages")); | 328 | emit updateStatus(tr("No new messages")); |
337 | } | 329 | } |
338 | 330 | ||
339 | socket->close(); | 331 | socket->close(); |
340 | receiving = FALSE; | 332 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 333 | emit mailTransfered(newM); |
342 | break; | 334 | break; |
343 | } | 335 | } |
344 | } | 336 | } |
345 | 337 | ||
346 | } | 338 | } |
347 | 339 | ||
348 | // if( bAPOPAuthentication ) | 340 | // if( bAPOPAuthentication ) |
349 | // { | 341 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 342 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 343 | // { |
352 | // SetLastError("Apop error!"); | 344 | // SetLastError("Apop error!"); |
353 | // return false; | 345 | // return false; |
354 | // } | 346 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 347 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 348 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 349 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 350 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 351 | // if(ret == SOCKET_ERROR) |
360 | // { | 352 | // { |
361 | // SetLastError("Socket error!"); | 353 | // SetLastError("Socket error!"); |
362 | // m_bSocketOK = false; | 354 | // m_bSocketOK = false; |
363 | // m_bConnected = false; | 355 | // m_bConnected = false; |
364 | // return false; | 356 | // return false; |
365 | // } | 357 | // } |
366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) | 358 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) |
367 | // return false; | 359 | // return false; |
368 | // if( 0 == strResult.Find('-' , 0) ) | 360 | // if( 0 == strResult.Find('-' , 0) ) |
369 | // { | 361 | // { |
370 | // SetLastError("Username or Password error!"); | 362 | // SetLastError("Username or Password error!"); |
371 | // return false; | 363 | // return false; |
372 | // } | 364 | // } |
373 | // m_bConnected = true; | 365 | // m_bConnected = true; |
374 | 366 | ||
375 | // } | 367 | // } |
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index dc98a6f..4eae7f6 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp | |||
@@ -1,357 +1,367 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | replyButton->setWhatsThis(tr("Click here to reply to the selected mail")); | |
63 | |||
63 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), | 64 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), |
64 | QString::null, 0, this, 0 ); | 65 | QString::null, 0, this, 0 ); |
65 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); | 66 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); |
67 | forwardButton->setWhatsThis(tr("Click here to forward the selected mail")); | ||
66 | 68 | ||
67 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 69 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
68 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 70 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
69 | previousButton->addTo(bar); | 71 | previousButton->addTo(bar); |
70 | previousButton->addTo(viewMenu); | 72 | previousButton->addTo(viewMenu); |
73 | previousButton->setWhatsThis(tr("Read the previous mail in the list")); | ||
71 | 74 | ||
72 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 75 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
73 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 76 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
74 | nextButton->addTo(bar); | 77 | nextButton->addTo(bar); |
75 | nextButton->addTo(viewMenu); | 78 | nextButton->addTo(viewMenu); |
79 | previousButton->setWhatsThis(tr("Read the next mail in the list")); | ||
76 | 80 | ||
77 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 81 | attachmentButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
78 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 82 | connect( attachmentButton, SIGNAL( activated() ), this, |
79 | SLOT( viewAttatchments() ) ); | 83 | SLOT( viewAttachments() ) ); |
80 | attatchmentsButton->addTo(bar); | 84 | attachmentButton->addTo(bar); |
81 | attatchmentsButton->addTo(viewMenu); | 85 | attachmentButton->addTo(viewMenu); |
86 | attachmentButton->setWhatsThis(tr("Click here to add attachments to your mail")); | ||
82 | 87 | ||
83 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 88 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
84 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 89 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
85 | plainTextButton->addTo(bar); | 90 | plainTextButton->addTo(bar); |
86 | plainTextButton->addTo(viewMenu); | 91 | plainTextButton->addTo(viewMenu); |
92 | plainTextButton->setWhatsThis(tr("The mail view has 2 modes:\n" | ||
93 | "<LI><B>RichText</B> shows the mail as HTML with reach features (no standard line breaks)</LI>" | ||
94 | "<LI><B>Plain</B> shows the mail as standard plain text</LI>" | ||
95 | "Click here to switch between those view modes" )); | ||
87 | 96 | ||
88 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 97 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
89 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 98 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
90 | deleteButton->addTo(bar); | 99 | deleteButton->addTo(bar); |
91 | deleteButton->addTo(mailMenu); | 100 | deleteButton->addTo(mailMenu); |
101 | deleteButton->setWhatsThis(tr("Click here to remove the selected mail")); | ||
92 | 102 | ||
93 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 103 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
94 | 104 | ||
95 | emailView = new QTextView( this, "emailView" ); | 105 | emailView = new QTextView( this, "emailView" ); |
96 | 106 | ||
97 | setCentralWidget(emailView); | 107 | setCentralWidget(emailView); |
98 | 108 | ||
99 | mime = new QMimeSourceFactory(); | 109 | mime = new QMimeSourceFactory(); |
100 | emailView->setMimeSourceFactory(mime); | 110 | emailView->setMimeSourceFactory(mime); |
101 | } | 111 | } |
102 | 112 | ||
103 | void ReadMail::updateView() | 113 | void ReadMail::updateView() |
104 | { | 114 | { |
105 | Enclosure *ePtr; | 115 | Enclosure *ePtr; |
106 | QString mailStringSize; | 116 | QString mailStringSize; |
107 | QString text, temp; | 117 | QString text, temp; |
108 | 118 | ||
109 | mail->read = TRUE; //mark as read | 119 | mail->read = TRUE; //mark as read |
110 | inbox = mail->received; | 120 | inbox = mail->received; |
111 | 121 | ||
112 | replyButton->removeFrom(mailMenu); | 122 | replyButton->removeFrom(mailMenu); |
113 | replyButton->removeFrom(bar); | 123 | replyButton->removeFrom(bar); |
114 | forwardButton->removeFrom(mailMenu); | 124 | forwardButton->removeFrom(mailMenu); |
115 | forwardButton->removeFrom(bar); | 125 | forwardButton->removeFrom(bar); |
116 | 126 | ||
117 | if (inbox == TRUE) { | 127 | if (inbox == TRUE) { |
118 | replyButton->addTo(bar); | 128 | replyButton->addTo(bar); |
119 | replyButton->addTo(mailMenu); | 129 | replyButton->addTo(mailMenu); |
120 | forwardButton->addTo(bar); | 130 | forwardButton->addTo(bar); |
121 | forwardButton->addTo(mailMenu); | 131 | forwardButton->addTo(mailMenu); |
122 | 132 | ||
123 | 133 | ||
124 | if (!mail->downloaded) { | 134 | if (!mail->downloaded) { |
125 | //report currently viewed mail so that it will be | 135 | //report currently viewed mail so that it will be |
126 | //placed first in the queue of new mails to download | 136 | //placed first in the queue of new mails to download |
127 | emit viewingMail(mail); | 137 | emit viewingMail(mail); |
128 | 138 | ||
129 | double mailSize = (double) mail->size; | 139 | double mailSize = (double) mail->size; |
130 | if (mailSize < 1024) { | 140 | if (mailSize < 1024) { |
131 | mailStringSize.setNum(mailSize); | 141 | mailStringSize.setNum(mailSize); |
132 | mailStringSize += " Bytes"; | 142 | mailStringSize += " Bytes"; |
133 | } else if (mailSize < 1024*1024) { | 143 | } else if (mailSize < 1024*1024) { |
134 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 144 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
135 | mailStringSize += " Kb"; | 145 | mailStringSize += " Kb"; |
136 | } else { | 146 | } else { |
137 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 147 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
138 | mailStringSize += " Mb"; | 148 | mailStringSize += " Mb"; |
139 | } | 149 | } |
140 | } | 150 | } |
141 | } | 151 | } |
142 | 152 | ||
143 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 153 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
144 | 154 | ||
145 | if (! plainTxt) { //use RichText, inline pics etc. | 155 | if (! plainTxt) { //use RichText, inline pics etc. |
146 | emailView->setTextFormat(QTextView::RichText); | 156 | emailView->setTextFormat(QTextView::RichText); |
147 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 157 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
148 | +"</font></center></big></b><br>"; | 158 | +"</font></center></big></b><br>"; |
149 | text += "<b>From: </b>" + mail->from + " <i>" + | 159 | text += "<b>From: </b>" + mail->from + " <i>" + |
150 | mail->fromMail + "</i><br>"; | 160 | mail->fromMail + "</i><br>"; |
151 | 161 | ||
152 | text +="<b>To: </b>"; | 162 | text +="<b>To: </b>"; |
153 | for (QStringList::Iterator it = mail->recipients.begin(); | 163 | for (QStringList::Iterator it = mail->recipients.begin(); |
154 | it != mail->recipients.end(); ++it ) { | 164 | it != mail->recipients.end(); ++it ) { |
155 | text += *it + " "; | 165 | text += *it + " "; |
156 | } | 166 | } |
157 | 167 | ||
158 | text +="<br><b>CC: </b>"; | 168 | text +="<br><b>CC: </b>"; |
159 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | 169 | for (QStringList::Iterator it = mail->carbonCopies.begin(); |
160 | it != mail->carbonCopies.end(); ++it ) { | 170 | it != mail->carbonCopies.end(); ++it ) { |
161 | text += *it + " "; | 171 | text += *it + " "; |
162 | } | 172 | } |
163 | 173 | ||
164 | text += "<br>" + mail->date; | 174 | text += "<br>" + mail->date; |
165 | 175 | ||
166 | if (mail->files.count() > 0) { | 176 | if (mail->files.count() > 0) { |
167 | text += "<br><b>Attatchments: </b>"; | 177 | text += "<br><b>Attatchments: </b>"; |
168 | 178 | ||
169 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 179 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
170 | text += ePtr->originalName + " "; | 180 | text += ePtr->originalName + " "; |
171 | } | 181 | } |
172 | text += "<hr><br>" + mail->body; | 182 | text += "<hr><br>" + mail->body; |
173 | 183 | ||
174 | if (inbox) { | 184 | if (inbox) { |
175 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 185 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
176 | 186 | ||
177 | text += "<br><hr><b>Attatchment: </b>" + | 187 | text += "<br><hr><b>Attatchment: </b>" + |
178 | ePtr->originalName + "<hr>"; | 188 | ePtr->originalName + "<hr>"; |
179 | 189 | ||
180 | if (ePtr->contentType == "TEXT") { | 190 | if (ePtr->contentType == "TEXT") { |
181 | QFile f(ePtr->path + ePtr->name); | 191 | QFile f(ePtr->path + ePtr->name); |
182 | 192 | ||
183 | if (f.open(IO_ReadOnly) ) { | 193 | if (f.open(IO_ReadOnly) ) { |
184 | QTextStream t(&f); | 194 | QTextStream t(&f); |
185 | temp = t.read(); | 195 | temp = t.read(); |
186 | text += temp + "<br>"; | 196 | text += temp + "<br>"; |
187 | f.close(); | 197 | f.close(); |
188 | } else { | 198 | } else { |
189 | text += "<b>Could not locate file</b><br>"; | 199 | text += "<b>Could not locate file</b><br>"; |
190 | } | 200 | } |
191 | 201 | ||
192 | } | 202 | } |
193 | if (ePtr->contentType == "IMAGE") { | 203 | if (ePtr->contentType == "IMAGE") { |
194 | // temp.setNum(emailView->width());//get display width | 204 | // temp.setNum(emailView->width());//get display width |
195 | // text += "<img width=" + temp +" src =""" + | 205 | // text += "<img width=" + temp +" src =""" + |
196 | // ePtr->originalName + """> </img>"; | 206 | // ePtr->originalName + """> </img>"; |
197 | text += "<img src =""" + | 207 | text += "<img src =""" + |
198 | ePtr->originalName + """> </img>"; | 208 | ePtr->originalName + """> </img>"; |
199 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 209 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
200 | } | 210 | } |
201 | } | 211 | } |
202 | } | 212 | } |
203 | } else { | 213 | } else { |
204 | if (mail->downloaded || !inbox) { | 214 | if (mail->downloaded || !inbox) { |
205 | text += "<hr><br>" + mail->body; | 215 | text += "<hr><br>" + mail->body; |
206 | } else { | 216 | } else { |
207 | text += "<hr><br><b> Awaiting download </b><br>"; | 217 | text += "<hr><br><b> Awaiting download </b><br>"; |
208 | text += "Size of mail: " + mailStringSize; | 218 | text += "Size of mail: " + mailStringSize; |
209 | } | 219 | } |
210 | } | 220 | } |
211 | emailView->setText(text); | 221 | emailView->setText(text); |
212 | } else { // show plain txt mail | 222 | } else { // show plain txt mail |
213 | emailView->setTextFormat(QTextView::PlainText); | 223 | emailView->setTextFormat(QTextView::PlainText); |
214 | text = "Subject: " + mail->subject + "\n"; | 224 | text = "Subject: " + mail->subject + "\n"; |
215 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 225 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
216 | text += "To: "; | 226 | text += "To: "; |
217 | for (QStringList::Iterator it = mail->recipients.begin(); | 227 | for (QStringList::Iterator it = mail->recipients.begin(); |
218 | it != mail->recipients.end(); ++it ) { | 228 | it != mail->recipients.end(); ++it ) { |
219 | text += *it + " "; | 229 | text += *it + " "; |
220 | } | 230 | } |
221 | 231 | ||
222 | text += "\nCC: "; | 232 | text += "\nCC: "; |
223 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | 233 | for (QStringList::Iterator it = mail->carbonCopies.begin(); |
224 | it != mail->carbonCopies.end(); ++it ) { | 234 | it != mail->carbonCopies.end(); ++it ) { |
225 | text += *it + " "; | 235 | text += *it + " "; |
226 | } | 236 | } |
227 | 237 | ||
228 | 238 | ||
229 | text += "\nDate: " + mail->date + "\n"; | 239 | text += "\nDate: " + mail->date + "\n"; |
230 | if (mail->files.count() > 0) { | 240 | if (mail->files.count() > 0) { |
231 | text += "Attatchments: "; | 241 | text += "Attatchments: "; |
232 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 242 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
233 | text += ePtr->originalName + " "; | 243 | text += ePtr->originalName + " "; |
234 | } | 244 | } |
235 | text += "\n\n"; | 245 | text += "\n\n"; |
236 | } else text += "\n"; | 246 | } else text += "\n"; |
237 | 247 | ||
238 | if (!inbox) { | 248 | if (!inbox) { |
239 | text += mail->body; | 249 | text += mail->body; |
240 | } else if (mail->downloaded) { | 250 | } else if (mail->downloaded) { |
241 | text += mail->bodyPlain; | 251 | text += mail->bodyPlain; |
242 | } else { | 252 | } else { |
243 | text += "\nAwaiting download\n"; | 253 | text += "\nAwaiting download\n"; |
244 | text += "Size of mail: " + mailStringSize; | 254 | text += "Size of mail: " + mailStringSize; |
245 | } | 255 | } |
246 | 256 | ||
247 | emailView->setText(text); | 257 | emailView->setText(text); |
248 | } | 258 | } |
249 | 259 | ||
250 | if (mail->files.count() == 0) | 260 | if (mail->files.count() == 0) |
251 | attatchmentsButton->setEnabled(FALSE); | 261 | attachmentButton->setEnabled(FALSE); |
252 | else attatchmentsButton->setEnabled(TRUE); | 262 | else attachmentButton->setEnabled(TRUE); |
253 | 263 | ||
254 | setCaption("Examining mail: " + mail->subject); | 264 | setCaption("Examining mail: " + mail->subject); |
255 | } | 265 | } |
256 | 266 | ||
257 | //update view with current EmailListItem (item) | 267 | //update view with current EmailListItem (item) |
258 | void ReadMail::update(QListView *thisView, Email *mailIn) | 268 | void ReadMail::update(QListView *thisView, Email *mailIn) |
259 | { | 269 | { |
260 | view = thisView; | 270 | view = thisView; |
261 | item = (EmailListItem *) view->selectedItem(); | 271 | item = (EmailListItem *) view->selectedItem(); |
262 | mail = mailIn; | 272 | mail = mailIn; |
263 | updateView(); | 273 | updateView(); |
264 | updateButtons(); | 274 | updateButtons(); |
265 | } | 275 | } |
266 | 276 | ||
267 | void ReadMail::mailUpdated(Email *mailIn) | 277 | void ReadMail::mailUpdated(Email *mailIn) |
268 | { | 278 | { |
269 | if (mailIn == mail) { | 279 | if (mailIn == mail) { |
270 | updateView(); | 280 | updateView(); |
271 | } else { | 281 | } else { |
272 | updateButtons(); | 282 | updateButtons(); |
273 | } | 283 | } |
274 | } | 284 | } |
275 | 285 | ||
276 | void ReadMail::close() | 286 | void ReadMail::close() |
277 | { | 287 | { |
278 | emit cancelView(); | 288 | emit cancelView(); |
279 | } | 289 | } |
280 | 290 | ||
281 | //gets next item in listview, exits if there is no next | 291 | //gets next item in listview, exits if there is no next |
282 | void ReadMail::next() | 292 | void ReadMail::next() |
283 | { | 293 | { |
284 | item = (EmailListItem *) item->nextSibling(); | 294 | item = (EmailListItem *) item->nextSibling(); |
285 | if (item != NULL) { | 295 | if (item != NULL) { |
286 | mail = item->getMail(); | 296 | mail = item->getMail(); |
287 | updateView(); | 297 | updateView(); |
288 | } | 298 | } |
289 | updateButtons(); | 299 | updateButtons(); |
290 | } | 300 | } |
291 | 301 | ||
292 | //gets previous item in listview, exits if there is no previous | 302 | //gets previous item in listview, exits if there is no previous |
293 | void ReadMail::previous() | 303 | void ReadMail::previous() |
294 | { | 304 | { |
295 | item = (EmailListItem *) item->itemAbove(); | 305 | item = (EmailListItem *) item->itemAbove(); |
296 | if (item != NULL) { | 306 | if (item != NULL) { |
297 | mail = item->getMail(); | 307 | mail = item->getMail(); |
298 | updateView(); | 308 | updateView(); |
299 | } | 309 | } |
300 | updateButtons(); | 310 | updateButtons(); |
301 | } | 311 | } |
302 | 312 | ||
303 | //deletes item, tries bringing up next or previous, exits if unsucessful | 313 | //deletes item, tries bringing up next or previous, exits if unsucessful |
304 | void ReadMail::deleteItem() | 314 | void ReadMail::deleteItem() |
305 | { | 315 | { |
306 | EmailListItem *temp = item; | 316 | EmailListItem *temp = item; |
307 | temp = (EmailListItem *) item->nextSibling();//trybelow | 317 | temp = (EmailListItem *) item->nextSibling();//trybelow |
308 | if (temp == NULL) | 318 | if (temp == NULL) |
309 | temp = (EmailListItem *) item->itemAbove(); //try above | 319 | temp = (EmailListItem *) item->itemAbove(); //try above |
310 | 320 | ||
311 | emit removeItem(item, inbox); | 321 | emit removeItem(item, inbox); |
312 | 322 | ||
313 | item = temp; | 323 | item = temp; |
314 | if (item != NULL) { //more items in list | 324 | if (item != NULL) { //more items in list |
315 | mail = item->getMail(); | 325 | mail = item->getMail(); |
316 | updateView(); | 326 | updateView(); |
317 | updateButtons(); | 327 | updateButtons(); |
318 | } else close(); //no more items to see | 328 | } else close(); //no more items to see |
319 | } | 329 | } |
320 | 330 | ||
321 | void ReadMail::updateButtons() | 331 | void ReadMail::updateButtons() |
322 | { | 332 | { |
323 | EmailListItem *temp; | 333 | EmailListItem *temp; |
324 | 334 | ||
325 | temp = item; | 335 | temp = item; |
326 | if ((EmailListItem *) temp->nextSibling() == NULL) | 336 | if ((EmailListItem *) temp->nextSibling() == NULL) |
327 | nextButton->setEnabled(FALSE); | 337 | nextButton->setEnabled(FALSE); |
328 | else nextButton->setEnabled(TRUE); | 338 | else nextButton->setEnabled(TRUE); |
329 | 339 | ||
330 | temp = item; | 340 | temp = item; |
331 | if ((EmailListItem *) temp->itemAbove() == NULL) | 341 | if ((EmailListItem *) temp->itemAbove() == NULL) |
332 | previousButton->setEnabled(FALSE); | 342 | previousButton->setEnabled(FALSE); |
333 | else previousButton->setEnabled(TRUE); | 343 | else previousButton->setEnabled(TRUE); |
334 | } | 344 | } |
335 | 345 | ||
336 | void ReadMail::shiftText() | 346 | void ReadMail::shiftText() |
337 | { | 347 | { |
338 | plainTxt = ! plainTxt; | 348 | plainTxt = ! plainTxt; |
339 | updateView(); | 349 | updateView(); |
340 | } | 350 | } |
341 | 351 | ||
342 | void ReadMail::viewAttatchments() | 352 | void ReadMail::viewAttachments() |
343 | { | 353 | { |
344 | viewAtt->update(mail, inbox); | 354 | viewAtt->update(mail, inbox); |
345 | viewAtt->showMaximized(); | 355 | viewAtt->showMaximized(); |
346 | } | 356 | } |
347 | 357 | ||
348 | void ReadMail::reply() | 358 | void ReadMail::reply() |
349 | { | 359 | { |
350 | emit replyRequested(*mail, (bool&)TRUE); | 360 | emit replyRequested(*mail, (bool&)TRUE); |
351 | } | 361 | } |
352 | 362 | ||
353 | void ReadMail::forward() | 363 | void ReadMail::forward() |
354 | { | 364 | { |
355 | emit forwardRequested(*mail); | 365 | emit forwardRequested(*mail); |
356 | } | 366 | } |
357 | 367 | ||
diff --git a/noncore/net/mailit/readmail.h b/noncore/net/mailit/readmail.h index 0fe0646..df32c34 100644 --- a/noncore/net/mailit/readmail.h +++ b/noncore/net/mailit/readmail.h | |||
@@ -1,89 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef READMAIL_H | 20 | #ifndef READMAIL_H |
21 | #define READMAIL_H | 21 | #define READMAIL_H |
22 | 22 | ||
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtextview.h> | 30 | #include <qtextview.h> |
31 | 31 | ||
32 | #include "emailhandler.h" | 32 | #include "emailhandler.h" |
33 | #include "emaillistitem.h" | 33 | #include "emaillistitem.h" |
34 | #include "viewatt.h" | 34 | #include "viewatt.h" |
35 | 35 | ||
36 | class ReadMail : public QMainWindow | 36 | class ReadMail : public QMainWindow |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~ReadMail(); | 42 | ~ReadMail(); |
43 | void update(QListView *thisView, Email *mailIn); | 43 | void update(QListView *thisView, Email *mailIn); |
44 | void updateView(); | 44 | void updateView(); |
45 | void mailUpdated(Email *mailIn); | 45 | void mailUpdated(Email *mailIn); |
46 | 46 | ||
47 | signals: | 47 | signals: |
48 | void cancelView(); | 48 | void cancelView(); |
49 | void replyRequested(Email &, bool &); | 49 | void replyRequested(Email &, bool &); |
50 | void forwardRequested(Email&); | 50 | void forwardRequested(Email&); |
51 | void removeItem(EmailListItem *, bool &); | 51 | void removeItem(EmailListItem *, bool &); |
52 | void viewingMail(Email *); | 52 | void viewingMail(Email *); |
53 | 53 | ||
54 | public slots: | 54 | public slots: |
55 | void close(); | 55 | void close(); |
56 | void next(); | 56 | void next(); |
57 | void previous(); | 57 | void previous(); |
58 | void deleteItem(); | 58 | void deleteItem(); |
59 | void shiftText(); | 59 | void shiftText(); |
60 | void viewAttatchments(); | 60 | void viewAttachments(); |
61 | void reply(); | 61 | void reply(); |
62 | void forward(); | 62 | void forward(); |
63 | 63 | ||
64 | private: | 64 | private: |
65 | void init(); | 65 | void init(); |
66 | void updateButtons(); | 66 | void updateButtons(); |
67 | 67 | ||
68 | private: | 68 | private: |
69 | QListView *view; | 69 | QListView *view; |
70 | EmailListItem *item; | 70 | EmailListItem *item; |
71 | bool plainTxt, inbox; | 71 | bool plainTxt, inbox; |
72 | Email *mail; | 72 | Email *mail; |
73 | ViewAtt *viewAtt; | 73 | ViewAtt *viewAtt; |
74 | 74 | ||
75 | QToolBar *bar; | 75 | QToolBar *bar; |
76 | QMenuBar *menu; | 76 | QMenuBar *menu; |
77 | QPopupMenu *viewMenu, *mailMenu; | 77 | QPopupMenu *viewMenu, *mailMenu; |
78 | QAction *deleteButton; | 78 | QAction *deleteButton; |
79 | QMimeSourceFactory *mime; | 79 | QMimeSourceFactory *mime; |
80 | QAction *plainTextButton; | 80 | QAction *plainTextButton; |
81 | QAction *nextButton; | 81 | QAction *nextButton; |
82 | QTextView *emailView; | 82 | QTextView *emailView; |
83 | QAction *attatchmentsButton; | 83 | QAction *attachmentButton; |
84 | QAction *previousButton; | 84 | QAction *previousButton; |
85 | QAction *replyButton; | 85 | QAction *replyButton; |
86 | QAction *forwardButton; | 86 | QAction *forwardButton; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #endif // READMAIL_H | 89 | #endif // READMAIL_H |
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp index b2e38e5..8a51a5b 100644 --- a/noncore/net/mailit/smtpclient.cpp +++ b/noncore/net/mailit/smtpclient.cpp | |||
@@ -1,171 +1,163 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "smtpclient.h" | 20 | #include "smtpclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | 22 | ||
23 | SmtpClient::SmtpClient() | 23 | SmtpClient::SmtpClient() |
24 | { | 24 | { |
25 | socket = new QSocket(this, "smtpClient"); | 25 | socket = new QSocket(this, "smtpClient"); |
26 | stream = new QTextStream(socket); | 26 | stream = new QTextStream(socket); |
27 | mailList.setAutoDelete(TRUE); | 27 | mailList.setAutoDelete(TRUE); |
28 | 28 | ||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus(tr("Connection established")); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | //qDebug(response); | ||
91 | 90 | ||
92 | switch(status) { | 91 | switch(status) { |
93 | case Init: { | 92 | case Init: { |
94 | if (response[0] == '2') { | 93 | if (response[0] == '2') { |
95 | status = From; | 94 | status = From; |
96 | mailPtr = mailList.first(); | 95 | mailPtr = mailList.first(); |
97 | *stream << "HELO there\r\n"; | 96 | *stream << "HELO there\r\n"; |
98 | //qDebug("HELO"); | ||
99 | } else errorHandling(ErrUnknownResponse); | 97 | } else errorHandling(ErrUnknownResponse); |
100 | break; | 98 | break; |
101 | } | 99 | } |
102 | case From: { | 100 | case From: { |
103 | if (response[0] == '2') { | 101 | if (response[0] == '2') { |
104 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; | 102 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; |
105 | status = Recv; | 103 | status = Recv; |
106 | //qDebug("MAIL FROM: "+mailPtr->from); | ||
107 | } else errorHandling(ErrUnknownResponse); | 104 | } else errorHandling(ErrUnknownResponse); |
108 | break; | 105 | break; |
109 | } | 106 | } |
110 | case Recv: { | 107 | case Recv: { |
111 | if (response[0] == '2') { | 108 | if (response[0] == '2') { |
112 | it = mailPtr->to.begin(); | 109 | it = mailPtr->to.begin(); |
113 | if (it == NULL) | 110 | if (it == NULL) |
114 | errorHandling(ErrUnknownResponse); | 111 | errorHandling(ErrUnknownResponse); |
115 | *stream << "RCPT TO: " << *it << ">\r\n"; | 112 | *stream << "RCPT TO: " << *it << ">\r\n"; |
116 | //qDebug("RCPT TO: "+ *it); | ||
117 | status = MRcv; | 113 | status = MRcv; |
118 | } else errorHandling(ErrUnknownResponse); | 114 | } else errorHandling(ErrUnknownResponse); |
119 | break; | 115 | break; |
120 | } | 116 | } |
121 | case MRcv: { | 117 | case MRcv: { |
122 | if (response[0] == '2') { | 118 | if (response[0] == '2') { |
123 | it++; | 119 | it++; |
124 | if ( it != mailPtr->to.end() ) { | 120 | if ( it != mailPtr->to.end() ) { |
125 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 121 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
126 | //qDebug("RCPT TO: "+ *it); | ||
127 | break; | 122 | break; |
128 | } else { | 123 | } else { |
129 | status = Data; | 124 | status = Data; |
130 | } | 125 | } |
131 | } else errorHandling(ErrUnknownResponse); | 126 | } else errorHandling(ErrUnknownResponse); |
132 | } | 127 | } |
133 | case Data: { | 128 | case Data: { |
134 | if (response[0] == '2') { | 129 | if (response[0] == '2') { |
135 | *stream << "DATA\r\n"; | 130 | *stream << "DATA\r\n"; |
136 | status = Body; | 131 | status = Body; |
137 | //qDebug("DATA"); | ||
138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); | 132 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
139 | } else errorHandling(ErrUnknownResponse); | 133 | } else errorHandling(ErrUnknownResponse); |
140 | break; | 134 | break; |
141 | } | 135 | } |
142 | case Body: { | 136 | case Body: { |
143 | if (response[0] == '3') { | 137 | if (response[0] == '3') { |
144 | *stream << mailPtr->body << "\r\n.\r\n"; | 138 | *stream << mailPtr->body << "\r\n.\r\n"; |
145 | mailPtr = mailList.next(); | 139 | mailPtr = mailList.next(); |
146 | if (mailPtr != NULL) { | 140 | if (mailPtr != NULL) { |
147 | status = From; | 141 | status = From; |
148 | } else { | 142 | } else { |
149 | status = Quit; | 143 | status = Quit; |
150 | } | 144 | } |
151 | //qDebug("BODY"); | ||
152 | } else errorHandling(ErrUnknownResponse); | 145 | } else errorHandling(ErrUnknownResponse); |
153 | break; | 146 | break; |
154 | } | 147 | } |
155 | case Quit: { | 148 | case Quit: { |
156 | if (response[0] == '2') { | 149 | if (response[0] == '2') { |
157 | *stream << "QUIT\r\n"; | 150 | *stream << "QUIT\r\n"; |
158 | status = Done; | 151 | status = Done; |
159 | QString temp; | 152 | QString temp; |
160 | temp.setNum(mailList.count()); | 153 | temp.setNum(mailList.count()); |
161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); | 154 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
162 | emit mailSent(); | 155 | emit mailSent(); |
163 | mailList.clear(); | 156 | mailList.clear(); |
164 | sending = FALSE; | 157 | sending = FALSE; |
165 | socket->close(); | 158 | socket->close(); |
166 | //qDebug("QUIT"); | ||
167 | } else errorHandling(ErrUnknownResponse); | 159 | } else errorHandling(ErrUnknownResponse); |
168 | break; | 160 | break; |
169 | } | 161 | } |
170 | } | 162 | } |
171 | } | 163 | } |
diff --git a/noncore/net/mailit/textparser.cpp b/noncore/net/mailit/textparser.cpp index f082417..3fa5f6e 100644 --- a/noncore/net/mailit/textparser.cpp +++ b/noncore/net/mailit/textparser.cpp | |||
@@ -1,294 +1,304 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "textparser.h" | 20 | #include "textparser.h" |
21 | 21 | ||
22 | TextParser::TextParser(QString in, QString lineBreak) | 22 | TextParser::TextParser(QString in, QString lineBreak) |
23 | { | 23 | { |
24 | data = in; | 24 | data = in; |
25 | lineSep = lineBreak; | 25 | lineSep = lineBreak; |
26 | 26 | ||
27 | init(); | 27 | init(); |
28 | createSeparators(); | 28 | createSeparators(); |
29 | split(); | 29 | split(); |
30 | } | 30 | } |
31 | 31 | ||
32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) | 32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) |
33 | { | 33 | { |
34 | data = in; | 34 | data = in; |
35 | lineSep = lineBreak; | 35 | lineSep = lineBreak; |
36 | 36 | ||
37 | init(); | 37 | init(); |
38 | separators = sep; | 38 | separators = sep; |
39 | split(); | 39 | split(); |
40 | } | 40 | } |
41 | 41 | ||
42 | void TextParser::init() | 42 | void TextParser::init() |
43 | { | 43 | { |
44 | lineCount = 0; | 44 | lineCount = 0; |
45 | linePos = 0; | 45 | linePos = 0; |
46 | totalElmCount = 0; | 46 | totalElmCount = 0; |
47 | separatorPos = -1; //not initialized | 47 | separatorPos = -1; //not initialized |
48 | wordPos = -1; //not initialized | 48 | wordPos = -1; //not initialized |
49 | sepAtLine = 0; | 49 | sepAtLine = 0; |
50 | sepAtPosElm = -1; //such that nextSep equals 0 | 50 | sepAtPosElm = -1; //such that nextSep equals 0 |
51 | wordAtLine = 0; | 51 | wordAtLine = 0; |
52 | wordAtPosElm = -1; //such that nextWord equals 0 | 52 | wordAtPosElm = -1; //such that nextWord equals 0 |
53 | atLine = 0; | 53 | atLine = 0; |
54 | atPosElm = 0; | 54 | atPosElm = 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | void TextParser::createSeparators() | 57 | void TextParser::createSeparators() |
58 | { | 58 | { |
59 | separators = " @#,.:;<>*/(){}|'?-+=_"; | 59 | separators = " @#,.:;<>*/(){}|'?-+=_"; |
60 | } | 60 | } |
61 | 61 | ||
62 | /*Returns pos of given search criteria, -1 if not found */ | 62 | /*Returns pos of given search criteria, -1 if not found */ |
63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) | 63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) |
64 | { | 64 | { |
65 | |||
66 | t_splitElm parsstr; | ||
67 | QString pString; | ||
68 | |||
65 | int atLine = 0, atPosElm = 0; | 69 | int atLine = 0, atPosElm = 0; |
66 | 70 | ||
67 | for (int x = 0; x < totalElmCount; x++) { | 71 | getLineReference(pos,&atLine,&atPosElm); |
68 | if (x >= pos) { | 72 | |
69 | if (upperCase) { | 73 | for (int x = pos; x < totalElmCount; x++) |
70 | if ((splitDone[atLine].elm[atPosElm].str.upper() == target) && | 74 | { |
71 | (splitDone[atLine].elm[atPosElm].separator == sep)) | 75 | parsstr=splitDone[atLine].elm[atPosElm++]; |
72 | return x; | 76 | |
73 | } else { | 77 | if (upperCase) |
74 | if ((splitDone[atLine].elm[atPosElm].str == target) && | 78 | { |
75 | (splitDone[atLine].elm[atPosElm].separator == sep)) | 79 | pString=parsstr.str.upper(); |
76 | return x; | 80 | target=target.upper(); |
77 | } | 81 | } |
78 | } | 82 | else |
79 | atPosElm++; | 83 | { |
80 | if (atPosElm >= splitDone[atLine].elmCount) { //new Line | 84 | pString=parsstr.str; |
85 | } | ||
86 | if ((pString == target) && (parsstr.separator == sep)) | ||
87 | { | ||
88 | return x; | ||
89 | } | ||
90 | if (atPosElm >= splitDone[atLine].elmCount) | ||
91 | { //new Line | ||
81 | atLine++; | 92 | atLine++; |
82 | atPosElm = 0; | 93 | atPosElm = 0; |
83 | } | 94 | } |
84 | } | 95 | } |
85 | |||
86 | return -1; | 96 | return -1; |
87 | } | 97 | } |
88 | 98 | ||
89 | int TextParser::elmCount() | 99 | int TextParser::elmCount() |
90 | { | 100 | { |
91 | return totalElmCount; | 101 | return totalElmCount; |
92 | } | 102 | } |
93 | 103 | ||
94 | QChar TextParser::separatorAt(int pos) | 104 | QChar TextParser::separatorAt(int pos) |
95 | { | 105 | { |
96 | if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) | 106 | if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) |
97 | return QChar::null; | 107 | return QChar::null; |
98 | 108 | ||
99 | separatorPos = pos; | 109 | separatorPos = pos; |
100 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; | 110 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; |
101 | } | 111 | } |
102 | 112 | ||
103 | QChar TextParser::nextSeparator() | 113 | QChar TextParser::nextSeparator() |
104 | { | 114 | { |
105 | sepAtPosElm++; | 115 | sepAtPosElm++; |
106 | if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { | 116 | if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { |
107 | sepAtLine++; | 117 | sepAtLine++; |
108 | sepAtPosElm = 0; | 118 | sepAtPosElm = 0; |
109 | } | 119 | } |
110 | 120 | ||
111 | separatorPos++; | 121 | separatorPos++; |
112 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; | 122 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; |
113 | } | 123 | } |
114 | 124 | ||
115 | bool TextParser::hasNextSeparator() | 125 | bool TextParser::hasNextSeparator() |
116 | { | 126 | { |
117 | return ((separatorPos+1) < totalElmCount); | 127 | return ((separatorPos+1) < totalElmCount); |
118 | } | 128 | } |
119 | 129 | ||
120 | QString TextParser::wordAt(int pos) | 130 | QString TextParser::wordAt(int pos) |
121 | { | 131 | { |
122 | if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) | 132 | if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) |
123 | return NULL; | 133 | return NULL; |
124 | 134 | ||
125 | wordPos = pos; | 135 | wordPos = pos; |
126 | return splitDone[wordAtLine].elm[wordAtPosElm].str; | 136 | return splitDone[wordAtLine].elm[wordAtPosElm].str; |
127 | } | 137 | } |
128 | 138 | ||
129 | QString TextParser::nextWord() | 139 | QString TextParser::nextWord() |
130 | { | 140 | { |
131 | wordAtPosElm++; | 141 | wordAtPosElm++; |
132 | if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { | 142 | if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { |
133 | wordAtLine++; | 143 | wordAtLine++; |
134 | wordAtPosElm = 0; | 144 | wordAtPosElm = 0; |
135 | } | 145 | } |
136 | 146 | ||
137 | wordPos++; | 147 | wordPos++; |
138 | return splitDone[wordAtLine].elm[wordAtPosElm].str; | 148 | return splitDone[wordAtLine].elm[wordAtPosElm].str; |
139 | } | 149 | } |
140 | 150 | ||
141 | bool TextParser::hasNextWord() | 151 | bool TextParser::hasNextWord() |
142 | { | 152 | { |
143 | return ((wordPos + 1) < totalElmCount); | 153 | return ((wordPos + 1) < totalElmCount); |
144 | } | 154 | } |
145 | 155 | ||
146 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) | 156 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) |
147 | { | 157 | { |
148 | QString returnStr = wordAt(*pos); | 158 | QString returnStr = wordAt(*pos); |
149 | QChar chr = separatorAt(*pos); | 159 | QChar chr = separatorAt(*pos); |
150 | QString s; | 160 | QString s; |
151 | 161 | ||
152 | if (returnStr == "") | 162 | if (returnStr == "") |
153 | return ""; | 163 | return ""; |
154 | if (chr == stop) | 164 | if (chr == stop) |
155 | return returnStr; | 165 | return returnStr; |
156 | 166 | ||
157 | if (!lineEnd) { | 167 | if (!lineEnd) { |
158 | while ((chr != stop) && hasNextWord()) { | 168 | while ((chr != stop) && hasNextWord()) { |
159 | returnStr.append(chr); | 169 | returnStr.append(chr); |
160 | returnStr += nextWord(); | 170 | returnStr += nextWord(); |
161 | chr = nextSeparator(); | 171 | chr = nextSeparator(); |
162 | } | 172 | } |
163 | } else { //copy from pos to end of line | 173 | } else { //copy from pos to end of line |
164 | getLineReference(*pos, &atLine, &atPosElm); | 174 | getLineReference(*pos, &atLine, &atPosElm); |
165 | returnStr = ""; | 175 | returnStr = ""; |
166 | while (atPosElm < splitDone[atLine].elmCount) { | 176 | while (atPosElm < splitDone[atLine].elmCount) { |
167 | if (splitDone[atLine].elm[atPosElm].str != "") { | 177 | if (splitDone[atLine].elm[atPosElm].str != "") { |
168 | returnStr += splitDone[atLine].elm[atPosElm].str; | 178 | returnStr += splitDone[atLine].elm[atPosElm].str; |
169 | } | 179 | } |
170 | chr = splitDone[atLine].elm[atPosElm].separator; | 180 | chr = splitDone[atLine].elm[atPosElm].separator; |
171 | if (!chr.isNull() && (int) chr != 0) { | 181 | if (!chr.isNull() && (int) chr != 0) { |
172 | returnStr.append(splitDone[atLine].elm[atPosElm].separator); | 182 | returnStr.append(splitDone[atLine].elm[atPosElm].separator); |
173 | } | 183 | } |
174 | atPosElm++; | 184 | atPosElm++; |
175 | } | 185 | } |
176 | } | 186 | } |
177 | 187 | ||
178 | *pos = wordPos; | 188 | *pos = wordPos; |
179 | return returnStr; | 189 | return returnStr; |
180 | } | 190 | } |
181 | 191 | ||
182 | QString TextParser::getNextLine() | 192 | QString TextParser::getNextLine() |
183 | { | 193 | { |
184 | atLine++; | 194 | atLine++; |
185 | atPosElm = 0; | 195 | atPosElm = 0; |
186 | if (atLine < lineCount) | 196 | if (atLine < lineCount) |
187 | return splitDone[atLine].str; | 197 | return splitDone[atLine].str; |
188 | return ""; | 198 | return ""; |
189 | } | 199 | } |
190 | 200 | ||
191 | bool TextParser::hasNextLine() | 201 | bool TextParser::hasNextLine() |
192 | { | 202 | { |
193 | if (atLine+1 < lineCount) | 203 | if (atLine+1 < lineCount) |
194 | return TRUE;; | 204 | return TRUE;; |
195 | return FALSE; | 205 | return FALSE; |
196 | } | 206 | } |
197 | 207 | ||
198 | int TextParser::endLinePos(int pos) | 208 | int TextParser::endLinePos(int pos) |
199 | { | 209 | { |
200 | if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) | 210 | if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) |
201 | return -1; | 211 | return -1; |
202 | 212 | ||
203 | return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); | 213 | return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); |
204 | } | 214 | } |
205 | 215 | ||
206 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) | 216 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) |
207 | { | 217 | { |
208 | int currentPos = 0; | 218 | int currentPos = 0; |
209 | 219 | ||
210 | for (int x = 0; x < lineCount; x++) { | 220 | for (int x = 0; x < lineCount; x++) { |
211 | if ( currentPos + splitDone[x].elmCount > pos) { | 221 | if ( currentPos + splitDone[x].elmCount > pos) { |
212 | *line = x; | 222 | *line = x; |
213 | *inLinePos = pos - currentPos; | 223 | *inLinePos = pos - currentPos; |
214 | return 0; //pos found okay | 224 | return 0; //pos found okay |
215 | } | 225 | } |
216 | currentPos += splitDone[x].elmCount; | 226 | currentPos += splitDone[x].elmCount; |
217 | } | 227 | } |
218 | return -1; //no reference found | 228 | return -1; //no reference found |
219 | } | 229 | } |
220 | 230 | ||
221 | void TextParser::split() | 231 | void TextParser::split() |
222 | { | 232 | { |
223 | t_splitLine newLine; | 233 | t_splitLine newLine; |
224 | 234 | ||
225 | while ((uint) linePos < data.length()) { | 235 | while ((uint) linePos < data.length()) { |
226 | newLine = nextLine(); | 236 | newLine = nextLine(); |
227 | splitDone[lineCount] = splitLine(newLine); | 237 | splitDone[lineCount] = splitLine(newLine); |
228 | totalElmCount += splitDone[lineCount].elmCount; | 238 | totalElmCount += splitDone[lineCount].elmCount; |
229 | lineCount++; | 239 | lineCount++; |
230 | } | 240 | } |
231 | } | 241 | } |
232 | 242 | ||
233 | t_splitLine TextParser::splitLine(t_splitLine line) | 243 | t_splitLine TextParser::splitLine(t_splitLine line) |
234 | { | 244 | { |
235 | uint pos = 0; | 245 | uint pos = 0; |
236 | uint elmCount = 0; | 246 | uint elmCount = 0; |
237 | t_splitLine tempLine = line; | 247 | t_splitLine tempLine = line; |
238 | 248 | ||
239 | tempLine.str = line.str.simplifyWhiteSpace(); | 249 | tempLine.str = line.str.simplifyWhiteSpace(); |
240 | tempLine.elm[0].str = ""; | 250 | tempLine.elm[0].str = ""; |
241 | while ( pos < line.str.length() ) { | 251 | while ( pos < line.str.length() ) { |
242 | if ( isSeparator(tempLine.str[pos]) ) { | 252 | if ( isSeparator(tempLine.str[pos]) ) { |
243 | tempLine.elm[elmCount].separator = tempLine.str[pos]; | 253 | tempLine.elm[elmCount].separator = tempLine.str[pos]; |
244 | elmCount++; | 254 | elmCount++; |
245 | pos++; | 255 | pos++; |
246 | while (tempLine.str[pos] == ' ') | 256 | while (tempLine.str[pos] == ' ') |
247 | pos++; | 257 | pos++; |
248 | if (pos > line.str.length()) | 258 | if (pos > line.str.length()) |
249 | elmCount--; | 259 | elmCount--; |
250 | tempLine.elm[elmCount].str = ""; | 260 | tempLine.elm[elmCount].str = ""; |
251 | } else { | 261 | } else { |
252 | if (!tempLine.str[pos].isNull()) | 262 | if (!tempLine.str[pos].isNull()) |
253 | tempLine.elm[elmCount].str += tempLine.str[pos]; | 263 | tempLine.elm[elmCount].str += tempLine.str[pos]; |
254 | pos++; | 264 | pos++; |
255 | } | 265 | } |
256 | } | 266 | } |
257 | 267 | ||
258 | tempLine.elmCount = elmCount + 1; | 268 | tempLine.elmCount = elmCount + 1; |
259 | return tempLine; | 269 | return tempLine; |
260 | } | 270 | } |
261 | 271 | ||
262 | bool TextParser::isSeparator(QChar chr) | 272 | bool TextParser::isSeparator(QChar chr) |
263 | { | 273 | { |
264 | for (uint x = 0; x < separators.length(); x++) { | 274 | for (uint x = 0; x < separators.length(); x++) { |
265 | if (chr == separators[x]) | 275 | if (chr == separators[x]) |
266 | return true; | 276 | return true; |
267 | } | 277 | } |
268 | return false; | 278 | return false; |
269 | } | 279 | } |
270 | 280 | ||
271 | t_splitLine TextParser::nextLine() | 281 | t_splitLine TextParser::nextLine() |
272 | { | 282 | { |
273 | int newLinePos; | 283 | int newLinePos; |
274 | t_splitLine lineType; | 284 | t_splitLine lineType; |
275 | 285 | ||
276 | newLinePos = data.find(lineSep, linePos); | 286 | newLinePos = data.find(lineSep, linePos); |
277 | 287 | ||
278 | lineType.lineType = NewLine; | 288 | lineType.lineType = NewLine; |
279 | lineType.str = ""; | 289 | lineType.str = ""; |
280 | 290 | ||
281 | if (newLinePos == -1) { | 291 | if (newLinePos == -1) { |
282 | newLinePos = data.length(); | 292 | newLinePos = data.length(); |
283 | lineType.lineType = LastLine; | 293 | lineType.lineType = LastLine; |
284 | } | 294 | } |
285 | 295 | ||
286 | for (int x = linePos; x < newLinePos; x++) | 296 | for (int x = linePos; x < newLinePos; x++) |
287 | lineType.str += data[x]; | 297 | lineType.str += data[x]; |
288 | 298 | ||
289 | linePos = newLinePos; | 299 | linePos = newLinePos; |
290 | if ((uint) linePos < data.length()) //if not EOF, add length of lineSep | 300 | if ((uint) linePos < data.length()) //if not EOF, add length of lineSep |
291 | linePos += lineSep.length(); | 301 | linePos += lineSep.length(); |
292 | 302 | ||
293 | return lineType; | 303 | return lineType; |
294 | } | 304 | } |
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp index b6f5015..21885c2 100644 --- a/noncore/net/mailit/viewatt.cpp +++ b/noncore/net/mailit/viewatt.cpp | |||
@@ -1,118 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "resource.h" | 20 | #include "resource.h" |
21 | #include "viewatt.h" | 21 | #include "viewatt.h" |
22 | #include <qwhatsthis.h> | ||
22 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
23 | #include <qpe/mimetype.h> | 24 | #include <qpe/mimetype.h> |
24 | 25 | ||
25 | ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) | 26 | ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) |
26 | : QMainWindow(parent, name, f) | 27 | : QMainWindow(parent, name, f) |
27 | { | 28 | { |
28 | setCaption("Exploring attatchments"); | 29 | setCaption("Exploring attatchments"); |
29 | 30 | ||
30 | setToolBarsMovable( FALSE ); | 31 | setToolBarsMovable( FALSE ); |
31 | bar = new QToolBar(this); | 32 | bar = new QToolBar(this); |
32 | installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); | 33 | installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); |
33 | connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); | 34 | connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); |
35 | installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); | ||
34 | 36 | ||
35 | listView = new QListView(this, "AttView"); | 37 | listView = new QListView(this, "AttView"); |
36 | listView->addColumn( "Attatchment" ); | 38 | listView->addColumn( "Attatchment" ); |
37 | listView->addColumn( "Type" ); | 39 | listView->addColumn( "Type" ); |
38 | listView->addColumn( "Installed" ); | 40 | listView->addColumn( "Installed" ); |
39 | setCentralWidget(listView); | 41 | setCentralWidget(listView); |
42 | QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | void ViewAtt::update(Email *mailIn, bool inbox) | 45 | void ViewAtt::update(Email *mailIn, bool inbox) |
43 | { | 46 | { |
44 | QListViewItem *item; | 47 | QListViewItem *item; |
45 | Enclosure *ePtr; | 48 | Enclosure *ePtr; |
46 | 49 | ||
47 | 50 | ||
48 | 51 | ||
49 | listView->clear(); | 52 | listView->clear(); |
50 | if (inbox) { | 53 | if (inbox) { |
51 | bar->clear(); | 54 | bar->clear(); |
52 | installButton->addTo( bar ); | 55 | installButton->addTo( bar ); |
53 | bar->show(); | 56 | bar->show(); |
54 | } else { | 57 | } else { |
55 | bar->hide(); | 58 | bar->hide(); |
56 | } | 59 | } |
57 | 60 | ||
58 | mail = mailIn; | 61 | mail = mailIn; |
59 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 62 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
60 | 63 | ||
61 | QString isInstalled = "No"; | 64 | QString isInstalled = "No"; |
62 | if (ePtr->installed) | 65 | if (ePtr->installed) |
63 | isInstalled = "Yes"; | 66 | isInstalled = "Yes"; |
64 | item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); | 67 | item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); |
65 | 68 | ||
66 | const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; | 69 | const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; |
67 | 70 | ||
68 | MimeType mt(mtypeDef); | 71 | MimeType mt(mtypeDef); |
69 | 72 | ||
70 | item->setPixmap(0, mt.pixmap()); | 73 | item->setPixmap(0, mt.pixmap()); |
71 | 74 | ||
72 | /* | 75 | /* |
73 | if (ePtr->contentType == "TEXT") { | 76 | if (ePtr->contentType == "TEXT") { |
74 | actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); | 77 | actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); |
75 | actions->addTo(bar); | 78 | actions->addTo(bar); |
76 | } | 79 | } |
77 | if (ePtr->contentType == "AUDIO") { | 80 | if (ePtr->contentType == "AUDIO") { |
78 | actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); | 81 | actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); |
79 | actions->addTo(bar); | 82 | actions->addTo(bar); |
80 | item->setPixmap(0, Resource::loadPixmap("play")); | 83 | item->setPixmap(0, Resource::loadPixmap("play")); |
81 | } | 84 | } |
82 | if (ePtr->contentType == "IMAGE") { | 85 | if (ePtr->contentType == "IMAGE") { |
83 | actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); | 86 | actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); |
84 | actions->addTo(bar); | 87 | actions->addTo(bar); |
85 | item->setPixmap(0, Resource::loadPixmap("pixmap")); | 88 | item->setPixmap(0, Resource::loadPixmap("pixmap")); |
86 | }*/ | 89 | }*/ |
87 | } | 90 | } |
88 | } | 91 | } |
89 | 92 | ||
90 | void ViewAtt::install() | 93 | void ViewAtt::install() |
91 | { | 94 | { |
92 | Enclosure *ePtr, *selPtr; | 95 | Enclosure *ePtr, *selPtr; |
93 | QListViewItem *item; | 96 | QListViewItem *item; |
94 | QString filename; | 97 | QString filename; |
95 | DocLnk d; | 98 | DocLnk d; |
96 | 99 | ||
97 | item = listView->selectedItem(); | 100 | item = listView->selectedItem(); |
98 | if (item != NULL) { | 101 | if (item != NULL) { |
99 | filename = item->text(0); | 102 | filename = item->text(0); |
100 | selPtr = NULL; | 103 | selPtr = NULL; |
101 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 104 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
102 | if (ePtr->originalName == filename) | 105 | if (ePtr->originalName == filename) |
103 | selPtr = ePtr; | 106 | selPtr = ePtr; |
104 | } | 107 | } |
105 | 108 | ||
106 | if (selPtr == NULL) { | 109 | if (selPtr == NULL) { |
107 | qWarning("Internal error, file is not installed to documents"); | 110 | qWarning("Internal error, file is not installed to documents"); |
108 | return; | 111 | return; |
109 | } | 112 | } |
110 | 113 | ||
111 | d.setName(selPtr->originalName); | 114 | d.setName(selPtr->originalName); |
112 | d.setFile(selPtr->path + selPtr->name); | 115 | d.setFile(selPtr->path + selPtr->name); |
113 | d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); | 116 | d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); |
114 | d.writeLink(); | 117 | d.writeLink(); |
115 | selPtr->installed = TRUE; | 118 | selPtr->installed = TRUE; |
116 | item->setText(2, "Yes"); | 119 | item->setText(2, "Yes"); |
117 | } | 120 | } |
118 | } | 121 | } |
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index a9dcb02..0336c83 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp | |||
@@ -1,373 +1,381 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qwhatsthis.h> | ||
21 | #include "writemail.h" | 22 | #include "writemail.h" |
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | 24 | ||
24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) | 25 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) |
25 | : QMainWindow( parent, name, fl ) | 26 | : QMainWindow( parent, name, fl ) |
26 | { | 27 | { |
27 | showingAddressList = FALSE; | 28 | showingAddressList = FALSE; |
28 | init(); | 29 | init(); |
29 | 30 | ||
30 | addAtt = new AddAtt(0, "Add Attatchments"); | 31 | addAtt = new AddAtt(0, "Add Attachments"); |
31 | } | 32 | } |
32 | 33 | ||
33 | WriteMail::~WriteMail() | 34 | WriteMail::~WriteMail() |
34 | { | 35 | { |
35 | delete addAtt; | 36 | delete addAtt; |
36 | } | 37 | } |
37 | 38 | ||
38 | void WriteMail::setAddressList(AddressList *list) | 39 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 40 | { |
40 | Contact *cPtr; | 41 | Contact *cPtr; |
41 | 42 | ||
42 | addressList = list; | 43 | addressList = list; |
43 | 44 | ||
44 | addressView->clear(); | 45 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 46 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 47 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 48 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); | 49 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); |
49 | } | 50 | } |
50 | } | 51 | } |
51 | 52 | ||
52 | void WriteMail::init() | 53 | void WriteMail::init() |
53 | { | 54 | { |
54 | setToolBarsMovable(FALSE); | 55 | setToolBarsMovable(FALSE); |
55 | 56 | ||
56 | bar = new QToolBar(this); | 57 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 58 | bar->setHorizontalStretchable( TRUE ); |
58 | 59 | ||
59 | menu = new QMenuBar( bar ); | 60 | menu = new QMenuBar( bar ); |
60 | 61 | ||
61 | mailMenu = new QPopupMenu(menu); | 62 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 63 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 64 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 65 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 66 | ||
66 | bar = new QToolBar(this); | 67 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); | 68 | attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 69 | attachButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 70 | attachButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 71 | connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); |
71 | 72 | attachButton->setWhatsThis(tr("Click here to attach files to your mail")); | |
73 | |||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 74 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 75 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 76 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 77 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
78 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); | ||
76 | 79 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 80 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 81 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 82 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 83 | newButton->setWhatsThis(tr("Click here to create a new mail")); | |
84 | |||
81 | widget = new QWidget(this, "widget"); | 85 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 86 | grid = new QGridLayout( widget ); |
83 | 87 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 88 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 89 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 90 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 91 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 92 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | 93 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); |
90 | 94 | ||
91 | |||
92 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 95 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
93 | subjetLabel->setText( tr( "Subject:" ) ); | 96 | subjetLabel->setText( tr( "Subject:" ) ); |
94 | 97 | ||
95 | grid->addWidget( subjetLabel, 1, 0 ); | 98 | grid->addWidget( subjetLabel, 1, 0 ); |
96 | 99 | ||
97 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 100 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
98 | ToolButton13_2->setText( tr( "..." ) ); | 101 | ToolButton13_2->setText( tr( "..." ) ); |
99 | grid->addWidget( ToolButton13_2, 1, 2 ); | 102 | grid->addWidget( ToolButton13_2, 1, 2 ); |
100 | 103 | ||
101 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 104 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
102 | grid->addWidget( subjectInput, 1, 1 ); | 105 | grid->addWidget( subjectInput, 1, 1 ); |
106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); | ||
103 | 107 | ||
104 | toInput = new QLineEdit( widget, "toInput" ); | 108 | toInput = new QLineEdit( widget, "toInput" ); |
105 | grid->addWidget( toInput, 0, 1 ); | 109 | grid->addWidget( toInput, 0, 1 ); |
110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); | ||
106 | 111 | ||
107 | ccInput = new QLineEdit( widget, "ccInput" ); | 112 | ccInput = new QLineEdit( widget, "ccInput" ); |
108 | ccInput->hide(); | 113 | ccInput->hide(); |
109 | grid->addWidget( ccInput, 0, 1 ); | 114 | grid->addWidget( ccInput, 0, 1 ); |
115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); | ||
110 | 116 | ||
111 | |||
112 | addressButton = new QToolButton( widget, "addressButton" ); | 117 | addressButton = new QToolButton( widget, "addressButton" ); |
113 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
114 | addressButton->setToggleButton(TRUE); | 119 | addressButton->setToggleButton(TRUE); |
115 | grid->addWidget( addressButton, 0, 2 ); | 120 | grid->addWidget( addressButton, 0, 2 ); |
116 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); | ||
117 | 123 | ||
118 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
119 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
126 | QWhatsThis::add(recipientsBox,QWidget::tr("Enter your mail text here")); | ||
120 | 127 | ||
121 | |||
122 | addressView = new QListView( widget, "addressView"); | 128 | addressView = new QListView( widget, "addressView"); |
123 | addressView->addColumn("Name"); | 129 | addressView->addColumn("Name"); |
124 | addressView->addColumn("EMail"); | 130 | addressView->addColumn("EMail"); |
125 | addressView->setAllColumnsShowFocus(TRUE); | 131 | addressView->setAllColumnsShowFocus(TRUE); |
126 | addressView->setMultiSelection(TRUE); | 132 | addressView->setMultiSelection(TRUE); |
127 | addressView->hide(); | 133 | addressView->hide(); |
128 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
129 | 135 | QWhatsThis::add(recipientsBox,QWidget::tr("Chose the recipients from this list")); | |
136 | |||
130 | okButton = new QToolButton(bar, "ok"); | 137 | okButton = new QToolButton(bar, "ok"); |
131 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 138 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
132 | okButton->hide(); | 139 | okButton->hide(); |
133 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); | ||
134 | 142 | ||
135 | setCentralWidget(widget); | 143 | setCentralWidget(widget); |
136 | } | 144 | } |
137 | 145 | ||
138 | void WriteMail::reject() | 146 | void WriteMail::reject() |
139 | { | 147 | { |
140 | emit cancelMail(); | 148 | emit cancelMail(); |
141 | } | 149 | } |
142 | 150 | ||
143 | // need to insert date | 151 | // need to insert date |
144 | void WriteMail::accept() | 152 | void WriteMail::accept() |
145 | { | 153 | { |
146 | QStringList attatchedFiles, attatchmentsType; | 154 | QStringList attachedFiles, attachmentsType; |
147 | int idCount = 0; | 155 | int idCount = 0; |
148 | 156 | ||
149 | if (toInput->text() == "") | 157 | if (toInput->text() == "") |
150 | { | 158 | { |
151 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | 159 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); |
152 | return; | 160 | return; |
153 | } | 161 | } |
154 | 162 | ||
155 | if (! getRecipients(false) ) | 163 | if (! getRecipients(false) ) |
156 | { | 164 | { |
157 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | 165 | QMessageBox::warning(this,tr("Incorrect recipient separator"), |
158 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 166 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
159 | return; | 167 | return; |
160 | } | 168 | } |
161 | 169 | ||
162 | if ((ccInput->text()!="") && (! getRecipients(true) )) | 170 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
163 | { | 171 | { |
164 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | 172 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), |
165 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 173 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
166 | return; | 174 | return; |
167 | } | 175 | } |
168 | 176 | ||
169 | mail.subject = subjectInput->text(); | 177 | mail.subject = subjectInput->text(); |
170 | mail.body = emailInput->text(); | 178 | mail.body = emailInput->text(); |
171 | mail.sent = false; | 179 | mail.sent = false; |
172 | mail.received = false; | 180 | mail.received = false; |
173 | 181 | ||
174 | mail.rawMail = "To: "; | 182 | mail.rawMail = "To: "; |
175 | 183 | ||
176 | for (QStringList::Iterator it = mail.recipients.begin(); | 184 | for (QStringList::Iterator it = mail.recipients.begin(); |
177 | it != mail.recipients.end(); ++it) { | 185 | it != mail.recipients.end(); ++it) { |
178 | 186 | ||
179 | mail.rawMail += (*it); | 187 | mail.rawMail += (*it); |
180 | mail.rawMail += ",\n"; | 188 | mail.rawMail += ",\n"; |
181 | } | 189 | } |
182 | 190 | ||
183 | mail.rawMail.truncate(mail.rawMail.length()-2); | 191 | mail.rawMail.truncate(mail.rawMail.length()-2); |
184 | 192 | ||
185 | mail.rawMail += "\nCC: "; | 193 | mail.rawMail += "\nCC: "; |
186 | 194 | ||
187 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | 195 | for (QStringList::Iterator it = mail.carbonCopies.begin(); |
188 | it != mail.carbonCopies.end(); ++it) { | 196 | it != mail.carbonCopies.end(); ++it) { |
189 | 197 | ||
190 | mail.rawMail += (*it); | 198 | mail.rawMail += (*it); |
191 | mail.rawMail += ",\n"; | 199 | mail.rawMail += ",\n"; |
192 | } | 200 | } |
193 | 201 | ||
194 | mail.rawMail += mail.from; | 202 | mail.rawMail += mail.from; |
195 | mail.rawMail += "\nSubject: "; | 203 | mail.rawMail += "\nSubject: "; |
196 | mail.rawMail += mail.subject; | 204 | mail.rawMail += mail.subject; |
197 | mail.rawMail += "\n\n"; | 205 | mail.rawMail += "\n\n"; |
198 | 206 | ||
199 | attatchedFiles = addAtt->returnAttatchedFiles(); | 207 | attachedFiles = addAtt->returnattachedFiles(); |
200 | attatchmentsType = addAtt->returnFileTypes(); | 208 | attachmentsType = addAtt->returnFileTypes(); |
201 | 209 | ||
202 | QStringList::Iterator itType = attatchmentsType.begin(); | 210 | QStringList::Iterator itType = attachmentsType.begin(); |
203 | 211 | ||
204 | Enclosure e; | 212 | Enclosure e; |
205 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { | 213 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { |
206 | e.id = idCount; | 214 | e.id = idCount; |
207 | e.originalName = (*it).latin1(); | 215 | e.originalName = (*it).latin1(); |
208 | e.contentType = (*itType).latin1(); | 216 | e.contentType = (*itType).latin1(); |
209 | e.contentAttribute = (*itType).latin1(); | 217 | e.contentAttribute = (*itType).latin1(); |
210 | e.saved = TRUE; | 218 | e.saved = TRUE; |
211 | mail.addEnclosure(&e); | 219 | mail.addEnclosure(&e); |
212 | 220 | ||
213 | itType++; | 221 | itType++; |
214 | idCount++; | 222 | idCount++; |
215 | } | 223 | } |
216 | mail.rawMail += mail.body; | 224 | mail.rawMail += mail.body; |
217 | mail.rawMail += "\n"; | 225 | mail.rawMail += "\n"; |
218 | mail.rawMail += ".\n"; | 226 | mail.rawMail += ".\n"; |
219 | emit sendMailRequested(mail); | 227 | emit sendMailRequested(mail); |
220 | addAtt->clear(); | 228 | addAtt->clear(); |
221 | } | 229 | } |
222 | 230 | ||
223 | void WriteMail::getAddress() | 231 | void WriteMail::getAddress() |
224 | { | 232 | { |
225 | showingAddressList = !showingAddressList; | 233 | showingAddressList = !showingAddressList; |
226 | 234 | ||
227 | if (showingAddressList) { | 235 | if (showingAddressList) { |
228 | emailInput->hide(); | 236 | emailInput->hide(); |
229 | addressView->show(); | 237 | addressView->show(); |
230 | okButton->show(); | 238 | okButton->show(); |
231 | 239 | ||
232 | } else { | 240 | } else { |
233 | addressView->hide(); | 241 | addressView->hide(); |
234 | okButton->hide(); | 242 | okButton->hide(); |
235 | emailInput->show(); | 243 | emailInput->show(); |
236 | } | 244 | } |
237 | } | 245 | } |
238 | 246 | ||
239 | void WriteMail::attatchFile() | 247 | void WriteMail::attachFile() |
240 | { | 248 | { |
241 | addAtt->showMaximized(); | 249 | addAtt->showMaximized(); |
242 | } | 250 | } |
243 | 251 | ||
244 | void WriteMail::reply(Email replyMail, bool replyAll) | 252 | void WriteMail::reply(Email replyMail, bool replyAll) |
245 | { | 253 | { |
246 | int pos; | 254 | int pos; |
247 | 255 | ||
248 | mail = replyMail; | 256 | mail = replyMail; |
249 | mail.files.clear(); | 257 | mail.files.clear(); |
250 | 258 | ||
251 | toInput->setText(mail.fromMail); | 259 | toInput->setText(mail.fromMail); |
252 | //replyAll ? ccInput->setText(mail.c) | 260 | //replyAll ? ccInput->setText(mail.c) |
253 | 261 | ||
254 | addRecipients(replyAll); | 262 | addRecipients(replyAll); |
255 | 263 | ||
256 | subjectInput->setText(tr("Re: ") + mail.subject); | 264 | subjectInput->setText(tr("Re: ") + mail.subject); |
257 | 265 | ||
258 | pos = 0; | 266 | pos = 0; |
259 | mail.body.insert(pos, ">>"); | 267 | mail.body.insert(pos, ">"); |
260 | while (pos != -1) { | 268 | while (pos != -1) { |
261 | pos = mail.body.find('\n', pos); | 269 | pos = mail.body.find('\n', pos); |
262 | if (pos != -1) | 270 | if (pos != -1) |
263 | mail.body.insert(++pos, ">>"); | 271 | mail.body.insert(++pos, ">>"); |
264 | } | 272 | } |
265 | 273 | ||
266 | emailInput->setText(mail.body); | 274 | emailInput->setText(mail.body); |
267 | } | 275 | } |
268 | 276 | ||
269 | void WriteMail::forward(Email forwMail) | 277 | void WriteMail::forward(Email forwMail) |
270 | { | 278 | { |
271 | int pos=0; | 279 | int pos=0; |
272 | 280 | ||
273 | QString fwdBody=tr("======forwarded message from "); | 281 | QString fwdBody=tr("======forwarded message from "); |
274 | fwdBody.append(forwMail.fromMail); | 282 | fwdBody.append(forwMail.fromMail); |
275 | fwdBody.append(tr(" starts======\n\n")); | 283 | fwdBody.append(tr(" starts======\n\n")); |
276 | 284 | ||
277 | mail=forwMail; | 285 | mail=forwMail; |
278 | toInput->setText(""); | 286 | toInput->setText(""); |
279 | ccInput->setText(""); | 287 | ccInput->setText(""); |
280 | subjectInput->setText(tr("FWD: ") + mail.subject); | 288 | subjectInput->setText(tr("FWD: ") + mail.subject); |
281 | 289 | ||
282 | fwdBody+=mail.body; | 290 | fwdBody+=mail.body; |
283 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | 291 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); |
284 | 292 | ||
285 | emailInput->setText(fwdBody); | 293 | emailInput->setText(fwdBody); |
286 | } | 294 | } |
287 | 295 | ||
288 | bool WriteMail::getRecipients(bool ccField) | 296 | bool WriteMail::getRecipients(bool ccField) |
289 | { | 297 | { |
290 | QString str, temp; | 298 | QString str, temp; |
291 | int pos = 0; | 299 | int pos = 0; |
292 | 300 | ||
293 | mail.recipients.clear(); | 301 | mail.recipients.clear(); |
294 | 302 | ||
295 | ccField ? temp = ccInput->text() : temp=toInput->text() ; | 303 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
296 | 304 | ||
297 | while ( (pos = temp.find(';')) != -1) { | 305 | while ( (pos = temp.find(';')) != -1) { |
298 | str = temp.left(pos).stripWhiteSpace(); | 306 | str = temp.left(pos).stripWhiteSpace(); |
299 | temp = temp.right(temp.length() - (pos + 1)); | 307 | temp = temp.right(temp.length() - (pos + 1)); |
300 | if ( str.find('@') == -1) | 308 | if ( str.find('@') == -1) |
301 | return false; | 309 | return false; |
302 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); | 310 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
303 | addressList->addContact(str, ""); | 311 | addressList->addContact(str, ""); |
304 | } | 312 | } |
305 | temp = temp.stripWhiteSpace(); | 313 | temp = temp.stripWhiteSpace(); |
306 | if ( temp.find('@') == -1) | 314 | if ( temp.find('@') == -1) |
307 | return false; | 315 | return false; |
308 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); | 316 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
309 | addressList->addContact(temp, ""); | 317 | addressList->addContact(temp, ""); |
310 | 318 | ||
311 | return TRUE; | 319 | return TRUE; |
312 | } | 320 | } |
313 | 321 | ||
314 | void WriteMail::addRecipients() | 322 | void WriteMail::addRecipients() |
315 | { | 323 | { |
316 | 324 | ||
317 | addRecipients(false); | 325 | addRecipients(false); |
318 | } | 326 | } |
319 | 327 | ||
320 | void WriteMail::addRecipients(bool ccField) | 328 | void WriteMail::addRecipients(bool ccField) |
321 | { | 329 | { |
322 | QString recipients = ""; | 330 | QString recipients = ""; |
323 | 331 | ||
324 | mail.recipients.clear(); | 332 | mail.recipients.clear(); |
325 | 333 | ||
326 | QListViewItem *item = addressView->firstChild(); | 334 | QListViewItem *item = addressView->firstChild(); |
327 | while (item != NULL) { | 335 | while (item != NULL) { |
328 | if ( item->isSelected() ) { | 336 | if ( item->isSelected() ) { |
329 | if (recipients == "") { | 337 | if (recipients == "") { |
330 | recipients = item->text(0); | 338 | recipients = item->text(0); |
331 | } else { | 339 | } else { |
332 | recipients += "; " + item->text(0); | 340 | recipients += "; " + item->text(0); |
333 | } | 341 | } |
334 | } | 342 | } |
335 | item = item->nextSibling(); | 343 | item = item->nextSibling(); |
336 | } | 344 | } |
337 | 345 | ||
338 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | 346 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); |
339 | 347 | ||
340 | addressView->hide(); | 348 | addressView->hide(); |
341 | okButton->hide(); | 349 | okButton->hide(); |
342 | emailInput->show(); | 350 | emailInput->show(); |
343 | addressButton->setOn(FALSE); | 351 | addressButton->setOn(FALSE); |
344 | showingAddressList = !showingAddressList; | 352 | showingAddressList = !showingAddressList; |
345 | } | 353 | } |
346 | 354 | ||
347 | void WriteMail::changeRecipients(int selection) | 355 | void WriteMail::changeRecipients(int selection) |
348 | { | 356 | { |
349 | if (selection==0) | 357 | if (selection==0) |
350 | { | 358 | { |
351 | toInput->show(); | 359 | toInput->show(); |
352 | ccInput->hide(); | 360 | ccInput->hide(); |
353 | } | 361 | } |
354 | else if (selection==1) | 362 | else if (selection==1) |
355 | { | 363 | { |
356 | toInput->hide(); | 364 | toInput->hide(); |
357 | ccInput->show(); | 365 | ccInput->show(); |
358 | } | 366 | } |
359 | } | 367 | } |
360 | 368 | ||
361 | void WriteMail::setRecipient(const QString &recipient) | 369 | void WriteMail::setRecipient(const QString &recipient) |
362 | { | 370 | { |
363 | toInput->setText(recipient); | 371 | toInput->setText(recipient); |
364 | } | 372 | } |
365 | 373 | ||
366 | void WriteMail::newMail() | 374 | void WriteMail::newMail() |
367 | { | 375 | { |
368 | toInput->clear(); | 376 | toInput->clear(); |
369 | subjectInput->clear(); | 377 | subjectInput->clear(); |
370 | emailInput->clear(); | 378 | emailInput->clear(); |
371 | //to clear selected | 379 | //to clear selected |
372 | setAddressList(addressList); | 380 | setAddressList(addressList); |
373 | } | 381 | } |
diff --git a/noncore/net/mailit/writemail.h b/noncore/net/mailit/writemail.h index f193b13..921f27e 100644 --- a/noncore/net/mailit/writemail.h +++ b/noncore/net/mailit/writemail.h | |||
@@ -1,96 +1,96 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WRITEMAIL_H | 20 | #ifndef WRITEMAIL_H |
21 | #define WRITEMAIL_H | 21 | #define WRITEMAIL_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | 34 | ||
35 | #include "emailhandler.h" | 35 | #include "emailhandler.h" |
36 | #include "addresslist.h" | 36 | #include "addresslist.h" |
37 | #include "addatt.h" | 37 | #include "addatt.h" |
38 | 38 | ||
39 | class WriteMail : public QMainWindow | 39 | class WriteMail : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); | 44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); |
45 | ~WriteMail(); | 45 | ~WriteMail(); |
46 | void reply(Email replyMail, bool replyAll); | 46 | void reply(Email replyMail, bool replyAll); |
47 | void setRecipient(const QString &recipient); | 47 | void setRecipient(const QString &recipient); |
48 | void setAddressList(AddressList *list); | 48 | void setAddressList(AddressList *list); |
49 | void forward(Email forwMail); | 49 | void forward(Email forwMail); |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void sendMailRequested(const Email &mail); | 52 | void sendMailRequested(const Email &mail); |
53 | void cancelMail(); | 53 | void cancelMail(); |
54 | 54 | ||
55 | 55 | ||
56 | public slots: | 56 | public slots: |
57 | void getAddress(); | 57 | void getAddress(); |
58 | void attatchFile(); | 58 | void attachFile(); |
59 | void addRecipients(); | 59 | void addRecipients(); |
60 | void newMail(); | 60 | void newMail(); |
61 | void accept(); | 61 | void accept(); |
62 | void reject(); | 62 | void reject(); |
63 | void changeRecipients(int); | 63 | void changeRecipients(int); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | bool getRecipients(bool); | 66 | bool getRecipients(bool); |
67 | void init(); | 67 | void init(); |
68 | void addRecipients(bool); | 68 | void addRecipients(bool); |
69 | 69 | ||
70 | Email mail; | 70 | Email mail; |
71 | AddAtt *addAtt; | 71 | AddAtt *addAtt; |
72 | AddressList *addressList; | 72 | AddressList *addressList; |
73 | bool showingAddressList; | 73 | bool showingAddressList; |
74 | 74 | ||
75 | QToolBar *bar; | 75 | QToolBar *bar; |
76 | QMenuBar *menu; | 76 | QMenuBar *menu; |
77 | QPopupMenu *addMenu, *mailMenu; | 77 | QPopupMenu *addMenu, *mailMenu; |
78 | QListView *addressView; | 78 | QListView *addressView; |
79 | 79 | ||
80 | QToolButton *okButton; | 80 | QToolButton *okButton; |
81 | QWidget *widget; | 81 | QWidget *widget; |
82 | QAction *attatchButton; | 82 | QAction *attachButton; |
83 | QAction *confirmButton; | 83 | QAction *confirmButton; |
84 | QAction *newButton; | 84 | QAction *newButton; |
85 | QLabel* subjetLabel; | 85 | QLabel* subjetLabel; |
86 | QToolButton* ToolButton13_2; | 86 | QToolButton* ToolButton13_2; |
87 | QComboBox* recipientsBox; | 87 | QComboBox* recipientsBox; |
88 | QLineEdit *subjectInput; | 88 | QLineEdit *subjectInput; |
89 | QLineEdit *toInput; | 89 | QLineEdit *toInput; |
90 | QLineEdit *ccInput; | 90 | QLineEdit *ccInput; |
91 | QToolButton* addressButton; | 91 | QToolButton* addressButton; |
92 | QMultiLineEdit* emailInput; | 92 | QMultiLineEdit* emailInput; |
93 | QGridLayout* grid; | 93 | QGridLayout* grid; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | #endif // WRITEMAIL_H | 96 | #endif // WRITEMAIL_H |
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp index d268f1f..daefac6 100644 --- a/noncore/unsupported/mailit/addatt.cpp +++ b/noncore/unsupported/mailit/addatt.cpp | |||
@@ -1,224 +1,224 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include "addatt.h" | 25 | #include "addatt.h" |
26 | 26 | ||
27 | FileItem::FileItem(QListView *parent, DocLnk* dl) | 27 | FileItem::FileItem(QListView *parent, DocLnk* dl) |
28 | : QListViewItem(parent) | 28 | : QListViewItem(parent) |
29 | { | 29 | { |
30 | /*file = fileInfo; | 30 | /*file = fileInfo; |
31 | type = fileType;*/ | 31 | type = fileType;*/ |
32 | 32 | ||
33 | doclnk=dl; | 33 | doclnk=dl; |
34 | 34 | ||
35 | setText(0, doclnk->name()); | 35 | setText(0, doclnk->name()); |
36 | 36 | ||
37 | /*if (fileType == "Picture") { | 37 | /*if (fileType == "Picture") { |
38 | setPixmap(0, Resource::loadPixmap("pixmap")); | 38 | setPixmap(0, Resource::loadPixmap("pixmap")); |
39 | } else if (fileType == "Document") { | 39 | } else if (fileType == "Document") { |
40 | setPixmap(0, Resource::loadPixmap("txt")); | 40 | setPixmap(0, Resource::loadPixmap("txt")); |
41 | } else if (fileType == "Sound") { | 41 | } else if (fileType == "Sound") { |
42 | setPixmap(0, Resource::loadPixmap("play")); | 42 | setPixmap(0, Resource::loadPixmap("play")); |
43 | } else if (fileType == "Movie") { | 43 | } else if (fileType == "Movie") { |
44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | 44 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); |
45 | } else if (fileType == "File") { | 45 | } else if (fileType == "File") { |
46 | setPixmap(0, Resource::loadPixmap("exec")); | 46 | setPixmap(0, Resource::loadPixmap("exec")); |
47 | }*/ | 47 | }*/ |
48 | } | 48 | } |
49 | 49 | ||
50 | FileItem::~FileItem() | 50 | FileItem::~FileItem() |
51 | { | 51 | { |
52 | if (doclnk!=NULL) delete doclnk; | 52 | if (doclnk!=NULL) delete doclnk; |
53 | doclnk=NULL; | 53 | doclnk=NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | 56 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) |
57 | : QDialog(parent, name, f) | 57 | : QDialog(parent, name, f) |
58 | { | 58 | { |
59 | setCaption("Adding attatchments"); | 59 | setCaption("Adding attachments"); |
60 | 60 | ||
61 | QGridLayout *top = new QGridLayout(this, 1,1 ); | 61 | QGridLayout *top = new QGridLayout(this, 1,1 ); |
62 | 62 | ||
63 | QHBox *buttons=new QHBox(this); | 63 | QHBox *buttons=new QHBox(this); |
64 | /*fileCategoryButton = new QPushButton(this);*/ | 64 | /*fileCategoryButton = new QPushButton(this);*/ |
65 | attatchButton = new QPushButton(tr("Attatch..."), buttons); | 65 | attachButton = new QPushButton(tr("attach..."), buttons); |
66 | removeButton = new QPushButton(tr("Remove"), buttons); | 66 | removeButton = new QPushButton(tr("Remove"), buttons); |
67 | 67 | ||
68 | /*fileCategories = new QPopupMenu(fileCategoryButton); | 68 | /*fileCategories = new QPopupMenu(fileCategoryButton); |
69 | fileCategoryButton->setPopup(fileCategories); | 69 | fileCategoryButton->setPopup(fileCategories); |
70 | fileCategories->insertItem("Document"); | 70 | fileCategories->insertItem("Document"); |
71 | fileCategories->insertItem("Picture"); | 71 | fileCategories->insertItem("Picture"); |
72 | fileCategories->insertItem("Sound"); | 72 | fileCategories->insertItem("Sound"); |
73 | fileCategories->insertItem("Movie"); | 73 | fileCategories->insertItem("Movie"); |
74 | fileCategories->insertItem("File"); | 74 | fileCategories->insertItem("File"); |
75 | 75 | ||
76 | fileCategoryButton->setText("Document"); | 76 | fileCategoryButton->setText("Document"); |
77 | top->addWidget(fileCategoryButton, 0, 0);*/ | 77 | top->addWidget(fileCategoryButton, 0, 0);*/ |
78 | 78 | ||
79 | 79 | ||
80 | top->addWidget(buttons,1,0); | 80 | top->addWidget(buttons,1,0); |
81 | //buttons->addWidget(attatchButton,0,0); | 81 | //buttons->addWidget(attachButton,0,0); |
82 | //buttons->addWidget(removeButton,0,1); | 82 | //buttons->addWidget(removeButton,0,1); |
83 | 83 | ||
84 | //connect(fileCategories, SIGNAL(activated(int)), this, | 84 | //connect(fileCategories, SIGNAL(activated(int)), this, |
85 | //SLOT(fileCategorySelected(int)) );*/ | 85 | //SLOT(fileCategorySelected(int)) );*/ |
86 | connect(attatchButton, SIGNAL(clicked()), this, | 86 | connect(attachButton, SIGNAL(clicked()), this, |
87 | SLOT(addAttatchment()) ); | 87 | SLOT(addattachment()) ); |
88 | connect(removeButton, SIGNAL(clicked()), this, | 88 | connect(removeButton, SIGNAL(clicked()), this, |
89 | SLOT(removeAttatchment()) ); | 89 | SLOT(removeattachment()) ); |
90 | 90 | ||
91 | /*listView = new QListView(this, "AttView"); | 91 | /*listView = new QListView(this, "AttView"); |
92 | listView->addColumn("Documents");* | 92 | listView->addColumn("Documents");* |
93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | 93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, |
94 | SLOT(addAttatchment()) );*/ | 94 | SLOT(addattachment()) );*/ |
95 | 95 | ||
96 | 96 | ||
97 | attView = new QListView(this, "Selected"); | 97 | attView = new QListView(this, "Selected"); |
98 | attView->addColumn(tr("Attached")); | 98 | attView->addColumn(tr("Attached")); |
99 | attView->addColumn(tr("File type")); | 99 | attView->addColumn(tr("File type")); |
100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | 100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, |
101 | SLOT(removeAttatchment()) ); | 101 | SLOT(removeattachment()) ); |
102 | 102 | ||
103 | //top->addWidget(ofs, 0,0); | 103 | //top->addWidget(ofs, 0,0); |
104 | top->addWidget(attView, 0,0); | 104 | top->addWidget(attView, 0,0); |
105 | 105 | ||
106 | clear(); | 106 | clear(); |
107 | 107 | ||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | void AddAtt::clear() | 111 | void AddAtt::clear() |
112 | { | 112 | { |
113 | attView->clear(); | 113 | attView->clear(); |
114 | //getFiles(); | 114 | //getFiles(); |
115 | modified = FALSE; | 115 | modified = FALSE; |
116 | } | 116 | } |
117 | 117 | ||
118 | /*void AddAtt::fileCategorySelected(int id) | 118 | /*void AddAtt::fileCategorySelected(int id) |
119 | { | 119 | { |
120 | fileCategoryButton->setText(fileCategories->text(id)); | 120 | fileCategoryButton->setText(fileCategories->text(id)); |
121 | getFiles(); | 121 | getFiles(); |
122 | }*/ | 122 | }*/ |
123 | 123 | ||
124 | void AddAtt::addAttatchment() | 124 | void AddAtt::addattachment() |
125 | { | 125 | { |
126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); | 126 | OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); |
127 | 127 | ||
128 | ofs.showMaximized(); | 128 | ofs.showMaximized(); |
129 | 129 | ||
130 | if (ofs.exec()==QDialog::Accepted) | 130 | if (ofs.exec()==QDialog::Accepted) |
131 | { | 131 | { |
132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); | 132 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); |
133 | FileItem* fi=new FileItem(attView,dl); | 133 | FileItem* fi=new FileItem(attView,dl); |
134 | fi->setPixmap(0,dl->pixmap()); | 134 | fi->setPixmap(0,dl->pixmap()); |
135 | fi->setText(1,dl->type()); | 135 | fi->setText(1,dl->type()); |
136 | attView->insertItem(fi); | 136 | attView->insertItem(fi); |
137 | modified = TRUE; | 137 | modified = TRUE; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | void AddAtt::removeAttatchment() | 141 | void AddAtt::removeattachment() |
142 | { | 142 | { |
143 | if (attView->selectedItem() != NULL) | 143 | if (attView->selectedItem() != NULL) |
144 | { | 144 | { |
145 | attView->takeItem(attView->selectedItem()); | 145 | attView->takeItem(attView->selectedItem()); |
146 | } | 146 | } |
147 | modified = TRUE; | 147 | modified = TRUE; |
148 | } | 148 | } |
149 | 149 | ||
150 | void AddAtt::reject() | 150 | void AddAtt::reject() |
151 | { | 151 | { |
152 | if (modified) { | 152 | if (modified) { |
153 | attView->clear(); | 153 | attView->clear(); |
154 | modified = FALSE; | 154 | modified = FALSE; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void AddAtt::accept() | 158 | void AddAtt::accept() |
159 | { | 159 | { |
160 | modified = FALSE; | 160 | modified = FALSE; |
161 | hide(); | 161 | hide(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void AddAtt::getFiles() | 164 | void AddAtt::getFiles() |
165 | { | 165 | { |
166 | QString path, selected; | 166 | QString path, selected; |
167 | 167 | ||
168 | /*listView->clear(); | 168 | /*listView->clear(); |
169 | 169 | ||
170 | selected = fileCategoryButton->text(); | 170 | selected = fileCategoryButton->text(); |
171 | if (selected == "Picture") { | 171 | if (selected == "Picture") { |
172 | path = "../pics/"; | 172 | path = "../pics/"; |
173 | } else if (selected == "Document") { | 173 | } else if (selected == "Document") { |
174 | path = "" ; //sub-dirs not decided | 174 | path = "" ; //sub-dirs not decided |
175 | } else if (selected == "Sound") { | 175 | } else if (selected == "Sound") { |
176 | path = "../sounds/"; //sub-dirs not decided | 176 | path = "../sounds/"; //sub-dirs not decided |
177 | } else if (selected == "Movie") { | 177 | } else if (selected == "Movie") { |
178 | path = ""; //sub-dirs not decided | 178 | path = ""; //sub-dirs not decided |
179 | } else if (selected == "File") { | 179 | } else if (selected == "File") { |
180 | path = ""; //sub-dirs not decided | 180 | path = ""; //sub-dirs not decided |
181 | } | 181 | } |
182 | 182 | ||
183 | dir = new QDir(path); | 183 | dir = new QDir(path); |
184 | dir->setFilter(QDir::Files); | 184 | dir->setFilter(QDir::Files); |
185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | 185 | const QFileInfoList *dirInfoList = dir->entryInfoList(); |
186 | 186 | ||
187 | QFileInfoListIterator it(*dirInfoList); // create list iterator | 187 | QFileInfoListIterator it(*dirInfoList); // create list iterator |
188 | 188 | ||
189 | while ( (fi=it.current()) ) { // for each file... | 189 | while ( (fi=it.current()) ) { // for each file... |
190 | item = new FileItem(lis+ütView, *fi, selected); | 190 | item = new FileItem(lis+ütView, *fi, selected); |
191 | ++it; // goto next list element | 191 | ++it; // goto next list element |
192 | }*/ | 192 | }*/ |
193 | } | 193 | } |
194 | 194 | ||
195 | QStringList AddAtt::returnAttatchedFiles() | 195 | QStringList AddAtt::returnattachedFiles() |
196 | { | 196 | { |
197 | QFileInfo info; | 197 | QFileInfo info; |
198 | QStringList list; | 198 | QStringList list; |
199 | 199 | ||
200 | item = (FileItem *) attView->firstChild(); | 200 | item = (FileItem *) attView->firstChild(); |
201 | 201 | ||
202 | 202 | ||
203 | while (item != NULL) { | 203 | while (item != NULL) { |
204 | DocLnk* dl=item->getDocLnk(); | 204 | DocLnk* dl=item->getDocLnk(); |
205 | list+=dl->file(); | 205 | list+=dl->file(); |
206 | /*info = item->getFileInfo(); | 206 | /*info = item->getFileInfo(); |
207 | list += info.filePath();*/ | 207 | list += info.filePath();*/ |
208 | item = (FileItem *) item->nextSibling(); | 208 | item = (FileItem *) item->nextSibling(); |
209 | } | 209 | } |
210 | return list; | 210 | return list; |
211 | } | 211 | } |
212 | 212 | ||
213 | QStringList AddAtt::returnFileTypes() | 213 | QStringList AddAtt::returnFileTypes() |
214 | { | 214 | { |
215 | QStringList list; | 215 | QStringList list; |
216 | 216 | ||
217 | item = (FileItem *) attView->firstChild(); | 217 | item = (FileItem *) attView->firstChild(); |
218 | 218 | ||
219 | while (item != NULL) { | 219 | while (item != NULL) { |
220 | list += item->getDocLnk()->type(); | 220 | list += item->getDocLnk()->type(); |
221 | item = (FileItem *) item->nextSibling(); | 221 | item = (FileItem *) item->nextSibling(); |
222 | } | 222 | } |
223 | return list; | 223 | return list; |
224 | } | 224 | } |
diff --git a/noncore/unsupported/mailit/addatt.h b/noncore/unsupported/mailit/addatt.h index fcf3279..a365947 100644 --- a/noncore/unsupported/mailit/addatt.h +++ b/noncore/unsupported/mailit/addatt.h | |||
@@ -1,76 +1,76 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef ADDATT_H | 20 | #ifndef ADDATT_H |
21 | #define ADDATT_H | 21 | #define ADDATT_H |
22 | 22 | ||
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <opie/ofiledialog.h> | 30 | #include <opie/ofiledialog.h> |
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | 32 | ||
33 | class FileItem : public QListViewItem | 33 | class FileItem : public QListViewItem |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); | 36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); |
37 | FileItem(QListView*, DocLnk*); | 37 | FileItem(QListView*, DocLnk*); |
38 | ~FileItem(); | 38 | ~FileItem(); |
39 | DocLnk* getDocLnk() {return doclnk;} | 39 | DocLnk* getDocLnk() {return doclnk;} |
40 | 40 | ||
41 | 41 | ||
42 | private: | 42 | private: |
43 | DocLnk* doclnk; | 43 | DocLnk* doclnk; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | class AddAtt : public QDialog | 46 | class AddAtt : public QDialog |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | 49 | ||
50 | public: | 50 | public: |
51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
52 | QStringList returnAttatchedFiles(); | 52 | QStringList returnattachedFiles(); |
53 | QStringList returnFileTypes(); | 53 | QStringList returnFileTypes(); |
54 | void getFiles(); | 54 | void getFiles(); |
55 | void clear(); | 55 | void clear(); |
56 | 56 | ||
57 | 57 | ||
58 | public slots: | 58 | public slots: |
59 | //void fileCategorySelected(int); | 59 | //void fileCategorySelected(int); |
60 | void addAttatchment(); | 60 | void addattachment(); |
61 | void removeAttatchment(); | 61 | void removeattachment(); |
62 | void reject(); | 62 | void reject(); |
63 | void accept(); | 63 | void accept(); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | FileItem* item; | 66 | FileItem* item; |
67 | QListView *attView; | 67 | QListView *attView; |
68 | QPushButton *attatchButton, *removeButton; | 68 | QPushButton *attachButton, *removeButton; |
69 | QPopupMenu *fileCategories; | 69 | QPopupMenu *fileCategories; |
70 | bool modified; | 70 | bool modified; |
71 | //QFileInfo *fi; | 71 | //QFileInfo *fi; |
72 | 72 | ||
73 | OFileDialog* ofs; | 73 | OFileDialog* ofs; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | #endif | 76 | #endif |
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp index 8d9ab91..7d60ebf 100644 --- a/noncore/unsupported/mailit/addresslist.cpp +++ b/noncore/unsupported/mailit/addresslist.cpp | |||
@@ -1,161 +1,161 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #include <opie/ocontactaccess.h> | 22 | #include <opie/ocontactaccess.h> |
23 | #include <opie/ocontact.h> | 23 | #include <opie/ocontact.h> |
24 | 24 | ||
25 | #include "addresslist.h" | 25 | #include "addresslist.h" |
26 | 26 | ||
27 | AddressList::AddressList() | 27 | AddressList::AddressList() |
28 | { | 28 | { |
29 | addresses.setAutoDelete(TRUE); | 29 | addresses.setAutoDelete(TRUE); |
30 | read(); | 30 | read(); |
31 | dirty = FALSE; | 31 | dirty = FALSE; |
32 | } | 32 | } |
33 | 33 | ||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void AddressList::addContact(QString email, QString name) |
40 | { | 40 | { |
41 | //skip if not a valid email address, | 41 | //skip if not a valid email address, |
42 | if (email.find( '@') == -1) | 42 | if (email.find( '@') == -1) |
43 | return; | 43 | return; |
44 | 44 | ||
45 | if ( ! containsEmail(email) ) { | 45 | if ( ! containsEmail(email) ) { |
46 | Contact *in = new Contact; | 46 | Contact *in = new Contact; |
47 | in->email = email; | 47 | in->email = email; |
48 | in->name = name; | 48 | in->name = name; |
49 | addresses.append(in); | 49 | addresses.append(in); |
50 | dirty = TRUE; | 50 | dirty = TRUE; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(QString email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(QString name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString AddressList::getNameByEmail(QString email) |
65 | { | 65 | { |
66 | int pos = getEmailRef(email); | 66 | int pos = getEmailRef(email); |
67 | if (pos != -1) { | 67 | if (pos != -1) { |
68 | Contact *ptr = addresses.at(pos); | 68 | Contact *ptr = addresses.at(pos); |
69 | return ptr->name; | 69 | return ptr->name; |
70 | } | 70 | } |
71 | 71 | ||
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | 74 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString AddressList::getEmailByName(QString name) |
76 | { | 76 | { |
77 | int pos = getNameRef(name); | 77 | int pos = getNameRef(name); |
78 | if (pos != -1) { | 78 | if (pos != -1) { |
79 | Contact *ptr = addresses.at(pos); | 79 | Contact *ptr = addresses.at(pos); |
80 | return ptr->email; | 80 | return ptr->email; |
81 | } | 81 | } |
82 | 82 | ||
83 | return NULL; | 83 | return NULL; |
84 | } | 84 | } |
85 | 85 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int AddressList::getEmailRef(QString email) |
87 | { | 87 | { |
88 | int pos = 0; | 88 | int pos = 0; |
89 | Contact *ptr; | 89 | Contact *ptr; |
90 | 90 | ||
91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
92 | if (ptr->email == email) | 92 | if (ptr->email == email) |
93 | return pos; | 93 | return pos; |
94 | pos++; | 94 | pos++; |
95 | } | 95 | } |
96 | return -1; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int AddressList::getNameRef(QString name) |
100 | { | 100 | { |
101 | int pos = 0; | 101 | int pos = 0; |
102 | Contact *ptr; | 102 | Contact *ptr; |
103 | 103 | ||
104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
105 | if (ptr->name == name) | 105 | if (ptr->name == name) |
106 | return pos; | 106 | return pos; |
107 | pos++; | 107 | pos++; |
108 | } | 108 | } |
109 | return -1; | 109 | return -1; |
110 | } | 110 | } |
111 | 111 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void AddressList::read() |
118 | { | 118 | { |
119 | OContactAccess::List::Iterator it; | 119 | OContactAccess::List::Iterator it; |
120 | 120 | ||
121 | QString lineEmail, lineName, email, name; | 121 | QString lineEmail, lineName, email, name; |
122 | OContactAccess m_contactdb("mailit"); | 122 | OContactAccess m_contactdb("mailit"); |
123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
124 | //OContact* oc; | 124 | //OContact* oc;(*it).defaultEmail() |
125 | 125 | ||
126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
127 | { | 127 | { |
128 | //oc=(OContact*) it; | 128 | //oc=(OContact*) it; |
129 | if ((*it).defaultEmail().length()!=0) | 129 | if ((*it).defaultEmail().length()!=0) |
130 | addContact((*it).defaultEmail(),(*it).fileAs()); | 130 | addContact((*it).defaultEmail(),(*it).fileAs()); |
131 | } | 131 | } |
132 | 132 | ||
133 | /*if (! f.open(IO_ReadOnly) ) | 133 | /*if (! f.open(IO_ReadOnly) ) |
134 | return; | 134 | return; |
135 | 135 | ||
136 | QTextStream stream(&f); | 136 | QTextStream stream(&f); |
137 | 137 | ||
138 | while (! stream.atEnd() ) { | 138 | while (! stream.atEnd() ) { |
139 | lineEmail = stream.readLine(); | 139 | lineEmail = stream.readLine(); |
140 | if (! stream.atEnd() ) | 140 | if (! stream.atEnd() ) |
141 | lineName = stream.readLine(); | 141 | lineName = stream.readLine(); |
142 | else return; | 142 | else return; |
143 | 143 | ||
144 | email = getRightString(lineEmail); | 144 | email = getRightString(lineEmail); |
145 | name = getRightString(lineName); | 145 | name = getRightString(lineName); |
146 | addContact(email, name); | 146 | addContact(email, name); |
147 | } | 147 | } |
148 | f.close();*/ | 148 | f.close();*/ |
149 | } | 149 | } |
150 | 150 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString AddressList::getRightString(QString in) |
152 | { | 152 | { |
153 | QString out = ""; | 153 | QString out = ""; |
154 | 154 | ||
155 | int pos = in.find('='); | 155 | int pos = in.find('='); |
156 | if (pos != -1) { | 156 | if (pos != -1) { |
157 | out = in.mid(pos+1).stripWhiteSpace(); | 157 | out = in.mid(pos+1).stripWhiteSpace(); |
158 | } | 158 | } |
159 | return out; | 159 | return out; |
160 | } | 160 | } |
161 | 161 | ||
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index ad1e0b4..23059cf 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -1,1004 +1,981 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qwhatsthis.h> | ||
26 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
27 | #include "emailclient.h" | 28 | #include "emailclient.h" |
28 | 29 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 30 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 31 | { |
31 | return dupl( (MailAccount *) d); | 32 | return dupl( (MailAccount *) d); |
32 | } | 33 | } |
33 | 34 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 35 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 36 | { |
36 | ac = new MailAccount(*in); | 37 | ac = new MailAccount(*in); |
37 | return ac; | 38 | return ac; |
38 | } | 39 | } |
39 | 40 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 41 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 42 | : QMainWindow( parent, name, fl ) |
42 | { | 43 | { |
43 | emailHandler = new EmailHandler(); | 44 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList(); | 45 | addressList = new AddressList(); |
45 | 46 | ||
46 | sending = FALSE; | 47 | sending = FALSE; |
47 | receiving = FALSE; | 48 | receiving = FALSE; |
48 | previewingMail = FALSE; | 49 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 50 | mailIdCount = 1; |
50 | accountIdCount = 1; | 51 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 52 | allAccounts = FALSE; |
52 | 53 | ||
53 | init(); | 54 | init(); |
54 | 55 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 56 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 57 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 58 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 59 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 60 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 61 | SLOT(popError(int)) ); |
61 | 62 | ||
62 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 63 | connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 64 | connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | 65 | ||
65 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); | 66 | connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); |
66 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); | 67 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); |
67 | 68 | ||
68 | 69 | ||
69 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 70 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
70 | SLOT(mailArrived(const Email &, bool)) ); | 71 | SLOT(mailArrived(const Email &, bool)) ); |
71 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 72 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
72 | SLOT(allMailArrived(int)) ); | 73 | SLOT(allMailArrived(int)) ); |
73 | 74 | ||
74 | mailconf = new Config("mailit"); | 75 | mailconf = new Config("mailit"); |
75 | //In case Synchronize is not defined in settings.txt | 76 | //In case Synchronize is not defined in settings.txt |
76 | 77 | ||
77 | readSettings(); | 78 | readSettings(); |
78 | 79 | ||
79 | updateAccounts(); | 80 | updateAccounts(); |
80 | 81 | ||
81 | lineShift = "\n"; | 82 | lineShift = "\n"; |
82 | readMail(); | 83 | readMail(); |
83 | lineShift = "\r\n"; | 84 | lineShift = "\r\n"; |
84 | 85 | ||
86 | mailboxView->setCurrentTab(0); //ensure that inbox has focus | ||
85 | } | 87 | } |
86 | 88 | ||
87 | 89 | ||
88 | EmailClient::~EmailClient() | 90 | EmailClient::~EmailClient() |
89 | { | 91 | { |
90 | //needs to be moved from destructor to closewindow event | 92 | //needs to be moved from destructor to closewindow event |
91 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 93 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
92 | //does not currently work. Defining outbox in the same | 94 | //does not currently work. Defining outbox in the same |
93 | //format as inbox is not a good solution as they have | 95 | //format as inbox is not a good solution as they have |
94 | //different properties | 96 | //different properties |
95 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 97 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
96 | saveSettings(); | 98 | saveSettings(); |
97 | 99 | ||
98 | mailconf->write(); | 100 | mailconf->write(); |
99 | delete mailconf; | 101 | delete mailconf; |
100 | 102 | ||
101 | } | 103 | } |
102 | 104 | ||
103 | void EmailClient::init() | 105 | void EmailClient::init() |
104 | { | 106 | { |
105 | statusBar = new QStatusBar(this); | 107 | statusBar = new QStatusBar(this); |
106 | statusBar->setSizeGripEnabled(FALSE); | 108 | statusBar->setSizeGripEnabled(FALSE); |
107 | 109 | ||
108 | status1Label = new QLabel( tr("Idle"), statusBar); | 110 | status1Label = new QLabel( tr("Idle"), statusBar); |
109 | status2Label = new QLabel("", statusBar); | 111 | status2Label = new QLabel("", statusBar); |
110 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 112 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
111 | status2Label, SLOT(setText(const QString &)) ); | 113 | status2Label, SLOT(setText(const QString &)) ); |
112 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 114 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
113 | status2Label, SLOT(setText(const QString &)) ); | 115 | status2Label, SLOT(setText(const QString &)) ); |
114 | 116 | ||
115 | progressBar = new QProgressBar(statusBar); | 117 | progressBar = new QProgressBar(statusBar); |
118 | |||
116 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 119 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
117 | this, SLOT(setTotalSize(int)) ); | 120 | this, SLOT(setTotalSize(int)) ); |
118 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 121 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
119 | this, SLOT(setMailSize(int)) ); | 122 | this, SLOT(setMailSize(int)) ); |
120 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 123 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
121 | this, SLOT(setDownloadedSize(int)) ); | 124 | this, SLOT(setDownloadedSize(int)) ); |
122 | 125 | ||
123 | statusBar->addWidget(status1Label); | 126 | statusBar->addWidget(status1Label); |
124 | statusBar->addWidget(progressBar); | 127 | statusBar->addWidget(progressBar); |
125 | statusBar->addWidget(status2Label); | 128 | statusBar->addWidget(status2Label); |
126 | 129 | ||
127 | setToolBarsMovable(FALSE); | 130 | setToolBarsMovable(FALSE); |
128 | 131 | ||
129 | bar = new QToolBar(this); | 132 | bar = new QToolBar(this); |
133 | QWhatsThis::add(bar,tr("Main operation toolbar")); | ||
130 | bar->setHorizontalStretchable( TRUE ); | 134 | bar->setHorizontalStretchable( TRUE ); |
131 | 135 | ||
132 | mb = new QMenuBar( bar ); | 136 | mb = new QMenuBar( bar ); |
133 | 137 | ||
134 | QPopupMenu *mail = new QPopupMenu(mb); | 138 | QPopupMenu *mail = new QPopupMenu(mb); |
135 | mb->insertItem( tr( "&Mail" ), mail); | 139 | mb->insertItem( tr( "&Mail" ), mail); |
136 | 140 | ||
137 | QPopupMenu *configure = new QPopupMenu(mb); | 141 | QPopupMenu *configure = new QPopupMenu(mb); |
138 | mb->insertItem( tr( "Accounts" ), configure); | 142 | mb->insertItem( tr( "Accounts" ), configure); |
139 | 143 | ||
140 | selectAccountMenu = new QPopupMenu(mb); | 144 | selectAccountMenu = new QPopupMenu(mb); |
141 | editAccountMenu = new QPopupMenu(mb); | 145 | editAccountMenu = new QPopupMenu(mb); |
142 | deleteAccountMenu = new QPopupMenu(mb); | 146 | deleteAccountMenu = new QPopupMenu(mb); |
143 | 147 | ||
144 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 148 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
145 | configure->insertItem(tr("Edit account"), editAccountMenu); | 149 | configure->insertItem(tr("Edit account"), editAccountMenu); |
146 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 150 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
147 | 151 | ||
148 | bar = new QToolBar(this); | 152 | bar = new QToolBar(this); |
149 | 153 | ||
150 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); | 154 | getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); |
151 | //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); | 155 | QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); |
152 | // setAccountButton->addTo(bar); | 156 | |
153 | //setAccountButton->addTo(mail); | ||
154 | |||
155 | /*idCount = 0; | ||
156 | |||
157 | for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; | ||
158 | accountPtr = accountList.next()) { | ||
159 | |||
160 | selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); | ||
161 | idCount++; | ||
162 | }*/ | ||
163 | getMailButton->setPopup(selectAccountMenu); | 157 | getMailButton->setPopup(selectAccountMenu); |
164 | 158 | ||
165 | |||
166 | /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | ||
167 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | ||
168 | getMailButton->addTo(bar);*/ | ||
169 | //getMailButton->addTo(mail); | ||
170 | |||
171 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); | 159 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); |
172 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 160 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
173 | sendMailButton->addTo(bar); | 161 | sendMailButton->addTo(bar); |
174 | sendMailButton->addTo(mail); | 162 | sendMailButton->addTo(mail); |
163 | sendMailButton->setWhatsThis("Send mail queued in the outbox"); | ||
175 | 164 | ||
176 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 165 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
177 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 166 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
178 | composeButton->addTo(bar); | 167 | composeButton->addTo(bar); |
179 | composeButton->addTo(mail); | 168 | composeButton->addTo(mail); |
169 | composeButton->setWhatsThis("Compose a new mail"); | ||
180 | 170 | ||
181 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 171 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
182 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 172 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
183 | cancelButton->addTo(mail); | 173 | cancelButton->addTo(mail); |
184 | cancelButton->addTo(bar); | 174 | cancelButton->addTo(bar); |
185 | cancelButton->setEnabled(FALSE); | 175 | cancelButton->setEnabled(FALSE); |
176 | cancelButton->setWhatsThis("Stop the currently active mail transfer"); | ||
177 | |||
186 | 178 | ||
187 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 179 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
188 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 180 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
189 | deleteButton->addTo(bar); | 181 | deleteButton->addTo(bar); |
182 | deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); | ||
190 | 183 | ||
191 | mailboxView = new OTabWidget( this, "mailboxView" ); | 184 | mailboxView = new OTabWidget( this, "mailboxView" ); |
192 | 185 | ||
193 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 186 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
194 | grid_2 = new QGridLayout( widget ); | 187 | grid_2 = new QGridLayout( widget ); |
195 | // grid_2->setSpacing(6); | 188 | // grid_2->setSpacing(6); |
196 | // grid_2->setMargin( 11 ); | 189 | // grid_2->setMargin( 11 ); |
197 | 190 | ||
198 | inboxView = new QListView( widget, "inboxView" ); | 191 | inboxView = new QListView( widget, "inboxView" ); |
199 | inboxView->addColumn( tr( "From" ) ); | 192 | inboxView->addColumn( tr( "From" ) ); |
200 | inboxView->addColumn( tr( "Subject" ) ); | 193 | inboxView->addColumn( tr( "Subject" ) ); |
201 | inboxView->addColumn( tr( "Date" ) ); | 194 | inboxView->addColumn( tr( "Date" ) ); |
202 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 195 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
203 | inboxView->setAllColumnsShowFocus(TRUE); | 196 | inboxView->setAllColumnsShowFocus(TRUE); |
197 | QWhatsThis::add(inboxView,QWidget::tr("This is the inbox view.\n It keeps the fetched mail which can be viewed by double clicking the entry.\n" | ||
198 | " A blue attachment icon shows whether this mail has attachments.")); | ||
204 | 199 | ||
205 | grid_2->addWidget( inboxView, 2, 0 ); | 200 | grid_2->addWidget( inboxView, 2, 0 ); |
206 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 201 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
207 | 202 | ||
208 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 203 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
209 | grid_3 = new QGridLayout( widget_2 ); | 204 | grid_3 = new QGridLayout( widget_2 ); |
210 | // grid_3->setSpacing(6); | 205 | // grid_3->setSpacing(6); |
211 | // grid_3->setMargin( 11 ); | 206 | // grid_3->setMargin( 11 ); |
212 | 207 | ||
213 | outboxView = new QListView( widget_2, "outboxView" ); | 208 | outboxView = new QListView( widget_2, "outboxView" ); |
214 | outboxView->addColumn( tr( "To" ) ); | 209 | outboxView->addColumn( tr( "To" ) ); |
215 | outboxView->addColumn( tr( "Subject" ) ); | 210 | outboxView->addColumn( tr( "Subject" ) ); |
216 | outboxView->setAllColumnsShowFocus(TRUE); | 211 | outboxView->setAllColumnsShowFocus(TRUE); |
217 | 212 | ||
213 | QWhatsThis::add(outboxView,QWidget::tr("This is the oubox view.\n It keeps the queued mails to send which can be reviewed by double clicking the entry.")); | ||
218 | grid_3->addWidget( outboxView, 0, 0 ); | 214 | grid_3->addWidget( outboxView, 0, 0 ); |
219 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 215 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
220 | 216 | ||
221 | setCentralWidget(mailboxView); | 217 | setCentralWidget(mailboxView); |
222 | 218 | ||
223 | mailboxView->setCurrentTab(0); | ||
224 | } | 219 | } |
225 | 220 | ||
226 | void EmailClient::compose() | 221 | void EmailClient::compose() |
227 | { | 222 | { |
228 | emit composeRequested(); | 223 | emit composeRequested(); |
229 | } | 224 | } |
230 | 225 | ||
231 | void EmailClient::cancel() | 226 | void EmailClient::cancel() |
232 | { | 227 | { |
233 | emailHandler->cancel(); | 228 | emailHandler->cancel(); |
234 | } | 229 | } |
235 | 230 | ||
236 | AddressList* EmailClient::getAdrListRef() | 231 | AddressList* EmailClient::getAdrListRef() |
237 | { | 232 | { |
238 | return addressList; | 233 | return addressList; |
239 | } | 234 | } |
240 | 235 | ||
241 | //this needs to be rewritten to syncronize with outboxView | 236 | //this needs to be rewritten to syncronize with outboxView |
242 | void EmailClient::enqueMail(const Email &mail) | 237 | void EmailClient::enqueMail(const Email &mail) |
243 | { | 238 | { |
244 | if (accountList.count() == 0) { | 239 | if (accountList.count() == 0) { |
245 | QMessageBox::warning(qApp->activeWindow(), | 240 | QMessageBox::warning(qApp->activeWindow(), |
246 | tr("No account selected"), tr("You must create an account"), "OK\n"); | 241 | tr("No account selected"), tr("You must create an account"), "OK\n"); |
247 | return; | 242 | return; |
248 | } | 243 | } |
249 | 244 | ||
250 | if (accountList.count() > 0) { | 245 | if (accountList.count() > 0) { |
251 | currentAccount = accountList.first(); | 246 | currentAccount = accountList.first(); |
252 | qWarning("using account " + currentAccount->name); | 247 | qWarning("using account " + currentAccount->name); |
253 | } | 248 | } |
254 | 249 | ||
255 | Email addMail = mail; | 250 | Email addMail = mail; |
256 | addMail.from = currentAccount->name; | 251 | addMail.from = currentAccount->name; |
257 | addMail.fromMail = currentAccount->emailAddress; | 252 | addMail.fromMail = currentAccount->emailAddress; |
258 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 253 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
259 | item = new EmailListItem(outboxView, addMail, false); | 254 | item = new EmailListItem(outboxView, addMail, false); |
260 | 255 | ||
261 | mailboxView->setCurrentTab(1); | 256 | mailboxView->setCurrentTab(1); |
262 | 257 | ||
263 | } | 258 | } |
264 | 259 | ||
265 | void EmailClient::sendQuedMail() | 260 | void EmailClient::sendQuedMail() |
266 | { | 261 | { |
267 | int count = 0; | 262 | int count = 0; |
268 | 263 | ||
269 | if (accountList.count() == 0) { | 264 | if (accountList.count() == 0) { |
270 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); | 265 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
271 | return; | 266 | return; |
272 | } | 267 | } |
273 | //traverse listview, find messages to send | 268 | //traverse listview, find messages to send |
274 | if (! sending) { | 269 | if (! sending) { |
275 | item = (EmailListItem *) outboxView->firstChild(); | 270 | item = (EmailListItem *) outboxView->firstChild(); |
276 | if (item != NULL) { | 271 | if (item != NULL) { |
277 | while (item != NULL) { | 272 | while (item != NULL) { |
278 | quedMessages.append(item->getMail()); | 273 | quedMessages.append(item->getMail()); |
279 | item = (EmailListItem *) item->nextSibling(); | 274 | item = (EmailListItem *) item->nextSibling(); |
280 | count++; | 275 | count++; |
281 | } | 276 | } |
282 | setMailAccount(); | 277 | setMailAccount(); |
283 | emailHandler->sendMail(&quedMessages); | 278 | emailHandler->sendMail(&quedMessages); |
284 | sending = TRUE; | 279 | sending = TRUE; |
285 | sendMailButton->setEnabled(FALSE); | 280 | sendMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 281 | cancelButton->setEnabled(TRUE); |
287 | } else { | 282 | } else { |
288 | qWarning("sendQuedMail(): no messages to send"); | 283 | qWarning("sendQuedMail(): no messages to send"); |
289 | } | 284 | } |
290 | } | 285 | } |
291 | } | 286 | } |
292 | 287 | ||
293 | void EmailClient::setMailAccount() | 288 | void EmailClient::setMailAccount() |
294 | { | 289 | { |
295 | emailHandler->setAccount(*currentAccount); | 290 | emailHandler->setAccount(*currentAccount); |
296 | } | 291 | } |
297 | 292 | ||
298 | void EmailClient::mailSent() | 293 | void EmailClient::mailSent() |
299 | { | 294 | { |
300 | sending = FALSE; | 295 | sending = FALSE; |
301 | sendMailButton->setEnabled(TRUE); | 296 | sendMailButton->setEnabled(TRUE); |
302 | 297 | ||
303 | quedMessages.clear(); | 298 | quedMessages.clear(); |
304 | outboxView->clear(); //should be moved to an sentBox | 299 | outboxView->clear(); //should be moved to an sentBox |
305 | } | 300 | } |
306 | 301 | ||
307 | void EmailClient::getNewMail() { | 302 | void EmailClient::getNewMail() { |
308 | 303 | ||
309 | if (accountList.count() == 0) { | 304 | if (accountList.count() == 0) { |
310 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 305 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
311 | "You must create an account", "OK\n"); | 306 | "You must create an account", "OK\n"); |
312 | return; | 307 | return; |
313 | } | 308 | } |
314 | 309 | ||
315 | setMailAccount(); | 310 | setMailAccount(); |
316 | 311 | ||
317 | receiving = TRUE; | 312 | receiving = TRUE; |
318 | previewingMail = TRUE; | 313 | previewingMail = TRUE; |
319 | getMailButton->setEnabled(FALSE); | 314 | getMailButton->setEnabled(FALSE); |
320 | cancelButton->setEnabled(TRUE); | 315 | cancelButton->setEnabled(TRUE); |
321 | selectAccountMenu->setEnabled(FALSE); | 316 | selectAccountMenu->setEnabled(FALSE); |
322 | 317 | ||
323 | status1Label->setText(currentAccount->accountName + " headers"); | 318 | status1Label->setText(currentAccount->accountName + " headers"); |
324 | progressBar->reset(); | 319 | progressBar->reset(); |
325 | 320 | ||
326 | //get any previous mails not downloaded and add to queue | 321 | //get any previous mails not downloaded and add to queue |
327 | /* mailDownloadList.clear(); | 322 | mailDownloadList.clear(); |
328 | Email *mailPtr; | 323 | Email *mailPtr; |
329 | item = (EmailListItem *) inboxView->firstChild(); | 324 | item = (EmailListItem *) inboxView->firstChild(); |
330 | while (item != NULL) { | 325 | while (item != NULL) { |
331 | mailPtr = item->getMail(); | 326 | mailPtr = item->getMail(); |
332 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 327 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
333 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 328 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
334 | } | 329 | } |
335 | item = (EmailListItem *) item->nextSibling(); | 330 | item = (EmailListItem *) item->nextSibling(); |
336 | }*/ | 331 | } |
337 | 332 | ||
338 | emailHandler->getMailHeaders(); | 333 | emailHandler->getMailHeaders(); |
334 | |||
339 | } | 335 | } |
340 | 336 | ||
341 | void EmailClient::getAllNewMail() | 337 | void EmailClient::getAllNewMail() |
342 | { | 338 | { |
343 | allAccounts = TRUE; | 339 | allAccounts = TRUE; |
344 | currentAccount = accountList.first(); | 340 | currentAccount = accountList.first(); |
345 | getNewMail(); | 341 | getNewMail(); |
346 | } | 342 | } |
347 | 343 | ||
348 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 344 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
349 | { | 345 | { |
350 | Enclosure *ePtr; | 346 | Enclosure *ePtr; |
351 | Email newMail; | 347 | Email newMail; |
352 | int thisMailId; | 348 | int thisMailId; |
353 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 349 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
354 | |||
355 | mailconf->setGroup(newMail.id); | 350 | mailconf->setGroup(newMail.id); |
356 | 351 | ||
357 | if (fromDisk) { | 352 | if (fromDisk) |
353 | { | ||
358 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 354 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
359 | newMail.size = mailconf->readNumEntry("size"); | 355 | newMail.size = mailconf->readNumEntry("size"); |
360 | newMail.serverId = mailconf->readNumEntry("serverid"); | 356 | newMail.serverId = mailconf->readNumEntry("serverid"); |
361 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 357 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
362 | } else { //mail arrived from server | 358 | } |
359 | else | ||
360 | { //mail arrived from server | ||
363 | newMail.serverId = mail.serverId; | 361 | newMail.serverId = mail.serverId; |
364 | newMail.size = mail.size; | 362 | newMail.size = mail.size; |
365 | newMail.downloaded = mail.downloaded; | 363 | newMail.downloaded = mail.downloaded; |
366 | 364 | ||
367 | newMail.fromAccountId = currentAccount->id; | 365 | newMail.fromAccountId = currentAccount->id; |
368 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); | 366 | mailconf->writeEntry("fromaccountid", newMail.fromAccountId); |
369 | } | 367 | } |
370 | 368 | ||
371 | //add if read or not | 369 | //add if read or not |
372 | newMail.read = mailconf->readBoolEntry("mailread"); | 370 | newMail.read = mailconf->readBoolEntry("mailread"); |
373 | 371 | ||
374 | //check if new mail | 372 | //check if new mail |
375 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { | 373 | if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { |
376 | thisMailId = mailIdCount; | 374 | thisMailId = mailIdCount; |
377 | mailIdCount++; | 375 | mailIdCount++; |
378 | 376 | ||
379 | //set server count, so that if the user aborts, the new | 377 | //set server count, so that if the user aborts, the new |
380 | //header is not reloaded | 378 | //header is not reloaded |
381 | if (currentAccount->synchronize) | 379 | if ((currentAccount)&&(currentAccount->synchronize)) |
382 | currentAccount->lastServerMailCount++; | 380 | currentAccount->lastServerMailCount++; |
383 | 381 | ||
384 | mailconf->writeEntry("internalmailid", thisMailId); | 382 | mailconf->writeEntry("internalmailid", thisMailId); |
385 | mailconf->writeEntry("downloaded", newMail.downloaded); | 383 | mailconf->writeEntry("downloaded", newMail.downloaded); |
386 | mailconf->writeEntry("size", (int) newMail.size); | 384 | mailconf->writeEntry("size", (int) newMail.size); |
387 | mailconf->writeEntry("serverid", newMail.serverId); | 385 | mailconf->writeEntry("serverid", newMail.serverId); |
388 | 386 | ||
389 | addressList->addContact(newMail.fromMail, newMail.from); | 387 | //addressList->addContact(newMail.fromMail, newMail.from); |
390 | } else if (!fromDisk) { //body to header arrived | ||
391 | mailconf->writeEntry("downloaded", TRUE); | ||
392 | } | 388 | } |
389 | |||
390 | mailconf->writeEntry("downloaded", newMail.downloaded); | ||
391 | |||
393 | QString stringMailId; | 392 | QString stringMailId; |
394 | stringMailId.setNum(thisMailId); | 393 | stringMailId.setNum(thisMailId); |
395 | //se if any attatchments needs to be stored | 394 | //see if any attatchments needs to be stored |
395 | |||
396 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { | 396 | for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { |
397 | QString stringId; | 397 | QString stringId; |
398 | stringId.setNum(ePtr->id); | 398 | stringId.setNum(ePtr->id); |
399 | 399 | ||
400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); | 400 | int id = mailconf->readNumEntry("enclosureid_" + stringId); |
401 | if (id != ePtr->id) { //new entry | 401 | if (id != ePtr->id) { //new entry |
402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); | 402 | mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); |
403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); | 403 | mailconf->writeEntry("name_" + stringId, ePtr->originalName); |
404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); | 404 | mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); |
405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); | 405 | mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); |
406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 406 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
407 | mailconf->writeEntry("installed_" + stringId, FALSE); | 407 | mailconf->writeEntry("installed_" + stringId, FALSE); |
408 | 408 | ||
409 | ePtr->name = stringMailId + "_" + stringId; | 409 | ePtr->name = stringMailId + "_" + stringId; |
410 | ePtr->path = getPath(TRUE); | 410 | ePtr->path = getPath(TRUE); |
411 | if (emailHandler->getEnclosure(ePtr)) { //file saved | 411 | if (emailHandler->getEnclosure(ePtr)) { //file saved |
412 | ePtr->saved = TRUE; | 412 | ePtr->saved = TRUE; |
413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 413 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); | 414 | mailconf->writeEntry("filename_" + stringId, ePtr->name); |
415 | mailconf->writeEntry("path_" + stringId, ePtr->path); | 415 | mailconf->writeEntry("path_" + stringId, ePtr->path); |
416 | } else { | 416 | } else { |
417 | ePtr->saved = FALSE; | 417 | ePtr->saved = FALSE; |
418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); | 418 | mailconf->writeEntry("saved_" + stringId, ePtr->saved); |
419 | } | 419 | } |
420 | } else { | 420 | } else { |
421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); | 421 | ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); |
422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); | 422 | ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); |
423 | if (ePtr->saved) { | 423 | if (ePtr->saved) { |
424 | ePtr->name = mailconf->readEntry("filename_" + stringId); | 424 | ePtr->name = mailconf->readEntry("filename_" + stringId); |
425 | ePtr->path = mailconf->readEntry("path_" + stringId); | 425 | ePtr->path = mailconf->readEntry("path_" + stringId); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if (!previewingMail && !fromDisk) { | 429 | |
430 | bool found=false; | ||
431 | |||
432 | if (!fromDisk) | ||
433 | { | ||
434 | |||
430 | Email *mailPtr; | 435 | Email *mailPtr; |
431 | item = (EmailListItem *) inboxView->firstChild(); | 436 | item = (EmailListItem *) inboxView->firstChild(); |
432 | while (item != NULL) { | 437 | while ((item != NULL)&&(!found)) |
438 | { | ||
433 | mailPtr = item->getMail(); | 439 | mailPtr = item->getMail(); |
434 | if (mailPtr->id == newMail.id) { | 440 | if (mailPtr->id == newMail.id) { |
435 | item->setMail(newMail); | 441 | item->setMail(newMail); |
436 | emit mailUpdated(item->getMail()); | 442 | emit mailUpdated(item->getMail()); |
443 | found = true; | ||
437 | } | 444 | } |
438 | item = (EmailListItem *) item->nextSibling(); | 445 | item = (EmailListItem *) item->nextSibling(); |
439 | } | 446 | } |
440 | } else { | ||
441 | item = new EmailListItem(inboxView, newMail, TRUE); | ||
442 | if (!newMail.downloaded) | ||
443 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size); | ||
444 | } | 447 | } |
448 | if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE); | ||
449 | |||
450 | /*if (!newMail.downloaded) | ||
451 | mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ | ||
445 | 452 | ||
446 | mailboxView->setCurrentTab(0); | 453 | mailboxView->setCurrentTab(0); |
447 | 454 | ||
448 | } | 455 | } |
449 | 456 | ||
450 | void EmailClient::allMailArrived(int count) | 457 | void EmailClient::allMailArrived(int count) |
451 | { | 458 | { |
452 | // not previewing means all mailtransfer has been done | 459 | // not previewing means all mailtransfer has been done |
453 | if (!previewingMail) { | 460 | /*if (!previewingMail) {*/ |
454 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { | 461 | if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) { |
455 | emit newCaption("Mailit - " + currentAccount->accountName); | 462 | emit newCaption("Mailit - " + currentAccount->accountName); |
456 | getNewMail(); | 463 | getNewMail(); |
457 | return; | 464 | return; |
458 | } else { | 465 | } else { |
459 | allAccounts = FALSE; | 466 | allAccounts = FALSE; |
460 | receiving = FALSE; | 467 | receiving = FALSE; |
461 | getMailButton->setEnabled(TRUE); | 468 | getMailButton->setEnabled(TRUE); |
462 | cancelButton->setEnabled(FALSE); | 469 | cancelButton->setEnabled(FALSE); |
463 | selectAccountMenu->setEnabled(TRUE); | 470 | selectAccountMenu->setEnabled(TRUE); |
464 | status1Label->setText("Idle"); | 471 | status1Label->setText("Idle"); |
465 | 472 | ||
466 | progressBar->reset(); | 473 | progressBar->reset(); |
467 | return; | 474 | return; |
468 | } | 475 | } |
469 | } | 476 | //} |
470 | 477 | ||
471 | // all headers downloaded from server, start downloading remaining mails | 478 | // all headers downloaded from server, start downloading remaining mails |
472 | previewingMail = FALSE; | 479 | previewingMail = FALSE; |
473 | status1Label->setText(currentAccount->accountName); | 480 | status1Label->setText(currentAccount->accountName); |
474 | progressBar->reset(); | 481 | progressBar->reset(); |
475 | 482 | ||
476 | emailHandler->getMailByList(&mailDownloadList); | 483 | //emailHandler->getMailByList(&mailDownloadList); |
477 | 484 | ||
478 | mailboxView->setCurrentTab(0); | 485 | mailboxView->setCurrentTab(0); |
479 | } | 486 | } |
480 | 487 | ||
481 | void EmailClient::moveMailFront(Email *mailPtr) | 488 | void EmailClient::moveMailFront(Email *mailPtr) |
482 | { | 489 | { |
483 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 490 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
484 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 491 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
485 | } | 492 | } |
486 | } | 493 | } |
487 | 494 | ||
488 | void EmailClient::smtpError(int code) | 495 | void EmailClient::smtpError(int code) |
489 | { | 496 | { |
490 | QString temp; | 497 | QString temp; |
491 | 498 | ||
492 | if (code == ErrUnknownResponse) | 499 | if (code == ErrUnknownResponse) |
493 | temp = "Unknown response from server"; | 500 | temp = "Unknown response from server"; |
494 | 501 | ||
495 | if (code == QSocket::ErrHostNotFound) | 502 | if (code == QSocket::ErrHostNotFound) |
496 | temp = "host not found"; | 503 | temp = "host not found"; |
497 | if (code == QSocket::ErrConnectionRefused) | 504 | if (code == QSocket::ErrConnectionRefused) |
498 | temp = "connection refused"; | 505 | temp = "connection refused"; |
499 | if (code == QSocket::ErrSocketRead) | 506 | if (code == QSocket::ErrSocketRead) |
500 | temp = "socket packet error"; | 507 | temp = "socket packet error"; |
501 | 508 | ||
502 | if (code != ErrCancel) { | 509 | if (code != ErrCancel) { |
503 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 510 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
504 | } else { | 511 | } else { |
505 | status2Label->setText("Aborted by user"); | 512 | status2Label->setText("Aborted by user"); |
506 | } | 513 | } |
507 | 514 | ||
508 | sending = FALSE; | 515 | sending = FALSE; |
509 | sendMailButton->setEnabled(TRUE); | 516 | sendMailButton->setEnabled(TRUE); |
510 | cancelButton->setEnabled(FALSE); | 517 | cancelButton->setEnabled(FALSE); |
511 | quedMessages.clear(); | 518 | quedMessages.clear(); |
512 | } | 519 | } |
513 | 520 | ||
514 | void EmailClient::popError(int code) | 521 | void EmailClient::popError(int code) |
515 | { | 522 | { |
516 | QString temp; | 523 | QString temp; |
517 | 524 | ||
518 | if (code == ErrUnknownResponse) | 525 | if (code == ErrUnknownResponse) |
519 | temp = "Unknown response from server"; | 526 | temp = "Unknown response from server"; |
520 | if (code == ErrLoginFailed) | 527 | if (code == ErrLoginFailed) |
521 | temp = "Login failed\nCheck user name and password"; | 528 | temp = "Login failed\nCheck user name and password"; |
522 | 529 | ||
523 | if (code == QSocket::ErrHostNotFound) | 530 | if (code == QSocket::ErrHostNotFound) |
524 | temp = "host not found"; | 531 | temp = "host not found"; |
525 | if (code == QSocket::ErrConnectionRefused) | 532 | if (code == QSocket::ErrConnectionRefused) |
526 | temp = "connection refused"; | 533 | temp = "connection refused"; |
527 | if (code == QSocket::ErrSocketRead) | 534 | if (code == QSocket::ErrSocketRead) |
528 | temp = "socket packet error"; | 535 | temp = "socket packet error"; |
529 | 536 | ||
530 | if (code != ErrCancel) { | 537 | if (code != ErrCancel) { |
531 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 538 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
532 | } else { | 539 | } else { |
533 | status2Label->setText("Aborted by user"); | 540 | status2Label->setText("Aborted by user"); |
534 | } | 541 | } |
535 | 542 | ||
536 | receiving = FALSE; | 543 | receiving = FALSE; |
537 | getMailButton->setEnabled(TRUE); | 544 | getMailButton->setEnabled(TRUE); |
538 | cancelButton->setEnabled(FALSE); | 545 | cancelButton->setEnabled(FALSE); |
539 | selectAccountMenu->setEnabled(TRUE); | 546 | selectAccountMenu->setEnabled(TRUE); |
540 | } | 547 | } |
541 | 548 | ||
542 | void EmailClient::inboxItemSelected() | 549 | void EmailClient::inboxItemSelected() |
543 | { | 550 | { |
544 | killTimer(timerID); | 551 | //killTimer(timerID); |
545 | 552 | ||
546 | item = (EmailListItem*) inboxView->selectedItem(); | 553 | item = (EmailListItem*) inboxView->selectedItem(); |
547 | if (item != NULL) { | 554 | if (item != NULL) { |
548 | emit viewEmail(inboxView, item->getMail()); | 555 | emit viewEmail(inboxView, item->getMail()); |
549 | } | 556 | } |
550 | } | 557 | } |
551 | 558 | ||
552 | void EmailClient::outboxItemSelected() | 559 | void EmailClient::outboxItemSelected() |
553 | { | 560 | { |
554 | killTimer(timerID); | 561 | //killTimer(timerID); |
555 | 562 | ||
556 | item = (EmailListItem*) outboxView->selectedItem(); | 563 | item = (EmailListItem*) outboxView->selectedItem(); |
557 | if (item != NULL) { | 564 | if (item != NULL) { |
558 | emit viewEmail(outboxView, item->getMail()); | 565 | emit viewEmail(outboxView, item->getMail()); |
559 | } | 566 | } |
560 | 567 | ||
561 | } | 568 | } |
562 | 569 | ||
563 | void EmailClient::readMail() | 570 | void EmailClient::readMail() |
564 | { | 571 | { |
565 | Email mail; | 572 | Email mail; |
566 | int start, stop; | 573 | int start, stop; |
567 | QString s, del; | 574 | QString s, del; |
568 | 575 | ||
569 | QFile f(getPath(FALSE) + "inbox.txt"); | 576 | QFile f(getPath(FALSE) + "inbox.txt"); |
570 | // QFileInfo fi(f); | 577 | |
571 | //qDebug( f.name()); | ||
572 | |||
573 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 578 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
574 | QTextStream t( &f ); // use a text stream | 579 | QTextStream t( &f ); // use a text stream |
575 | s = t.read(); | 580 | s = t.read(); |
576 | f.close(); | 581 | f.close(); |
577 | 582 | ||
578 | start = 0; | 583 | start = 0; |
579 | del = "\n.\n"; | 584 | del = "\n.\n"; |
580 | while ((uint) start < s.length()) { | 585 | while ((uint) start < s.length()) { |
581 | stop = s.find(del, start); | 586 | stop = s.find(del, start); |
582 | if (stop == -1) | 587 | if (stop == -1) |
583 | stop = s.length() - del.length(); | 588 | stop = s.length() - del.length(); |
584 | 589 | ||
585 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 590 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
586 | start = stop + del.length(); | 591 | start = stop + del.length(); |
587 | mailArrived(mail, TRUE); | 592 | mailArrived(mail, TRUE); |
588 | } | 593 | } |
589 | } | 594 | } |
590 | 595 | ||
591 | QFile fo(getPath(FALSE) + "outbox.txt"); | 596 | QFile fo(getPath(FALSE) + "outbox.txt"); |
592 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 597 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
593 | QTextStream t( &fo ); // use a text stream | 598 | QTextStream t( &fo ); // use a text stream |
594 | s = t.read(); | 599 | s = t.read(); |
595 | fo.close(); | 600 | fo.close(); |
596 | 601 | ||
597 | start = 0; | 602 | start = 0; |
598 | del = "\n.\n"; | 603 | del = "\n.\n"; |
599 | while ((uint) start < s.length()) { | 604 | while ((uint) start < s.length()) { |
600 | stop = s.find(del, start); | 605 | stop = s.find(del, start); |
601 | if (stop == -1) | 606 | if (stop == -1) |
602 | stop = s.length() - del.length(); | 607 | stop = s.length() - del.length(); |
603 | 608 | ||
604 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 609 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
605 | start = stop + del.length(); | 610 | start = stop + del.length(); |
606 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 611 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
607 | mail.sent = false; | 612 | mail.sent = false; |
608 | mail.received = false; | 613 | mail.received = false; |
609 | enqueMail(mail); | 614 | enqueMail(mail); |
610 | 615 | ||
611 | } | 616 | } |
612 | } | 617 | } |
613 | } | 618 | } |
614 | 619 | ||
615 | void EmailClient::saveMail(QString fileName, QListView *view) | 620 | void EmailClient::saveMail(QString fileName, QListView *view) |
616 | { | 621 | { |
617 | QFile f(fileName); | 622 | QFile f(fileName); |
618 | Email *mail; | 623 | Email *mail; |
619 | 624 | ||
620 | if (! f.open(IO_WriteOnly) ) { | 625 | if (! f.open(IO_WriteOnly) ) { |
621 | qWarning("could not open file"); | 626 | qWarning("could not open file"); |
622 | return; | 627 | return; |
623 | } | 628 | } |
624 | item = (EmailListItem *) view->firstChild(); | 629 | item = (EmailListItem *) view->firstChild(); |
625 | //qDebug (QString("Write : ") ); | ||
626 | QTextStream t(&f); | 630 | QTextStream t(&f); |
627 | while (item != NULL) { | 631 | while (item != NULL) { |
628 | mail = item->getMail(); | 632 | mail = item->getMail(); |
629 | //qDebug(mail->rawMail); | ||
630 | //qDebug(mail->recipients.first()); | ||
631 | t << mail->rawMail; | 633 | t << mail->rawMail; |
632 | 634 | ||
633 | mailconf->setGroup(mail->id); | 635 | mailconf->setGroup(mail->id); |
634 | mailconf->writeEntry("mailread", mail->read); | 636 | mailconf->writeEntry("mailread", mail->read); |
635 | 637 | ||
636 | item = (EmailListItem *) item->nextSibling(); | 638 | item = (EmailListItem *) item->nextSibling(); |
637 | } | 639 | } |
638 | f.close(); | 640 | f.close(); |
639 | } | 641 | } |
640 | 642 | ||
641 | //paths for mailit, is settings, inbox, enclosures | 643 | //paths for mailit, is settings, inbox, enclosures |
642 | QString EmailClient::getPath(bool enclosurePath) | 644 | QString EmailClient::getPath(bool enclosurePath) |
643 | { | 645 | { |
644 | QString basePath = "qtmail"; | 646 | QString basePath = "qtmail"; |
645 | QString enclosures = "enclosures"; | 647 | QString enclosures = "enclosures"; |
646 | 648 | ||
647 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 649 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
648 | if ( !dir.exists() ) | 650 | if ( !dir.exists() ) |
649 | dir.mkdir( dir.path() ); | 651 | dir.mkdir( dir.path() ); |
650 | 652 | ||
651 | if (enclosurePath) { | 653 | if (enclosurePath) { |
652 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 654 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
653 | 655 | ||
654 | if ( !dir.exists() ) | 656 | if ( !dir.exists() ) |
655 | dir.mkdir( dir.path() ); | 657 | dir.mkdir( dir.path() ); |
656 | 658 | ||
657 | return (dir.path() + "/"); | 659 | return (dir.path() + "/"); |
658 | 660 | ||
659 | } | 661 | } |
660 | return (dir.path() + "/"); | 662 | return (dir.path() + "/"); |
661 | } | 663 | } |
662 | 664 | ||
663 | void EmailClient::readSettings() | 665 | void EmailClient::readSettings() |
664 | { | 666 | { |
665 | TextParser *p; | 667 | int y,acc_count, accountPos=0; |
666 | QString s; | ||
667 | int pos, accountPos, y; | ||
668 | QFile f( getPath(FALSE) + "settings.txt"); | ||
669 | |||
670 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
671 | QTextStream t( &f ); // use a text stream | ||
672 | s = t.read(); | ||
673 | f.close(); | ||
674 | 668 | ||
675 | p = new TextParser(s, "\n"); | 669 | mailconf->setGroup("mailitglobal"); |
676 | 670 | acc_count=mailconf->readNumEntry("Accounts",0); | |
677 | accountPos = 0; | ||
678 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | ||
679 | accountPos++; | ||
680 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | ||
681 | account.accountName = p->getString(& ++pos, 'z', TRUE); | ||
682 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | ||
683 | account.name = p->getString(& ++pos, 'z', TRUE); | ||
684 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | ||
685 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | ||
686 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | ||
687 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | ||
688 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | ||
689 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | ||
690 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | ||
691 | account.popServer = p->getString(& ++pos, 'z', TRUE); | ||
692 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | ||
693 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | ||
694 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | ||
695 | s = p->getString(& ++pos, 'z', TRUE); | ||
696 | account.id = s.toInt(); | ||
697 | } | ||
698 | 671 | ||
672 | for (int accountPos = 0;accountPos<acc_count ; accountPos++) | ||
673 | { | ||
674 | mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... | ||
675 | account.accountName = mailconf->readEntry("AccName",""); | ||
676 | account.name = mailconf->readEntry("UserName",""); | ||
677 | account.emailAddress = mailconf->readEntry("Email",""); | ||
678 | account.popUserName = mailconf->readEntry("POPUser",""); | ||
679 | account.popPasswd = mailconf->readEntryCrypt("POPPassword",""); | ||
680 | account.popServer = mailconf->readEntry("POPServer",""); | ||
681 | account.smtpServer = mailconf->readEntry("SMTPServer",""); | ||
682 | account.id = mailconf->readNumEntry("AccountId",0); | ||
683 | account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); | ||
699 | account.lastServerMailCount = 0; | 684 | account.lastServerMailCount = 0; |
700 | account.synchronize = FALSE; | 685 | account.synchronize = FALSE; |
701 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 686 | |
702 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 687 | account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); |
703 | account.synchronize = TRUE; | 688 | if (account.synchronize) |
704 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 689 | { |
705 | s = p->getString(& ++pos, 'z', TRUE); | 690 | mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); |
706 | account.lastServerMailCount = s.toInt(); | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | |||
711 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | ||
712 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | ||
713 | } | 691 | } |
714 | |||
715 | 692 | ||
716 | accountList.append(&account); | 693 | accountList.append(&account); |
717 | } | 694 | } |
718 | delete p; | 695 | |
719 | } | ||
720 | mailconf->setGroup("mailitglobal"); | 696 | mailconf->setGroup("mailitglobal"); |
721 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 697 | |
698 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) | ||
699 | { | ||
722 | mailIdCount = y; | 700 | mailIdCount = y; |
723 | } | 701 | } |
724 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 702 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) |
703 | { | ||
725 | accountIdCount = y; | 704 | accountIdCount = y; |
726 | } | 705 | } |
727 | } | 706 | } |
728 | 707 | ||
729 | void EmailClient::saveSettings() | 708 | void EmailClient::saveSettings() |
730 | { | 709 | { |
731 | 710 | int acc_count=0; | |
732 | QString temp; | ||
733 | QFile f( getPath(FALSE) + "settings.txt"); | ||
734 | MailAccount *accountPtr; | 711 | MailAccount *accountPtr; |
735 | 712 | ||
736 | if (! f.open(IO_WriteOnly) ) { | 713 | |
737 | qWarning("could not save settings file"); | 714 | if (!mailconf) |
715 | { | ||
716 | qWarning("could not save settings"); | ||
738 | return; | 717 | return; |
739 | } | 718 | } |
740 | QTextStream t(&f); | ||
741 | t << "#Settings for OPIE Mailit program\n"; | ||
742 | 719 | ||
743 | for (accountPtr = accountList.first(); accountPtr != 0; | 720 | for (accountPtr = accountList.first(); accountPtr != 0; |
744 | accountPtr = accountList.next()) { | 721 | accountPtr = accountList.next()) |
745 | 722 | { | |
746 | t << "accountStart;\n"; | 723 | mailconf->setGroup("Account_"+QString::number(++acc_count)); |
747 | t << "AccountName: " + accountPtr->accountName + "\n"; | 724 | mailconf->writeEntry("AccName",accountPtr->accountName ); |
748 | t << "Name: " + accountPtr->name + "\n"; | 725 | mailconf->writeEntry("UserName",accountPtr->name); |
749 | t << "Email: " + accountPtr->emailAddress + "\n"; | 726 | mailconf->writeEntry("Email",accountPtr->emailAddress); |
750 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 727 | mailconf->writeEntry("POPUser",accountPtr->popUserName); |
751 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 728 | mailconf->writeEntryCrypt("POPPassword",accountPtr->popPasswd); |
752 | t << "POPServer: " + accountPtr->popServer + "\n"; | 729 | mailconf->writeEntry("POPServer",accountPtr->popServer); |
753 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 730 | mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); |
754 | t << "AccountId: " << accountPtr->id << "\n"; | 731 | mailconf->writeEntry("AccountId",accountPtr->id); |
755 | if (accountPtr->synchronize) { | 732 | if (accountPtr->synchronize) |
756 | t << "Synchronize: Yes\n"; | 733 | { |
757 | t << "LastServerMailCount: "; | 734 | mailconf->writeEntry("Synchronize","Yes"); |
758 | t << accountPtr->lastServerMailCount << "\n"; | 735 | mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); |
759 | } else { | 736 | mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); |
760 | t << "Synchronize: No\n"; | 737 | } |
738 | else | ||
739 | { | ||
740 | mailconf->writeEntry("Synchronize", "No"); | ||
761 | } | 741 | } |
762 | t << "SyncLimit: "; | ||
763 | t << accountPtr->syncLimit << "\n"; | ||
764 | t << "accountEnd;\n"; | ||
765 | } | 742 | } |
766 | f.close(); | ||
767 | 743 | ||
768 | mailconf->setGroup("mailitglobal"); | 744 | mailconf->setGroup("mailitglobal"); |
745 | mailconf->writeEntry("Accounts",acc_count); | ||
769 | mailconf->writeEntry("mailidcount", mailIdCount); | 746 | mailconf->writeEntry("mailidcount", mailIdCount); |
770 | mailconf->writeEntry("accountidcount", accountIdCount); | 747 | mailconf->writeEntry("accountidcount", accountIdCount); |
771 | } | 748 | } |
772 | 749 | ||
773 | void EmailClient::selectAccount(int id) | 750 | void EmailClient::selectAccount(int id) |
774 | { | 751 | { |
775 | if (accountList.count() > 0) { | 752 | if (accountList.count() > 0) { |
776 | currentAccount = accountList.at(id); | 753 | currentAccount = accountList.at(id); |
777 | emit newCaption("Mailit - " + currentAccount->accountName); | 754 | emit newCaption("Mailit - " + currentAccount->accountName); |
778 | getNewMail(); | 755 | getNewMail(); |
779 | } else { | 756 | } else { |
780 | emit newCaption("Mailit ! No account defined"); | 757 | emit newCaption("Mailit ! No account defined"); |
781 | } | 758 | } |
782 | } | 759 | } |
783 | 760 | ||
784 | void EmailClient::editAccount(int id) | 761 | void EmailClient::editAccount(int id) |
785 | { | 762 | { |
786 | MailAccount *newAccount; | 763 | MailAccount *newAccount; |
787 | 764 | ||
788 | editAccountView = new EditAccount(this, "account", TRUE); | 765 | editAccountView = new EditAccount(this, "account", TRUE); |
789 | if (id == newAccountId) { //new account | 766 | if (id == newAccountId) { //new account |
790 | newAccount = new MailAccount; | 767 | newAccount = new MailAccount; |
791 | editAccountView->setAccount(newAccount); | 768 | editAccountView->setAccount(newAccount); |
792 | } else { | 769 | } else { |
793 | newAccount = accountList.at(id); | 770 | newAccount = accountList.at(id); |
794 | editAccountView->setAccount(newAccount, FALSE); | 771 | editAccountView->setAccount(newAccount, FALSE); |
795 | } | 772 | } |
796 | 773 | ||
797 | editAccountView->showMaximized(); | 774 | editAccountView->showMaximized(); |
798 | editAccountView->exec(); | 775 | editAccountView->exec(); |
799 | 776 | ||
800 | if (editAccountView->result() == QDialog::Accepted) { | 777 | if (editAccountView->result() == QDialog::Accepted) { |
801 | if (id == newAccountId) { | 778 | if (id == newAccountId) { |
802 | newAccount->id = accountIdCount; | 779 | newAccount->id = accountIdCount; |
803 | accountIdCount++; | 780 | accountIdCount++; |
804 | accountList.append(newAccount); | 781 | accountList.append(newAccount); |
805 | updateAccounts(); | 782 | updateAccounts(); |
806 | } else { | 783 | } else { |
807 | updateAccounts(); | 784 | updateAccounts(); |
808 | } | 785 | } |
809 | } | 786 | } |
810 | 787 | ||
811 | delete editAccountView; | 788 | delete editAccountView; |
812 | } | 789 | } |
813 | 790 | ||
814 | void EmailClient::deleteAccount(int id) | 791 | void EmailClient::deleteAccount(int id) |
815 | { | 792 | { |
816 | MailAccount *newAccount; | 793 | MailAccount *newAccount; |
817 | QString message; | 794 | QString message; |
818 | 795 | ||
819 | newAccount = accountList.at(id); | 796 | newAccount = accountList.at(id); |
820 | message = "Delete account:\n" + newAccount->accountName; | 797 | message = "Delete account:\n" + newAccount->accountName; |
821 | switch( QMessageBox::warning( this, "Mailit", message, | 798 | switch( QMessageBox::warning( this, "Mailit", message, |
822 | "Yes", "No", 0, 0, 1 ) ) { | 799 | "Yes", "No", 0, 0, 1 ) ) { |
823 | 800 | ||
824 | case 0: accountList.remove(id); | 801 | case 0: accountList.remove(id); |
825 | updateAccounts(); | 802 | updateAccounts(); |
826 | break; | 803 | break; |
827 | case 1: | 804 | case 1: |
828 | break; | 805 | break; |
829 | } | 806 | } |
830 | } | 807 | } |
831 | 808 | ||
832 | void EmailClient::updateAccounts() | 809 | void EmailClient::updateAccounts() |
833 | { | 810 | { |
834 | MailAccount *accountPtr; | 811 | MailAccount *accountPtr; |
835 | 812 | ||
836 | //rebuild menus, clear all first | 813 | //rebuild menus, clear all first |
837 | editAccountMenu->clear(); | 814 | editAccountMenu->clear(); |
838 | selectAccountMenu->clear(); | 815 | selectAccountMenu->clear(); |
839 | deleteAccountMenu->clear(); | 816 | deleteAccountMenu->clear(); |
840 | 817 | ||
841 | newAccountId = editAccountMenu->insertItem("New", this, | 818 | newAccountId = editAccountMenu->insertItem("New", this, |
842 | SLOT(editAccount(int)) ); | 819 | SLOT(editAccount(int)) ); |
843 | editAccountMenu->insertSeparator(); | 820 | editAccountMenu->insertSeparator(); |
844 | 821 | ||
845 | idCount = 0; | 822 | idCount = 0; |
846 | for (accountPtr = accountList.first(); accountPtr != 0; | 823 | for (accountPtr = accountList.first(); accountPtr != 0; |
847 | accountPtr = accountList.next()) { | 824 | accountPtr = accountList.next()) { |
848 | 825 | ||
849 | editAccountMenu->insertItem(accountPtr->accountName, | 826 | editAccountMenu->insertItem(accountPtr->accountName, |
850 | this, SLOT(editAccount(int)), 0, idCount); | 827 | this, SLOT(editAccount(int)), 0, idCount); |
851 | selectAccountMenu->insertItem(accountPtr->accountName, | 828 | selectAccountMenu->insertItem(accountPtr->accountName, |
852 | this, SLOT(selectAccount(int)), 0, idCount); | 829 | this, SLOT(selectAccount(int)), 0, idCount); |
853 | deleteAccountMenu->insertItem(accountPtr->accountName, | 830 | deleteAccountMenu->insertItem(accountPtr->accountName, |
854 | this, SLOT(deleteAccount(int)), 0, idCount); | 831 | this, SLOT(deleteAccount(int)), 0, idCount); |
855 | idCount++; | 832 | idCount++; |
856 | } | 833 | } |
857 | } | 834 | } |
858 | 835 | ||
859 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) | 836 | void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) |
860 | { | 837 | { |
861 | Email *mPtr; | 838 | Email *mPtr; |
862 | Enclosure *ePtr; | 839 | Enclosure *ePtr; |
863 | 840 | ||
864 | if (inbox) | 841 | if (inbox) |
865 | { | 842 | { |
866 | mPtr = mailItem->getMail(); | 843 | mPtr = mailItem->getMail(); |
867 | 844 | ||
868 | //if mail is in queue for download, remove it from | 845 | //if mail is in queue for download, remove it from |
869 | //queue if possible | 846 | //queue if possible |
870 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { | 847 | if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { |
871 | if ( !mPtr->downloaded ) | 848 | if ( !mPtr->downloaded ) |
872 | mailDownloadList.remove(mPtr->serverId, mPtr->size); | 849 | mailDownloadList.remove(mPtr->serverId, mPtr->size); |
873 | } | 850 | } |
874 | 851 | ||
875 | mailconf->setGroup(mPtr->id); | 852 | mailconf->setGroup(mPtr->id); |
876 | mailconf->clearGroup(); | 853 | mailconf->clearGroup(); |
877 | 854 | ||
878 | //delete any temporary attatchemnts storing | 855 | //delete any temporary attatchemnts storing |
879 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { | 856 | for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { |
880 | if (ePtr->saved) { | 857 | if (ePtr->saved) { |
881 | QFile::remove( (ePtr->path + ePtr->name) ); | 858 | QFile::remove( (ePtr->path + ePtr->name) ); |
882 | } | 859 | } |
883 | } | 860 | } |
884 | inboxView->takeItem(mailItem); | 861 | inboxView->takeItem(mailItem); |
885 | } | 862 | } |
886 | else | 863 | else |
887 | { | 864 | { |
888 | outboxView->takeItem(mailItem); | 865 | outboxView->takeItem(mailItem); |
889 | } | 866 | } |
890 | } | 867 | } |
891 | 868 | ||
892 | void EmailClient::setMailSize(int size) | 869 | void EmailClient::setMailSize(int size) |
893 | { | 870 | { |
894 | progressBar->reset(); | 871 | progressBar->reset(); |
895 | progressBar->setTotalSteps(size); | 872 | progressBar->setTotalSteps(size); |
896 | } | 873 | } |
897 | 874 | ||
898 | void EmailClient::setTotalSize(int size) | 875 | void EmailClient::setTotalSize(int size) |
899 | { | 876 | { |
900 | 877 | ||
901 | } | 878 | } |
902 | 879 | ||
903 | void EmailClient::setDownloadedSize(int size) | 880 | void EmailClient::setDownloadedSize(int size) |
904 | { | 881 | { |
905 | int total = progressBar->totalSteps(); | 882 | int total = progressBar->totalSteps(); |
906 | 883 | ||
907 | if (size < total) { | 884 | if (size < total) { |
908 | progressBar->setProgress(size); | 885 | progressBar->setProgress(size); |
909 | } else { | 886 | } else { |
910 | progressBar->setProgress(total); | 887 | progressBar->setProgress(total); |
911 | } | 888 | } |
912 | } | 889 | } |
913 | 890 | ||
914 | void EmailClient::deleteItem() | 891 | void EmailClient::deleteItem() |
915 | { | 892 | { |
916 | bool inbox=mailboxView->currentTab()==0; | 893 | bool inbox=mailboxView->currentTab()==0; |
917 | 894 | ||
918 | EmailListItem* eli; | 895 | EmailListItem* eli; |
919 | 896 | ||
920 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); | 897 | inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); |
921 | 898 | ||
922 | if (eli) | 899 | if (eli) |
923 | deleteMail(eli,(bool&)inbox); | 900 | deleteMail(eli,(bool&)inbox); |
924 | } | 901 | } |
925 | 902 | ||
926 | void EmailClient::inboxItemPressed() | 903 | void EmailClient::inboxItemPressed() |
927 | { | 904 | { |
928 | //timerID=startTimer(500); | 905 | //timerID=startTimer(500); |
929 | } | 906 | } |
930 | 907 | ||
931 | void EmailClient::inboxItemReleased() | 908 | void EmailClient::inboxItemReleased() |
932 | { | 909 | { |
933 | //killTimer(timerID); | 910 | //killTimer(timerID); |
934 | } | 911 | } |
935 | 912 | ||
936 | void EmailClient::timerEvent(QTimerEvent *e) | 913 | void EmailClient::timerEvent(QTimerEvent *e) |
937 | { | 914 | { |
938 | /*killTimer(timerID); | 915 | /*killTimer(timerID); |
939 | 916 | ||
940 | 917 | ||
941 | QPopupMenu *action = new QPopupMenu(this); | 918 | QPopupMenu *action = new QPopupMenu(this); |
942 | 919 | ||
943 | int reply=0; | 920 | int reply=0; |
944 | 921 | ||
945 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); | 922 | action->insertItem(tr( "Reply To" ),this,SLOT(reply())); |
946 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); | 923 | action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); |
947 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); | 924 | action->insertItem( tr( "Forward" ), this,SLOT(forward())); |
948 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); | 925 | action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); |
949 | 926 | ||
950 | action->exec(QCursor::pos()); | 927 | action->exec(QCursor::pos()); |
951 | 928 | ||
952 | if (action) delete action; | 929 | if (action) delete action; |
953 | */ | 930 | */ |
954 | } | 931 | } |
955 | 932 | ||
956 | Email* EmailClient::getCurrentMail() | 933 | Email* EmailClient::getCurrentMail() |
957 | { | 934 | { |
958 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); | 935 | EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); |
959 | if (eli!=NULL) | 936 | if (eli!=NULL) |
960 | return eli->getMail(); | 937 | return eli->getMail(); |
961 | else | 938 | else |
962 | return NULL; | 939 | return NULL; |
963 | } | 940 | } |
964 | 941 | ||
965 | /* | 942 | /* |
966 | void EmailClient::reply() | 943 | void EmailClient::reply() |
967 | { | 944 | { |
968 | Email* mail=getCurrentMail(); | 945 | Email* mail=getCurrentMail(); |
969 | 946 | ||
970 | if (mail!=NULL) | 947 | if (mail!=NULL) |
971 | { | 948 | { |
972 | emit reply(*mail); | 949 | emit reply(*mail); |
973 | } | 950 | } |
974 | } | 951 | } |
975 | 952 | ||
976 | void EmailClient::replyAll() | 953 | void EmailClient::replyAll() |
977 | { | 954 | { |
978 | Email* mail=getCurrentMail(); | 955 | Email* mail=getCurrentMail(); |
979 | 956 | ||
980 | if (mail!=NULL) | 957 | if (mail!=NULL) |
981 | { | 958 | { |
982 | emit replyAll(*mail); | 959 | emit replyAll(*mail); |
983 | } | 960 | } |
984 | } | 961 | } |
985 | 962 | ||
986 | void EmailClient::forward() | 963 | void EmailClient::forward() |
987 | { | 964 | { |
988 | Email* mail=getCurrentMail(); | 965 | Email* mail=getCurrentMail(); |
989 | 966 | ||
990 | if (mail!=NULL) | 967 | if (mail!=NULL) |
991 | { | 968 | { |
992 | emit reply(*mail); | 969 | emit reply(*mail); |
993 | } | 970 | } |
994 | } | 971 | } |
995 | 972 | ||
996 | void EmailClient::remove() | 973 | void EmailClient::remove() |
997 | { | 974 | { |
998 | Email* mail=getCurrentMail(); | 975 | Email* mail=getCurrentMail(); |
999 | 976 | ||
1000 | if (mail!=NULL) | 977 | if (mail!=NULL) |
1001 | { | 978 | { |
1002 | emit remove(*mail); | 979 | emit remove(*mail); |
1003 | } | 980 | } |
1004 | }*/ \ No newline at end of file | 981 | }*/ |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index f6c6d60..b180051 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -1,612 +1,628 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qfileinfo.h> | 20 | #include <qfileinfo.h> |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include "emailhandler.h" | 25 | #include "emailhandler.h" |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/filemanager.h> | 27 | #include <qpe/filemanager.h> |
28 | 28 | ||
29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) | 29 | QCollection::Item EnclosureList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (Enclosure *) d); | 31 | return dupl( (Enclosure *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | Enclosure* EnclosureList::dupl(Enclosure *in) | 34 | Enclosure* EnclosureList::dupl(Enclosure *in) |
35 | { | 35 | { |
36 | ac = new Enclosure(*in); | 36 | ac = new Enclosure(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailHandler::EmailHandler() | 40 | EmailHandler::EmailHandler() |
41 | { | 41 | { |
42 | smtpClient = new SmtpClient(); | 42 | smtpClient = new SmtpClient(); |
43 | popClient = new PopClient(); | 43 | popClient = new PopClient(); |
44 | 44 | ||
45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, | 45 | connect(smtpClient, SIGNAL(errorOccurred(int)), this, |
46 | SIGNAL(smtpError(int)) ); | 46 | SIGNAL(smtpError(int)) ); |
47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); | 47 | connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); |
48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, | 48 | connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, |
49 | SIGNAL(updateSmtpStatus(const QString &)) ); | 49 | SIGNAL(updateSmtpStatus(const QString &)) ); |
50 | 50 | ||
51 | connect(popClient, SIGNAL(errorOccurred(int)), this, | 51 | connect(popClient, SIGNAL(errorOccurred(int)), this, |
52 | SIGNAL(popError(int)) ); | 52 | SIGNAL(popError(int)) ); |
53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), | 53 | connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)), |
54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); | 54 | this, SLOT(messageArrived(const QString &, int, uint, bool)) ); |
55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, | 55 | connect(popClient, SIGNAL(updateStatus(const QString &)), this, |
56 | SIGNAL(updatePopStatus(const QString &)) ); | 56 | SIGNAL(updatePopStatus(const QString &)) ); |
57 | connect(popClient, SIGNAL(mailTransfered(int)), this, | 57 | connect(popClient, SIGNAL(mailTransfered(int)), this, |
58 | SIGNAL(mailTransfered(int)) ); | 58 | SIGNAL(mailTransfered(int)) ); |
59 | 59 | ||
60 | 60 | ||
61 | //relaying size information | 61 | //relaying size information |
62 | connect(popClient, SIGNAL(currentMailSize(int)), | 62 | connect(popClient, SIGNAL(currentMailSize(int)), |
63 | this, SIGNAL(currentMailSize(int)) ); | 63 | this, SIGNAL(currentMailSize(int)) ); |
64 | connect(popClient, SIGNAL(downloadedSize(int)), | 64 | connect(popClient, SIGNAL(downloadedSize(int)), |
65 | this, SIGNAL(downloadedSize(int)) ); | 65 | this, SIGNAL(downloadedSize(int)) ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void EmailHandler::sendMail(QList<Email> *mailList) | 68 | void EmailHandler::sendMail(QList<Email> *mailList) |
69 | { | 69 | { |
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | //popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize(); |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | ||
116 | } else { | ||
117 | popClient->removeSynchronize(); | ||
118 | } | ||
119 | 115 | ||
120 | headers = TRUE; | 116 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 117 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 118 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 119 | } |
124 | 120 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 121 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 122 | { |
127 | if (mailList->count() == 0) { //should not occur though | 123 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 124 | emit mailTransfered(0); |
129 | return; | 125 | return; |
130 | } | 126 | } |
131 | 127 | ||
132 | headers = FALSE; | 128 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 129 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 130 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 131 | popClient->setSelectedMails(mailList); |
136 | } | 132 | } |
137 | 133 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 134 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete) |
139 | { | 135 | { |
140 | Email mail; | 136 | Email mail; |
141 | 137 | ||
142 | mail.rawMail = message; | 138 | mail.rawMail = message; |
143 | mail.serverId = id; | 139 | mail.serverId = id; |
144 | mail.size = size; | 140 | mail.size = size; |
145 | mail.downloaded = complete; | 141 | mail.downloaded = incomplete; |
146 | 142 | ||
147 | emit mailArrived(mail, FALSE); | 143 | emit mailArrived(mail, FALSE); |
148 | } | 144 | } |
149 | 145 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 146 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 147 | { |
152 | QString temp, boundary; | 148 | QString temp, boundary; |
153 | int pos; | 149 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 150 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 151 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 152 | QString fileName, storedName; |
157 | int enclosureId = 0; | 153 | int enclosureId = 0; |
158 | 154 | ||
159 | mail->rawMail = in; | 155 | mail->rawMail = in; |
160 | mail->received = TRUE; | 156 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 157 | mail->files.setAutoDelete(TRUE); |
162 | 158 | ||
163 | temp = lineShift + "." + lineShift; | 159 | temp = lineShift + "." + lineShift; |
164 | 160 | ||
165 | if (in.right(temp.length()) != temp) { | 161 | if (in.right(temp.length()) != temp) { |
166 | mail->rawMail += temp; | 162 | mail->rawMail += temp; |
167 | } | 163 | } |
168 | 164 | ||
169 | 165 | ||
170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 166 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
171 | pos = in.find(delimiter, 0, FALSE); | 167 | pos = in.find(delimiter, 0, FALSE); |
172 | header = in.left(pos); | 168 | header = in.left(pos); |
173 | body = in.right(in.length() - pos - delimiter.length()); | 169 | body = in.right(in.length() - pos - delimiter.length()); |
174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 170 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
175 | body.truncate(body.length()-2); | 171 | body.truncate(body.length()-2); |
176 | 172 | ||
177 | TextParser p(header, lineShift); | 173 | TextParser p(header, lineShift); |
178 | 174 | ||
179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 175 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
180 | pos++; | 176 | pos++; |
181 | if (p.separatorAt(pos) == ' ') { | 177 | if (p.separatorAt(pos) == ' ') { |
182 | mail->from = p.getString(&pos, '<', false); | 178 | mail->from = p.getString(&pos, '<', false); |
183 | mail->from = mail->from.stripWhiteSpace(); | 179 | mail->from = mail->from.stripWhiteSpace(); |
184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 180 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
185 | mail->from = mail->from.left(mail->from.length() - 1); | 181 | mail->from = mail->from.left(mail->from.length() - 1); |
186 | mail->from = mail->from.right(mail->from.length() - 1); | 182 | mail->from = mail->from.right(mail->from.length() - 1); |
187 | } | 183 | } |
188 | pos++; | 184 | pos++; |
185 | |||
189 | mail->fromMail = p.getString(&pos, '>', false); | 186 | mail->fromMail = p.getString(&pos, '>', false); |
190 | } else { | 187 | } else { |
191 | if ((p.separatorAt(pos) == '<') | 188 | if ((p.separatorAt(pos) == '<') |
192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 189 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
193 | pos++; | 190 | pos++; |
194 | pos++; | 191 | pos++; |
195 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 192 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 193 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
197 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 194 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
198 | mail->from=mail->fromMail; | 195 | mail->from=mail->fromMail; |
199 | } | 196 | } |
200 | } | 197 | } |
201 | 198 | ||
202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 199 | pos=0; |
203 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) | 200 | |
201 | //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: | ||
202 | while((pos = p.find("TO",':', pos+1, TRUE))!=-1) | ||
204 | { | 203 | { |
205 | pos++; | 204 | QString rec; |
206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 205 | |
206 | if (p.separatorAt(pos-1)!='-') | ||
207 | { | ||
208 | pos++; | ||
209 | mail->recipients.append(p.getString(&pos, '\r', TRUE)); | ||
210 | } | ||
211 | /*else { | ||
212 | if ((p.separatorAt(pos) == '<')|| (p.separatorAt(pos) == ' ')) //No name.. nasty | ||
213 | pos++; | ||
214 | pos++; | ||
215 | mail->fromMail = p.getString(&pos, 'z', TRUE); | ||
216 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | ||
217 | mail->fromMail.truncate(mail->fromMail.length() - 1); | ||
218 | mail->from=mail->fromMail; | ||
219 | } | ||
220 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | ||
221 | }*/ | ||
207 | } | 222 | } |
208 | 223 | // | |
209 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 224 | //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); |
225 | |||
210 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) | 226 | if ((pos = p.find("CC",':', 0, TRUE)) != -1) |
211 | { | 227 | { |
212 | pos++; | 228 | pos++; |
213 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); | 229 | mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); |
214 | } | 230 | } |
215 | 231 | ||
216 | |||
217 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 232 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
218 | pos++; | 233 | pos++; |
219 | mail->subject = p.getString(&pos, 'z', TRUE); | 234 | mail->subject = p.getString(&pos, 'z', TRUE); |
220 | } | 235 | } |
236 | |||
221 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 237 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
222 | pos++; | 238 | pos++; |
223 | mail->date = p.getString(&pos, 'z', true); | 239 | mail->date = p.getString(&pos, 'z', TRUE); |
224 | } | 240 | } |
225 | 241 | ||
226 | 242 | ||
227 | 243 | ||
228 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 244 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
229 | pos++; | 245 | pos++; |
230 | if ( (p.wordAt(pos).upper() == "ID") && | 246 | if ( (p.wordAt(pos).upper() == "ID") && |
231 | (p.separatorAt(pos) == ':') ) { | 247 | (p.separatorAt(pos) == ':') ) { |
232 | 248 | ||
233 | id = p.getString(&pos, 'z', TRUE); | 249 | id = p.getString(&pos, 'z', TRUE); |
234 | mail->id = id; | 250 | mail->id = id; |
235 | } | 251 | } |
236 | } | 252 | } |
237 | 253 | ||
238 | pos = 0; | 254 | pos = 0; |
239 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 255 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
240 | pos++; | 256 | pos++; |
241 | if ( (p.wordAt(pos).upper() == "VERSION") && | 257 | if ( (p.wordAt(pos).upper() == "VERSION") && |
242 | (p.separatorAt(pos) == ':') ) { | 258 | (p.separatorAt(pos) == ':') ) { |
243 | pos++; | 259 | pos++; |
244 | if (p.getString(&pos, 'z', true) == "1.0") { | 260 | if (p.getString(&pos, 'z', true) == "1.0") { |
245 | mail->mimeType = 1; | 261 | mail->mimeType = 1; |
246 | } | 262 | } |
247 | } | 263 | } |
248 | } | 264 | } |
249 | 265 | ||
250 | if (mail->mimeType == 1) { | 266 | if (mail->mimeType == 1) { |
251 | boundary = ""; | 267 | boundary = ""; |
252 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 268 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
253 | pos++; | 269 | pos++; |
254 | boundary = p.getString(&pos, 'z', true); | 270 | boundary = p.getString(&pos, 'z', true); |
255 | if (boundary[0] == '"') { | 271 | if (boundary[0] == '"') { |
256 | boundary = boundary.left(boundary.length() - 1); //strip " | 272 | boundary = boundary.left(boundary.length() - 1); //strip " |
257 | boundary = boundary.right(boundary.length() - 1); //strip " | 273 | boundary = boundary.right(boundary.length() - 1); //strip " |
258 | } | 274 | } |
259 | boundary = "--" + boundary; //create boundary field | 275 | boundary = "--" + boundary; //create boundary field |
260 | } | 276 | } |
261 | 277 | ||
262 | if (boundary == "") { //fooled by Mime-Version | 278 | if (boundary == "") { //fooled by Mime-Version |
263 | mail->body = body; | 279 | mail->body = body; |
264 | mail->bodyPlain = body; | 280 | mail->bodyPlain = body; |
265 | return mail; | 281 | return mail; |
266 | } | 282 | } |
267 | 283 | ||
268 | while (body.length() > 0) { | 284 | while (body.length() > 0) { |
269 | pos = body.find(boundary, 0, FALSE); | 285 | pos = body.find(boundary, 0, FALSE); |
270 | pos = body.find(delimiter, pos, FALSE); | 286 | pos = body.find(delimiter, pos, FALSE); |
271 | mimeHeader = body.left(pos); | 287 | mimeHeader = body.left(pos); |
272 | mimeBody = body.right(body.length() - pos - delimiter.length()); | 288 | mimeBody = body.right(body.length() - pos - delimiter.length()); |
273 | TextParser bp(mimeHeader, lineShift); | 289 | TextParser bp(mimeHeader, lineShift); |
274 | 290 | ||
275 | contentType = ""; | 291 | contentType = ""; |
276 | contentAttribute = ""; | 292 | contentAttribute = ""; |
277 | fileName = ""; | 293 | fileName = ""; |
278 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { | 294 | if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { |
279 | pos++; | 295 | pos++; |
280 | if ( (bp.wordAt(pos).upper() == "TYPE") && | 296 | if ( (bp.wordAt(pos).upper() == "TYPE") && |
281 | (bp.separatorAt(pos) == ':') ) { | 297 | (bp.separatorAt(pos) == ':') ) { |
282 | contentType = bp.nextWord().upper(); | 298 | contentType = bp.nextWord().upper(); |
283 | if (bp.nextSeparator() == '/') | 299 | if (bp.nextSeparator() == '/') |
284 | contentAttribute = bp.nextWord().upper(); | 300 | contentAttribute = bp.nextWord().upper(); |
285 | content = contentType + "/" + contentAttribute; | 301 | content = contentType + "/" + contentAttribute; |
286 | } | 302 | } |
287 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { | 303 | if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { |
288 | pos++; | 304 | pos++; |
289 | encoding = bp.getString(&pos, 'z', TRUE); | 305 | encoding = bp.getString(&pos, 'z', TRUE); |
290 | } | 306 | } |
291 | 307 | ||
292 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { | 308 | if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { |
293 | pos++; | 309 | pos++; |
294 | fileName = bp.getString(&pos, 'z', TRUE); | 310 | fileName = bp.getString(&pos, 'z', TRUE); |
295 | fileName = fileName.right(fileName.length() - 1); | 311 | fileName = fileName.right(fileName.length() - 1); |
296 | fileName = fileName.left(fileName.length() - 1); | 312 | fileName = fileName.left(fileName.length() - 1); |
297 | } | 313 | } |
298 | 314 | ||
299 | } | 315 | } |
300 | pos = mimeBody.find(boundary, 0, FALSE); | 316 | pos = mimeBody.find(boundary, 0, FALSE); |
301 | if (pos == -1) //should not occur, malformed mail | 317 | if (pos == -1) //should not occur, malformed mail |
302 | pos = mimeBody.length(); | 318 | pos = mimeBody.length(); |
303 | body = mimeBody.right(mimeBody.length() - pos); | 319 | body = mimeBody.right(mimeBody.length() - pos); |
304 | mimeBody = mimeBody.left(pos); | 320 | mimeBody = mimeBody.left(pos); |
305 | 321 | ||
306 | if (fileName != "") { //attatchments of some type, audio, image etc. | 322 | if (fileName != "") { //attatchments of some type, audio, image etc. |
307 | 323 | ||
308 | Enclosure e; | 324 | Enclosure e; |
309 | e.id = enclosureId; | 325 | e.id = enclosureId; |
310 | e.originalName = fileName; | 326 | e.originalName = fileName; |
311 | e.contentType = contentType; | 327 | e.contentType = contentType; |
312 | e.contentAttribute = contentAttribute; | 328 | e.contentAttribute = contentAttribute; |
313 | e.encoding = encoding; | 329 | e.encoding = encoding; |
314 | e.body = mimeBody; | 330 | e.body = mimeBody; |
315 | e.saved = FALSE; | 331 | e.saved = FALSE; |
316 | mail->addEnclosure(&e); | 332 | mail->addEnclosure(&e); |
317 | enclosureId++; | 333 | enclosureId++; |
318 | 334 | ||
319 | } else if (contentType == "TEXT") { | 335 | } else if (contentType == "TEXT") { |
320 | if (contentAttribute == "PLAIN") { | 336 | if (contentAttribute == "PLAIN") { |
321 | mail->body = mimeBody; | 337 | mail->body = mimeBody; |
322 | mail->bodyPlain = mimeBody; | 338 | mail->bodyPlain = mimeBody; |
323 | } | 339 | } |
324 | if (contentAttribute == "HTML") { | 340 | if (contentAttribute == "HTML") { |
325 | mail->body = mimeBody; | 341 | mail->body = mimeBody; |
326 | } | 342 | } |
327 | } | 343 | } |
328 | } | 344 | } |
329 | } else { | 345 | } else { |
330 | mail->bodyPlain = body; | 346 | mail->bodyPlain = body; |
331 | mail->body = body; | 347 | mail->body = body; |
332 | } | 348 | } |
333 | return TRUE; | 349 | return TRUE; |
334 | } | 350 | } |
335 | 351 | ||
336 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 352 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
337 | { | 353 | { |
338 | QFile f(ePtr->path + ePtr->name); | 354 | QFile f(ePtr->path + ePtr->name); |
339 | char src[4]; | 355 | char src[4]; |
340 | char *destPtr; | 356 | char *destPtr; |
341 | QByteArray buffer; | 357 | QByteArray buffer; |
342 | uint bufCount, pos, decodedCount, size, x; | 358 | uint bufCount, pos, decodedCount, size, x; |
343 | 359 | ||
344 | if (! f.open(IO_WriteOnly) ) { | 360 | if (! f.open(IO_WriteOnly) ) { |
345 | qWarning("could not save: " + ePtr->path + ePtr->name); | 361 | qWarning("could not save: " + ePtr->path + ePtr->name); |
346 | return FALSE; | 362 | return FALSE; |
347 | } | 363 | } |
348 | 364 | ||
349 | if (ePtr->encoding.upper() == "BASE64") { | 365 | if (ePtr->encoding.upper() == "BASE64") { |
350 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 366 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
351 | buffer.resize(size); | 367 | buffer.resize(size); |
352 | bufCount = 0; | 368 | bufCount = 0; |
353 | pos = 0; | 369 | pos = 0; |
354 | destPtr = buffer.data(); | 370 | destPtr = buffer.data(); |
355 | 371 | ||
356 | while (pos < ePtr->body.length()) { | 372 | while (pos < ePtr->body.length()) { |
357 | decodedCount = 4; | 373 | decodedCount = 4; |
358 | x = 0; | 374 | x = 0; |
359 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 375 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
360 | src[x] = ePtr->body[pos].latin1(); | 376 | src[x] = ePtr->body[pos].latin1(); |
361 | pos++; | 377 | pos++; |
362 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 378 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
363 | x--; | 379 | x--; |
364 | x++; | 380 | x++; |
365 | } | 381 | } |
366 | if (x > 1) { | 382 | if (x > 1) { |
367 | decodedCount = parse64base(src, destPtr); | 383 | decodedCount = parse64base(src, destPtr); |
368 | destPtr += decodedCount; | 384 | destPtr += decodedCount; |
369 | bufCount += decodedCount; | 385 | bufCount += decodedCount; |
370 | } | 386 | } |
371 | } | 387 | } |
372 | 388 | ||
373 | buffer.resize(bufCount); //set correct length of file | 389 | buffer.resize(bufCount); //set correct length of file |
374 | f.writeBlock(buffer); | 390 | f.writeBlock(buffer); |
375 | } else { | 391 | } else { |
376 | QTextStream t(&f); | 392 | QTextStream t(&f); |
377 | t << ePtr->body; | 393 | t << ePtr->body; |
378 | } | 394 | } |
379 | return TRUE; | 395 | return TRUE; |
380 | } | 396 | } |
381 | 397 | ||
382 | int EmailHandler::parse64base(char *src, char *bufOut) { | 398 | int EmailHandler::parse64base(char *src, char *bufOut) { |
383 | 399 | ||
384 | char c, z; | 400 | char c, z; |
385 | char li[4]; | 401 | char li[4]; |
386 | int processed; | 402 | int processed; |
387 | 403 | ||
388 | //conversion table withouth table... | 404 | //conversion table withouth table... |
389 | for (int x = 0; x < 4; x++) { | 405 | for (int x = 0; x < 4; x++) { |
390 | c = src[x]; | 406 | c = src[x]; |
391 | 407 | ||
392 | if ( (int) c >= 'A' && (int) c <= 'Z') | 408 | if ( (int) c >= 'A' && (int) c <= 'Z') |
393 | li[x] = (int) c - (int) 'A'; | 409 | li[x] = (int) c - (int) 'A'; |
394 | if ( (int) c >= 'a' && (int) c <= 'z') | 410 | if ( (int) c >= 'a' && (int) c <= 'z') |
395 | li[x] = (int) c - (int) 'a' + 26; | 411 | li[x] = (int) c - (int) 'a' + 26; |
396 | if ( (int) c >= '0' && (int) c <= '9') | 412 | if ( (int) c >= '0' && (int) c <= '9') |
397 | li[x] = (int) c - (int) '0' + 52; | 413 | li[x] = (int) c - (int) '0' + 52; |
398 | if (c == '+') | 414 | if (c == '+') |
399 | li[x] = 62; | 415 | li[x] = 62; |
400 | if (c == '/') | 416 | if (c == '/') |
401 | li[x] = 63; | 417 | li[x] = 63; |
402 | } | 418 | } |
403 | 419 | ||
404 | processed = 1; | 420 | processed = 1; |
405 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 421 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
406 | bufOut[0] <<= 2; | 422 | bufOut[0] <<= 2; |
407 | z = li[1] >> 4; | 423 | z = li[1] >> 4; |
408 | bufOut[0] = bufOut[0] | z; //first byte retrived | 424 | bufOut[0] = bufOut[0] | z; //first byte retrived |
409 | 425 | ||
410 | if (src[2] != '=') { | 426 | if (src[2] != '=') { |
411 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 427 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
412 | bufOut[1] <<= 4; | 428 | bufOut[1] <<= 4; |
413 | z = li[2] >> 2; | 429 | z = li[2] >> 2; |
414 | bufOut[1] = bufOut[1] | z; //second byte retrived | 430 | bufOut[1] = bufOut[1] | z; //second byte retrived |
415 | processed++; | 431 | processed++; |
416 | 432 | ||
417 | if (src[3] != '=') { | 433 | if (src[3] != '=') { |
418 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 434 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
419 | bufOut[2] <<= 6; | 435 | bufOut[2] <<= 6; |
420 | z = li[3]; | 436 | z = li[3]; |
421 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 437 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
422 | processed++; | 438 | processed++; |
423 | } | 439 | } |
424 | } | 440 | } |
425 | return processed; | 441 | return processed; |
426 | } | 442 | } |
427 | 443 | ||
428 | int EmailHandler::encodeMime(Email *mail) | 444 | int EmailHandler::encodeMime(Email *mail) |
429 | { | 445 | { |
430 | 446 | ||
431 | QString fileName, fileType, contentType, newBody, boundary; | 447 | QString fileName, fileType, contentType, newBody, boundary; |
432 | Enclosure *ePtr; | 448 | Enclosure *ePtr; |
433 | 449 | ||
434 | QString userName = mailAccount.name; | 450 | QString userName = mailAccount.name; |
435 | if (userName.length()>0)//only embrace it if there is a user name | 451 | if (userName.length()>0)//only embrace it if there is a user name |
436 | userName += " <" + mailAccount.emailAddress + ">"; | 452 | userName += " <" + mailAccount.emailAddress + ">"; |
437 | 453 | ||
438 | //add standard headers | 454 | //add standard headers |
439 | newBody = "From: " + userName + "\r\nTo: "; | 455 | newBody = "From: " + userName + "\r\nTo: "; |
440 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 456 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
441 | newBody += *it + " "; | 457 | newBody += *it + " "; |
442 | } | 458 | } |
443 | 459 | ||
444 | newBody += "\r\nCC: "; | 460 | newBody += "\r\nCC: "; |
445 | 461 | ||
446 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { | 462 | for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { |
447 | newBody += *it + " "; | 463 | newBody += *it + " "; |
448 | } | 464 | } |
449 | 465 | ||
450 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 466 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
451 | 467 | ||
452 | if (mail->files.count() == 0) { //just a simple mail | 468 | if (mail->files.count() == 0) { //just a simple mail |
453 | newBody += "\r\n" + mail->body; | 469 | newBody += "\r\n" + mail->body; |
454 | mail->rawMail = newBody; | 470 | mail->rawMail = newBody; |
455 | return 0; | 471 | return 0; |
456 | } | 472 | } |
457 | 473 | ||
458 | //Build mime encoded mail | 474 | //Build mime encoded mail |
459 | boundary = "-----4345=next_bound=0495----"; | 475 | boundary = "-----4345=next_bound=0495----"; |
460 | 476 | ||
461 | newBody += "Mime-Version: 1.0\r\n"; | 477 | newBody += "Mime-Version: 1.0\r\n"; |
462 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 478 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
463 | boundary + "\"\r\n\r\n"; | 479 | boundary + "\"\r\n\r\n"; |
464 | 480 | ||
465 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 481 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
466 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 482 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
467 | newBody += mail->body; | 483 | newBody += mail->body; |
468 | 484 | ||
469 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 485 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
470 | fileName = ePtr->originalName; | 486 | fileName = ePtr->originalName; |
471 | fileType = ePtr->contentType; | 487 | fileType = ePtr->contentType; |
472 | QFileInfo fi(fileName); | 488 | QFileInfo fi(fileName); |
473 | 489 | ||
474 | // This specification of contentType is temporary | 490 | // This specification of contentType is temporary |
475 | contentType = ""; | 491 | contentType = ""; |
476 | if (fileType == "Picture") { | 492 | if (fileType == "Picture") { |
477 | contentType = "image/x-image"; | 493 | contentType = "image/x-image"; |
478 | } else if (fileType == "Document") { | 494 | } else if (fileType == "Document") { |
479 | contentType = "text/plain"; | 495 | contentType = "text/plain"; |
480 | } else if (fileType == "Sound") { | 496 | } else if (fileType == "Sound") { |
481 | contentType = "audio/x-wav"; | 497 | contentType = "audio/x-wav"; |
482 | } else if (fileType == "Movie") { | 498 | } else if (fileType == "Movie") { |
483 | contentType = "video/mpeg"; | 499 | contentType = "video/mpeg"; |
484 | } else { | 500 | } else { |
485 | contentType = "application/octet-stream"; | 501 | contentType = "application/octet-stream"; |
486 | } | 502 | } |
487 | 503 | ||
488 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 504 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
489 | newBody += "Content-Type: " + contentType + "; name=\"" + | 505 | newBody += "Content-Type: " + contentType + "; name=\"" + |
490 | fi.fileName() + "\"\r\n"; | 506 | fi.fileName() + "\"\r\n"; |
491 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 507 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
492 | newBody += "Content-Disposition: inline; filename=\"" + | 508 | newBody += "Content-Disposition: inline; filename=\"" + |
493 | fi.fileName() + "\"\r\n\r\n"; | 509 | fi.fileName() + "\"\r\n\r\n"; |
494 | 510 | ||
495 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 511 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
496 | return -1; | 512 | return -1; |
497 | } | 513 | } |
498 | 514 | ||
499 | newBody += "\r\n\r\n--" + boundary + "--"; | 515 | newBody += "\r\n\r\n--" + boundary + "--"; |
500 | mail->rawMail = newBody; | 516 | mail->rawMail = newBody; |
501 | 517 | ||
502 | return 0; | 518 | return 0; |
503 | } | 519 | } |
504 | 520 | ||
505 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 521 | int EmailHandler::encodeFile(QString fileName, QString *toBody) |
506 | { | 522 | { |
507 | char *fileData; | 523 | char *fileData; |
508 | char *dataPtr; | 524 | char *dataPtr; |
509 | QString temp; | 525 | QString temp; |
510 | uint dataSize, count; | 526 | uint dataSize, count; |
511 | QFile f(fileName); | 527 | QFile f(fileName); |
512 | 528 | ||
513 | if (! f.open(IO_ReadOnly) ) { | 529 | if (! f.open(IO_ReadOnly) ) { |
514 | qWarning("could not open file: " + fileName); | 530 | qWarning("could not open file: " + fileName); |
515 | return -1; | 531 | return -1; |
516 | } | 532 | } |
517 | QTextStream s(&f); | 533 | QTextStream s(&f); |
518 | dataSize = f.size(); | 534 | dataSize = f.size(); |
519 | fileData = (char *) malloc(dataSize + 3); | 535 | fileData = (char *) malloc(dataSize + 3); |
520 | s.readRawBytes(fileData, dataSize); | 536 | s.readRawBytes(fileData, dataSize); |
521 | 537 | ||
522 | temp = ""; | 538 | temp = ""; |
523 | dataPtr = fileData; | 539 | dataPtr = fileData; |
524 | count = 0; | 540 | count = 0; |
525 | while (dataSize > 0) { | 541 | while (dataSize > 0) { |
526 | if (dataSize < 3) { | 542 | if (dataSize < 3) { |
527 | encode64base(dataPtr, &temp, dataSize); | 543 | encode64base(dataPtr, &temp, dataSize); |
528 | dataSize = 0; | 544 | dataSize = 0; |
529 | } else { | 545 | } else { |
530 | encode64base(dataPtr, &temp, 3); | 546 | encode64base(dataPtr, &temp, 3); |
531 | dataSize -= 3; | 547 | dataSize -= 3; |
532 | dataPtr += 3; | 548 | dataPtr += 3; |
533 | count += 4; | 549 | count += 4; |
534 | } | 550 | } |
535 | if (count > 72) { | 551 | if (count > 72) { |
536 | count = 0; | 552 | count = 0; |
537 | temp += "\r\n"; | 553 | temp += "\r\n"; |
538 | } | 554 | } |
539 | } | 555 | } |
540 | toBody->append(temp); | 556 | toBody->append(temp); |
541 | 557 | ||
542 | delete(fileData); | 558 | delete(fileData); |
543 | f.close(); | 559 | f.close(); |
544 | return 0; | 560 | return 0; |
545 | } | 561 | } |
546 | 562 | ||
547 | void EmailHandler::encode64base(char *src, QString *dest, int len) | 563 | void EmailHandler::encode64base(char *src, QString *dest, int len) |
548 | { | 564 | { |
549 | QString temp; | 565 | QString temp; |
550 | uchar c; | 566 | uchar c; |
551 | uchar bufOut[4]; | 567 | uchar bufOut[4]; |
552 | 568 | ||
553 | bufOut[0] = src[0]; | 569 | bufOut[0] = src[0]; |
554 | bufOut[0] >>= 2; //Done byte 0 | 570 | bufOut[0] >>= 2; //Done byte 0 |
555 | 571 | ||
556 | bufOut[1] = src[0]; | 572 | bufOut[1] = src[0]; |
557 | bufOut[1] = bufOut[1] & (1 + 2); //mask out top 6 bits | 573 | bufOut[1] = bufOut[1] & (1 + 2); //mask out top 6 bits |
558 | bufOut[1] <<= 4; //copy up 4 places | 574 | bufOut[1] <<= 4; //copy up 4 places |
559 | if (len > 1) { | 575 | if (len > 1) { |
560 | c = src[1]; | 576 | c = src[1]; |
561 | } else { | 577 | } else { |
562 | c = 0; | 578 | c = 0; |
563 | } | 579 | } |
564 | 580 | ||
565 | c = c & (16 + 32 + 64 + 128); | 581 | c = c & (16 + 32 + 64 + 128); |
566 | c >>= 4; | 582 | c >>= 4; |
567 | bufOut[1] = bufOut[1] | c; //Done byte 1 | 583 | bufOut[1] = bufOut[1] | c; //Done byte 1 |
568 | 584 | ||
569 | bufOut[2] = src[1]; | 585 | bufOut[2] = src[1]; |
570 | bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8); | 586 | bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8); |
571 | bufOut[2] <<= 2; | 587 | bufOut[2] <<= 2; |
572 | if (len > 2) { | 588 | if (len > 2) { |
573 | c = src[2]; | 589 | c = src[2]; |
574 | } else { | 590 | } else { |
575 | c = 0; | 591 | c = 0; |
576 | } | 592 | } |
577 | c >>= 6; | 593 | c >>= 6; |
578 | bufOut[2] = bufOut[2] | c; | 594 | bufOut[2] = bufOut[2] | c; |
579 | 595 | ||
580 | bufOut[3] = src[2]; | 596 | bufOut[3] = src[2]; |
581 | bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32); | 597 | bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32); |
582 | 598 | ||
583 | if (len == 1) { | 599 | if (len == 1) { |
584 | bufOut[2] = 64; | 600 | bufOut[2] = 64; |
585 | bufOut[3] = 64; | 601 | bufOut[3] = 64; |
586 | } | 602 | } |
587 | if (len == 2) { | 603 | if (len == 2) { |
588 | bufOut[3] = 64; | 604 | bufOut[3] = 64; |
589 | } | 605 | } |
590 | for (int x = 0; x < 4; x++) { | 606 | for (int x = 0; x < 4; x++) { |
591 | if (bufOut[x] <= 25) | 607 | if (bufOut[x] <= 25) |
592 | bufOut[x] += (uint) 'A'; | 608 | bufOut[x] += (uint) 'A'; |
593 | else if (bufOut[x] >= 26 && bufOut[x] <= 51) | 609 | else if (bufOut[x] >= 26 && bufOut[x] <= 51) |
594 | bufOut[x] += (uint) 'a' - 26; | 610 | bufOut[x] += (uint) 'a' - 26; |
595 | else if (bufOut[x] >= 52 && bufOut[x] <= 61) | 611 | else if (bufOut[x] >= 52 && bufOut[x] <= 61) |
596 | bufOut[x] += (uint) '0' - 52; | 612 | bufOut[x] += (uint) '0' - 52; |
597 | else if (bufOut[x] == 62) | 613 | else if (bufOut[x] == 62) |
598 | bufOut[x] = '+'; | 614 | bufOut[x] = '+'; |
599 | else if (bufOut[x] == 63) | 615 | else if (bufOut[x] == 63) |
600 | bufOut[x] = '/'; | 616 | bufOut[x] = '/'; |
601 | else if (bufOut[x] == 64) | 617 | else if (bufOut[x] == 64) |
602 | bufOut[x] = '='; | 618 | bufOut[x] = '='; |
603 | 619 | ||
604 | dest->append(bufOut[x]); | 620 | dest->append(bufOut[x]); |
605 | } | 621 | } |
606 | } | 622 | } |
607 | 623 | ||
608 | void EmailHandler::cancel() | 624 | void EmailHandler::cancel() |
609 | { | 625 | { |
610 | popClient->errorHandling(ErrCancel); | 626 | popClient->errorHandling(ErrCancel); |
611 | smtpClient->errorHandling(ErrCancel); | 627 | smtpClient->errorHandling(ErrCancel); |
612 | } | 628 | } |
diff --git a/noncore/unsupported/mailit/emaillistitem.cpp b/noncore/unsupported/mailit/emaillistitem.cpp index a325766..b925a1c 100644 --- a/noncore/unsupported/mailit/emaillistitem.cpp +++ b/noncore/unsupported/mailit/emaillistitem.cpp | |||
@@ -1,97 +1,99 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qstring.h> | 20 | #include <qstring.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include "emaillistitem.h" | 22 | #include "emaillistitem.h" |
23 | 23 | ||
24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | 24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) |
25 | : QListViewItem(parent) | 25 | : QListViewItem(parent) |
26 | { | 26 | { |
27 | QString temp; | 27 | QString temp; |
28 | 28 | ||
29 | mail = mailIn; | 29 | mail = mailIn; |
30 | 30 | ||
31 | if (inbox) { | 31 | if (inbox) { |
32 | setText(0, mail.from); | 32 | setText(0, mail.from); |
33 | } else { | 33 | } else { |
34 | QStringList::Iterator it = mail.recipients.begin(); | 34 | QStringList::Iterator it = mail.recipients.begin(); |
35 | temp = *it; | 35 | temp = *it; |
36 | if (mail.recipients.count() > 1) | 36 | if (mail.recipients.count() > 1) |
37 | temp += "..."; | 37 | temp += "..."; |
38 | setText(0, temp); | 38 | setText(0, temp); |
39 | } | 39 | } |
40 | setText(1, mail.subject); | 40 | setText(1, mail.subject); |
41 | setText(2,mail.date); | ||
41 | 42 | ||
42 | if (mailIn.files.count()>0) | 43 | if (mailIn.files.count()>0) |
43 | { | 44 | { |
44 | setPixmap(0, Resource::loadPixmap("mailit/attach")); | 45 | setPixmap(0, Resource::loadPixmap("mailit/attach")); |
45 | } | 46 | } |
47 | |||
46 | selected = FALSE; | 48 | selected = FALSE; |
47 | } | 49 | } |
48 | 50 | ||
49 | Email* EmailListItem::getMail() | 51 | Email* EmailListItem::getMail() |
50 | { | 52 | { |
51 | return &mail; | 53 | return &mail; |
52 | } | 54 | } |
53 | 55 | ||
54 | void EmailListItem::setMail(Email newMail) | 56 | void EmailListItem::setMail(Email newMail) |
55 | { | 57 | { |
56 | mail = newMail; | 58 | mail = newMail; |
57 | repaint(); | 59 | repaint(); |
58 | } | 60 | } |
59 | 61 | ||
60 | void EmailListItem::setItemSelected(bool enable) | 62 | void EmailListItem::setItemSelected(bool enable) |
61 | { | 63 | { |
62 | selected = enable; | 64 | selected = enable; |
63 | setSelected(enable); | 65 | setSelected(enable); |
64 | repaint(); | 66 | repaint(); |
65 | } | 67 | } |
66 | 68 | ||
67 | bool EmailListItem::isItemSelected() | 69 | bool EmailListItem::isItemSelected() |
68 | { | 70 | { |
69 | return selected; | 71 | return selected; |
70 | } | 72 | } |
71 | 73 | ||
72 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | 74 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, |
73 | int column, int width, int alignment ) | 75 | int column, int width, int alignment ) |
74 | { | 76 | { |
75 | 77 | ||
76 | QColorGroup _cg( cg ); | 78 | QColorGroup _cg( cg ); |
77 | QColor c = _cg.text(); | 79 | QColor c = _cg.text(); |
78 | 80 | ||
79 | if ( (! mail.read) && (mail.received) ) | 81 | if ( (! mail.read) && (mail.received) ) |
80 | _cg.setColor( QColorGroup::Text, Qt::blue); | 82 | _cg.setColor( QColorGroup::Text, Qt::blue); |
81 | if (!mail.downloaded) | 83 | if (!mail.downloaded) |
82 | _cg.setColor( QColorGroup::Text, Qt::red); | 84 | _cg.setColor( QColorGroup::Text, Qt::red); |
83 | 85 | ||
84 | /*if (selected) { | 86 | /*if (selected) { |
85 | _cg.setColor(QColorGroup::Base, Qt::blue); | 87 | _cg.setColor(QColorGroup::Base, Qt::blue); |
86 | _cg.setColor(QColorGroup::Text, Qt::yellow); | 88 | _cg.setColor(QColorGroup::Text, Qt::yellow); |
87 | if (isSelected()) { | 89 | if (isSelected()) { |
88 | _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); | 90 | _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); |
89 | } else { | 91 | } else { |
90 | _cg.setColor(QColorGroup::Highlight, Qt::blue); | 92 | _cg.setColor(QColorGroup::Highlight, Qt::blue); |
91 | } | 93 | } |
92 | } | 94 | } |
93 | */ | 95 | */ |
94 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 96 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
95 | 97 | ||
96 | _cg.setColor( QColorGroup::Text, c ); | 98 | _cg.setColor( QColorGroup::Text, c ); |
97 | } | 99 | } |
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index ef5fc09..7181adf 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp | |||
@@ -1,165 +1,143 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qwhatsthis.h> | ||
20 | #include "mailitwindow.h" | 21 | #include "mailitwindow.h" |
21 | 22 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 23 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 24 | : QMainWindow(parent, name, WStyle_ContextHelp) |
24 | { | 25 | { |
25 | currentCaption = "Mailit"; | 26 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 27 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 28 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 29 | setCentralWidget(views); |
29 | 30 | QWhatsThis::add(views,tr("Central view area")); | |
30 | emailClient = new EmailClient(views, "client"); | 31 | emailClient = new EmailClient(views, "client"); |
31 | writeMail = new WriteMail(views, "writing"); | 32 | writeMail = new WriteMail(views, "writing"); |
32 | readMail = new ReadMail(views, "reading"); | 33 | readMail = new ReadMail(views, "reading"); |
33 | 34 | ||
34 | views->raiseWidget(emailClient); | 35 | views->raiseWidget(emailClient); |
35 | 36 | ||
36 | connect(emailClient, SIGNAL(composeRequested()), | 37 | connect(emailClient, SIGNAL(composeRequested()), |
37 | this, SLOT(compose()) ); | 38 | this, SLOT(compose()) ); |
38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 39 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
39 | SLOT(viewMail(QListView *, Email *)) ); | 40 | SLOT(viewMail(QListView *, Email *)) ); |
40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 41 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
41 | SLOT(updateMailView(Email *)) ); | 42 | SLOT(updateMailView(Email *)) ); |
42 | 43 | ||
43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 44 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 45 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
45 | SLOT(showEmailClient()) ); | 46 | SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 47 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
47 | SLOT(enqueMail(const Email &)) ); | 48 | SLOT(enqueMail(const Email &)) ); |
48 | 49 | ||
49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 50 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
50 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, | 51 | connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, |
51 | SLOT(composeReply(Email &, bool&)) ); | 52 | SLOT(composeReply(Email &, bool&)) ); |
52 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, | 53 | connect(readMail, SIGNAL(forwardRequested(Email &)), this, |
53 | SLOT(composeForward(Email &)) ); | 54 | SLOT(composeForward(Email &)) ); |
54 | 55 | ||
55 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 56 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
56 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 57 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
57 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 58 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
58 | SLOT(moveMailFront(Email *)) ); | 59 | SLOT(moveMailFront(Email *)) ); |
59 | 60 | ||
60 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 61 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
61 | this, SLOT(updateCaption(const QString &)) ); | 62 | this, SLOT(updateCaption(const QString &)) ); |
62 | viewingMail = FALSE; | 63 | viewingMail = FALSE; |
63 | 64 | ||
64 | } | 65 | } |
65 | 66 | ||
66 | MailItWindow::~MailItWindow() | 67 | MailItWindow::~MailItWindow() |
67 | { | 68 | { |
68 | } | 69 | } |
69 | 70 | ||
70 | void MailItWindow::closeEvent(QCloseEvent *e) | 71 | void MailItWindow::closeEvent(QCloseEvent *e) |
71 | { | 72 | { |
72 | if (views->visibleWidget() == emailClient) { | 73 | if (views->visibleWidget() == emailClient) { |
73 | e->accept(); | 74 | e->accept(); |
74 | } else { | 75 | } else { |
75 | showEmailClient(); | 76 | showEmailClient(); |
76 | } | 77 | } |
77 | } | 78 | } |
78 | 79 | ||
79 | void MailItWindow::compose() | 80 | void MailItWindow::compose() |
80 | { | 81 | { |
81 | viewingMail = FALSE; | 82 | viewingMail = FALSE; |
82 | emailClient->hide(); | 83 | emailClient->hide(); |
83 | readMail->hide(); | 84 | readMail->hide(); |
84 | views->raiseWidget(writeMail); | 85 | views->raiseWidget(writeMail); |
85 | writeMail->setAddressList(emailClient->getAdrListRef()); | 86 | writeMail->setAddressList(emailClient->getAdrListRef()); |
86 | setCaption( tr( "Write mail" ) ); | 87 | setCaption( tr( "Write mail" ) ); |
87 | } | 88 | } |
88 | 89 | ||
89 | void MailItWindow::composeReply(Email &mail, bool& replyAll) | 90 | void MailItWindow::composeReply(Email &mail, bool& replyAll) |
90 | { | 91 | { |
91 | compose(); | 92 | compose(); |
92 | writeMail->reply(mail,replyAll) ; | 93 | writeMail->reply(mail,replyAll) ; |
93 | } | 94 | } |
94 | 95 | ||
95 | void MailItWindow::composeForward(Email &mail) | 96 | void MailItWindow::composeForward(Email &mail) |
96 | { | 97 | { |
97 | compose(); | 98 | compose(); |
98 | writeMail->forward(mail) ; | 99 | writeMail->forward(mail) ; |
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
102 | void MailItWindow::showEmailClient() | 103 | void MailItWindow::showEmailClient() |
103 | { | 104 | { |
104 | viewingMail = FALSE; | 105 | viewingMail = FALSE; |
105 | writeMail->hide(); | 106 | writeMail->hide(); |
106 | readMail->hide(); | 107 | readMail->hide(); |
107 | views->raiseWidget(emailClient); | 108 | views->raiseWidget(emailClient); |
108 | setCaption( tr(currentCaption) ); | 109 | setCaption( tr(currentCaption) ); |
109 | } | 110 | } |
110 | 111 | ||
111 | void MailItWindow::viewMail(QListView *view, Email *mail) | 112 | void MailItWindow::viewMail(QListView *view, Email *mail) |
112 | { | 113 | { |
113 | viewingMail = TRUE; | 114 | viewingMail = TRUE; |
114 | emailClient->hide(); | 115 | emailClient->hide(); |
115 | readMail->update(view, mail); | 116 | readMail->update(view, mail); |
116 | views->raiseWidget(readMail); | 117 | views->raiseWidget(readMail); |
117 | setCaption( tr( "Examine mail" ) ); | 118 | setCaption( tr( "Examine mail" ) ); |
118 | } | 119 | } |
119 | 120 | ||
120 | void MailItWindow::updateMailView(Email *mail) | 121 | void MailItWindow::updateMailView(Email *mail) |
121 | { | 122 | { |
122 | if (viewingMail) { | 123 | if (viewingMail) { |
123 | readMail->mailUpdated(mail); | 124 | readMail->mailUpdated(mail); |
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | void MailItWindow::updateCaption(const QString &newCaption) | 128 | void MailItWindow::updateCaption(const QString &newCaption) |
128 | { | 129 | { |
129 | currentCaption = newCaption; | 130 | currentCaption = newCaption; |
130 | setCaption(tr(currentCaption)); | 131 | setCaption(tr(currentCaption)); |
131 | } | 132 | } |
132 | 133 | ||
133 | void MailItWindow::setDocument(const QString &_address) | 134 | void MailItWindow::setDocument(const QString &_address) |
134 | { | 135 | { |
135 | // strip leading 'mailto:' | 136 | // strip leading 'mailto:' |
136 | QString address = _address; | 137 | QString address = _address; |
137 | if (address.startsWith("mailto:")) | 138 | if (address.startsWith("mailto:")) |
138 | address = address.mid(6); | 139 | address = address.mid(6); |
139 | 140 | ||
140 | compose(); | 141 | compose(); |
141 | writeMail->setRecipient(address); | 142 | writeMail->setRecipient(address); |
142 | } | 143 | } |
143 | |||
144 | /*void MailItWindow::reply(Email& mail) | ||
145 | { | ||
146 | qDebug("####EmailClient: 0 reached"); | ||
147 | composeReply(mail,(bool&)FALSE); | ||
148 | } | ||
149 | |||
150 | void MailItWindow::replyAll(Email& mail) | ||
151 | { | ||
152 | qDebug("####EmailClient: 1 reached"); | ||
153 | composeReply(mail,(bool&)TRUE); | ||
154 | } | ||
155 | |||
156 | void MailItWindow::forward(Email& mail) | ||
157 | { | ||
158 | qDebug("####EmailClient: 2 reached"); | ||
159 | } | ||
160 | |||
161 | void MailItWindow::remove(Email&) | ||
162 | { | ||
163 | qDebug("####EmailClient: 3 reached"); | ||
164 | //emit removeItem(eli,(bool&)TRUE); | ||
165 | } */ \ No newline at end of file | ||
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp index f9cc337..67306be 100644 --- a/noncore/unsupported/mailit/popclient.cpp +++ b/noncore/unsupported/mailit/popclient.cpp | |||
@@ -1,375 +1,367 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "popclient.h" | 20 | #include "popclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | //#define APOP_TEST | 22 | //#define APOP_TEST |
23 | 23 | ||
24 | extern "C" { | 24 | extern "C" { |
25 | #include "md5.h" | 25 | #include "md5.h" |
26 | } | 26 | } |
27 | 27 | ||
28 | #include <qcstring.h> | 28 | #include <qcstring.h> |
29 | 29 | ||
30 | PopClient::PopClient() | 30 | PopClient::PopClient() |
31 | { | 31 | { |
32 | socket = new QSocket(this, "popClient"); | 32 | socket = new QSocket(this, "popClient"); |
33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
36 | 36 | ||
37 | stream = new QTextStream(socket); | 37 | stream = new QTextStream(socket); |
38 | 38 | ||
39 | receiving = FALSE; | 39 | receiving = FALSE; |
40 | synchronize = FALSE; | 40 | synchronize = FALSE; |
41 | lastSync = 0; | 41 | lastSync = 0; |
42 | headerLimit = 0; | 42 | headerLimit = 0; |
43 | preview = FALSE; | 43 | preview = FALSE; |
44 | } | 44 | } |
45 | 45 | ||
46 | PopClient::~PopClient() | 46 | PopClient::~PopClient() |
47 | { | 47 | { |
48 | delete socket; | 48 | delete socket; |
49 | delete stream; | 49 | delete stream; |
50 | } | 50 | } |
51 | 51 | ||
52 | void PopClient::newConnection(QString target, int port) | 52 | void PopClient::newConnection(QString target, int port) |
53 | { | 53 | { |
54 | if (receiving) { | 54 | if (receiving) { |
55 | qWarning("socket in use, connection refused"); | 55 | qWarning("socket in use, connection refused"); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | status = Init; | 59 | status = Init; |
60 | 60 | ||
61 | socket->connectToHost(target, port); | 61 | socket->connectToHost(target, port); |
62 | receiving = TRUE; | 62 | receiving = TRUE; |
63 | selected = FALSE; | 63 | selected = FALSE; |
64 | 64 | ||
65 | emit updateStatus("DNS lookup"); | 65 | emit updateStatus("DNS lookup"); |
66 | } | 66 | } |
67 | 67 | ||
68 | void PopClient::setAccount(QString popUser, QString popPasswd) | 68 | void PopClient::setAccount(QString popUser, QString popPasswd) |
69 | { | 69 | { |
70 | popUserName = popUser; | 70 | popUserName = popUser; |
71 | popPassword = popPasswd; | 71 | popPassword = popPasswd; |
72 | } | 72 | } |
73 | 73 | ||
74 | void PopClient::setSynchronize(int lastCount) | 74 | void PopClient::setSynchronize(int lastCount) |
75 | { | 75 | { |
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus(tr("Connection established")); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus(tr("Error Occured")); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void PopClient::incomingData() | 111 | void PopClient::incomingData() |
112 | { | 112 | { |
113 | QString response, temp, temp2, timeStamp; | 113 | QString response, temp, temp2, timeStamp; |
114 | QString md5Source; | 114 | QString md5Source; |
115 | int start, end; | 115 | int start, end; |
116 | // char *md5Digest; | 116 | // char *md5Digest; |
117 | char md5Digest[16]; | 117 | char md5Digest[16]; |
118 | // if ( !socket->canReadLine() ) | 118 | // if ( !socket->canReadLine() ) |
119 | // return; | 119 | // return; |
120 | 120 | ||
121 | response = socket->readLine(); | 121 | response = socket->readLine(); |
122 | //qDebug(response +" %d", status); | ||
123 | 122 | ||
124 | switch(status) { | 123 | switch(status) { |
125 | //logging in | 124 | //logging in |
126 | case Init: { | 125 | case Init: { |
127 | #ifdef APOP_TEST | 126 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 127 | start = response.find('<',0); |
129 | end = response.find('>', start); | 128 | end = response.find('>', start); |
130 | if( start >= 0 && end > start ) | 129 | if( start >= 0 && end > start ) |
131 | { | 130 | { |
132 | timeStamp = response.mid( start , end - start + 1); | 131 | timeStamp = response.mid( start , end - start + 1); |
133 | md5Source = timeStamp + popPassword; | 132 | md5Source = timeStamp + popPassword; |
134 | //qDebug( md5Source); | ||
135 | // for( int i = 0; i < md5Source.length(); i++) { | ||
136 | // buff[i] = (QChar)md5Source[i]; | ||
137 | // } | ||
138 | 133 | ||
139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); | 134 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); |
140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); | ||
141 | |||
142 | // MD5_Init( &ctx); | ||
143 | // MD5_Update( &ctx, buff, sizeof( buff) ); | ||
144 | // MD5_Final( md5Digest, &ctx); | ||
145 | // MD5( buff, md5Source.length(), md5Digest); | ||
146 | 135 | ||
147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) | 136 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) |
148 | { | 137 | { |
149 | printf("%x", md5Digest[j]); | 138 | printf("%x", md5Digest[j]); |
150 | } | 139 | } |
151 | printf("\n"); | 140 | printf("\n"); |
152 | // qDebug(md5Digest); | 141 | // qDebug(md5Digest); |
153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; | 142 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; |
154 | // qDebug("%s", stream); | 143 | // qDebug("%s", stream); |
155 | status = Stat; | 144 | status = Stat; |
156 | } | 145 | } |
157 | else | 146 | else |
158 | #endif | 147 | #endif |
159 | { | 148 | { |
160 | timeStamp = ""; | 149 | timeStamp = ""; |
161 | *stream << "USER " << popUserName << "\r\n"; | 150 | *stream << "USER " << popUserName << "\r\n"; |
162 | status = Pass; | 151 | status = Pass; |
163 | } | 152 | } |
164 | 153 | ||
165 | break; | 154 | break; |
166 | } | 155 | } |
167 | //password shhh. don't tell anyone (implement APOP...) | 156 | |
168 | case Pass: { | 157 | case Pass: { |
169 | *stream << "PASS " << popPassword << "\r\n"; | 158 | *stream << "PASS " << popPassword << "\r\n"; |
170 | status = Stat; | 159 | status = Stat; |
171 | break; | 160 | break; |
172 | } | 161 | } |
173 | //ask for number of messages | 162 | //ask for number of messages |
174 | case Stat: { | 163 | case Stat: { |
175 | if (response[0] == '+') { | 164 | if (response[0] == '+') { |
176 | *stream << "STAT" << "\r\n"; | 165 | *stream << "STAT" << "\r\n"; |
177 | status = Mcnt; | 166 | status = Mcnt; |
178 | } else errorHandling(ErrLoginFailed); | 167 | } else errorHandling(ErrLoginFailed); |
179 | break; | 168 | break; |
180 | } | 169 | } |
181 | //get count of messages, eg "+OK 4 900.." -> int 4 | 170 | //get count of messages, eg "+OK 4 900.." -> int 4 |
182 | case Mcnt: { | 171 | case Mcnt: { |
183 | if (response[0] == '+') { | 172 | if (response[0] == '+') { |
184 | temp = response.replace(0, 4, ""); | 173 | temp = response.replace(0, 4, ""); |
185 | int x = temp.find(" ", 0); | 174 | int x = temp.find(" ", 0); |
186 | temp.truncate((uint) x); | 175 | temp.truncate((uint) x); |
187 | newMessages = temp.toInt(); | 176 | newMessages = temp.toInt(); |
188 | messageCount = 1; | 177 | messageCount = 1; |
189 | status = List; | 178 | status = List; |
190 | 179 | ||
191 | if (synchronize) { | 180 | if (synchronize) { |
192 | //messages deleted from server, reload all | 181 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 182 | if (newMessages < lastSync) |
194 | lastSync = 0; | 183 | lastSync = 0; |
195 | messageCount = 1; | 184 | messageCount = 1; |
196 | } | 185 | } |
197 | 186 | ||
198 | if (selected) { | 187 | if (selected) { |
199 | int *ptr = mailList->first(); | 188 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 189 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 190 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 191 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 192 | } else newMessages = 0; |
204 | } | 193 | } |
205 | } else errorHandling(ErrUnknownResponse); | 194 | } else errorHandling(ErrUnknownResponse); |
206 | } | 195 | } |
207 | //Read message number x, count upwards to messageCount | 196 | //Read message number x, count upwards to messageCount |
208 | case List: { | 197 | case List: { |
209 | if (messageCount <= newMessages) { | 198 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 199 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 200 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 201 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 202 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 203 | if (!selected) { |
215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 204 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 205 | } else { |
217 | //completing a previously closed transfer | 206 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 207 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 208 | temp.setNum(messageCount); |
220 | emit updateStatus(tr("Previous message ") + temp); | 209 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 210 | } else { |
222 | emit updateStatus(tr("Completing message ") + temp); | 211 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 212 | } |
224 | } | 213 | } |
225 | break; | 214 | break; |
226 | } else { | 215 | } else { |
227 | emit updateStatus(tr("No new Messages")); | 216 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 217 | status = Quit; |
229 | } | 218 | } |
230 | } | 219 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 220 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 221 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 222 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 223 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 224 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 225 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 226 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 227 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 228 | emit currentMailSize(mailSize); |
240 | 229 | ||
241 | status = Retr; | 230 | status = Retr; |
242 | } else { | 231 | } else { |
243 | //qWarning(response); | 232 | //qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 233 | errorHandling(ErrUnknownResponse); |
245 | } | 234 | } |
246 | } | 235 | } |
247 | } | 236 | } |
248 | //Read message number x, count upwards to messageCount | 237 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 238 | case Retr: { |
250 | if (status != Quit) { | 239 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 240 | if (mailSize <= headerLimit) |
241 | { | ||
252 | *stream << "RETR " << messageCount << "\r\n"; | 242 | *stream << "RETR " << messageCount << "\r\n"; |
253 | } else { //only header | 243 | } else { //only header |
254 | *stream << "TOP " << messageCount << " 0\r\n"; | 244 | *stream << "TOP " << messageCount << " 0\r\n"; |
255 | } | 245 | } |
256 | messageCount++; | 246 | messageCount++; |
257 | status = Ignore; | 247 | status = Ignore; |
258 | break; | 248 | break; |
259 | } } | 249 | } } |
260 | case Ignore: { | 250 | case Ignore: { |
261 | if (status != Quit) { //because of idiotic switch | 251 | if (status != Quit) { //because of idiotic switch |
262 | if (response[0] == '+') { | 252 | if (response[0] == '+') { |
263 | message = ""; | 253 | message = ""; |
264 | status = Read; | 254 | status = Read; |
265 | if (!socket->canReadLine()) //sync. problems | 255 | if (!socket->canReadLine()) //sync. problems |
266 | break; | 256 | break; |
267 | response = socket->readLine(); | 257 | response = socket->readLine(); |
268 | } else errorHandling(ErrUnknownResponse); | 258 | } else errorHandling(ErrUnknownResponse); |
269 | } | 259 | } |
270 | } | 260 | } |
271 | //add all incoming lines to body. When size is reached, send | 261 | //add all incoming lines to body. When size is reached, send |
272 | //message, and go back to read new message | 262 | //message, and go back to read new message |
273 | case Read: { | 263 | case Read: { |
274 | if (status != Quit) { //because of idiotic switch | 264 | if (status != Quit) { //because of idiotic switch |
275 | message += response; | 265 | message += response; |
276 | while ( socket->canReadLine() ) { | 266 | while ( socket->canReadLine() ) { |
277 | response = socket->readLine(); | 267 | response = socket->readLine(); |
278 | message += response; | 268 | message += response; |
279 | } | 269 | } |
280 | emit downloadedSize(message.length()); | 270 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 271 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 272 | if (x == -1) { |
283 | break; | 273 | break; |
284 | } else { //message reach entire size | 274 | } else { //message reach entire size |
285 | //complete mail downloaded | 275 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 276 | //if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 277 | if ( mailSize <= headerLimit) |
278 | { | ||
279 | emit newMessage(message, messageCount-1, mailSize, TRUE); | ||
288 | } else { //incomplete mail downloaded | 280 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 281 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 282 | } |
291 | if (messageCount > newMessages) //that was the last message | 283 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 284 | status = Quit; |
293 | else { //ask for new message | 285 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 286 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 287 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 288 | if (ptr != 0) { |
297 | messageCount = *ptr; | 289 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 290 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 291 | status = Size; |
300 | //completing a previously closed transfer | 292 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 293 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 294 | temp.setNum(messageCount); |
303 | emit updateStatus(tr("Previous message ") + temp); | 295 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 296 | } else { |
305 | temp.setNum(messageCount - lastSync); | 297 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus(tr("Completing message ") + temp); | 298 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 299 | } |
308 | break; | 300 | break; |
309 | } else { | 301 | } else { |
310 | newMessages--; | 302 | newMessages--; |
311 | status = Quit; | 303 | status = Quit; |
312 | } | 304 | } |
313 | } else { | 305 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 306 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 307 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 308 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 309 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 310 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 311 | ||
320 | break; | 312 | break; |
321 | } | 313 | } |
322 | } | 314 | } |
323 | } | 315 | } |
324 | if (status != Quit) | 316 | if (status != Quit) |
325 | break; | 317 | break; |
326 | } | 318 | } |
327 | } | 319 | } |
328 | case Quit: { | 320 | case Quit: { |
329 | *stream << "Quit\r\n"; | 321 | *stream << "Quit\r\n"; |
330 | status = Done; | 322 | status = Done; |
331 | int newM = newMessages - lastSync; | 323 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 324 | if (newM > 0) { |
333 | temp.setNum(newM); | 325 | temp.setNum(newM); |
334 | emit updateStatus(temp + tr(" new messages")); | 326 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 327 | } else { |
336 | emit updateStatus(tr("No new messages")); | 328 | emit updateStatus(tr("No new messages")); |
337 | } | 329 | } |
338 | 330 | ||
339 | socket->close(); | 331 | socket->close(); |
340 | receiving = FALSE; | 332 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 333 | emit mailTransfered(newM); |
342 | break; | 334 | break; |
343 | } | 335 | } |
344 | } | 336 | } |
345 | 337 | ||
346 | } | 338 | } |
347 | 339 | ||
348 | // if( bAPOPAuthentication ) | 340 | // if( bAPOPAuthentication ) |
349 | // { | 341 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 342 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 343 | // { |
352 | // SetLastError("Apop error!"); | 344 | // SetLastError("Apop error!"); |
353 | // return false; | 345 | // return false; |
354 | // } | 346 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 347 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 348 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 349 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 350 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 351 | // if(ret == SOCKET_ERROR) |
360 | // { | 352 | // { |
361 | // SetLastError("Socket error!"); | 353 | // SetLastError("Socket error!"); |
362 | // m_bSocketOK = false; | 354 | // m_bSocketOK = false; |
363 | // m_bConnected = false; | 355 | // m_bConnected = false; |
364 | // return false; | 356 | // return false; |
365 | // } | 357 | // } |
366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) | 358 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) |
367 | // return false; | 359 | // return false; |
368 | // if( 0 == strResult.Find('-' , 0) ) | 360 | // if( 0 == strResult.Find('-' , 0) ) |
369 | // { | 361 | // { |
370 | // SetLastError("Username or Password error!"); | 362 | // SetLastError("Username or Password error!"); |
371 | // return false; | 363 | // return false; |
372 | // } | 364 | // } |
373 | // m_bConnected = true; | 365 | // m_bConnected = true; |
374 | 366 | ||
375 | // } | 367 | // } |
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index dc98a6f..4eae7f6 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp | |||
@@ -1,357 +1,367 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | replyButton->setWhatsThis(tr("Click here to reply to the selected mail")); | |
63 | |||
63 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), | 64 | forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), |
64 | QString::null, 0, this, 0 ); | 65 | QString::null, 0, this, 0 ); |
65 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); | 66 | connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); |
67 | forwardButton->setWhatsThis(tr("Click here to forward the selected mail")); | ||
66 | 68 | ||
67 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 69 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
68 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 70 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
69 | previousButton->addTo(bar); | 71 | previousButton->addTo(bar); |
70 | previousButton->addTo(viewMenu); | 72 | previousButton->addTo(viewMenu); |
73 | previousButton->setWhatsThis(tr("Read the previous mail in the list")); | ||
71 | 74 | ||
72 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 75 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
73 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 76 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
74 | nextButton->addTo(bar); | 77 | nextButton->addTo(bar); |
75 | nextButton->addTo(viewMenu); | 78 | nextButton->addTo(viewMenu); |
79 | previousButton->setWhatsThis(tr("Read the next mail in the list")); | ||
76 | 80 | ||
77 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 81 | attachmentButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
78 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 82 | connect( attachmentButton, SIGNAL( activated() ), this, |
79 | SLOT( viewAttatchments() ) ); | 83 | SLOT( viewAttachments() ) ); |
80 | attatchmentsButton->addTo(bar); | 84 | attachmentButton->addTo(bar); |
81 | attatchmentsButton->addTo(viewMenu); | 85 | attachmentButton->addTo(viewMenu); |
86 | attachmentButton->setWhatsThis(tr("Click here to add attachments to your mail")); | ||
82 | 87 | ||
83 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 88 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
84 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 89 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
85 | plainTextButton->addTo(bar); | 90 | plainTextButton->addTo(bar); |
86 | plainTextButton->addTo(viewMenu); | 91 | plainTextButton->addTo(viewMenu); |
92 | plainTextButton->setWhatsThis(tr("The mail view has 2 modes:\n" | ||
93 | "<LI><B>RichText</B> shows the mail as HTML with reach features (no standard line breaks)</LI>" | ||
94 | "<LI><B>Plain</B> shows the mail as standard plain text</LI>" | ||
95 | "Click here to switch between those view modes" )); | ||
87 | 96 | ||
88 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 97 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
89 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 98 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
90 | deleteButton->addTo(bar); | 99 | deleteButton->addTo(bar); |
91 | deleteButton->addTo(mailMenu); | 100 | deleteButton->addTo(mailMenu); |
101 | deleteButton->setWhatsThis(tr("Click here to remove the selected mail")); | ||
92 | 102 | ||
93 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 103 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
94 | 104 | ||
95 | emailView = new QTextView( this, "emailView" ); | 105 | emailView = new QTextView( this, "emailView" ); |
96 | 106 | ||
97 | setCentralWidget(emailView); | 107 | setCentralWidget(emailView); |
98 | 108 | ||
99 | mime = new QMimeSourceFactory(); | 109 | mime = new QMimeSourceFactory(); |
100 | emailView->setMimeSourceFactory(mime); | 110 | emailView->setMimeSourceFactory(mime); |
101 | } | 111 | } |
102 | 112 | ||
103 | void ReadMail::updateView() | 113 | void ReadMail::updateView() |
104 | { | 114 | { |
105 | Enclosure *ePtr; | 115 | Enclosure *ePtr; |
106 | QString mailStringSize; | 116 | QString mailStringSize; |
107 | QString text, temp; | 117 | QString text, temp; |
108 | 118 | ||
109 | mail->read = TRUE; //mark as read | 119 | mail->read = TRUE; //mark as read |
110 | inbox = mail->received; | 120 | inbox = mail->received; |
111 | 121 | ||
112 | replyButton->removeFrom(mailMenu); | 122 | replyButton->removeFrom(mailMenu); |
113 | replyButton->removeFrom(bar); | 123 | replyButton->removeFrom(bar); |
114 | forwardButton->removeFrom(mailMenu); | 124 | forwardButton->removeFrom(mailMenu); |
115 | forwardButton->removeFrom(bar); | 125 | forwardButton->removeFrom(bar); |
116 | 126 | ||
117 | if (inbox == TRUE) { | 127 | if (inbox == TRUE) { |
118 | replyButton->addTo(bar); | 128 | replyButton->addTo(bar); |
119 | replyButton->addTo(mailMenu); | 129 | replyButton->addTo(mailMenu); |
120 | forwardButton->addTo(bar); | 130 | forwardButton->addTo(bar); |
121 | forwardButton->addTo(mailMenu); | 131 | forwardButton->addTo(mailMenu); |
122 | 132 | ||
123 | 133 | ||
124 | if (!mail->downloaded) { | 134 | if (!mail->downloaded) { |
125 | //report currently viewed mail so that it will be | 135 | //report currently viewed mail so that it will be |
126 | //placed first in the queue of new mails to download | 136 | //placed first in the queue of new mails to download |
127 | emit viewingMail(mail); | 137 | emit viewingMail(mail); |
128 | 138 | ||
129 | double mailSize = (double) mail->size; | 139 | double mailSize = (double) mail->size; |
130 | if (mailSize < 1024) { | 140 | if (mailSize < 1024) { |
131 | mailStringSize.setNum(mailSize); | 141 | mailStringSize.setNum(mailSize); |
132 | mailStringSize += " Bytes"; | 142 | mailStringSize += " Bytes"; |
133 | } else if (mailSize < 1024*1024) { | 143 | } else if (mailSize < 1024*1024) { |
134 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 144 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
135 | mailStringSize += " Kb"; | 145 | mailStringSize += " Kb"; |
136 | } else { | 146 | } else { |
137 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 147 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
138 | mailStringSize += " Mb"; | 148 | mailStringSize += " Mb"; |
139 | } | 149 | } |
140 | } | 150 | } |
141 | } | 151 | } |
142 | 152 | ||
143 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 153 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
144 | 154 | ||
145 | if (! plainTxt) { //use RichText, inline pics etc. | 155 | if (! plainTxt) { //use RichText, inline pics etc. |
146 | emailView->setTextFormat(QTextView::RichText); | 156 | emailView->setTextFormat(QTextView::RichText); |
147 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 157 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
148 | +"</font></center></big></b><br>"; | 158 | +"</font></center></big></b><br>"; |
149 | text += "<b>From: </b>" + mail->from + " <i>" + | 159 | text += "<b>From: </b>" + mail->from + " <i>" + |
150 | mail->fromMail + "</i><br>"; | 160 | mail->fromMail + "</i><br>"; |
151 | 161 | ||
152 | text +="<b>To: </b>"; | 162 | text +="<b>To: </b>"; |
153 | for (QStringList::Iterator it = mail->recipients.begin(); | 163 | for (QStringList::Iterator it = mail->recipients.begin(); |
154 | it != mail->recipients.end(); ++it ) { | 164 | it != mail->recipients.end(); ++it ) { |
155 | text += *it + " "; | 165 | text += *it + " "; |
156 | } | 166 | } |
157 | 167 | ||
158 | text +="<br><b>CC: </b>"; | 168 | text +="<br><b>CC: </b>"; |
159 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | 169 | for (QStringList::Iterator it = mail->carbonCopies.begin(); |
160 | it != mail->carbonCopies.end(); ++it ) { | 170 | it != mail->carbonCopies.end(); ++it ) { |
161 | text += *it + " "; | 171 | text += *it + " "; |
162 | } | 172 | } |
163 | 173 | ||
164 | text += "<br>" + mail->date; | 174 | text += "<br>" + mail->date; |
165 | 175 | ||
166 | if (mail->files.count() > 0) { | 176 | if (mail->files.count() > 0) { |
167 | text += "<br><b>Attatchments: </b>"; | 177 | text += "<br><b>Attatchments: </b>"; |
168 | 178 | ||
169 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 179 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
170 | text += ePtr->originalName + " "; | 180 | text += ePtr->originalName + " "; |
171 | } | 181 | } |
172 | text += "<hr><br>" + mail->body; | 182 | text += "<hr><br>" + mail->body; |
173 | 183 | ||
174 | if (inbox) { | 184 | if (inbox) { |
175 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 185 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
176 | 186 | ||
177 | text += "<br><hr><b>Attatchment: </b>" + | 187 | text += "<br><hr><b>Attatchment: </b>" + |
178 | ePtr->originalName + "<hr>"; | 188 | ePtr->originalName + "<hr>"; |
179 | 189 | ||
180 | if (ePtr->contentType == "TEXT") { | 190 | if (ePtr->contentType == "TEXT") { |
181 | QFile f(ePtr->path + ePtr->name); | 191 | QFile f(ePtr->path + ePtr->name); |
182 | 192 | ||
183 | if (f.open(IO_ReadOnly) ) { | 193 | if (f.open(IO_ReadOnly) ) { |
184 | QTextStream t(&f); | 194 | QTextStream t(&f); |
185 | temp = t.read(); | 195 | temp = t.read(); |
186 | text += temp + "<br>"; | 196 | text += temp + "<br>"; |
187 | f.close(); | 197 | f.close(); |
188 | } else { | 198 | } else { |
189 | text += "<b>Could not locate file</b><br>"; | 199 | text += "<b>Could not locate file</b><br>"; |
190 | } | 200 | } |
191 | 201 | ||
192 | } | 202 | } |
193 | if (ePtr->contentType == "IMAGE") { | 203 | if (ePtr->contentType == "IMAGE") { |
194 | // temp.setNum(emailView->width());//get display width | 204 | // temp.setNum(emailView->width());//get display width |
195 | // text += "<img width=" + temp +" src =""" + | 205 | // text += "<img width=" + temp +" src =""" + |
196 | // ePtr->originalName + """> </img>"; | 206 | // ePtr->originalName + """> </img>"; |
197 | text += "<img src =""" + | 207 | text += "<img src =""" + |
198 | ePtr->originalName + """> </img>"; | 208 | ePtr->originalName + """> </img>"; |
199 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 209 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
200 | } | 210 | } |
201 | } | 211 | } |
202 | } | 212 | } |
203 | } else { | 213 | } else { |
204 | if (mail->downloaded || !inbox) { | 214 | if (mail->downloaded || !inbox) { |
205 | text += "<hr><br>" + mail->body; | 215 | text += "<hr><br>" + mail->body; |
206 | } else { | 216 | } else { |
207 | text += "<hr><br><b> Awaiting download </b><br>"; | 217 | text += "<hr><br><b> Awaiting download </b><br>"; |
208 | text += "Size of mail: " + mailStringSize; | 218 | text += "Size of mail: " + mailStringSize; |
209 | } | 219 | } |
210 | } | 220 | } |
211 | emailView->setText(text); | 221 | emailView->setText(text); |
212 | } else { // show plain txt mail | 222 | } else { // show plain txt mail |
213 | emailView->setTextFormat(QTextView::PlainText); | 223 | emailView->setTextFormat(QTextView::PlainText); |
214 | text = "Subject: " + mail->subject + "\n"; | 224 | text = "Subject: " + mail->subject + "\n"; |
215 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; | 225 | text += "From: " + mail->from + " " + mail->fromMail + "\n"; |
216 | text += "To: "; | 226 | text += "To: "; |
217 | for (QStringList::Iterator it = mail->recipients.begin(); | 227 | for (QStringList::Iterator it = mail->recipients.begin(); |
218 | it != mail->recipients.end(); ++it ) { | 228 | it != mail->recipients.end(); ++it ) { |
219 | text += *it + " "; | 229 | text += *it + " "; |
220 | } | 230 | } |
221 | 231 | ||
222 | text += "\nCC: "; | 232 | text += "\nCC: "; |
223 | for (QStringList::Iterator it = mail->carbonCopies.begin(); | 233 | for (QStringList::Iterator it = mail->carbonCopies.begin(); |
224 | it != mail->carbonCopies.end(); ++it ) { | 234 | it != mail->carbonCopies.end(); ++it ) { |
225 | text += *it + " "; | 235 | text += *it + " "; |
226 | } | 236 | } |
227 | 237 | ||
228 | 238 | ||
229 | text += "\nDate: " + mail->date + "\n"; | 239 | text += "\nDate: " + mail->date + "\n"; |
230 | if (mail->files.count() > 0) { | 240 | if (mail->files.count() > 0) { |
231 | text += "Attatchments: "; | 241 | text += "Attatchments: "; |
232 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 242 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
233 | text += ePtr->originalName + " "; | 243 | text += ePtr->originalName + " "; |
234 | } | 244 | } |
235 | text += "\n\n"; | 245 | text += "\n\n"; |
236 | } else text += "\n"; | 246 | } else text += "\n"; |
237 | 247 | ||
238 | if (!inbox) { | 248 | if (!inbox) { |
239 | text += mail->body; | 249 | text += mail->body; |
240 | } else if (mail->downloaded) { | 250 | } else if (mail->downloaded) { |
241 | text += mail->bodyPlain; | 251 | text += mail->bodyPlain; |
242 | } else { | 252 | } else { |
243 | text += "\nAwaiting download\n"; | 253 | text += "\nAwaiting download\n"; |
244 | text += "Size of mail: " + mailStringSize; | 254 | text += "Size of mail: " + mailStringSize; |
245 | } | 255 | } |
246 | 256 | ||
247 | emailView->setText(text); | 257 | emailView->setText(text); |
248 | } | 258 | } |
249 | 259 | ||
250 | if (mail->files.count() == 0) | 260 | if (mail->files.count() == 0) |
251 | attatchmentsButton->setEnabled(FALSE); | 261 | attachmentButton->setEnabled(FALSE); |
252 | else attatchmentsButton->setEnabled(TRUE); | 262 | else attachmentButton->setEnabled(TRUE); |
253 | 263 | ||
254 | setCaption("Examining mail: " + mail->subject); | 264 | setCaption("Examining mail: " + mail->subject); |
255 | } | 265 | } |
256 | 266 | ||
257 | //update view with current EmailListItem (item) | 267 | //update view with current EmailListItem (item) |
258 | void ReadMail::update(QListView *thisView, Email *mailIn) | 268 | void ReadMail::update(QListView *thisView, Email *mailIn) |
259 | { | 269 | { |
260 | view = thisView; | 270 | view = thisView; |
261 | item = (EmailListItem *) view->selectedItem(); | 271 | item = (EmailListItem *) view->selectedItem(); |
262 | mail = mailIn; | 272 | mail = mailIn; |
263 | updateView(); | 273 | updateView(); |
264 | updateButtons(); | 274 | updateButtons(); |
265 | } | 275 | } |
266 | 276 | ||
267 | void ReadMail::mailUpdated(Email *mailIn) | 277 | void ReadMail::mailUpdated(Email *mailIn) |
268 | { | 278 | { |
269 | if (mailIn == mail) { | 279 | if (mailIn == mail) { |
270 | updateView(); | 280 | updateView(); |
271 | } else { | 281 | } else { |
272 | updateButtons(); | 282 | updateButtons(); |
273 | } | 283 | } |
274 | } | 284 | } |
275 | 285 | ||
276 | void ReadMail::close() | 286 | void ReadMail::close() |
277 | { | 287 | { |
278 | emit cancelView(); | 288 | emit cancelView(); |
279 | } | 289 | } |
280 | 290 | ||
281 | //gets next item in listview, exits if there is no next | 291 | //gets next item in listview, exits if there is no next |
282 | void ReadMail::next() | 292 | void ReadMail::next() |
283 | { | 293 | { |
284 | item = (EmailListItem *) item->nextSibling(); | 294 | item = (EmailListItem *) item->nextSibling(); |
285 | if (item != NULL) { | 295 | if (item != NULL) { |
286 | mail = item->getMail(); | 296 | mail = item->getMail(); |
287 | updateView(); | 297 | updateView(); |
288 | } | 298 | } |
289 | updateButtons(); | 299 | updateButtons(); |
290 | } | 300 | } |
291 | 301 | ||
292 | //gets previous item in listview, exits if there is no previous | 302 | //gets previous item in listview, exits if there is no previous |
293 | void ReadMail::previous() | 303 | void ReadMail::previous() |
294 | { | 304 | { |
295 | item = (EmailListItem *) item->itemAbove(); | 305 | item = (EmailListItem *) item->itemAbove(); |
296 | if (item != NULL) { | 306 | if (item != NULL) { |
297 | mail = item->getMail(); | 307 | mail = item->getMail(); |
298 | updateView(); | 308 | updateView(); |
299 | } | 309 | } |
300 | updateButtons(); | 310 | updateButtons(); |
301 | } | 311 | } |
302 | 312 | ||
303 | //deletes item, tries bringing up next or previous, exits if unsucessful | 313 | //deletes item, tries bringing up next or previous, exits if unsucessful |
304 | void ReadMail::deleteItem() | 314 | void ReadMail::deleteItem() |
305 | { | 315 | { |
306 | EmailListItem *temp = item; | 316 | EmailListItem *temp = item; |
307 | temp = (EmailListItem *) item->nextSibling();//trybelow | 317 | temp = (EmailListItem *) item->nextSibling();//trybelow |
308 | if (temp == NULL) | 318 | if (temp == NULL) |
309 | temp = (EmailListItem *) item->itemAbove(); //try above | 319 | temp = (EmailListItem *) item->itemAbove(); //try above |
310 | 320 | ||
311 | emit removeItem(item, inbox); | 321 | emit removeItem(item, inbox); |
312 | 322 | ||
313 | item = temp; | 323 | item = temp; |
314 | if (item != NULL) { //more items in list | 324 | if (item != NULL) { //more items in list |
315 | mail = item->getMail(); | 325 | mail = item->getMail(); |
316 | updateView(); | 326 | updateView(); |
317 | updateButtons(); | 327 | updateButtons(); |
318 | } else close(); //no more items to see | 328 | } else close(); //no more items to see |
319 | } | 329 | } |
320 | 330 | ||
321 | void ReadMail::updateButtons() | 331 | void ReadMail::updateButtons() |
322 | { | 332 | { |
323 | EmailListItem *temp; | 333 | EmailListItem *temp; |
324 | 334 | ||
325 | temp = item; | 335 | temp = item; |
326 | if ((EmailListItem *) temp->nextSibling() == NULL) | 336 | if ((EmailListItem *) temp->nextSibling() == NULL) |
327 | nextButton->setEnabled(FALSE); | 337 | nextButton->setEnabled(FALSE); |
328 | else nextButton->setEnabled(TRUE); | 338 | else nextButton->setEnabled(TRUE); |
329 | 339 | ||
330 | temp = item; | 340 | temp = item; |
331 | if ((EmailListItem *) temp->itemAbove() == NULL) | 341 | if ((EmailListItem *) temp->itemAbove() == NULL) |
332 | previousButton->setEnabled(FALSE); | 342 | previousButton->setEnabled(FALSE); |
333 | else previousButton->setEnabled(TRUE); | 343 | else previousButton->setEnabled(TRUE); |
334 | } | 344 | } |
335 | 345 | ||
336 | void ReadMail::shiftText() | 346 | void ReadMail::shiftText() |
337 | { | 347 | { |
338 | plainTxt = ! plainTxt; | 348 | plainTxt = ! plainTxt; |
339 | updateView(); | 349 | updateView(); |
340 | } | 350 | } |
341 | 351 | ||
342 | void ReadMail::viewAttatchments() | 352 | void ReadMail::viewAttachments() |
343 | { | 353 | { |
344 | viewAtt->update(mail, inbox); | 354 | viewAtt->update(mail, inbox); |
345 | viewAtt->showMaximized(); | 355 | viewAtt->showMaximized(); |
346 | } | 356 | } |
347 | 357 | ||
348 | void ReadMail::reply() | 358 | void ReadMail::reply() |
349 | { | 359 | { |
350 | emit replyRequested(*mail, (bool&)TRUE); | 360 | emit replyRequested(*mail, (bool&)TRUE); |
351 | } | 361 | } |
352 | 362 | ||
353 | void ReadMail::forward() | 363 | void ReadMail::forward() |
354 | { | 364 | { |
355 | emit forwardRequested(*mail); | 365 | emit forwardRequested(*mail); |
356 | } | 366 | } |
357 | 367 | ||
diff --git a/noncore/unsupported/mailit/readmail.h b/noncore/unsupported/mailit/readmail.h index 0fe0646..df32c34 100644 --- a/noncore/unsupported/mailit/readmail.h +++ b/noncore/unsupported/mailit/readmail.h | |||
@@ -1,89 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef READMAIL_H | 20 | #ifndef READMAIL_H |
21 | #define READMAIL_H | 21 | #define READMAIL_H |
22 | 22 | ||
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtextview.h> | 30 | #include <qtextview.h> |
31 | 31 | ||
32 | #include "emailhandler.h" | 32 | #include "emailhandler.h" |
33 | #include "emaillistitem.h" | 33 | #include "emaillistitem.h" |
34 | #include "viewatt.h" | 34 | #include "viewatt.h" |
35 | 35 | ||
36 | class ReadMail : public QMainWindow | 36 | class ReadMail : public QMainWindow |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~ReadMail(); | 42 | ~ReadMail(); |
43 | void update(QListView *thisView, Email *mailIn); | 43 | void update(QListView *thisView, Email *mailIn); |
44 | void updateView(); | 44 | void updateView(); |
45 | void mailUpdated(Email *mailIn); | 45 | void mailUpdated(Email *mailIn); |
46 | 46 | ||
47 | signals: | 47 | signals: |
48 | void cancelView(); | 48 | void cancelView(); |
49 | void replyRequested(Email &, bool &); | 49 | void replyRequested(Email &, bool &); |
50 | void forwardRequested(Email&); | 50 | void forwardRequested(Email&); |
51 | void removeItem(EmailListItem *, bool &); | 51 | void removeItem(EmailListItem *, bool &); |
52 | void viewingMail(Email *); | 52 | void viewingMail(Email *); |
53 | 53 | ||
54 | public slots: | 54 | public slots: |
55 | void close(); | 55 | void close(); |
56 | void next(); | 56 | void next(); |
57 | void previous(); | 57 | void previous(); |
58 | void deleteItem(); | 58 | void deleteItem(); |
59 | void shiftText(); | 59 | void shiftText(); |
60 | void viewAttatchments(); | 60 | void viewAttachments(); |
61 | void reply(); | 61 | void reply(); |
62 | void forward(); | 62 | void forward(); |
63 | 63 | ||
64 | private: | 64 | private: |
65 | void init(); | 65 | void init(); |
66 | void updateButtons(); | 66 | void updateButtons(); |
67 | 67 | ||
68 | private: | 68 | private: |
69 | QListView *view; | 69 | QListView *view; |
70 | EmailListItem *item; | 70 | EmailListItem *item; |
71 | bool plainTxt, inbox; | 71 | bool plainTxt, inbox; |
72 | Email *mail; | 72 | Email *mail; |
73 | ViewAtt *viewAtt; | 73 | ViewAtt *viewAtt; |
74 | 74 | ||
75 | QToolBar *bar; | 75 | QToolBar *bar; |
76 | QMenuBar *menu; | 76 | QMenuBar *menu; |
77 | QPopupMenu *viewMenu, *mailMenu; | 77 | QPopupMenu *viewMenu, *mailMenu; |
78 | QAction *deleteButton; | 78 | QAction *deleteButton; |
79 | QMimeSourceFactory *mime; | 79 | QMimeSourceFactory *mime; |
80 | QAction *plainTextButton; | 80 | QAction *plainTextButton; |
81 | QAction *nextButton; | 81 | QAction *nextButton; |
82 | QTextView *emailView; | 82 | QTextView *emailView; |
83 | QAction *attatchmentsButton; | 83 | QAction *attachmentButton; |
84 | QAction *previousButton; | 84 | QAction *previousButton; |
85 | QAction *replyButton; | 85 | QAction *replyButton; |
86 | QAction *forwardButton; | 86 | QAction *forwardButton; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #endif // READMAIL_H | 89 | #endif // READMAIL_H |
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp index b2e38e5..8a51a5b 100644 --- a/noncore/unsupported/mailit/smtpclient.cpp +++ b/noncore/unsupported/mailit/smtpclient.cpp | |||
@@ -1,171 +1,163 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "smtpclient.h" | 20 | #include "smtpclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | 22 | ||
23 | SmtpClient::SmtpClient() | 23 | SmtpClient::SmtpClient() |
24 | { | 24 | { |
25 | socket = new QSocket(this, "smtpClient"); | 25 | socket = new QSocket(this, "smtpClient"); |
26 | stream = new QTextStream(socket); | 26 | stream = new QTextStream(socket); |
27 | mailList.setAutoDelete(TRUE); | 27 | mailList.setAutoDelete(TRUE); |
28 | 28 | ||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus(tr("Connection established")); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | //qDebug(response); | ||
91 | 90 | ||
92 | switch(status) { | 91 | switch(status) { |
93 | case Init: { | 92 | case Init: { |
94 | if (response[0] == '2') { | 93 | if (response[0] == '2') { |
95 | status = From; | 94 | status = From; |
96 | mailPtr = mailList.first(); | 95 | mailPtr = mailList.first(); |
97 | *stream << "HELO there\r\n"; | 96 | *stream << "HELO there\r\n"; |
98 | //qDebug("HELO"); | ||
99 | } else errorHandling(ErrUnknownResponse); | 97 | } else errorHandling(ErrUnknownResponse); |
100 | break; | 98 | break; |
101 | } | 99 | } |
102 | case From: { | 100 | case From: { |
103 | if (response[0] == '2') { | 101 | if (response[0] == '2') { |
104 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; | 102 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; |
105 | status = Recv; | 103 | status = Recv; |
106 | //qDebug("MAIL FROM: "+mailPtr->from); | ||
107 | } else errorHandling(ErrUnknownResponse); | 104 | } else errorHandling(ErrUnknownResponse); |
108 | break; | 105 | break; |
109 | } | 106 | } |
110 | case Recv: { | 107 | case Recv: { |
111 | if (response[0] == '2') { | 108 | if (response[0] == '2') { |
112 | it = mailPtr->to.begin(); | 109 | it = mailPtr->to.begin(); |
113 | if (it == NULL) | 110 | if (it == NULL) |
114 | errorHandling(ErrUnknownResponse); | 111 | errorHandling(ErrUnknownResponse); |
115 | *stream << "RCPT TO: " << *it << ">\r\n"; | 112 | *stream << "RCPT TO: " << *it << ">\r\n"; |
116 | //qDebug("RCPT TO: "+ *it); | ||
117 | status = MRcv; | 113 | status = MRcv; |
118 | } else errorHandling(ErrUnknownResponse); | 114 | } else errorHandling(ErrUnknownResponse); |
119 | break; | 115 | break; |
120 | } | 116 | } |
121 | case MRcv: { | 117 | case MRcv: { |
122 | if (response[0] == '2') { | 118 | if (response[0] == '2') { |
123 | it++; | 119 | it++; |
124 | if ( it != mailPtr->to.end() ) { | 120 | if ( it != mailPtr->to.end() ) { |
125 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 121 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
126 | //qDebug("RCPT TO: "+ *it); | ||
127 | break; | 122 | break; |
128 | } else { | 123 | } else { |
129 | status = Data; | 124 | status = Data; |
130 | } | 125 | } |
131 | } else errorHandling(ErrUnknownResponse); | 126 | } else errorHandling(ErrUnknownResponse); |
132 | } | 127 | } |
133 | case Data: { | 128 | case Data: { |
134 | if (response[0] == '2') { | 129 | if (response[0] == '2') { |
135 | *stream << "DATA\r\n"; | 130 | *stream << "DATA\r\n"; |
136 | status = Body; | 131 | status = Body; |
137 | //qDebug("DATA"); | ||
138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); | 132 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
139 | } else errorHandling(ErrUnknownResponse); | 133 | } else errorHandling(ErrUnknownResponse); |
140 | break; | 134 | break; |
141 | } | 135 | } |
142 | case Body: { | 136 | case Body: { |
143 | if (response[0] == '3') { | 137 | if (response[0] == '3') { |
144 | *stream << mailPtr->body << "\r\n.\r\n"; | 138 | *stream << mailPtr->body << "\r\n.\r\n"; |
145 | mailPtr = mailList.next(); | 139 | mailPtr = mailList.next(); |
146 | if (mailPtr != NULL) { | 140 | if (mailPtr != NULL) { |
147 | status = From; | 141 | status = From; |
148 | } else { | 142 | } else { |
149 | status = Quit; | 143 | status = Quit; |
150 | } | 144 | } |
151 | //qDebug("BODY"); | ||
152 | } else errorHandling(ErrUnknownResponse); | 145 | } else errorHandling(ErrUnknownResponse); |
153 | break; | 146 | break; |
154 | } | 147 | } |
155 | case Quit: { | 148 | case Quit: { |
156 | if (response[0] == '2') { | 149 | if (response[0] == '2') { |
157 | *stream << "QUIT\r\n"; | 150 | *stream << "QUIT\r\n"; |
158 | status = Done; | 151 | status = Done; |
159 | QString temp; | 152 | QString temp; |
160 | temp.setNum(mailList.count()); | 153 | temp.setNum(mailList.count()); |
161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); | 154 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
162 | emit mailSent(); | 155 | emit mailSent(); |
163 | mailList.clear(); | 156 | mailList.clear(); |
164 | sending = FALSE; | 157 | sending = FALSE; |
165 | socket->close(); | 158 | socket->close(); |
166 | //qDebug("QUIT"); | ||
167 | } else errorHandling(ErrUnknownResponse); | 159 | } else errorHandling(ErrUnknownResponse); |
168 | break; | 160 | break; |
169 | } | 161 | } |
170 | } | 162 | } |
171 | } | 163 | } |
diff --git a/noncore/unsupported/mailit/textparser.cpp b/noncore/unsupported/mailit/textparser.cpp index f082417..3fa5f6e 100644 --- a/noncore/unsupported/mailit/textparser.cpp +++ b/noncore/unsupported/mailit/textparser.cpp | |||
@@ -1,294 +1,304 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "textparser.h" | 20 | #include "textparser.h" |
21 | 21 | ||
22 | TextParser::TextParser(QString in, QString lineBreak) | 22 | TextParser::TextParser(QString in, QString lineBreak) |
23 | { | 23 | { |
24 | data = in; | 24 | data = in; |
25 | lineSep = lineBreak; | 25 | lineSep = lineBreak; |
26 | 26 | ||
27 | init(); | 27 | init(); |
28 | createSeparators(); | 28 | createSeparators(); |
29 | split(); | 29 | split(); |
30 | } | 30 | } |
31 | 31 | ||
32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) | 32 | TextParser::TextParser(QString in, QString lineBreak, QString sep) |
33 | { | 33 | { |
34 | data = in; | 34 | data = in; |
35 | lineSep = lineBreak; | 35 | lineSep = lineBreak; |
36 | 36 | ||
37 | init(); | 37 | init(); |
38 | separators = sep; | 38 | separators = sep; |
39 | split(); | 39 | split(); |
40 | } | 40 | } |
41 | 41 | ||
42 | void TextParser::init() | 42 | void TextParser::init() |
43 | { | 43 | { |
44 | lineCount = 0; | 44 | lineCount = 0; |
45 | linePos = 0; | 45 | linePos = 0; |
46 | totalElmCount = 0; | 46 | totalElmCount = 0; |
47 | separatorPos = -1; //not initialized | 47 | separatorPos = -1; //not initialized |
48 | wordPos = -1; //not initialized | 48 | wordPos = -1; //not initialized |
49 | sepAtLine = 0; | 49 | sepAtLine = 0; |
50 | sepAtPosElm = -1; //such that nextSep equals 0 | 50 | sepAtPosElm = -1; //such that nextSep equals 0 |
51 | wordAtLine = 0; | 51 | wordAtLine = 0; |
52 | wordAtPosElm = -1; //such that nextWord equals 0 | 52 | wordAtPosElm = -1; //such that nextWord equals 0 |
53 | atLine = 0; | 53 | atLine = 0; |
54 | atPosElm = 0; | 54 | atPosElm = 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | void TextParser::createSeparators() | 57 | void TextParser::createSeparators() |
58 | { | 58 | { |
59 | separators = " @#,.:;<>*/(){}|'?-+=_"; | 59 | separators = " @#,.:;<>*/(){}|'?-+=_"; |
60 | } | 60 | } |
61 | 61 | ||
62 | /*Returns pos of given search criteria, -1 if not found */ | 62 | /*Returns pos of given search criteria, -1 if not found */ |
63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) | 63 | int TextParser::find(QString target, QChar sep, int pos, bool upperCase) |
64 | { | 64 | { |
65 | |||
66 | t_splitElm parsstr; | ||
67 | QString pString; | ||
68 | |||
65 | int atLine = 0, atPosElm = 0; | 69 | int atLine = 0, atPosElm = 0; |
66 | 70 | ||
67 | for (int x = 0; x < totalElmCount; x++) { | 71 | getLineReference(pos,&atLine,&atPosElm); |
68 | if (x >= pos) { | 72 | |
69 | if (upperCase) { | 73 | for (int x = pos; x < totalElmCount; x++) |
70 | if ((splitDone[atLine].elm[atPosElm].str.upper() == target) && | 74 | { |
71 | (splitDone[atLine].elm[atPosElm].separator == sep)) | 75 | parsstr=splitDone[atLine].elm[atPosElm++]; |
72 | return x; | 76 | |
73 | } else { | 77 | if (upperCase) |
74 | if ((splitDone[atLine].elm[atPosElm].str == target) && | 78 | { |
75 | (splitDone[atLine].elm[atPosElm].separator == sep)) | 79 | pString=parsstr.str.upper(); |
76 | return x; | 80 | target=target.upper(); |
77 | } | 81 | } |
78 | } | 82 | else |
79 | atPosElm++; | 83 | { |
80 | if (atPosElm >= splitDone[atLine].elmCount) { //new Line | 84 | pString=parsstr.str; |
85 | } | ||
86 | if ((pString == target) && (parsstr.separator == sep)) | ||
87 | { | ||
88 | return x; | ||
89 | } | ||
90 | if (atPosElm >= splitDone[atLine].elmCount) | ||
91 | { //new Line | ||
81 | atLine++; | 92 | atLine++; |
82 | atPosElm = 0; | 93 | atPosElm = 0; |
83 | } | 94 | } |
84 | } | 95 | } |
85 | |||
86 | return -1; | 96 | return -1; |
87 | } | 97 | } |
88 | 98 | ||
89 | int TextParser::elmCount() | 99 | int TextParser::elmCount() |
90 | { | 100 | { |
91 | return totalElmCount; | 101 | return totalElmCount; |
92 | } | 102 | } |
93 | 103 | ||
94 | QChar TextParser::separatorAt(int pos) | 104 | QChar TextParser::separatorAt(int pos) |
95 | { | 105 | { |
96 | if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) | 106 | if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) |
97 | return QChar::null; | 107 | return QChar::null; |
98 | 108 | ||
99 | separatorPos = pos; | 109 | separatorPos = pos; |
100 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; | 110 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; |
101 | } | 111 | } |
102 | 112 | ||
103 | QChar TextParser::nextSeparator() | 113 | QChar TextParser::nextSeparator() |
104 | { | 114 | { |
105 | sepAtPosElm++; | 115 | sepAtPosElm++; |
106 | if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { | 116 | if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { |
107 | sepAtLine++; | 117 | sepAtLine++; |
108 | sepAtPosElm = 0; | 118 | sepAtPosElm = 0; |
109 | } | 119 | } |
110 | 120 | ||
111 | separatorPos++; | 121 | separatorPos++; |
112 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; | 122 | return splitDone[sepAtLine].elm[sepAtPosElm].separator; |
113 | } | 123 | } |
114 | 124 | ||
115 | bool TextParser::hasNextSeparator() | 125 | bool TextParser::hasNextSeparator() |
116 | { | 126 | { |
117 | return ((separatorPos+1) < totalElmCount); | 127 | return ((separatorPos+1) < totalElmCount); |
118 | } | 128 | } |
119 | 129 | ||
120 | QString TextParser::wordAt(int pos) | 130 | QString TextParser::wordAt(int pos) |
121 | { | 131 | { |
122 | if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) | 132 | if (getLineReference(pos, &wordAtLine, &wordAtPosElm) == -1) |
123 | return NULL; | 133 | return NULL; |
124 | 134 | ||
125 | wordPos = pos; | 135 | wordPos = pos; |
126 | return splitDone[wordAtLine].elm[wordAtPosElm].str; | 136 | return splitDone[wordAtLine].elm[wordAtPosElm].str; |
127 | } | 137 | } |
128 | 138 | ||
129 | QString TextParser::nextWord() | 139 | QString TextParser::nextWord() |
130 | { | 140 | { |
131 | wordAtPosElm++; | 141 | wordAtPosElm++; |
132 | if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { | 142 | if (splitDone[wordAtLine].elmCount <= wordAtPosElm) { |
133 | wordAtLine++; | 143 | wordAtLine++; |
134 | wordAtPosElm = 0; | 144 | wordAtPosElm = 0; |
135 | } | 145 | } |
136 | 146 | ||
137 | wordPos++; | 147 | wordPos++; |
138 | return splitDone[wordAtLine].elm[wordAtPosElm].str; | 148 | return splitDone[wordAtLine].elm[wordAtPosElm].str; |
139 | } | 149 | } |
140 | 150 | ||
141 | bool TextParser::hasNextWord() | 151 | bool TextParser::hasNextWord() |
142 | { | 152 | { |
143 | return ((wordPos + 1) < totalElmCount); | 153 | return ((wordPos + 1) < totalElmCount); |
144 | } | 154 | } |
145 | 155 | ||
146 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) | 156 | QString TextParser::getString(int *pos, QChar stop, bool lineEnd = false) |
147 | { | 157 | { |
148 | QString returnStr = wordAt(*pos); | 158 | QString returnStr = wordAt(*pos); |
149 | QChar chr = separatorAt(*pos); | 159 | QChar chr = separatorAt(*pos); |
150 | QString s; | 160 | QString s; |
151 | 161 | ||
152 | if (returnStr == "") | 162 | if (returnStr == "") |
153 | return ""; | 163 | return ""; |
154 | if (chr == stop) | 164 | if (chr == stop) |
155 | return returnStr; | 165 | return returnStr; |
156 | 166 | ||
157 | if (!lineEnd) { | 167 | if (!lineEnd) { |
158 | while ((chr != stop) && hasNextWord()) { | 168 | while ((chr != stop) && hasNextWord()) { |
159 | returnStr.append(chr); | 169 | returnStr.append(chr); |
160 | returnStr += nextWord(); | 170 | returnStr += nextWord(); |
161 | chr = nextSeparator(); | 171 | chr = nextSeparator(); |
162 | } | 172 | } |
163 | } else { //copy from pos to end of line | 173 | } else { //copy from pos to end of line |
164 | getLineReference(*pos, &atLine, &atPosElm); | 174 | getLineReference(*pos, &atLine, &atPosElm); |
165 | returnStr = ""; | 175 | returnStr = ""; |
166 | while (atPosElm < splitDone[atLine].elmCount) { | 176 | while (atPosElm < splitDone[atLine].elmCount) { |
167 | if (splitDone[atLine].elm[atPosElm].str != "") { | 177 | if (splitDone[atLine].elm[atPosElm].str != "") { |
168 | returnStr += splitDone[atLine].elm[atPosElm].str; | 178 | returnStr += splitDone[atLine].elm[atPosElm].str; |
169 | } | 179 | } |
170 | chr = splitDone[atLine].elm[atPosElm].separator; | 180 | chr = splitDone[atLine].elm[atPosElm].separator; |
171 | if (!chr.isNull() && (int) chr != 0) { | 181 | if (!chr.isNull() && (int) chr != 0) { |
172 | returnStr.append(splitDone[atLine].elm[atPosElm].separator); | 182 | returnStr.append(splitDone[atLine].elm[atPosElm].separator); |
173 | } | 183 | } |
174 | atPosElm++; | 184 | atPosElm++; |
175 | } | 185 | } |
176 | } | 186 | } |
177 | 187 | ||
178 | *pos = wordPos; | 188 | *pos = wordPos; |
179 | return returnStr; | 189 | return returnStr; |
180 | } | 190 | } |
181 | 191 | ||
182 | QString TextParser::getNextLine() | 192 | QString TextParser::getNextLine() |
183 | { | 193 | { |
184 | atLine++; | 194 | atLine++; |
185 | atPosElm = 0; | 195 | atPosElm = 0; |
186 | if (atLine < lineCount) | 196 | if (atLine < lineCount) |
187 | return splitDone[atLine].str; | 197 | return splitDone[atLine].str; |
188 | return ""; | 198 | return ""; |
189 | } | 199 | } |
190 | 200 | ||
191 | bool TextParser::hasNextLine() | 201 | bool TextParser::hasNextLine() |
192 | { | 202 | { |
193 | if (atLine+1 < lineCount) | 203 | if (atLine+1 < lineCount) |
194 | return TRUE;; | 204 | return TRUE;; |
195 | return FALSE; | 205 | return FALSE; |
196 | } | 206 | } |
197 | 207 | ||
198 | int TextParser::endLinePos(int pos) | 208 | int TextParser::endLinePos(int pos) |
199 | { | 209 | { |
200 | if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) | 210 | if ( (getLineReference(pos, &atLine, &atPosElm)) == -1) |
201 | return -1; | 211 | return -1; |
202 | 212 | ||
203 | return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); | 213 | return (pos + (splitDone[atLine].elmCount - atPosElm) + 1); |
204 | } | 214 | } |
205 | 215 | ||
206 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) | 216 | int TextParser::getLineReference(int pos, int *line, int *inLinePos) |
207 | { | 217 | { |
208 | int currentPos = 0; | 218 | int currentPos = 0; |
209 | 219 | ||
210 | for (int x = 0; x < lineCount; x++) { | 220 | for (int x = 0; x < lineCount; x++) { |
211 | if ( currentPos + splitDone[x].elmCount > pos) { | 221 | if ( currentPos + splitDone[x].elmCount > pos) { |
212 | *line = x; | 222 | *line = x; |
213 | *inLinePos = pos - currentPos; | 223 | *inLinePos = pos - currentPos; |
214 | return 0; //pos found okay | 224 | return 0; //pos found okay |
215 | } | 225 | } |
216 | currentPos += splitDone[x].elmCount; | 226 | currentPos += splitDone[x].elmCount; |
217 | } | 227 | } |
218 | return -1; //no reference found | 228 | return -1; //no reference found |
219 | } | 229 | } |
220 | 230 | ||
221 | void TextParser::split() | 231 | void TextParser::split() |
222 | { | 232 | { |
223 | t_splitLine newLine; | 233 | t_splitLine newLine; |
224 | 234 | ||
225 | while ((uint) linePos < data.length()) { | 235 | while ((uint) linePos < data.length()) { |
226 | newLine = nextLine(); | 236 | newLine = nextLine(); |
227 | splitDone[lineCount] = splitLine(newLine); | 237 | splitDone[lineCount] = splitLine(newLine); |
228 | totalElmCount += splitDone[lineCount].elmCount; | 238 | totalElmCount += splitDone[lineCount].elmCount; |
229 | lineCount++; | 239 | lineCount++; |
230 | } | 240 | } |
231 | } | 241 | } |
232 | 242 | ||
233 | t_splitLine TextParser::splitLine(t_splitLine line) | 243 | t_splitLine TextParser::splitLine(t_splitLine line) |
234 | { | 244 | { |
235 | uint pos = 0; | 245 | uint pos = 0; |
236 | uint elmCount = 0; | 246 | uint elmCount = 0; |
237 | t_splitLine tempLine = line; | 247 | t_splitLine tempLine = line; |
238 | 248 | ||
239 | tempLine.str = line.str.simplifyWhiteSpace(); | 249 | tempLine.str = line.str.simplifyWhiteSpace(); |
240 | tempLine.elm[0].str = ""; | 250 | tempLine.elm[0].str = ""; |
241 | while ( pos < line.str.length() ) { | 251 | while ( pos < line.str.length() ) { |
242 | if ( isSeparator(tempLine.str[pos]) ) { | 252 | if ( isSeparator(tempLine.str[pos]) ) { |
243 | tempLine.elm[elmCount].separator = tempLine.str[pos]; | 253 | tempLine.elm[elmCount].separator = tempLine.str[pos]; |
244 | elmCount++; | 254 | elmCount++; |
245 | pos++; | 255 | pos++; |
246 | while (tempLine.str[pos] == ' ') | 256 | while (tempLine.str[pos] == ' ') |
247 | pos++; | 257 | pos++; |
248 | if (pos > line.str.length()) | 258 | if (pos > line.str.length()) |
249 | elmCount--; | 259 | elmCount--; |
250 | tempLine.elm[elmCount].str = ""; | 260 | tempLine.elm[elmCount].str = ""; |
251 | } else { | 261 | } else { |
252 | if (!tempLine.str[pos].isNull()) | 262 | if (!tempLine.str[pos].isNull()) |
253 | tempLine.elm[elmCount].str += tempLine.str[pos]; | 263 | tempLine.elm[elmCount].str += tempLine.str[pos]; |
254 | pos++; | 264 | pos++; |
255 | } | 265 | } |
256 | } | 266 | } |
257 | 267 | ||
258 | tempLine.elmCount = elmCount + 1; | 268 | tempLine.elmCount = elmCount + 1; |
259 | return tempLine; | 269 | return tempLine; |
260 | } | 270 | } |
261 | 271 | ||
262 | bool TextParser::isSeparator(QChar chr) | 272 | bool TextParser::isSeparator(QChar chr) |
263 | { | 273 | { |
264 | for (uint x = 0; x < separators.length(); x++) { | 274 | for (uint x = 0; x < separators.length(); x++) { |
265 | if (chr == separators[x]) | 275 | if (chr == separators[x]) |
266 | return true; | 276 | return true; |
267 | } | 277 | } |
268 | return false; | 278 | return false; |
269 | } | 279 | } |
270 | 280 | ||
271 | t_splitLine TextParser::nextLine() | 281 | t_splitLine TextParser::nextLine() |
272 | { | 282 | { |
273 | int newLinePos; | 283 | int newLinePos; |
274 | t_splitLine lineType; | 284 | t_splitLine lineType; |
275 | 285 | ||
276 | newLinePos = data.find(lineSep, linePos); | 286 | newLinePos = data.find(lineSep, linePos); |
277 | 287 | ||
278 | lineType.lineType = NewLine; | 288 | lineType.lineType = NewLine; |
279 | lineType.str = ""; | 289 | lineType.str = ""; |
280 | 290 | ||
281 | if (newLinePos == -1) { | 291 | if (newLinePos == -1) { |
282 | newLinePos = data.length(); | 292 | newLinePos = data.length(); |
283 | lineType.lineType = LastLine; | 293 | lineType.lineType = LastLine; |
284 | } | 294 | } |
285 | 295 | ||
286 | for (int x = linePos; x < newLinePos; x++) | 296 | for (int x = linePos; x < newLinePos; x++) |
287 | lineType.str += data[x]; | 297 | lineType.str += data[x]; |
288 | 298 | ||
289 | linePos = newLinePos; | 299 | linePos = newLinePos; |
290 | if ((uint) linePos < data.length()) //if not EOF, add length of lineSep | 300 | if ((uint) linePos < data.length()) //if not EOF, add length of lineSep |
291 | linePos += lineSep.length(); | 301 | linePos += lineSep.length(); |
292 | 302 | ||
293 | return lineType; | 303 | return lineType; |
294 | } | 304 | } |
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp index b6f5015..21885c2 100644 --- a/noncore/unsupported/mailit/viewatt.cpp +++ b/noncore/unsupported/mailit/viewatt.cpp | |||
@@ -1,118 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "resource.h" | 20 | #include "resource.h" |
21 | #include "viewatt.h" | 21 | #include "viewatt.h" |
22 | #include <qwhatsthis.h> | ||
22 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
23 | #include <qpe/mimetype.h> | 24 | #include <qpe/mimetype.h> |
24 | 25 | ||
25 | ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) | 26 | ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) |
26 | : QMainWindow(parent, name, f) | 27 | : QMainWindow(parent, name, f) |
27 | { | 28 | { |
28 | setCaption("Exploring attatchments"); | 29 | setCaption("Exploring attatchments"); |
29 | 30 | ||
30 | setToolBarsMovable( FALSE ); | 31 | setToolBarsMovable( FALSE ); |
31 | bar = new QToolBar(this); | 32 | bar = new QToolBar(this); |
32 | installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); | 33 | installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); |
33 | connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); | 34 | connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); |
35 | installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); | ||
34 | 36 | ||
35 | listView = new QListView(this, "AttView"); | 37 | listView = new QListView(this, "AttView"); |
36 | listView->addColumn( "Attatchment" ); | 38 | listView->addColumn( "Attatchment" ); |
37 | listView->addColumn( "Type" ); | 39 | listView->addColumn( "Type" ); |
38 | listView->addColumn( "Installed" ); | 40 | listView->addColumn( "Installed" ); |
39 | setCentralWidget(listView); | 41 | setCentralWidget(listView); |
42 | QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | void ViewAtt::update(Email *mailIn, bool inbox) | 45 | void ViewAtt::update(Email *mailIn, bool inbox) |
43 | { | 46 | { |
44 | QListViewItem *item; | 47 | QListViewItem *item; |
45 | Enclosure *ePtr; | 48 | Enclosure *ePtr; |
46 | 49 | ||
47 | 50 | ||
48 | 51 | ||
49 | listView->clear(); | 52 | listView->clear(); |
50 | if (inbox) { | 53 | if (inbox) { |
51 | bar->clear(); | 54 | bar->clear(); |
52 | installButton->addTo( bar ); | 55 | installButton->addTo( bar ); |
53 | bar->show(); | 56 | bar->show(); |
54 | } else { | 57 | } else { |
55 | bar->hide(); | 58 | bar->hide(); |
56 | } | 59 | } |
57 | 60 | ||
58 | mail = mailIn; | 61 | mail = mailIn; |
59 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 62 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
60 | 63 | ||
61 | QString isInstalled = "No"; | 64 | QString isInstalled = "No"; |
62 | if (ePtr->installed) | 65 | if (ePtr->installed) |
63 | isInstalled = "Yes"; | 66 | isInstalled = "Yes"; |
64 | item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); | 67 | item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); |
65 | 68 | ||
66 | const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; | 69 | const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; |
67 | 70 | ||
68 | MimeType mt(mtypeDef); | 71 | MimeType mt(mtypeDef); |
69 | 72 | ||
70 | item->setPixmap(0, mt.pixmap()); | 73 | item->setPixmap(0, mt.pixmap()); |
71 | 74 | ||
72 | /* | 75 | /* |
73 | if (ePtr->contentType == "TEXT") { | 76 | if (ePtr->contentType == "TEXT") { |
74 | actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); | 77 | actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); |
75 | actions->addTo(bar); | 78 | actions->addTo(bar); |
76 | } | 79 | } |
77 | if (ePtr->contentType == "AUDIO") { | 80 | if (ePtr->contentType == "AUDIO") { |
78 | actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); | 81 | actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); |
79 | actions->addTo(bar); | 82 | actions->addTo(bar); |
80 | item->setPixmap(0, Resource::loadPixmap("play")); | 83 | item->setPixmap(0, Resource::loadPixmap("play")); |
81 | } | 84 | } |
82 | if (ePtr->contentType == "IMAGE") { | 85 | if (ePtr->contentType == "IMAGE") { |
83 | actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); | 86 | actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); |
84 | actions->addTo(bar); | 87 | actions->addTo(bar); |
85 | item->setPixmap(0, Resource::loadPixmap("pixmap")); | 88 | item->setPixmap(0, Resource::loadPixmap("pixmap")); |
86 | }*/ | 89 | }*/ |
87 | } | 90 | } |
88 | } | 91 | } |
89 | 92 | ||
90 | void ViewAtt::install() | 93 | void ViewAtt::install() |
91 | { | 94 | { |
92 | Enclosure *ePtr, *selPtr; | 95 | Enclosure *ePtr, *selPtr; |
93 | QListViewItem *item; | 96 | QListViewItem *item; |
94 | QString filename; | 97 | QString filename; |
95 | DocLnk d; | 98 | DocLnk d; |
96 | 99 | ||
97 | item = listView->selectedItem(); | 100 | item = listView->selectedItem(); |
98 | if (item != NULL) { | 101 | if (item != NULL) { |
99 | filename = item->text(0); | 102 | filename = item->text(0); |
100 | selPtr = NULL; | 103 | selPtr = NULL; |
101 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 104 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
102 | if (ePtr->originalName == filename) | 105 | if (ePtr->originalName == filename) |
103 | selPtr = ePtr; | 106 | selPtr = ePtr; |
104 | } | 107 | } |
105 | 108 | ||
106 | if (selPtr == NULL) { | 109 | if (selPtr == NULL) { |
107 | qWarning("Internal error, file is not installed to documents"); | 110 | qWarning("Internal error, file is not installed to documents"); |
108 | return; | 111 | return; |
109 | } | 112 | } |
110 | 113 | ||
111 | d.setName(selPtr->originalName); | 114 | d.setName(selPtr->originalName); |
112 | d.setFile(selPtr->path + selPtr->name); | 115 | d.setFile(selPtr->path + selPtr->name); |
113 | d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); | 116 | d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); |
114 | d.writeLink(); | 117 | d.writeLink(); |
115 | selPtr->installed = TRUE; | 118 | selPtr->installed = TRUE; |
116 | item->setText(2, "Yes"); | 119 | item->setText(2, "Yes"); |
117 | } | 120 | } |
118 | } | 121 | } |
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index a9dcb02..0336c83 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp | |||
@@ -1,373 +1,381 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qwhatsthis.h> | ||
21 | #include "writemail.h" | 22 | #include "writemail.h" |
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | 24 | ||
24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) | 25 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) |
25 | : QMainWindow( parent, name, fl ) | 26 | : QMainWindow( parent, name, fl ) |
26 | { | 27 | { |
27 | showingAddressList = FALSE; | 28 | showingAddressList = FALSE; |
28 | init(); | 29 | init(); |
29 | 30 | ||
30 | addAtt = new AddAtt(0, "Add Attatchments"); | 31 | addAtt = new AddAtt(0, "Add Attachments"); |
31 | } | 32 | } |
32 | 33 | ||
33 | WriteMail::~WriteMail() | 34 | WriteMail::~WriteMail() |
34 | { | 35 | { |
35 | delete addAtt; | 36 | delete addAtt; |
36 | } | 37 | } |
37 | 38 | ||
38 | void WriteMail::setAddressList(AddressList *list) | 39 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 40 | { |
40 | Contact *cPtr; | 41 | Contact *cPtr; |
41 | 42 | ||
42 | addressList = list; | 43 | addressList = list; |
43 | 44 | ||
44 | addressView->clear(); | 45 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 46 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 47 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 48 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); | 49 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); |
49 | } | 50 | } |
50 | } | 51 | } |
51 | 52 | ||
52 | void WriteMail::init() | 53 | void WriteMail::init() |
53 | { | 54 | { |
54 | setToolBarsMovable(FALSE); | 55 | setToolBarsMovable(FALSE); |
55 | 56 | ||
56 | bar = new QToolBar(this); | 57 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 58 | bar->setHorizontalStretchable( TRUE ); |
58 | 59 | ||
59 | menu = new QMenuBar( bar ); | 60 | menu = new QMenuBar( bar ); |
60 | 61 | ||
61 | mailMenu = new QPopupMenu(menu); | 62 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 63 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 64 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 65 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 66 | ||
66 | bar = new QToolBar(this); | 67 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); | 68 | attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 69 | attachButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 70 | attachButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 71 | connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); |
71 | 72 | attachButton->setWhatsThis(tr("Click here to attach files to your mail")); | |
73 | |||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 74 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 75 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 76 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 77 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
78 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); | ||
76 | 79 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 80 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 81 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 82 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 83 | newButton->setWhatsThis(tr("Click here to create a new mail")); | |
84 | |||
81 | widget = new QWidget(this, "widget"); | 85 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 86 | grid = new QGridLayout( widget ); |
83 | 87 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 88 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 89 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 90 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 91 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 92 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | 93 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); |
90 | 94 | ||
91 | |||
92 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 95 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
93 | subjetLabel->setText( tr( "Subject:" ) ); | 96 | subjetLabel->setText( tr( "Subject:" ) ); |
94 | 97 | ||
95 | grid->addWidget( subjetLabel, 1, 0 ); | 98 | grid->addWidget( subjetLabel, 1, 0 ); |
96 | 99 | ||
97 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 100 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
98 | ToolButton13_2->setText( tr( "..." ) ); | 101 | ToolButton13_2->setText( tr( "..." ) ); |
99 | grid->addWidget( ToolButton13_2, 1, 2 ); | 102 | grid->addWidget( ToolButton13_2, 1, 2 ); |
100 | 103 | ||
101 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 104 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
102 | grid->addWidget( subjectInput, 1, 1 ); | 105 | grid->addWidget( subjectInput, 1, 1 ); |
106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); | ||
103 | 107 | ||
104 | toInput = new QLineEdit( widget, "toInput" ); | 108 | toInput = new QLineEdit( widget, "toInput" ); |
105 | grid->addWidget( toInput, 0, 1 ); | 109 | grid->addWidget( toInput, 0, 1 ); |
110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); | ||
106 | 111 | ||
107 | ccInput = new QLineEdit( widget, "ccInput" ); | 112 | ccInput = new QLineEdit( widget, "ccInput" ); |
108 | ccInput->hide(); | 113 | ccInput->hide(); |
109 | grid->addWidget( ccInput, 0, 1 ); | 114 | grid->addWidget( ccInput, 0, 1 ); |
115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); | ||
110 | 116 | ||
111 | |||
112 | addressButton = new QToolButton( widget, "addressButton" ); | 117 | addressButton = new QToolButton( widget, "addressButton" ); |
113 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
114 | addressButton->setToggleButton(TRUE); | 119 | addressButton->setToggleButton(TRUE); |
115 | grid->addWidget( addressButton, 0, 2 ); | 120 | grid->addWidget( addressButton, 0, 2 ); |
116 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); | ||
117 | 123 | ||
118 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
119 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
126 | QWhatsThis::add(recipientsBox,QWidget::tr("Enter your mail text here")); | ||
120 | 127 | ||
121 | |||
122 | addressView = new QListView( widget, "addressView"); | 128 | addressView = new QListView( widget, "addressView"); |
123 | addressView->addColumn("Name"); | 129 | addressView->addColumn("Name"); |
124 | addressView->addColumn("EMail"); | 130 | addressView->addColumn("EMail"); |
125 | addressView->setAllColumnsShowFocus(TRUE); | 131 | addressView->setAllColumnsShowFocus(TRUE); |
126 | addressView->setMultiSelection(TRUE); | 132 | addressView->setMultiSelection(TRUE); |
127 | addressView->hide(); | 133 | addressView->hide(); |
128 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
129 | 135 | QWhatsThis::add(recipientsBox,QWidget::tr("Chose the recipients from this list")); | |
136 | |||
130 | okButton = new QToolButton(bar, "ok"); | 137 | okButton = new QToolButton(bar, "ok"); |
131 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 138 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
132 | okButton->hide(); | 139 | okButton->hide(); |
133 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); | ||
134 | 142 | ||
135 | setCentralWidget(widget); | 143 | setCentralWidget(widget); |
136 | } | 144 | } |
137 | 145 | ||
138 | void WriteMail::reject() | 146 | void WriteMail::reject() |
139 | { | 147 | { |
140 | emit cancelMail(); | 148 | emit cancelMail(); |
141 | } | 149 | } |
142 | 150 | ||
143 | // need to insert date | 151 | // need to insert date |
144 | void WriteMail::accept() | 152 | void WriteMail::accept() |
145 | { | 153 | { |
146 | QStringList attatchedFiles, attatchmentsType; | 154 | QStringList attachedFiles, attachmentsType; |
147 | int idCount = 0; | 155 | int idCount = 0; |
148 | 156 | ||
149 | if (toInput->text() == "") | 157 | if (toInput->text() == "") |
150 | { | 158 | { |
151 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | 159 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); |
152 | return; | 160 | return; |
153 | } | 161 | } |
154 | 162 | ||
155 | if (! getRecipients(false) ) | 163 | if (! getRecipients(false) ) |
156 | { | 164 | { |
157 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | 165 | QMessageBox::warning(this,tr("Incorrect recipient separator"), |
158 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 166 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
159 | return; | 167 | return; |
160 | } | 168 | } |
161 | 169 | ||
162 | if ((ccInput->text()!="") && (! getRecipients(true) )) | 170 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
163 | { | 171 | { |
164 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | 172 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), |
165 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 173 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
166 | return; | 174 | return; |
167 | } | 175 | } |
168 | 176 | ||
169 | mail.subject = subjectInput->text(); | 177 | mail.subject = subjectInput->text(); |
170 | mail.body = emailInput->text(); | 178 | mail.body = emailInput->text(); |
171 | mail.sent = false; | 179 | mail.sent = false; |
172 | mail.received = false; | 180 | mail.received = false; |
173 | 181 | ||
174 | mail.rawMail = "To: "; | 182 | mail.rawMail = "To: "; |
175 | 183 | ||
176 | for (QStringList::Iterator it = mail.recipients.begin(); | 184 | for (QStringList::Iterator it = mail.recipients.begin(); |
177 | it != mail.recipients.end(); ++it) { | 185 | it != mail.recipients.end(); ++it) { |
178 | 186 | ||
179 | mail.rawMail += (*it); | 187 | mail.rawMail += (*it); |
180 | mail.rawMail += ",\n"; | 188 | mail.rawMail += ",\n"; |
181 | } | 189 | } |
182 | 190 | ||
183 | mail.rawMail.truncate(mail.rawMail.length()-2); | 191 | mail.rawMail.truncate(mail.rawMail.length()-2); |
184 | 192 | ||
185 | mail.rawMail += "\nCC: "; | 193 | mail.rawMail += "\nCC: "; |
186 | 194 | ||
187 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | 195 | for (QStringList::Iterator it = mail.carbonCopies.begin(); |
188 | it != mail.carbonCopies.end(); ++it) { | 196 | it != mail.carbonCopies.end(); ++it) { |
189 | 197 | ||
190 | mail.rawMail += (*it); | 198 | mail.rawMail += (*it); |
191 | mail.rawMail += ",\n"; | 199 | mail.rawMail += ",\n"; |
192 | } | 200 | } |
193 | 201 | ||
194 | mail.rawMail += mail.from; | 202 | mail.rawMail += mail.from; |
195 | mail.rawMail += "\nSubject: "; | 203 | mail.rawMail += "\nSubject: "; |
196 | mail.rawMail += mail.subject; | 204 | mail.rawMail += mail.subject; |
197 | mail.rawMail += "\n\n"; | 205 | mail.rawMail += "\n\n"; |
198 | 206 | ||
199 | attatchedFiles = addAtt->returnAttatchedFiles(); | 207 | attachedFiles = addAtt->returnattachedFiles(); |
200 | attatchmentsType = addAtt->returnFileTypes(); | 208 | attachmentsType = addAtt->returnFileTypes(); |
201 | 209 | ||
202 | QStringList::Iterator itType = attatchmentsType.begin(); | 210 | QStringList::Iterator itType = attachmentsType.begin(); |
203 | 211 | ||
204 | Enclosure e; | 212 | Enclosure e; |
205 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { | 213 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { |
206 | e.id = idCount; | 214 | e.id = idCount; |
207 | e.originalName = (*it).latin1(); | 215 | e.originalName = (*it).latin1(); |
208 | e.contentType = (*itType).latin1(); | 216 | e.contentType = (*itType).latin1(); |
209 | e.contentAttribute = (*itType).latin1(); | 217 | e.contentAttribute = (*itType).latin1(); |
210 | e.saved = TRUE; | 218 | e.saved = TRUE; |
211 | mail.addEnclosure(&e); | 219 | mail.addEnclosure(&e); |
212 | 220 | ||
213 | itType++; | 221 | itType++; |
214 | idCount++; | 222 | idCount++; |
215 | } | 223 | } |
216 | mail.rawMail += mail.body; | 224 | mail.rawMail += mail.body; |
217 | mail.rawMail += "\n"; | 225 | mail.rawMail += "\n"; |
218 | mail.rawMail += ".\n"; | 226 | mail.rawMail += ".\n"; |
219 | emit sendMailRequested(mail); | 227 | emit sendMailRequested(mail); |
220 | addAtt->clear(); | 228 | addAtt->clear(); |
221 | } | 229 | } |
222 | 230 | ||
223 | void WriteMail::getAddress() | 231 | void WriteMail::getAddress() |
224 | { | 232 | { |
225 | showingAddressList = !showingAddressList; | 233 | showingAddressList = !showingAddressList; |
226 | 234 | ||
227 | if (showingAddressList) { | 235 | if (showingAddressList) { |
228 | emailInput->hide(); | 236 | emailInput->hide(); |
229 | addressView->show(); | 237 | addressView->show(); |
230 | okButton->show(); | 238 | okButton->show(); |
231 | 239 | ||
232 | } else { | 240 | } else { |
233 | addressView->hide(); | 241 | addressView->hide(); |
234 | okButton->hide(); | 242 | okButton->hide(); |
235 | emailInput->show(); | 243 | emailInput->show(); |
236 | } | 244 | } |
237 | } | 245 | } |
238 | 246 | ||
239 | void WriteMail::attatchFile() | 247 | void WriteMail::attachFile() |
240 | { | 248 | { |
241 | addAtt->showMaximized(); | 249 | addAtt->showMaximized(); |
242 | } | 250 | } |
243 | 251 | ||
244 | void WriteMail::reply(Email replyMail, bool replyAll) | 252 | void WriteMail::reply(Email replyMail, bool replyAll) |
245 | { | 253 | { |
246 | int pos; | 254 | int pos; |
247 | 255 | ||
248 | mail = replyMail; | 256 | mail = replyMail; |
249 | mail.files.clear(); | 257 | mail.files.clear(); |
250 | 258 | ||
251 | toInput->setText(mail.fromMail); | 259 | toInput->setText(mail.fromMail); |
252 | //replyAll ? ccInput->setText(mail.c) | 260 | //replyAll ? ccInput->setText(mail.c) |
253 | 261 | ||
254 | addRecipients(replyAll); | 262 | addRecipients(replyAll); |
255 | 263 | ||
256 | subjectInput->setText(tr("Re: ") + mail.subject); | 264 | subjectInput->setText(tr("Re: ") + mail.subject); |
257 | 265 | ||
258 | pos = 0; | 266 | pos = 0; |
259 | mail.body.insert(pos, ">>"); | 267 | mail.body.insert(pos, ">"); |
260 | while (pos != -1) { | 268 | while (pos != -1) { |
261 | pos = mail.body.find('\n', pos); | 269 | pos = mail.body.find('\n', pos); |
262 | if (pos != -1) | 270 | if (pos != -1) |
263 | mail.body.insert(++pos, ">>"); | 271 | mail.body.insert(++pos, ">>"); |
264 | } | 272 | } |
265 | 273 | ||
266 | emailInput->setText(mail.body); | 274 | emailInput->setText(mail.body); |
267 | } | 275 | } |
268 | 276 | ||
269 | void WriteMail::forward(Email forwMail) | 277 | void WriteMail::forward(Email forwMail) |
270 | { | 278 | { |
271 | int pos=0; | 279 | int pos=0; |
272 | 280 | ||
273 | QString fwdBody=tr("======forwarded message from "); | 281 | QString fwdBody=tr("======forwarded message from "); |
274 | fwdBody.append(forwMail.fromMail); | 282 | fwdBody.append(forwMail.fromMail); |
275 | fwdBody.append(tr(" starts======\n\n")); | 283 | fwdBody.append(tr(" starts======\n\n")); |
276 | 284 | ||
277 | mail=forwMail; | 285 | mail=forwMail; |
278 | toInput->setText(""); | 286 | toInput->setText(""); |
279 | ccInput->setText(""); | 287 | ccInput->setText(""); |
280 | subjectInput->setText(tr("FWD: ") + mail.subject); | 288 | subjectInput->setText(tr("FWD: ") + mail.subject); |
281 | 289 | ||
282 | fwdBody+=mail.body; | 290 | fwdBody+=mail.body; |
283 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | 291 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); |
284 | 292 | ||
285 | emailInput->setText(fwdBody); | 293 | emailInput->setText(fwdBody); |
286 | } | 294 | } |
287 | 295 | ||
288 | bool WriteMail::getRecipients(bool ccField) | 296 | bool WriteMail::getRecipients(bool ccField) |
289 | { | 297 | { |
290 | QString str, temp; | 298 | QString str, temp; |
291 | int pos = 0; | 299 | int pos = 0; |
292 | 300 | ||
293 | mail.recipients.clear(); | 301 | mail.recipients.clear(); |
294 | 302 | ||
295 | ccField ? temp = ccInput->text() : temp=toInput->text() ; | 303 | ccField ? temp = ccInput->text() : temp=toInput->text() ; |
296 | 304 | ||
297 | while ( (pos = temp.find(';')) != -1) { | 305 | while ( (pos = temp.find(';')) != -1) { |
298 | str = temp.left(pos).stripWhiteSpace(); | 306 | str = temp.left(pos).stripWhiteSpace(); |
299 | temp = temp.right(temp.length() - (pos + 1)); | 307 | temp = temp.right(temp.length() - (pos + 1)); |
300 | if ( str.find('@') == -1) | 308 | if ( str.find('@') == -1) |
301 | return false; | 309 | return false; |
302 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); | 310 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
303 | addressList->addContact(str, ""); | 311 | addressList->addContact(str, ""); |
304 | } | 312 | } |
305 | temp = temp.stripWhiteSpace(); | 313 | temp = temp.stripWhiteSpace(); |
306 | if ( temp.find('@') == -1) | 314 | if ( temp.find('@') == -1) |
307 | return false; | 315 | return false; |
308 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); | 316 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
309 | addressList->addContact(temp, ""); | 317 | addressList->addContact(temp, ""); |
310 | 318 | ||
311 | return TRUE; | 319 | return TRUE; |
312 | } | 320 | } |
313 | 321 | ||
314 | void WriteMail::addRecipients() | 322 | void WriteMail::addRecipients() |
315 | { | 323 | { |
316 | 324 | ||
317 | addRecipients(false); | 325 | addRecipients(false); |
318 | } | 326 | } |
319 | 327 | ||
320 | void WriteMail::addRecipients(bool ccField) | 328 | void WriteMail::addRecipients(bool ccField) |
321 | { | 329 | { |
322 | QString recipients = ""; | 330 | QString recipients = ""; |
323 | 331 | ||
324 | mail.recipients.clear(); | 332 | mail.recipients.clear(); |
325 | 333 | ||
326 | QListViewItem *item = addressView->firstChild(); | 334 | QListViewItem *item = addressView->firstChild(); |
327 | while (item != NULL) { | 335 | while (item != NULL) { |
328 | if ( item->isSelected() ) { | 336 | if ( item->isSelected() ) { |
329 | if (recipients == "") { | 337 | if (recipients == "") { |
330 | recipients = item->text(0); | 338 | recipients = item->text(0); |
331 | } else { | 339 | } else { |
332 | recipients += "; " + item->text(0); | 340 | recipients += "; " + item->text(0); |
333 | } | 341 | } |
334 | } | 342 | } |
335 | item = item->nextSibling(); | 343 | item = item->nextSibling(); |
336 | } | 344 | } |
337 | 345 | ||
338 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | 346 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); |
339 | 347 | ||
340 | addressView->hide(); | 348 | addressView->hide(); |
341 | okButton->hide(); | 349 | okButton->hide(); |
342 | emailInput->show(); | 350 | emailInput->show(); |
343 | addressButton->setOn(FALSE); | 351 | addressButton->setOn(FALSE); |
344 | showingAddressList = !showingAddressList; | 352 | showingAddressList = !showingAddressList; |
345 | } | 353 | } |
346 | 354 | ||
347 | void WriteMail::changeRecipients(int selection) | 355 | void WriteMail::changeRecipients(int selection) |
348 | { | 356 | { |
349 | if (selection==0) | 357 | if (selection==0) |
350 | { | 358 | { |
351 | toInput->show(); | 359 | toInput->show(); |
352 | ccInput->hide(); | 360 | ccInput->hide(); |
353 | } | 361 | } |
354 | else if (selection==1) | 362 | else if (selection==1) |
355 | { | 363 | { |
356 | toInput->hide(); | 364 | toInput->hide(); |
357 | ccInput->show(); | 365 | ccInput->show(); |
358 | } | 366 | } |
359 | } | 367 | } |
360 | 368 | ||
361 | void WriteMail::setRecipient(const QString &recipient) | 369 | void WriteMail::setRecipient(const QString &recipient) |
362 | { | 370 | { |
363 | toInput->setText(recipient); | 371 | toInput->setText(recipient); |
364 | } | 372 | } |
365 | 373 | ||
366 | void WriteMail::newMail() | 374 | void WriteMail::newMail() |
367 | { | 375 | { |
368 | toInput->clear(); | 376 | toInput->clear(); |
369 | subjectInput->clear(); | 377 | subjectInput->clear(); |
370 | emailInput->clear(); | 378 | emailInput->clear(); |
371 | //to clear selected | 379 | //to clear selected |
372 | setAddressList(addressList); | 380 | setAddressList(addressList); |
373 | } | 381 | } |
diff --git a/noncore/unsupported/mailit/writemail.h b/noncore/unsupported/mailit/writemail.h index f193b13..921f27e 100644 --- a/noncore/unsupported/mailit/writemail.h +++ b/noncore/unsupported/mailit/writemail.h | |||
@@ -1,96 +1,96 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WRITEMAIL_H | 20 | #ifndef WRITEMAIL_H |
21 | #define WRITEMAIL_H | 21 | #define WRITEMAIL_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | 34 | ||
35 | #include "emailhandler.h" | 35 | #include "emailhandler.h" |
36 | #include "addresslist.h" | 36 | #include "addresslist.h" |
37 | #include "addatt.h" | 37 | #include "addatt.h" |
38 | 38 | ||
39 | class WriteMail : public QMainWindow | 39 | class WriteMail : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); | 44 | WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); |
45 | ~WriteMail(); | 45 | ~WriteMail(); |
46 | void reply(Email replyMail, bool replyAll); | 46 | void reply(Email replyMail, bool replyAll); |
47 | void setRecipient(const QString &recipient); | 47 | void setRecipient(const QString &recipient); |
48 | void setAddressList(AddressList *list); | 48 | void setAddressList(AddressList *list); |
49 | void forward(Email forwMail); | 49 | void forward(Email forwMail); |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void sendMailRequested(const Email &mail); | 52 | void sendMailRequested(const Email &mail); |
53 | void cancelMail(); | 53 | void cancelMail(); |
54 | 54 | ||
55 | 55 | ||
56 | public slots: | 56 | public slots: |
57 | void getAddress(); | 57 | void getAddress(); |
58 | void attatchFile(); | 58 | void attachFile(); |
59 | void addRecipients(); | 59 | void addRecipients(); |
60 | void newMail(); | 60 | void newMail(); |
61 | void accept(); | 61 | void accept(); |
62 | void reject(); | 62 | void reject(); |
63 | void changeRecipients(int); | 63 | void changeRecipients(int); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | bool getRecipients(bool); | 66 | bool getRecipients(bool); |
67 | void init(); | 67 | void init(); |
68 | void addRecipients(bool); | 68 | void addRecipients(bool); |
69 | 69 | ||
70 | Email mail; | 70 | Email mail; |
71 | AddAtt *addAtt; | 71 | AddAtt *addAtt; |
72 | AddressList *addressList; | 72 | AddressList *addressList; |
73 | bool showingAddressList; | 73 | bool showingAddressList; |
74 | 74 | ||
75 | QToolBar *bar; | 75 | QToolBar *bar; |
76 | QMenuBar *menu; | 76 | QMenuBar *menu; |
77 | QPopupMenu *addMenu, *mailMenu; | 77 | QPopupMenu *addMenu, *mailMenu; |
78 | QListView *addressView; | 78 | QListView *addressView; |
79 | 79 | ||
80 | QToolButton *okButton; | 80 | QToolButton *okButton; |
81 | QWidget *widget; | 81 | QWidget *widget; |
82 | QAction *attatchButton; | 82 | QAction *attachButton; |
83 | QAction *confirmButton; | 83 | QAction *confirmButton; |
84 | QAction *newButton; | 84 | QAction *newButton; |
85 | QLabel* subjetLabel; | 85 | QLabel* subjetLabel; |
86 | QToolButton* ToolButton13_2; | 86 | QToolButton* ToolButton13_2; |
87 | QComboBox* recipientsBox; | 87 | QComboBox* recipientsBox; |
88 | QLineEdit *subjectInput; | 88 | QLineEdit *subjectInput; |
89 | QLineEdit *toInput; | 89 | QLineEdit *toInput; |
90 | QLineEdit *ccInput; | 90 | QLineEdit *ccInput; |
91 | QToolButton* addressButton; | 91 | QToolButton* addressButton; |
92 | QMultiLineEdit* emailInput; | 92 | QMultiLineEdit* emailInput; |
93 | QGridLayout* grid; | 93 | QGridLayout* grid; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | #endif // WRITEMAIL_H | 96 | #endif // WRITEMAIL_H |