-rw-r--r-- | noncore/net/mailit/addatt.cpp | 119 | ||||
-rw-r--r-- | noncore/net/mailit/addatt.h | 24 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addatt.cpp | 119 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addatt.h | 24 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 7 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 6 |
10 files changed, 200 insertions, 132 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp index c030e36..f279f52 100644 --- a/noncore/net/mailit/addatt.cpp +++ b/noncore/net/mailit/addatt.cpp | |||
@@ -1,209 +1,230 @@ | |||
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 <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | #include "addatt.h" | 24 | #include "addatt.h" |
25 | 25 | ||
26 | FileItem::FileItem(QListView *parent, QFileInfo fileInfo, QString fileType) | 26 | FileItem::FileItem(QListView *parent, DocLnk* dl) |
27 | : QListViewItem(parent) | 27 | : QListViewItem(parent) |
28 | { | 28 | { |
29 | file = fileInfo; | 29 | /*file = fileInfo; |
30 | type = fileType; | 30 | type = fileType;*/ |
31 | |||
32 | doclnk=dl; | ||
31 | 33 | ||
32 | setText(0, fileInfo.baseName()); | 34 | setText(0, doclnk->name()); |
33 | 35 | ||
34 | if (fileType == "Picture") { | 36 | /*if (fileType == "Picture") { |
35 | setPixmap(0, Resource::loadPixmap("pixmap")); | 37 | setPixmap(0, Resource::loadPixmap("pixmap")); |
36 | } else if (fileType == "Document") { | 38 | } else if (fileType == "Document") { |
37 | setPixmap(0, Resource::loadPixmap("txt")); | 39 | setPixmap(0, Resource::loadPixmap("txt")); |
38 | } else if (fileType == "Sound") { | 40 | } else if (fileType == "Sound") { |
39 | setPixmap(0, Resource::loadPixmap("play")); | 41 | setPixmap(0, Resource::loadPixmap("play")); |
40 | } else if (fileType == "Movie") { | 42 | } else if (fileType == "Movie") { |
41 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | 43 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); |
42 | } else if (fileType == "File") { | 44 | } else if (fileType == "File") { |
43 | setPixmap(0, Resource::loadPixmap("exec")); | 45 | setPixmap(0, Resource::loadPixmap("exec")); |
44 | } | 46 | }*/ |
45 | } | 47 | } |
46 | 48 | ||
47 | QFileInfo FileItem::getFileInfo() | 49 | FileItem::~FileItem() |
48 | { | 50 | { |
49 | return file; | 51 | if (doclnk!=NULL) delete doclnk; |
50 | } | 52 | doclnk=NULL; |
51 | |||
52 | QString FileItem::getFileType() | ||
53 | { | ||
54 | return type; | ||
55 | } | 53 | } |
56 | 54 | ||
57 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | 55 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) |
58 | : QDialog(parent, name, f) | 56 | : QDialog(parent, name, f) |
59 | { | 57 | { |
60 | setCaption("Adding attatchments"); | 58 | setCaption("Adding attatchments"); |
61 | 59 | ||
62 | QGridLayout *top = new QGridLayout(this, 3, 2); | 60 | QGridLayout *top = new QGridLayout(this, 3,1 ); |
61 | |||
63 | 62 | ||
64 | fileCategoryButton = new QPushButton(this); | 63 | /*fileCategoryButton = new QPushButton(this);*/ |
65 | attatchButton = new QPushButton("Attatch ->", this); | 64 | attatchButton = new QPushButton("Attatch ->", this); |
66 | removeButton = new QPushButton("Remove", this); | 65 | removeButton = new QPushButton("Remove", this); |
67 | 66 | ||
68 | fileCategories = new QPopupMenu(fileCategoryButton); | 67 | /*fileCategories = new QPopupMenu(fileCategoryButton); |
69 | fileCategoryButton->setPopup(fileCategories); | 68 | fileCategoryButton->setPopup(fileCategories); |
70 | fileCategories->insertItem("Document"); | 69 | fileCategories->insertItem("Document"); |
71 | fileCategories->insertItem("Picture"); | 70 | fileCategories->insertItem("Picture"); |
72 | fileCategories->insertItem("Sound"); | 71 | fileCategories->insertItem("Sound"); |
73 | fileCategories->insertItem("Movie"); | 72 | fileCategories->insertItem("Movie"); |
74 | fileCategories->insertItem("File"); | 73 | fileCategories->insertItem("File"); |
75 | 74 | ||
76 | fileCategoryButton->setText("Document"); | 75 | fileCategoryButton->setText("Document"); |
77 | top->addWidget(fileCategoryButton, 0, 0); | 76 | top->addWidget(fileCategoryButton, 0, 0);*/ |
78 | top->addWidget(attatchButton, 2, 0); | 77 | |
79 | top->addWidget(removeButton, 2, 1); | 78 | //ofs=new OFileSelector(this,2,0,"/root/Documents"); |
79 | |||
80 | |||
81 | top->addWidget(attatchButton,1,0); | ||
82 | top->addWidget(removeButton,2,0); | ||
80 | 83 | ||
81 | connect(fileCategories, SIGNAL(activated(int)), this, | 84 | /*connect(fileCategories, SIGNAL(activated(int)), this, |
82 | SLOT(fileCategorySelected(int)) ); | 85 | SLOT(fileCategorySelected(int)) );*/ |
83 | connect(attatchButton, SIGNAL(clicked()), this, | 86 | connect(attatchButton, SIGNAL(clicked()), this, |
84 | SLOT(addAttatchment()) ); | 87 | SLOT(addAttatchment()) ); |
85 | connect(removeButton, SIGNAL(clicked()), this, | 88 | connect(removeButton, SIGNAL(clicked()), this, |
86 | SLOT(removeAttatchment()) ); | 89 | SLOT(removeAttatchment()) ); |
87 | 90 | ||
88 | listView = new QListView(this, "AttView"); | 91 | /*listView = new QListView(this, "AttView"); |
89 | listView->addColumn("Documents"); | 92 | listView->addColumn("Documents");* |
90 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | 93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, |
91 | SLOT(addAttatchment()) ); | 94 | SLOT(addAttatchment()) );*/ |
95 | |||
92 | 96 | ||
93 | attView = new QListView(this, "Selected"); | 97 | attView = new QListView(this, "Selected"); |
94 | attView->addColumn("Attatched"); | 98 | attView->addColumn(tr("Attached")); |
99 | attView->addColumn(tr("File type")); | ||
95 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | 100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, |
96 | SLOT(removeAttatchment()) ); | 101 | SLOT(removeAttatchment()) ); |
97 | 102 | ||
98 | top->addWidget(listView, 1,0); | 103 | //top->addWidget(ofs, 0,0); |
99 | top->addWidget(attView, 1,1); | 104 | top->addWidget(attView, 0,0); |
105 | |||
106 | clear(); | ||
100 | 107 | ||
101 | clear(); | 108 | |
102 | } | 109 | } |
103 | 110 | ||
104 | void AddAtt::clear() | 111 | void AddAtt::clear() |
105 | { | 112 | { |
106 | attView->clear(); | 113 | attView->clear(); |
107 | getFiles(); | 114 | //getFiles(); |
108 | modified = FALSE; | 115 | modified = FALSE; |
109 | } | 116 | } |
110 | 117 | ||
111 | void AddAtt::fileCategorySelected(int id) | 118 | /*void AddAtt::fileCategorySelected(int id) |
112 | { | 119 | { |
113 | fileCategoryButton->setText(fileCategories->text(id)); | 120 | fileCategoryButton->setText(fileCategories->text(id)); |
114 | getFiles(); | 121 | getFiles(); |
115 | } | 122 | }*/ |
116 | 123 | ||
117 | void AddAtt::addAttatchment() | 124 | void AddAtt::addAttatchment() |
118 | { | 125 | { |
119 | QFileInfo info; | 126 | QDialog qd(this,tr("Select attachment"),true); |
120 | QString type; | 127 | |
128 | QGridLayout top(&qd,1,1); | ||
129 | |||
130 | OFileSelector ofs(&qd,1,0,"/root/Documents"); | ||
131 | |||
132 | top.addWidget(&ofs,0,0); | ||
121 | 133 | ||
122 | if (listView->selectedItem() != NULL) { | 134 | qd.showMaximized(); |
123 | item = (FileItem *) listView->selectedItem(); | 135 | |
124 | info = item->getFileInfo(); | 136 | if (qd.exec()==QDialog::Accepted) |
125 | type = item->getFileType(); | 137 | { |
126 | item = new FileItem(attView, info, type); | 138 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); |
139 | FileItem* fi=new FileItem(attView,dl); | ||
140 | fi->setPixmap(0,dl->pixmap()); | ||
141 | fi->setText(1,dl->type()); | ||
142 | attView->insertItem(fi); | ||
143 | modified = TRUE; | ||
127 | } | 144 | } |
128 | modified = TRUE; | ||
129 | } | 145 | } |
130 | 146 | ||
131 | void AddAtt::removeAttatchment() | 147 | void AddAtt::removeAttatchment() |
132 | { | 148 | { |
133 | if (attView->selectedItem() != NULL) { | 149 | if (attView->selectedItem() != NULL) |
150 | { | ||
134 | attView->takeItem(attView->selectedItem()); | 151 | attView->takeItem(attView->selectedItem()); |
135 | } | 152 | } |
136 | modified = TRUE; | 153 | modified = TRUE; |
137 | } | 154 | } |
138 | 155 | ||
139 | void AddAtt::reject() | 156 | void AddAtt::reject() |
140 | { | 157 | { |
141 | if (modified) { | 158 | if (modified) { |
142 | attView->clear(); | 159 | attView->clear(); |
143 | modified = FALSE; | 160 | modified = FALSE; |
144 | } | 161 | } |
145 | } | 162 | } |
146 | 163 | ||
147 | void AddAtt::accept() | 164 | void AddAtt::accept() |
148 | { | 165 | { |
149 | modified = FALSE; | 166 | modified = FALSE; |
150 | hide(); | 167 | hide(); |
151 | } | 168 | } |
152 | 169 | ||
153 | void AddAtt::getFiles() | 170 | void AddAtt::getFiles() |
154 | { | 171 | { |
155 | QString path, selected; | 172 | QString path, selected; |
156 | QDir *dir; | ||
157 | 173 | ||
158 | listView->clear(); | 174 | /*listView->clear(); |
159 | 175 | ||
160 | selected = fileCategoryButton->text(); | 176 | selected = fileCategoryButton->text(); |
161 | if (selected == "Picture") { | 177 | if (selected == "Picture") { |
162 | path = "../pics/"; | 178 | path = "../pics/"; |
163 | } else if (selected == "Document") { | 179 | } else if (selected == "Document") { |
164 | path = "" ; //sub-dirs not decided | 180 | path = "" ; //sub-dirs not decided |
165 | } else if (selected == "Sound") { | 181 | } else if (selected == "Sound") { |
166 | path = "../sounds/"; //sub-dirs not decided | 182 | path = "../sounds/"; //sub-dirs not decided |
167 | } else if (selected == "Movie") { | 183 | } else if (selected == "Movie") { |
168 | path = ""; //sub-dirs not decided | 184 | path = ""; //sub-dirs not decided |
169 | } else if (selected == "File") { | 185 | } else if (selected == "File") { |
170 | path = ""; //sub-dirs not decided | 186 | path = ""; //sub-dirs not decided |
171 | } | 187 | } |
172 | 188 | ||
173 | dir = new QDir(path); | 189 | dir = new QDir(path); |
174 | dir->setFilter(QDir::Files); | 190 | dir->setFilter(QDir::Files); |
175 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | 191 | const QFileInfoList *dirInfoList = dir->entryInfoList(); |
176 | 192 | ||
177 | QFileInfoListIterator it(*dirInfoList); // create list iterator | 193 | QFileInfoListIterator it(*dirInfoList); // create list iterator |
178 | 194 | ||
179 | while ( (fi=it.current()) ) { // for each file... | 195 | while ( (fi=it.current()) ) { // for each file... |
180 | item = new FileItem(listView, *fi, selected); | 196 | item = new FileItem(lis+ütView, *fi, selected); |
181 | ++it; // goto next list element | 197 | ++it; // goto next list element |
182 | } | 198 | }*/ |
183 | } | 199 | } |
184 | 200 | ||
185 | QStringList AddAtt::returnAttatchedFiles() | 201 | QStringList AddAtt::returnAttatchedFiles() |
186 | { | 202 | { |
187 | QFileInfo info; | 203 | QFileInfo info; |
188 | QStringList list; | 204 | QStringList list; |
189 | 205 | ||
190 | item = (FileItem *) attView->firstChild(); | 206 | item = (FileItem *) attView->firstChild(); |
207 | |||
208 | |||
191 | while (item != NULL) { | 209 | while (item != NULL) { |
192 | info = item->getFileInfo(); | 210 | DocLnk* dl=item->getDocLnk(); |
193 | list += info.filePath(); | 211 | list+=dl->file(); |
212 | /*info = item->getFileInfo(); | ||
213 | list += info.filePath();*/ | ||
194 | item = (FileItem *) item->nextSibling(); | 214 | item = (FileItem *) item->nextSibling(); |
195 | } | 215 | } |
196 | return list; | 216 | return list; |
197 | } | 217 | } |
198 | 218 | ||
199 | QStringList AddAtt::returnFileTypes() | 219 | QStringList AddAtt::returnFileTypes() |
200 | { | 220 | { |
201 | QStringList list; | 221 | QStringList list; |
202 | 222 | ||
203 | item = (FileItem *) attView->firstChild(); | 223 | item = (FileItem *) attView->firstChild(); |
224 | |||
204 | while (item != NULL) { | 225 | while (item != NULL) { |
205 | list += item->getFileType(); | 226 | list += item->getDocLnk()->type(); |
206 | item = (FileItem *) item->nextSibling(); | 227 | item = (FileItem *) item->nextSibling(); |
207 | } | 228 | } |
208 | return list; | 229 | return list; |
209 | } | 230 | } |
diff --git a/noncore/net/mailit/addatt.h b/noncore/net/mailit/addatt.h index 867c905..73062e2 100644 --- a/noncore/net/mailit/addatt.h +++ b/noncore/net/mailit/addatt.h | |||
@@ -1,70 +1,76 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef ADDATT_H | 20 | #ifndef ADDATT_H |
21 | #define ADDATT_H | 21 | #define ADDATT_H |
22 | 22 | ||
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <opie/ofileselector.h> | ||
31 | #include <qpe/applnk.h> | ||
30 | 32 | ||
31 | class FileItem : public QListViewItem | 33 | class FileItem : public QListViewItem |
32 | { | 34 | { |
33 | public: | 35 | public: |
34 | FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); | 36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); |
35 | QFileInfo getFileInfo(); | 37 | FileItem(QListView*, DocLnk*); |
36 | QString getFileType(); | 38 | ~FileItem(); |
37 | 39 | DocLnk* getDocLnk() {return doclnk;} | |
40 | |||
41 | |||
38 | private: | 42 | private: |
39 | QFileInfo file; | 43 | DocLnk* doclnk; |
40 | QString type; | ||
41 | }; | 44 | }; |
42 | 45 | ||
43 | class AddAtt : public QDialog | 46 | class AddAtt : public QDialog |
44 | { | 47 | { |
45 | Q_OBJECT | 48 | Q_OBJECT |
46 | 49 | ||
47 | public: | 50 | public: |
48 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
49 | QStringList returnAttatchedFiles(); | 52 | QStringList returnAttatchedFiles(); |
50 | QStringList returnFileTypes(); | 53 | QStringList returnFileTypes(); |
51 | void getFiles(); | 54 | void getFiles(); |
52 | void clear(); | 55 | void clear(); |
53 | 56 | ||
57 | |||
54 | public slots: | 58 | public slots: |
55 | void fileCategorySelected(int); | 59 | //void fileCategorySelected(int); |
56 | void addAttatchment(); | 60 | void addAttatchment(); |
57 | void removeAttatchment(); | 61 | void removeAttatchment(); |
58 | void reject(); | 62 | void reject(); |
59 | void accept(); | 63 | void accept(); |
60 | 64 | ||
61 | private: | 65 | private: |
62 | FileItem *item; | 66 | FileItem* item; |
63 | QListView *listView, *attView; | 67 | QListView *attView; |
64 | QPushButton *fileCategoryButton, *attatchButton, *removeButton; | 68 | QPushButton *fileCategoryButton, *attatchButton, *removeButton; |
65 | QPopupMenu *fileCategories; | 69 | QPopupMenu *fileCategories; |
66 | bool modified; | 70 | bool modified; |
67 | QFileInfo *fi; | 71 | QFileInfo *fi; |
72 | |||
73 | OFileSelector* ofs; | ||
68 | }; | 74 | }; |
69 | 75 | ||
70 | #endif | 76 | #endif |
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index fc4276b..9258aac 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -68,265 +68,271 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | |||
68 | SLOT(allMailArrived(int)) ); | 68 | SLOT(allMailArrived(int)) ); |
69 | 69 | ||
70 | mailconf = new Config("mailit"); | 70 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 71 | //In case Synchronize is not defined in settings.txt |
72 | 72 | ||
73 | readSettings(); | 73 | readSettings(); |
74 | 74 | ||
75 | updateAccounts(); | 75 | updateAccounts(); |
76 | 76 | ||
77 | lineShift = "\n"; | 77 | lineShift = "\n"; |
78 | readMail(); | 78 | readMail(); |
79 | lineShift = "\r\n"; | 79 | lineShift = "\r\n"; |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | EmailClient::~EmailClient() | 84 | EmailClient::~EmailClient() |
85 | { | 85 | { |
86 | //needs to be moved from destructor to closewindow event | 86 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 88 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 89 | //format as inbox is not a good solution as they have |
90 | //different properties | 90 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 92 | saveSettings(); |
93 | 93 | ||
94 | mailconf->write(); | 94 | mailconf->write(); |
95 | delete mailconf; | 95 | delete mailconf; |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void EmailClient::init() | 99 | void EmailClient::init() |
100 | { | 100 | { |
101 | statusBar = new QStatusBar(this); | 101 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 102 | statusBar->setSizeGripEnabled(FALSE); |
103 | 103 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 104 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 105 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 107 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 109 | status2Label, SLOT(setText(const QString &)) ); |
110 | 110 | ||
111 | progressBar = new QProgressBar(statusBar); | 111 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 112 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 113 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 114 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 115 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 116 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 117 | this, SLOT(setDownloadedSize(int)) ); |
118 | 118 | ||
119 | statusBar->addWidget(status1Label); | 119 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 120 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 121 | statusBar->addWidget(status2Label); |
122 | 122 | ||
123 | setToolBarsMovable(FALSE); | 123 | setToolBarsMovable(FALSE); |
124 | 124 | ||
125 | bar = new QToolBar(this); | 125 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | mb = new QMenuBar( bar ); | 128 | mb = new QMenuBar( bar ); |
129 | 129 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 130 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 131 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 132 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 133 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 134 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 135 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 136 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 137 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 138 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 139 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 141 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 143 | ||
144 | bar = new QToolBar(this); | 144 | bar = new QToolBar(this); |
145 | 145 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); |
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 148 | getMailButton->addTo(bar); |
149 | getMailButton->addTo(mail); | 149 | getMailButton->addTo(mail); |
150 | 150 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); | 151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 153 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 154 | sendMailButton->addTo(mail); |
155 | 155 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 158 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 159 | composeButton->addTo(mail); |
160 | 160 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 163 | cancelButton->addTo(mail); |
164 | cancelButton->addTo(bar); | ||
164 | cancelButton->setEnabled(FALSE); | 165 | cancelButton->setEnabled(FALSE); |
165 | 166 | ||
166 | mailboxView = new OTabWidget( this, "mailboxView" ); | 167 | mailboxView = new OTabWidget( this, "mailboxView" ); |
167 | 168 | ||
168 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 169 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
169 | grid_2 = new QGridLayout( widget ); | 170 | grid_2 = new QGridLayout( widget ); |
170 | // grid_2->setSpacing(6); | 171 | // grid_2->setSpacing(6); |
171 | // grid_2->setMargin( 11 ); | 172 | // grid_2->setMargin( 11 ); |
172 | 173 | ||
173 | inboxView = new QListView( widget, "inboxView" ); | 174 | inboxView = new QListView( widget, "inboxView" ); |
174 | inboxView->addColumn( tr( "From" ) ); | 175 | inboxView->addColumn( tr( "From" ) ); |
175 | inboxView->addColumn( tr( "Subject" ) ); | 176 | inboxView->addColumn( tr( "Subject" ) ); |
176 | inboxView->addColumn( tr( "Date" ) ); | 177 | inboxView->addColumn( tr( "Date" ) ); |
177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 178 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
178 | inboxView->setAllColumnsShowFocus(TRUE); | 179 | inboxView->setAllColumnsShowFocus(TRUE); |
179 | 180 | ||
180 | grid_2->addWidget( inboxView, 2, 0 ); | 181 | grid_2->addWidget( inboxView, 2, 0 ); |
181 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 182 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
182 | 183 | ||
183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 184 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
184 | grid_3 = new QGridLayout( widget_2 ); | 185 | grid_3 = new QGridLayout( widget_2 ); |
185 | // grid_3->setSpacing(6); | 186 | // grid_3->setSpacing(6); |
186 | // grid_3->setMargin( 11 ); | 187 | // grid_3->setMargin( 11 ); |
187 | 188 | ||
188 | outboxView = new QListView( widget_2, "outboxView" ); | 189 | outboxView = new QListView( widget_2, "outboxView" ); |
189 | outboxView->addColumn( tr( "To" ) ); | 190 | outboxView->addColumn( tr( "To" ) ); |
190 | outboxView->addColumn( tr( "Subject" ) ); | 191 | outboxView->addColumn( tr( "Subject" ) ); |
191 | outboxView->setAllColumnsShowFocus(TRUE); | 192 | outboxView->setAllColumnsShowFocus(TRUE); |
192 | 193 | ||
193 | grid_3->addWidget( outboxView, 0, 0 ); | 194 | grid_3->addWidget( outboxView, 0, 0 ); |
194 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 195 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
195 | 196 | ||
196 | setCentralWidget(mailboxView); | 197 | setCentralWidget(mailboxView); |
197 | } | 198 | } |
198 | 199 | ||
199 | void EmailClient::compose() | 200 | void EmailClient::compose() |
200 | { | 201 | { |
201 | emit composeRequested(); | 202 | emit composeRequested(); |
202 | } | 203 | } |
203 | 204 | ||
204 | void EmailClient::cancel() | 205 | void EmailClient::cancel() |
205 | { | 206 | { |
206 | emailHandler->cancel(); | 207 | emailHandler->cancel(); |
207 | } | 208 | } |
208 | 209 | ||
209 | AddressList* EmailClient::getAdrListRef() | 210 | AddressList* EmailClient::getAdrListRef() |
210 | { | 211 | { |
211 | return addressList; | 212 | return addressList; |
212 | } | 213 | } |
213 | 214 | ||
214 | //this needs to be rewritten to syncronize with outboxView | 215 | //this needs to be rewritten to syncronize with outboxView |
215 | void EmailClient::enqueMail(const Email &mail) | 216 | void EmailClient::enqueMail(const Email &mail) |
216 | { | 217 | { |
218 | if (accountList.count() == 0) { | ||
219 | QMessageBox::warning(qApp->activeWindow(), | ||
220 | tr("No account selected"), tr("You must create an account"), "OK\n"); | ||
221 | return; | ||
222 | } | ||
223 | |||
217 | if (accountList.count() > 0) { | 224 | if (accountList.count() > 0) { |
218 | currentAccount = accountList.first(); | 225 | currentAccount = accountList.first(); |
219 | qWarning("using account " + currentAccount->name); | 226 | qWarning("using account " + currentAccount->name); |
220 | } | 227 | } |
221 | 228 | ||
222 | Email addMail = mail; | 229 | Email addMail = mail; |
223 | addMail.from = currentAccount->name; | 230 | addMail.from = currentAccount->name; |
224 | addMail.fromMail = currentAccount->emailAddress; | 231 | addMail.fromMail = currentAccount->emailAddress; |
225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 232 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
226 | item = new EmailListItem(outboxView, addMail, false); | 233 | item = new EmailListItem(outboxView, addMail, false); |
227 | 234 | ||
228 | } | 235 | } |
229 | 236 | ||
230 | void EmailClient::sendQuedMail() | 237 | void EmailClient::sendQuedMail() |
231 | { | 238 | { |
232 | int count = 0; | 239 | int count = 0; |
233 | 240 | ||
234 | if (accountList.count() == 0) { | 241 | if (accountList.count() == 0) { |
235 | QMessageBox::warning(qApp->activeWindow(), | 242 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
236 | "No account selected", "You must create an account", "OK\n"); | ||
237 | return; | 243 | return; |
238 | } | 244 | } |
239 | //traverse listview, find messages to send | 245 | //traverse listview, find messages to send |
240 | if (! sending) { | 246 | if (! sending) { |
241 | item = (EmailListItem *) outboxView->firstChild(); | 247 | item = (EmailListItem *) outboxView->firstChild(); |
242 | if (item != NULL) { | 248 | if (item != NULL) { |
243 | while (item != NULL) { | 249 | while (item != NULL) { |
244 | quedMessages.append(item->getMail()); | 250 | quedMessages.append(item->getMail()); |
245 | item = (EmailListItem *) item->nextSibling(); | 251 | item = (EmailListItem *) item->nextSibling(); |
246 | count++; | 252 | count++; |
247 | } | 253 | } |
248 | setMailAccount(); | 254 | setMailAccount(); |
249 | emailHandler->sendMail(&quedMessages); | 255 | emailHandler->sendMail(&quedMessages); |
250 | sending = TRUE; | 256 | sending = TRUE; |
251 | sendMailButton->setEnabled(FALSE); | 257 | sendMailButton->setEnabled(FALSE); |
252 | cancelButton->setEnabled(TRUE); | 258 | cancelButton->setEnabled(TRUE); |
253 | } else { | 259 | } else { |
254 | qWarning("sendQuedMail(): no messages to send"); | 260 | qWarning("sendQuedMail(): no messages to send"); |
255 | } | 261 | } |
256 | } | 262 | } |
257 | } | 263 | } |
258 | 264 | ||
259 | void EmailClient::setMailAccount() | 265 | void EmailClient::setMailAccount() |
260 | { | 266 | { |
261 | emailHandler->setAccount(*currentAccount); | 267 | emailHandler->setAccount(*currentAccount); |
262 | } | 268 | } |
263 | 269 | ||
264 | void EmailClient::mailSent() | 270 | void EmailClient::mailSent() |
265 | { | 271 | { |
266 | sending = FALSE; | 272 | sending = FALSE; |
267 | sendMailButton->setEnabled(TRUE); | 273 | sendMailButton->setEnabled(TRUE); |
268 | 274 | ||
269 | quedMessages.clear(); | 275 | quedMessages.clear(); |
270 | outboxView->clear(); //should be moved to an sentBox | 276 | outboxView->clear(); //should be moved to an sentBox |
271 | } | 277 | } |
272 | 278 | ||
273 | void EmailClient::getNewMail() { | 279 | void EmailClient::getNewMail() { |
274 | 280 | ||
275 | if (accountList.count() == 0) { | 281 | if (accountList.count() == 0) { |
276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 282 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
277 | "You must create an account", "OK\n"); | 283 | "You must create an account", "OK\n"); |
278 | return; | 284 | return; |
279 | } | 285 | } |
280 | 286 | ||
281 | setMailAccount(); | 287 | setMailAccount(); |
282 | 288 | ||
283 | receiving = TRUE; | 289 | receiving = TRUE; |
284 | previewingMail = TRUE; | 290 | previewingMail = TRUE; |
285 | getMailButton->setEnabled(FALSE); | 291 | getMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 292 | cancelButton->setEnabled(TRUE); |
287 | selectAccountMenu->setEnabled(FALSE); | 293 | selectAccountMenu->setEnabled(FALSE); |
288 | 294 | ||
289 | status1Label->setText(currentAccount->accountName + " headers"); | 295 | status1Label->setText(currentAccount->accountName + " headers"); |
290 | progressBar->reset(); | 296 | progressBar->reset(); |
291 | 297 | ||
292 | //get any previous mails not downloaded and add to queue | 298 | //get any previous mails not downloaded and add to queue |
293 | mailDownloadList.clear(); | 299 | mailDownloadList.clear(); |
294 | Email *mailPtr; | 300 | Email *mailPtr; |
295 | item = (EmailListItem *) inboxView->firstChild(); | 301 | item = (EmailListItem *) inboxView->firstChild(); |
296 | while (item != NULL) { | 302 | while (item != NULL) { |
297 | mailPtr = item->getMail(); | 303 | mailPtr = item->getMail(); |
298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 304 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 305 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
300 | } | 306 | } |
301 | item = (EmailListItem *) item->nextSibling(); | 307 | item = (EmailListItem *) item->nextSibling(); |
302 | } | 308 | } |
303 | 309 | ||
304 | emailHandler->getMailHeaders(); | 310 | emailHandler->getMailHeaders(); |
305 | } | 311 | } |
306 | 312 | ||
307 | void EmailClient::getAllNewMail() | 313 | void EmailClient::getAllNewMail() |
308 | { | 314 | { |
309 | allAccounts = TRUE; | 315 | allAccounts = TRUE; |
310 | currentAccount = accountList.first(); | 316 | currentAccount = accountList.first(); |
311 | getNewMail(); | 317 | getNewMail(); |
312 | } | 318 | } |
313 | 319 | ||
314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 320 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
315 | { | 321 | { |
316 | Enclosure *ePtr; | 322 | Enclosure *ePtr; |
317 | Email newMail; | 323 | Email newMail; |
318 | int thisMailId; | 324 | int thisMailId; |
319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 325 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
320 | 326 | ||
321 | mailconf->setGroup(newMail.id); | 327 | mailconf->setGroup(newMail.id); |
322 | 328 | ||
323 | if (fromDisk) { | 329 | if (fromDisk) { |
324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 330 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
325 | newMail.size = mailconf->readNumEntry("size"); | 331 | newMail.size = mailconf->readNumEntry("size"); |
326 | newMail.serverId = mailconf->readNumEntry("serverid"); | 332 | newMail.serverId = mailconf->readNumEntry("serverid"); |
327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 333 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
328 | } else { //mail arrived from server | 334 | } else { //mail arrived from server |
329 | newMail.serverId = mail.serverId; | 335 | newMail.serverId = mail.serverId; |
330 | newMail.size = mail.size; | 336 | newMail.size = mail.size; |
331 | newMail.downloaded = mail.downloaded; | 337 | newMail.downloaded = mail.downloaded; |
332 | 338 | ||
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 2144899..1be16d4 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -319,198 +319,201 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
319 | } | 319 | } |
320 | return TRUE; | 320 | return TRUE; |
321 | } | 321 | } |
322 | 322 | ||
323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
324 | { | 324 | { |
325 | QFile f(ePtr->path + ePtr->name); | 325 | QFile f(ePtr->path + ePtr->name); |
326 | char src[4]; | 326 | char src[4]; |
327 | char *destPtr; | 327 | char *destPtr; |
328 | QByteArray buffer; | 328 | QByteArray buffer; |
329 | uint bufCount, pos, decodedCount, size, x; | 329 | uint bufCount, pos, decodedCount, size, x; |
330 | 330 | ||
331 | if (! f.open(IO_WriteOnly) ) { | 331 | if (! f.open(IO_WriteOnly) ) { |
332 | qWarning("could not save: " + ePtr->path + ePtr->name); | 332 | qWarning("could not save: " + ePtr->path + ePtr->name); |
333 | return FALSE; | 333 | return FALSE; |
334 | } | 334 | } |
335 | 335 | ||
336 | if (ePtr->encoding.upper() == "BASE64") { | 336 | if (ePtr->encoding.upper() == "BASE64") { |
337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
338 | buffer.resize(size); | 338 | buffer.resize(size); |
339 | bufCount = 0; | 339 | bufCount = 0; |
340 | pos = 0; | 340 | pos = 0; |
341 | destPtr = buffer.data(); | 341 | destPtr = buffer.data(); |
342 | 342 | ||
343 | while (pos < ePtr->body.length()) { | 343 | while (pos < ePtr->body.length()) { |
344 | decodedCount = 4; | 344 | decodedCount = 4; |
345 | x = 0; | 345 | x = 0; |
346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
347 | src[x] = ePtr->body[pos].latin1(); | 347 | src[x] = ePtr->body[pos].latin1(); |
348 | pos++; | 348 | pos++; |
349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
350 | x--; | 350 | x--; |
351 | x++; | 351 | x++; |
352 | } | 352 | } |
353 | if (x > 1) { | 353 | if (x > 1) { |
354 | decodedCount = parse64base(src, destPtr); | 354 | decodedCount = parse64base(src, destPtr); |
355 | destPtr += decodedCount; | 355 | destPtr += decodedCount; |
356 | bufCount += decodedCount; | 356 | bufCount += decodedCount; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | buffer.resize(bufCount); //set correct length of file | 360 | buffer.resize(bufCount); //set correct length of file |
361 | f.writeBlock(buffer); | 361 | f.writeBlock(buffer); |
362 | } else { | 362 | } else { |
363 | QTextStream t(&f); | 363 | QTextStream t(&f); |
364 | t << ePtr->body; | 364 | t << ePtr->body; |
365 | } | 365 | } |
366 | return TRUE; | 366 | return TRUE; |
367 | } | 367 | } |
368 | 368 | ||
369 | int EmailHandler::parse64base(char *src, char *bufOut) { | 369 | int EmailHandler::parse64base(char *src, char *bufOut) { |
370 | 370 | ||
371 | char c, z; | 371 | char c, z; |
372 | char li[4]; | 372 | char li[4]; |
373 | int processed; | 373 | int processed; |
374 | 374 | ||
375 | //conversion table withouth table... | 375 | //conversion table withouth table... |
376 | for (int x = 0; x < 4; x++) { | 376 | for (int x = 0; x < 4; x++) { |
377 | c = src[x]; | 377 | c = src[x]; |
378 | 378 | ||
379 | if ( (int) c >= 'A' && (int) c <= 'Z') | 379 | if ( (int) c >= 'A' && (int) c <= 'Z') |
380 | li[x] = (int) c - (int) 'A'; | 380 | li[x] = (int) c - (int) 'A'; |
381 | if ( (int) c >= 'a' && (int) c <= 'z') | 381 | if ( (int) c >= 'a' && (int) c <= 'z') |
382 | li[x] = (int) c - (int) 'a' + 26; | 382 | li[x] = (int) c - (int) 'a' + 26; |
383 | if ( (int) c >= '0' && (int) c <= '9') | 383 | if ( (int) c >= '0' && (int) c <= '9') |
384 | li[x] = (int) c - (int) '0' + 52; | 384 | li[x] = (int) c - (int) '0' + 52; |
385 | if (c == '+') | 385 | if (c == '+') |
386 | li[x] = 62; | 386 | li[x] = 62; |
387 | if (c == '/') | 387 | if (c == '/') |
388 | li[x] = 63; | 388 | li[x] = 63; |
389 | } | 389 | } |
390 | 390 | ||
391 | processed = 1; | 391 | processed = 1; |
392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
393 | bufOut[0] <<= 2; | 393 | bufOut[0] <<= 2; |
394 | z = li[1] >> 4; | 394 | z = li[1] >> 4; |
395 | bufOut[0] = bufOut[0] | z; //first byte retrived | 395 | bufOut[0] = bufOut[0] | z; //first byte retrived |
396 | 396 | ||
397 | if (src[2] != '=') { | 397 | if (src[2] != '=') { |
398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
399 | bufOut[1] <<= 4; | 399 | bufOut[1] <<= 4; |
400 | z = li[2] >> 2; | 400 | z = li[2] >> 2; |
401 | bufOut[1] = bufOut[1] | z; //second byte retrived | 401 | bufOut[1] = bufOut[1] | z; //second byte retrived |
402 | processed++; | 402 | processed++; |
403 | 403 | ||
404 | if (src[3] != '=') { | 404 | if (src[3] != '=') { |
405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
406 | bufOut[2] <<= 6; | 406 | bufOut[2] <<= 6; |
407 | z = li[3]; | 407 | z = li[3]; |
408 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 408 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
409 | processed++; | 409 | processed++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | return processed; | 412 | return processed; |
413 | } | 413 | } |
414 | 414 | ||
415 | int EmailHandler::encodeMime(Email *mail) { | 415 | int EmailHandler::encodeMime(Email *mail) |
416 | { | ||
417 | |||
416 | QString fileName, fileType, contentType, newBody, boundary; | 418 | QString fileName, fileType, contentType, newBody, boundary; |
417 | Enclosure *ePtr; | 419 | Enclosure *ePtr; |
418 | 420 | ||
419 | QString userName = mailAccount.name; | 421 | QString userName = mailAccount.name; |
420 | userName += " <" + mailAccount.emailAddress + ">"; | 422 | if (userName.length()>0)//only embrace it if there is a user name |
423 | userName += " <" + mailAccount.emailAddress + ">"; | ||
421 | 424 | ||
422 | //add standard headers | 425 | //add standard headers |
423 | newBody = "From: " + userName + "\r\nTo: "; | 426 | newBody = "From: " + userName + "\r\nTo: "; |
424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 427 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
425 | newBody += *it + " "; | 428 | newBody += *it + " "; |
426 | } | 429 | } |
427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 430 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
428 | 431 | ||
429 | if (mail->files.count() == 0) { //just a simple mail | 432 | if (mail->files.count() == 0) { //just a simple mail |
430 | newBody += "\r\n" + mail->body; | 433 | newBody += "\r\n" + mail->body; |
431 | mail->rawMail = newBody; | 434 | mail->rawMail = newBody; |
432 | return 0; | 435 | return 0; |
433 | } | 436 | } |
434 | 437 | ||
435 | //Build mime encoded mail | 438 | //Build mime encoded mail |
436 | boundary = "-----4345=next_bound=0495----"; | 439 | boundary = "-----4345=next_bound=0495----"; |
437 | 440 | ||
438 | newBody += "Mime-Version: 1.0\r\n"; | 441 | newBody += "Mime-Version: 1.0\r\n"; |
439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 442 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
440 | boundary + "\"\r\n\r\n"; | 443 | boundary + "\"\r\n\r\n"; |
441 | 444 | ||
442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 445 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 446 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
444 | newBody += mail->body; | 447 | newBody += mail->body; |
445 | 448 | ||
446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 449 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
447 | fileName = ePtr->originalName; | 450 | fileName = ePtr->originalName; |
448 | fileType = ePtr->contentType; | 451 | fileType = ePtr->contentType; |
449 | QFileInfo fi(fileName); | 452 | QFileInfo fi(fileName); |
450 | 453 | ||
451 | // This specification of contentType is temporary | 454 | // This specification of contentType is temporary |
452 | contentType = ""; | 455 | contentType = ""; |
453 | if (fileType == "Picture") { | 456 | if (fileType == "Picture") { |
454 | contentType = "image/x-image"; | 457 | contentType = "image/x-image"; |
455 | } else if (fileType == "Document") { | 458 | } else if (fileType == "Document") { |
456 | contentType = "text/plain"; | 459 | contentType = "text/plain"; |
457 | } else if (fileType == "Sound") { | 460 | } else if (fileType == "Sound") { |
458 | contentType = "audio/x-wav"; | 461 | contentType = "audio/x-wav"; |
459 | } else if (fileType == "Movie") { | 462 | } else if (fileType == "Movie") { |
460 | contentType = "video/mpeg"; | 463 | contentType = "video/mpeg"; |
461 | } else { | 464 | } else { |
462 | contentType = "application/octet-stream"; | 465 | contentType = "application/octet-stream"; |
463 | } | 466 | } |
464 | 467 | ||
465 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 468 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
466 | newBody += "Content-Type: " + contentType + "; name=\"" + | 469 | newBody += "Content-Type: " + contentType + "; name=\"" + |
467 | fi.fileName() + "\"\r\n"; | 470 | fi.fileName() + "\"\r\n"; |
468 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 471 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
469 | newBody += "Content-Disposition: inline; filename=\"" + | 472 | newBody += "Content-Disposition: inline; filename=\"" + |
470 | fi.fileName() + "\"\r\n\r\n"; | 473 | fi.fileName() + "\"\r\n\r\n"; |
471 | 474 | ||
472 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 475 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
473 | return -1; | 476 | return -1; |
474 | } | 477 | } |
475 | 478 | ||
476 | newBody += "\r\n\r\n--" + boundary + "--"; | 479 | newBody += "\r\n\r\n--" + boundary + "--"; |
477 | mail->rawMail = newBody; | 480 | mail->rawMail = newBody; |
478 | 481 | ||
479 | return 0; | 482 | return 0; |
480 | } | 483 | } |
481 | 484 | ||
482 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 485 | int EmailHandler::encodeFile(QString fileName, QString *toBody) |
483 | { | 486 | { |
484 | char *fileData; | 487 | char *fileData; |
485 | char *dataPtr; | 488 | char *dataPtr; |
486 | QString temp; | 489 | QString temp; |
487 | uint dataSize, count; | 490 | uint dataSize, count; |
488 | QFile f(fileName); | 491 | QFile f(fileName); |
489 | 492 | ||
490 | if (! f.open(IO_ReadOnly) ) { | 493 | if (! f.open(IO_ReadOnly) ) { |
491 | qWarning("could not open file: " + fileName); | 494 | qWarning("could not open file: " + fileName); |
492 | return -1; | 495 | return -1; |
493 | } | 496 | } |
494 | QTextStream s(&f); | 497 | QTextStream s(&f); |
495 | dataSize = f.size(); | 498 | dataSize = f.size(); |
496 | fileData = (char *) malloc(dataSize + 3); | 499 | fileData = (char *) malloc(dataSize + 3); |
497 | s.readRawBytes(fileData, dataSize); | 500 | s.readRawBytes(fileData, dataSize); |
498 | 501 | ||
499 | temp = ""; | 502 | temp = ""; |
500 | dataPtr = fileData; | 503 | dataPtr = fileData; |
501 | count = 0; | 504 | count = 0; |
502 | while (dataSize > 0) { | 505 | while (dataSize > 0) { |
503 | if (dataSize < 3) { | 506 | if (dataSize < 3) { |
504 | encode64base(dataPtr, &temp, dataSize); | 507 | encode64base(dataPtr, &temp, dataSize); |
505 | dataSize = 0; | 508 | dataSize = 0; |
506 | } else { | 509 | } else { |
507 | encode64base(dataPtr, &temp, 3); | 510 | encode64base(dataPtr, &temp, 3); |
508 | dataSize -= 3; | 511 | dataSize -= 3; |
509 | dataPtr += 3; | 512 | dataPtr += 3; |
510 | count += 4; | 513 | count += 4; |
511 | } | 514 | } |
512 | if (count > 72) { | 515 | if (count > 72) { |
513 | count = 0; | 516 | count = 0; |
514 | temp += "\r\n"; | 517 | temp += "\r\n"; |
515 | } | 518 | } |
516 | } | 519 | } |
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 1a7185e..70332a9 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp | |||
@@ -1,272 +1,270 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include "writemail.h" | 21 | #include "writemail.h" |
22 | #include "resource.h" | 22 | #include "resource.h" |
23 | 23 | ||
24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) | 24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) |
25 | : QMainWindow( parent, name, fl ) | 25 | : QMainWindow( parent, name, fl ) |
26 | { | 26 | { |
27 | showingAddressList = FALSE; | 27 | showingAddressList = FALSE; |
28 | init(); | 28 | init(); |
29 | 29 | ||
30 | addAtt = new AddAtt(0, "Add Attatchments"); | 30 | addAtt = new AddAtt(0, "Add Attatchments"); |
31 | } | 31 | } |
32 | 32 | ||
33 | WriteMail::~WriteMail() | 33 | WriteMail::~WriteMail() |
34 | { | 34 | { |
35 | delete addAtt; | 35 | delete addAtt; |
36 | } | 36 | } |
37 | 37 | ||
38 | void WriteMail::setAddressList(AddressList *list) | 38 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 39 | { |
40 | Contact *cPtr; | 40 | Contact *cPtr; |
41 | 41 | ||
42 | addressList = list; | 42 | addressList = list; |
43 | 43 | ||
44 | addressView->clear(); | 44 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 45 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 46 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->email, cPtr->name); | 48 | item = new QListViewItem(addressView, cPtr->email, cPtr->name); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void WriteMail::init() | 52 | void WriteMail::init() |
53 | { | 53 | { |
54 | setToolBarsMovable(FALSE); | 54 | setToolBarsMovable(FALSE); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
58 | 58 | ||
59 | menu = new QMenuBar( bar ); | 59 | menu = new QMenuBar( bar ); |
60 | 60 | ||
61 | mailMenu = new QPopupMenu(menu); | 61 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 62 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 63 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 64 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 65 | ||
66 | bar = new QToolBar(this); | 66 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("fileopen"), QString::null, 0, this, 0); | 67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 68 | attatchButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 69 | attatchButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); |
71 | 71 | ||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 73 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 74 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
76 | 76 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 78 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 80 | ||
81 | widget = new QWidget(this, "widget"); | 81 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 82 | grid = new QGridLayout( widget ); |
83 | 83 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 85 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 86 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 87 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 88 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | 89 | ||
90 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 90 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
91 | subjetLabel->setText( tr( "Subject:" ) ); | 91 | subjetLabel->setText( tr( "Subject:" ) ); |
92 | 92 | ||
93 | grid->addWidget( subjetLabel, 1, 0 ); | 93 | grid->addWidget( subjetLabel, 1, 0 ); |
94 | 94 | ||
95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
96 | ToolButton13_2->setText( tr( "..." ) ); | 96 | ToolButton13_2->setText( tr( "..." ) ); |
97 | grid->addWidget( ToolButton13_2, 1, 2 ); | 97 | grid->addWidget( ToolButton13_2, 1, 2 ); |
98 | 98 | ||
99 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 99 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
100 | grid->addWidget( subjectInput, 1, 1 ); | 100 | grid->addWidget( subjectInput, 1, 1 ); |
101 | 101 | ||
102 | toInput = new QLineEdit( widget, "toInput" ); | 102 | toInput = new QLineEdit( widget, "toInput" ); |
103 | grid->addWidget( toInput, 0, 1 ); | 103 | grid->addWidget( toInput, 0, 1 ); |
104 | 104 | ||
105 | addressButton = new QToolButton( widget, "addressButton" ); | 105 | addressButton = new QToolButton( widget, "addressButton" ); |
106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
107 | addressButton->setToggleButton(TRUE); | 107 | addressButton->setToggleButton(TRUE); |
108 | grid->addWidget( addressButton, 0, 2 ); | 108 | grid->addWidget( addressButton, 0, 2 ); |
109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
110 | 110 | ||
111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
113 | 113 | ||
114 | addressView = new QListView( widget, "addressView"); | 114 | addressView = new QListView( widget, "addressView"); |
115 | addressView->addColumn("Email"); | 115 | addressView->addColumn("Email"); |
116 | addressView->addColumn("Name"); | 116 | addressView->addColumn("Name"); |
117 | addressView->setAllColumnsShowFocus(TRUE); | 117 | addressView->setAllColumnsShowFocus(TRUE); |
118 | addressView->setMultiSelection(TRUE); | 118 | addressView->setMultiSelection(TRUE); |
119 | addressView->hide(); | 119 | addressView->hide(); |
120 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 120 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
121 | 121 | ||
122 | okButton = new QToolButton(bar, "ok"); | 122 | okButton = new QToolButton(bar, "ok"); |
123 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 123 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
124 | okButton->hide(); | 124 | okButton->hide(); |
125 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 125 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
126 | 126 | ||
127 | setCentralWidget(widget); | 127 | setCentralWidget(widget); |
128 | } | 128 | } |
129 | 129 | ||
130 | void WriteMail::reject() | 130 | void WriteMail::reject() |
131 | { | 131 | { |
132 | emit cancelMail(); | 132 | emit cancelMail(); |
133 | } | 133 | } |
134 | 134 | ||
135 | // need to insert date | 135 | // need to insert date |
136 | void WriteMail::accept() | 136 | void WriteMail::accept() |
137 | { | 137 | { |
138 | QStringList attatchedFiles, attatchmentsType; | 138 | QStringList attatchedFiles, attatchmentsType; |
139 | int idCount = 0; | 139 | int idCount = 0; |
140 | 140 | ||
141 | if (toInput->text() == "") { | 141 | if (toInput->text() == "") { |
142 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); | 142 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | if (! getRecipients() ) { | 145 | if (! getRecipients() ) { |
146 | QMessageBox::warning(this,"Incorrect recipient separator", | 146 | QMessageBox::warning(this,"Incorrect recipient separator", |
147 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); | 147 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | mail.subject = subjectInput->text(); | 150 | mail.subject = subjectInput->text(); |
151 | mail.body = emailInput->text(); | 151 | mail.body = emailInput->text(); |
152 | mail.sent = false; | 152 | mail.sent = false; |
153 | mail.received = false; | 153 | mail.received = false; |
154 | mail.rawMail = "To: "; | 154 | mail.rawMail = "To: "; |
155 | 155 | ||
156 | for (QStringList::Iterator it = mail.recipients.begin(); | 156 | for (QStringList::Iterator it = mail.recipients.begin(); |
157 | it != mail.recipients.end(); ++it) { | 157 | it != mail.recipients.end(); ++it) { |
158 | 158 | ||
159 | mail.rawMail += (*it); | 159 | mail.rawMail += (*it); |
160 | mail.rawMail += ",\n"; | 160 | mail.rawMail += ",\n"; |
161 | } | 161 | } |
162 | mail.rawMail.truncate(mail.rawMail.length()-2); | 162 | mail.rawMail.truncate(mail.rawMail.length()-2); |
163 | mail.rawMail += mail.from; | 163 | mail.rawMail += mail.from; |
164 | mail.rawMail += "\nSubject: "; | 164 | mail.rawMail += "\nSubject: "; |
165 | mail.rawMail += mail.subject; | 165 | mail.rawMail += mail.subject; |
166 | mail.rawMail += "\n\n"; | 166 | mail.rawMail += "\n\n"; |
167 | 167 | ||
168 | attatchedFiles = addAtt->returnAttatchedFiles(); | 168 | attatchedFiles = addAtt->returnAttatchedFiles(); |
169 | attatchmentsType = addAtt->returnFileTypes(); | 169 | attatchmentsType = addAtt->returnFileTypes(); |
170 | 170 | ||
171 | QStringList::Iterator itType = attatchmentsType.begin(); | 171 | QStringList::Iterator itType = attatchmentsType.begin(); |
172 | 172 | ||
173 | Enclosure e; | 173 | Enclosure e; |
174 | for ( QStringList::Iterator it = attatchedFiles.begin(); | 174 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { |
175 | it != attatchedFiles.end(); ++it ) { | ||
176 | |||
177 | e.id = idCount; | 175 | e.id = idCount; |
178 | e.originalName = (*it).latin1(); | 176 | e.originalName = (*it).latin1(); |
179 | e.contentType = (*itType).latin1(); | 177 | e.contentType = (*itType).latin1(); |
180 | e.contentAttribute = (*itType).latin1(); | 178 | e.contentAttribute = (*itType).latin1(); |
181 | e.saved = TRUE; | 179 | e.saved = TRUE; |
182 | mail.addEnclosure(&e); | 180 | mail.addEnclosure(&e); |
183 | 181 | ||
184 | itType++; | 182 | itType++; |
185 | idCount++; | 183 | idCount++; |
186 | } | 184 | } |
187 | mail.rawMail += mail.body; | 185 | mail.rawMail += mail.body; |
188 | mail.rawMail += "\n"; | 186 | mail.rawMail += "\n"; |
189 | mail.rawMail += ".\n"; | 187 | mail.rawMail += ".\n"; |
190 | emit sendMailRequested(mail); | 188 | emit sendMailRequested(mail); |
191 | addAtt->clear(); | 189 | addAtt->clear(); |
192 | } | 190 | } |
193 | 191 | ||
194 | void WriteMail::getAddress() | 192 | void WriteMail::getAddress() |
195 | { | 193 | { |
196 | showingAddressList = !showingAddressList; | 194 | showingAddressList = !showingAddressList; |
197 | 195 | ||
198 | if (showingAddressList) { | 196 | if (showingAddressList) { |
199 | emailInput->hide(); | 197 | emailInput->hide(); |
200 | addressView->show(); | 198 | addressView->show(); |
201 | okButton->show(); | 199 | okButton->show(); |
202 | 200 | ||
203 | } else { | 201 | } else { |
204 | addressView->hide(); | 202 | addressView->hide(); |
205 | okButton->hide(); | 203 | okButton->hide(); |
206 | emailInput->show(); | 204 | emailInput->show(); |
207 | } | 205 | } |
208 | } | 206 | } |
209 | 207 | ||
210 | void WriteMail::attatchFile() | 208 | void WriteMail::attatchFile() |
211 | { | 209 | { |
212 | addAtt->showMaximized(); | 210 | addAtt->showMaximized(); |
213 | } | 211 | } |
214 | 212 | ||
215 | void WriteMail::reply(Email replyMail) | 213 | void WriteMail::reply(Email replyMail) |
216 | { | 214 | { |
217 | int pos; | 215 | int pos; |
218 | 216 | ||
219 | mail = replyMail; | 217 | mail = replyMail; |
220 | mail.files.clear(); | 218 | mail.files.clear(); |
221 | 219 | ||
222 | toInput->setText(mail.fromMail); | 220 | toInput->setText(mail.fromMail); |
223 | subjectInput->setText("Re: " + mail.subject); | 221 | subjectInput->setText("Re: " + mail.subject); |
224 | 222 | ||
225 | pos = 0; | 223 | pos = 0; |
226 | mail.body.insert(pos, ">>"); | 224 | mail.body.insert(pos, ">>"); |
227 | while (pos != -1) { | 225 | while (pos != -1) { |
228 | pos = mail.body.find('\n', pos); | 226 | pos = mail.body.find('\n', pos); |
229 | if (pos != -1) | 227 | if (pos != -1) |
230 | mail.body.insert(++pos, ">>"); | 228 | mail.body.insert(++pos, ">>"); |
231 | } | 229 | } |
232 | 230 | ||
233 | emailInput->setText(mail.body); | 231 | emailInput->setText(mail.body); |
234 | } | 232 | } |
235 | 233 | ||
236 | bool WriteMail::getRecipients() | 234 | bool WriteMail::getRecipients() |
237 | { | 235 | { |
238 | QString str, temp; | 236 | QString str, temp; |
239 | int pos = 0; | 237 | int pos = 0; |
240 | 238 | ||
241 | mail.recipients.clear(); | 239 | mail.recipients.clear(); |
242 | 240 | ||
243 | temp = toInput->text(); | 241 | temp = toInput->text(); |
244 | while ( (pos = temp.find(';')) != -1) { | 242 | while ( (pos = temp.find(';')) != -1) { |
245 | str = temp.left(pos).stripWhiteSpace(); | 243 | str = temp.left(pos).stripWhiteSpace(); |
246 | temp = temp.right(temp.length() - (pos + 1)); | 244 | temp = temp.right(temp.length() - (pos + 1)); |
247 | if ( str.find('@') == -1) | 245 | if ( str.find('@') == -1) |
248 | return false; | 246 | return false; |
249 | mail.recipients.append(str); | 247 | mail.recipients.append(str); |
250 | addressList->addContact(str, ""); | 248 | addressList->addContact(str, ""); |
251 | } | 249 | } |
252 | temp = temp.stripWhiteSpace(); | 250 | temp = temp.stripWhiteSpace(); |
253 | if ( temp.find('@') == -1) | 251 | if ( temp.find('@') == -1) |
254 | return false; | 252 | return false; |
255 | mail.recipients.append(temp); | 253 | mail.recipients.append(temp); |
256 | addressList->addContact(temp, ""); | 254 | addressList->addContact(temp, ""); |
257 | 255 | ||
258 | return TRUE; | 256 | return TRUE; |
259 | } | 257 | } |
260 | 258 | ||
261 | 259 | ||
262 | void WriteMail::addRecipients() | 260 | void WriteMail::addRecipients() |
263 | { | 261 | { |
264 | QString recipients = ""; | 262 | QString recipients = ""; |
265 | 263 | ||
266 | mail.recipients.clear(); | 264 | mail.recipients.clear(); |
267 | QListViewItem *item = addressView->firstChild(); | 265 | QListViewItem *item = addressView->firstChild(); |
268 | while (item != NULL) { | 266 | while (item != NULL) { |
269 | if ( item->isSelected() ) { | 267 | if ( item->isSelected() ) { |
270 | if (recipients == "") { | 268 | if (recipients == "") { |
271 | recipients = item->text(0); | 269 | recipients = item->text(0); |
272 | } else { | 270 | } else { |
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp index c030e36..f279f52 100644 --- a/noncore/unsupported/mailit/addatt.cpp +++ b/noncore/unsupported/mailit/addatt.cpp | |||
@@ -1,209 +1,230 @@ | |||
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 <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | #include "addatt.h" | 24 | #include "addatt.h" |
25 | 25 | ||
26 | FileItem::FileItem(QListView *parent, QFileInfo fileInfo, QString fileType) | 26 | FileItem::FileItem(QListView *parent, DocLnk* dl) |
27 | : QListViewItem(parent) | 27 | : QListViewItem(parent) |
28 | { | 28 | { |
29 | file = fileInfo; | 29 | /*file = fileInfo; |
30 | type = fileType; | 30 | type = fileType;*/ |
31 | |||
32 | doclnk=dl; | ||
31 | 33 | ||
32 | setText(0, fileInfo.baseName()); | 34 | setText(0, doclnk->name()); |
33 | 35 | ||
34 | if (fileType == "Picture") { | 36 | /*if (fileType == "Picture") { |
35 | setPixmap(0, Resource::loadPixmap("pixmap")); | 37 | setPixmap(0, Resource::loadPixmap("pixmap")); |
36 | } else if (fileType == "Document") { | 38 | } else if (fileType == "Document") { |
37 | setPixmap(0, Resource::loadPixmap("txt")); | 39 | setPixmap(0, Resource::loadPixmap("txt")); |
38 | } else if (fileType == "Sound") { | 40 | } else if (fileType == "Sound") { |
39 | setPixmap(0, Resource::loadPixmap("play")); | 41 | setPixmap(0, Resource::loadPixmap("play")); |
40 | } else if (fileType == "Movie") { | 42 | } else if (fileType == "Movie") { |
41 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); | 43 | setPixmap(0, Resource::loadPixmap("MPEGPlayer")); |
42 | } else if (fileType == "File") { | 44 | } else if (fileType == "File") { |
43 | setPixmap(0, Resource::loadPixmap("exec")); | 45 | setPixmap(0, Resource::loadPixmap("exec")); |
44 | } | 46 | }*/ |
45 | } | 47 | } |
46 | 48 | ||
47 | QFileInfo FileItem::getFileInfo() | 49 | FileItem::~FileItem() |
48 | { | 50 | { |
49 | return file; | 51 | if (doclnk!=NULL) delete doclnk; |
50 | } | 52 | doclnk=NULL; |
51 | |||
52 | QString FileItem::getFileType() | ||
53 | { | ||
54 | return type; | ||
55 | } | 53 | } |
56 | 54 | ||
57 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) | 55 | AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) |
58 | : QDialog(parent, name, f) | 56 | : QDialog(parent, name, f) |
59 | { | 57 | { |
60 | setCaption("Adding attatchments"); | 58 | setCaption("Adding attatchments"); |
61 | 59 | ||
62 | QGridLayout *top = new QGridLayout(this, 3, 2); | 60 | QGridLayout *top = new QGridLayout(this, 3,1 ); |
61 | |||
63 | 62 | ||
64 | fileCategoryButton = new QPushButton(this); | 63 | /*fileCategoryButton = new QPushButton(this);*/ |
65 | attatchButton = new QPushButton("Attatch ->", this); | 64 | attatchButton = new QPushButton("Attatch ->", this); |
66 | removeButton = new QPushButton("Remove", this); | 65 | removeButton = new QPushButton("Remove", this); |
67 | 66 | ||
68 | fileCategories = new QPopupMenu(fileCategoryButton); | 67 | /*fileCategories = new QPopupMenu(fileCategoryButton); |
69 | fileCategoryButton->setPopup(fileCategories); | 68 | fileCategoryButton->setPopup(fileCategories); |
70 | fileCategories->insertItem("Document"); | 69 | fileCategories->insertItem("Document"); |
71 | fileCategories->insertItem("Picture"); | 70 | fileCategories->insertItem("Picture"); |
72 | fileCategories->insertItem("Sound"); | 71 | fileCategories->insertItem("Sound"); |
73 | fileCategories->insertItem("Movie"); | 72 | fileCategories->insertItem("Movie"); |
74 | fileCategories->insertItem("File"); | 73 | fileCategories->insertItem("File"); |
75 | 74 | ||
76 | fileCategoryButton->setText("Document"); | 75 | fileCategoryButton->setText("Document"); |
77 | top->addWidget(fileCategoryButton, 0, 0); | 76 | top->addWidget(fileCategoryButton, 0, 0);*/ |
78 | top->addWidget(attatchButton, 2, 0); | 77 | |
79 | top->addWidget(removeButton, 2, 1); | 78 | //ofs=new OFileSelector(this,2,0,"/root/Documents"); |
79 | |||
80 | |||
81 | top->addWidget(attatchButton,1,0); | ||
82 | top->addWidget(removeButton,2,0); | ||
80 | 83 | ||
81 | connect(fileCategories, SIGNAL(activated(int)), this, | 84 | /*connect(fileCategories, SIGNAL(activated(int)), this, |
82 | SLOT(fileCategorySelected(int)) ); | 85 | SLOT(fileCategorySelected(int)) );*/ |
83 | connect(attatchButton, SIGNAL(clicked()), this, | 86 | connect(attatchButton, SIGNAL(clicked()), this, |
84 | SLOT(addAttatchment()) ); | 87 | SLOT(addAttatchment()) ); |
85 | connect(removeButton, SIGNAL(clicked()), this, | 88 | connect(removeButton, SIGNAL(clicked()), this, |
86 | SLOT(removeAttatchment()) ); | 89 | SLOT(removeAttatchment()) ); |
87 | 90 | ||
88 | listView = new QListView(this, "AttView"); | 91 | /*listView = new QListView(this, "AttView"); |
89 | listView->addColumn("Documents"); | 92 | listView->addColumn("Documents");* |
90 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, | 93 | connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, |
91 | SLOT(addAttatchment()) ); | 94 | SLOT(addAttatchment()) );*/ |
95 | |||
92 | 96 | ||
93 | attView = new QListView(this, "Selected"); | 97 | attView = new QListView(this, "Selected"); |
94 | attView->addColumn("Attatched"); | 98 | attView->addColumn(tr("Attached")); |
99 | attView->addColumn(tr("File type")); | ||
95 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, | 100 | connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, |
96 | SLOT(removeAttatchment()) ); | 101 | SLOT(removeAttatchment()) ); |
97 | 102 | ||
98 | top->addWidget(listView, 1,0); | 103 | //top->addWidget(ofs, 0,0); |
99 | top->addWidget(attView, 1,1); | 104 | top->addWidget(attView, 0,0); |
105 | |||
106 | clear(); | ||
100 | 107 | ||
101 | clear(); | 108 | |
102 | } | 109 | } |
103 | 110 | ||
104 | void AddAtt::clear() | 111 | void AddAtt::clear() |
105 | { | 112 | { |
106 | attView->clear(); | 113 | attView->clear(); |
107 | getFiles(); | 114 | //getFiles(); |
108 | modified = FALSE; | 115 | modified = FALSE; |
109 | } | 116 | } |
110 | 117 | ||
111 | void AddAtt::fileCategorySelected(int id) | 118 | /*void AddAtt::fileCategorySelected(int id) |
112 | { | 119 | { |
113 | fileCategoryButton->setText(fileCategories->text(id)); | 120 | fileCategoryButton->setText(fileCategories->text(id)); |
114 | getFiles(); | 121 | getFiles(); |
115 | } | 122 | }*/ |
116 | 123 | ||
117 | void AddAtt::addAttatchment() | 124 | void AddAtt::addAttatchment() |
118 | { | 125 | { |
119 | QFileInfo info; | 126 | QDialog qd(this,tr("Select attachment"),true); |
120 | QString type; | 127 | |
128 | QGridLayout top(&qd,1,1); | ||
129 | |||
130 | OFileSelector ofs(&qd,1,0,"/root/Documents"); | ||
131 | |||
132 | top.addWidget(&ofs,0,0); | ||
121 | 133 | ||
122 | if (listView->selectedItem() != NULL) { | 134 | qd.showMaximized(); |
123 | item = (FileItem *) listView->selectedItem(); | 135 | |
124 | info = item->getFileInfo(); | 136 | if (qd.exec()==QDialog::Accepted) |
125 | type = item->getFileType(); | 137 | { |
126 | item = new FileItem(attView, info, type); | 138 | DocLnk* dl=new DocLnk(ofs.selectedDocument()); |
139 | FileItem* fi=new FileItem(attView,dl); | ||
140 | fi->setPixmap(0,dl->pixmap()); | ||
141 | fi->setText(1,dl->type()); | ||
142 | attView->insertItem(fi); | ||
143 | modified = TRUE; | ||
127 | } | 144 | } |
128 | modified = TRUE; | ||
129 | } | 145 | } |
130 | 146 | ||
131 | void AddAtt::removeAttatchment() | 147 | void AddAtt::removeAttatchment() |
132 | { | 148 | { |
133 | if (attView->selectedItem() != NULL) { | 149 | if (attView->selectedItem() != NULL) |
150 | { | ||
134 | attView->takeItem(attView->selectedItem()); | 151 | attView->takeItem(attView->selectedItem()); |
135 | } | 152 | } |
136 | modified = TRUE; | 153 | modified = TRUE; |
137 | } | 154 | } |
138 | 155 | ||
139 | void AddAtt::reject() | 156 | void AddAtt::reject() |
140 | { | 157 | { |
141 | if (modified) { | 158 | if (modified) { |
142 | attView->clear(); | 159 | attView->clear(); |
143 | modified = FALSE; | 160 | modified = FALSE; |
144 | } | 161 | } |
145 | } | 162 | } |
146 | 163 | ||
147 | void AddAtt::accept() | 164 | void AddAtt::accept() |
148 | { | 165 | { |
149 | modified = FALSE; | 166 | modified = FALSE; |
150 | hide(); | 167 | hide(); |
151 | } | 168 | } |
152 | 169 | ||
153 | void AddAtt::getFiles() | 170 | void AddAtt::getFiles() |
154 | { | 171 | { |
155 | QString path, selected; | 172 | QString path, selected; |
156 | QDir *dir; | ||
157 | 173 | ||
158 | listView->clear(); | 174 | /*listView->clear(); |
159 | 175 | ||
160 | selected = fileCategoryButton->text(); | 176 | selected = fileCategoryButton->text(); |
161 | if (selected == "Picture") { | 177 | if (selected == "Picture") { |
162 | path = "../pics/"; | 178 | path = "../pics/"; |
163 | } else if (selected == "Document") { | 179 | } else if (selected == "Document") { |
164 | path = "" ; //sub-dirs not decided | 180 | path = "" ; //sub-dirs not decided |
165 | } else if (selected == "Sound") { | 181 | } else if (selected == "Sound") { |
166 | path = "../sounds/"; //sub-dirs not decided | 182 | path = "../sounds/"; //sub-dirs not decided |
167 | } else if (selected == "Movie") { | 183 | } else if (selected == "Movie") { |
168 | path = ""; //sub-dirs not decided | 184 | path = ""; //sub-dirs not decided |
169 | } else if (selected == "File") { | 185 | } else if (selected == "File") { |
170 | path = ""; //sub-dirs not decided | 186 | path = ""; //sub-dirs not decided |
171 | } | 187 | } |
172 | 188 | ||
173 | dir = new QDir(path); | 189 | dir = new QDir(path); |
174 | dir->setFilter(QDir::Files); | 190 | dir->setFilter(QDir::Files); |
175 | const QFileInfoList *dirInfoList = dir->entryInfoList(); | 191 | const QFileInfoList *dirInfoList = dir->entryInfoList(); |
176 | 192 | ||
177 | QFileInfoListIterator it(*dirInfoList); // create list iterator | 193 | QFileInfoListIterator it(*dirInfoList); // create list iterator |
178 | 194 | ||
179 | while ( (fi=it.current()) ) { // for each file... | 195 | while ( (fi=it.current()) ) { // for each file... |
180 | item = new FileItem(listView, *fi, selected); | 196 | item = new FileItem(lis+ütView, *fi, selected); |
181 | ++it; // goto next list element | 197 | ++it; // goto next list element |
182 | } | 198 | }*/ |
183 | } | 199 | } |
184 | 200 | ||
185 | QStringList AddAtt::returnAttatchedFiles() | 201 | QStringList AddAtt::returnAttatchedFiles() |
186 | { | 202 | { |
187 | QFileInfo info; | 203 | QFileInfo info; |
188 | QStringList list; | 204 | QStringList list; |
189 | 205 | ||
190 | item = (FileItem *) attView->firstChild(); | 206 | item = (FileItem *) attView->firstChild(); |
207 | |||
208 | |||
191 | while (item != NULL) { | 209 | while (item != NULL) { |
192 | info = item->getFileInfo(); | 210 | DocLnk* dl=item->getDocLnk(); |
193 | list += info.filePath(); | 211 | list+=dl->file(); |
212 | /*info = item->getFileInfo(); | ||
213 | list += info.filePath();*/ | ||
194 | item = (FileItem *) item->nextSibling(); | 214 | item = (FileItem *) item->nextSibling(); |
195 | } | 215 | } |
196 | return list; | 216 | return list; |
197 | } | 217 | } |
198 | 218 | ||
199 | QStringList AddAtt::returnFileTypes() | 219 | QStringList AddAtt::returnFileTypes() |
200 | { | 220 | { |
201 | QStringList list; | 221 | QStringList list; |
202 | 222 | ||
203 | item = (FileItem *) attView->firstChild(); | 223 | item = (FileItem *) attView->firstChild(); |
224 | |||
204 | while (item != NULL) { | 225 | while (item != NULL) { |
205 | list += item->getFileType(); | 226 | list += item->getDocLnk()->type(); |
206 | item = (FileItem *) item->nextSibling(); | 227 | item = (FileItem *) item->nextSibling(); |
207 | } | 228 | } |
208 | return list; | 229 | return list; |
209 | } | 230 | } |
diff --git a/noncore/unsupported/mailit/addatt.h b/noncore/unsupported/mailit/addatt.h index 867c905..73062e2 100644 --- a/noncore/unsupported/mailit/addatt.h +++ b/noncore/unsupported/mailit/addatt.h | |||
@@ -1,70 +1,76 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef ADDATT_H | 20 | #ifndef ADDATT_H |
21 | #define ADDATT_H | 21 | #define ADDATT_H |
22 | 22 | ||
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qfileinfo.h> | 28 | #include <qfileinfo.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <opie/ofileselector.h> | ||
31 | #include <qpe/applnk.h> | ||
30 | 32 | ||
31 | class FileItem : public QListViewItem | 33 | class FileItem : public QListViewItem |
32 | { | 34 | { |
33 | public: | 35 | public: |
34 | FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); | 36 | //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); |
35 | QFileInfo getFileInfo(); | 37 | FileItem(QListView*, DocLnk*); |
36 | QString getFileType(); | 38 | ~FileItem(); |
37 | 39 | DocLnk* getDocLnk() {return doclnk;} | |
40 | |||
41 | |||
38 | private: | 42 | private: |
39 | QFileInfo file; | 43 | DocLnk* doclnk; |
40 | QString type; | ||
41 | }; | 44 | }; |
42 | 45 | ||
43 | class AddAtt : public QDialog | 46 | class AddAtt : public QDialog |
44 | { | 47 | { |
45 | Q_OBJECT | 48 | Q_OBJECT |
46 | 49 | ||
47 | public: | 50 | public: |
48 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 51 | AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
49 | QStringList returnAttatchedFiles(); | 52 | QStringList returnAttatchedFiles(); |
50 | QStringList returnFileTypes(); | 53 | QStringList returnFileTypes(); |
51 | void getFiles(); | 54 | void getFiles(); |
52 | void clear(); | 55 | void clear(); |
53 | 56 | ||
57 | |||
54 | public slots: | 58 | public slots: |
55 | void fileCategorySelected(int); | 59 | //void fileCategorySelected(int); |
56 | void addAttatchment(); | 60 | void addAttatchment(); |
57 | void removeAttatchment(); | 61 | void removeAttatchment(); |
58 | void reject(); | 62 | void reject(); |
59 | void accept(); | 63 | void accept(); |
60 | 64 | ||
61 | private: | 65 | private: |
62 | FileItem *item; | 66 | FileItem* item; |
63 | QListView *listView, *attView; | 67 | QListView *attView; |
64 | QPushButton *fileCategoryButton, *attatchButton, *removeButton; | 68 | QPushButton *fileCategoryButton, *attatchButton, *removeButton; |
65 | QPopupMenu *fileCategories; | 69 | QPopupMenu *fileCategories; |
66 | bool modified; | 70 | bool modified; |
67 | QFileInfo *fi; | 71 | QFileInfo *fi; |
72 | |||
73 | OFileSelector* ofs; | ||
68 | }; | 74 | }; |
69 | 75 | ||
70 | #endif | 76 | #endif |
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index fc4276b..9258aac 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -68,265 +68,271 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | |||
68 | SLOT(allMailArrived(int)) ); | 68 | SLOT(allMailArrived(int)) ); |
69 | 69 | ||
70 | mailconf = new Config("mailit"); | 70 | mailconf = new Config("mailit"); |
71 | //In case Synchronize is not defined in settings.txt | 71 | //In case Synchronize is not defined in settings.txt |
72 | 72 | ||
73 | readSettings(); | 73 | readSettings(); |
74 | 74 | ||
75 | updateAccounts(); | 75 | updateAccounts(); |
76 | 76 | ||
77 | lineShift = "\n"; | 77 | lineShift = "\n"; |
78 | readMail(); | 78 | readMail(); |
79 | lineShift = "\r\n"; | 79 | lineShift = "\r\n"; |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | EmailClient::~EmailClient() | 84 | EmailClient::~EmailClient() |
85 | { | 85 | { |
86 | //needs to be moved from destructor to closewindow event | 86 | //needs to be moved from destructor to closewindow event |
87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); | 87 | saveMail(getPath(FALSE) + "inbox.txt", inboxView); |
88 | //does not currently work. Defining outbox in the same | 88 | //does not currently work. Defining outbox in the same |
89 | //format as inbox is not a good solution as they have | 89 | //format as inbox is not a good solution as they have |
90 | //different properties | 90 | //different properties |
91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); | 91 | saveMail(getPath(FALSE) + "outbox.txt", outboxView); |
92 | saveSettings(); | 92 | saveSettings(); |
93 | 93 | ||
94 | mailconf->write(); | 94 | mailconf->write(); |
95 | delete mailconf; | 95 | delete mailconf; |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void EmailClient::init() | 99 | void EmailClient::init() |
100 | { | 100 | { |
101 | statusBar = new QStatusBar(this); | 101 | statusBar = new QStatusBar(this); |
102 | statusBar->setSizeGripEnabled(FALSE); | 102 | statusBar->setSizeGripEnabled(FALSE); |
103 | 103 | ||
104 | status1Label = new QLabel( tr("Idle"), statusBar); | 104 | status1Label = new QLabel( tr("Idle"), statusBar); |
105 | status2Label = new QLabel("", statusBar); | 105 | status2Label = new QLabel("", statusBar); |
106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), | 106 | connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), |
107 | status2Label, SLOT(setText(const QString &)) ); | 107 | status2Label, SLOT(setText(const QString &)) ); |
108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), | 108 | connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), |
109 | status2Label, SLOT(setText(const QString &)) ); | 109 | status2Label, SLOT(setText(const QString &)) ); |
110 | 110 | ||
111 | progressBar = new QProgressBar(statusBar); | 111 | progressBar = new QProgressBar(statusBar); |
112 | connect(emailHandler, SIGNAL(mailboxSize(int)), | 112 | connect(emailHandler, SIGNAL(mailboxSize(int)), |
113 | this, SLOT(setTotalSize(int)) ); | 113 | this, SLOT(setTotalSize(int)) ); |
114 | connect(emailHandler, SIGNAL(currentMailSize(int)), | 114 | connect(emailHandler, SIGNAL(currentMailSize(int)), |
115 | this, SLOT(setMailSize(int)) ); | 115 | this, SLOT(setMailSize(int)) ); |
116 | connect(emailHandler, SIGNAL(downloadedSize(int)), | 116 | connect(emailHandler, SIGNAL(downloadedSize(int)), |
117 | this, SLOT(setDownloadedSize(int)) ); | 117 | this, SLOT(setDownloadedSize(int)) ); |
118 | 118 | ||
119 | statusBar->addWidget(status1Label); | 119 | statusBar->addWidget(status1Label); |
120 | statusBar->addWidget(progressBar); | 120 | statusBar->addWidget(progressBar); |
121 | statusBar->addWidget(status2Label); | 121 | statusBar->addWidget(status2Label); |
122 | 122 | ||
123 | setToolBarsMovable(FALSE); | 123 | setToolBarsMovable(FALSE); |
124 | 124 | ||
125 | bar = new QToolBar(this); | 125 | bar = new QToolBar(this); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | mb = new QMenuBar( bar ); | 128 | mb = new QMenuBar( bar ); |
129 | 129 | ||
130 | QPopupMenu *mail = new QPopupMenu(mb); | 130 | QPopupMenu *mail = new QPopupMenu(mb); |
131 | mb->insertItem( tr( "&Mail" ), mail); | 131 | mb->insertItem( tr( "&Mail" ), mail); |
132 | 132 | ||
133 | QPopupMenu *configure = new QPopupMenu(mb); | 133 | QPopupMenu *configure = new QPopupMenu(mb); |
134 | mb->insertItem( tr( "Accounts" ), configure); | 134 | mb->insertItem( tr( "Accounts" ), configure); |
135 | 135 | ||
136 | selectAccountMenu = new QPopupMenu(mb); | 136 | selectAccountMenu = new QPopupMenu(mb); |
137 | editAccountMenu = new QPopupMenu(mb); | 137 | editAccountMenu = new QPopupMenu(mb); |
138 | deleteAccountMenu = new QPopupMenu(mb); | 138 | deleteAccountMenu = new QPopupMenu(mb); |
139 | 139 | ||
140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); | 140 | mail->insertItem(tr("Get Mail in"), selectAccountMenu); |
141 | configure->insertItem(tr("Edit account"), editAccountMenu); | 141 | configure->insertItem(tr("Edit account"), editAccountMenu); |
142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); | 142 | configure->insertItem(tr("Delete account"), deleteAccountMenu); |
143 | 143 | ||
144 | bar = new QToolBar(this); | 144 | bar = new QToolBar(this); |
145 | 145 | ||
146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); | 146 | getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); |
147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); | 147 | connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); |
148 | getMailButton->addTo(bar); | 148 | getMailButton->addTo(bar); |
149 | getMailButton->addTo(mail); | 149 | getMailButton->addTo(mail); |
150 | 150 | ||
151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); | 151 | sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), QString::null, 0, this, 0); |
152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); | 152 | connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); |
153 | sendMailButton->addTo(bar); | 153 | sendMailButton->addTo(bar); |
154 | sendMailButton->addTo(mail); | 154 | sendMailButton->addTo(mail); |
155 | 155 | ||
156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 156 | composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); | 157 | connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); |
158 | composeButton->addTo(bar); | 158 | composeButton->addTo(bar); |
159 | composeButton->addTo(mail); | 159 | composeButton->addTo(mail); |
160 | 160 | ||
161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); | 161 | cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); |
162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); | 162 | connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); |
163 | cancelButton->addTo(mail); | 163 | cancelButton->addTo(mail); |
164 | cancelButton->addTo(bar); | ||
164 | cancelButton->setEnabled(FALSE); | 165 | cancelButton->setEnabled(FALSE); |
165 | 166 | ||
166 | mailboxView = new OTabWidget( this, "mailboxView" ); | 167 | mailboxView = new OTabWidget( this, "mailboxView" ); |
167 | 168 | ||
168 | QWidget* widget = new QWidget( mailboxView, "widget" ); | 169 | QWidget* widget = new QWidget( mailboxView, "widget" ); |
169 | grid_2 = new QGridLayout( widget ); | 170 | grid_2 = new QGridLayout( widget ); |
170 | // grid_2->setSpacing(6); | 171 | // grid_2->setSpacing(6); |
171 | // grid_2->setMargin( 11 ); | 172 | // grid_2->setMargin( 11 ); |
172 | 173 | ||
173 | inboxView = new QListView( widget, "inboxView" ); | 174 | inboxView = new QListView( widget, "inboxView" ); |
174 | inboxView->addColumn( tr( "From" ) ); | 175 | inboxView->addColumn( tr( "From" ) ); |
175 | inboxView->addColumn( tr( "Subject" ) ); | 176 | inboxView->addColumn( tr( "Subject" ) ); |
176 | inboxView->addColumn( tr( "Date" ) ); | 177 | inboxView->addColumn( tr( "Date" ) ); |
177 | inboxView->setMinimumSize( QSize( 0, 0 ) ); | 178 | inboxView->setMinimumSize( QSize( 0, 0 ) ); |
178 | inboxView->setAllColumnsShowFocus(TRUE); | 179 | inboxView->setAllColumnsShowFocus(TRUE); |
179 | 180 | ||
180 | grid_2->addWidget( inboxView, 2, 0 ); | 181 | grid_2->addWidget( inboxView, 2, 0 ); |
181 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); | 182 | mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); |
182 | 183 | ||
183 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); | 184 | QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); |
184 | grid_3 = new QGridLayout( widget_2 ); | 185 | grid_3 = new QGridLayout( widget_2 ); |
185 | // grid_3->setSpacing(6); | 186 | // grid_3->setSpacing(6); |
186 | // grid_3->setMargin( 11 ); | 187 | // grid_3->setMargin( 11 ); |
187 | 188 | ||
188 | outboxView = new QListView( widget_2, "outboxView" ); | 189 | outboxView = new QListView( widget_2, "outboxView" ); |
189 | outboxView->addColumn( tr( "To" ) ); | 190 | outboxView->addColumn( tr( "To" ) ); |
190 | outboxView->addColumn( tr( "Subject" ) ); | 191 | outboxView->addColumn( tr( "Subject" ) ); |
191 | outboxView->setAllColumnsShowFocus(TRUE); | 192 | outboxView->setAllColumnsShowFocus(TRUE); |
192 | 193 | ||
193 | grid_3->addWidget( outboxView, 0, 0 ); | 194 | grid_3->addWidget( outboxView, 0, 0 ); |
194 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); | 195 | mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); |
195 | 196 | ||
196 | setCentralWidget(mailboxView); | 197 | setCentralWidget(mailboxView); |
197 | } | 198 | } |
198 | 199 | ||
199 | void EmailClient::compose() | 200 | void EmailClient::compose() |
200 | { | 201 | { |
201 | emit composeRequested(); | 202 | emit composeRequested(); |
202 | } | 203 | } |
203 | 204 | ||
204 | void EmailClient::cancel() | 205 | void EmailClient::cancel() |
205 | { | 206 | { |
206 | emailHandler->cancel(); | 207 | emailHandler->cancel(); |
207 | } | 208 | } |
208 | 209 | ||
209 | AddressList* EmailClient::getAdrListRef() | 210 | AddressList* EmailClient::getAdrListRef() |
210 | { | 211 | { |
211 | return addressList; | 212 | return addressList; |
212 | } | 213 | } |
213 | 214 | ||
214 | //this needs to be rewritten to syncronize with outboxView | 215 | //this needs to be rewritten to syncronize with outboxView |
215 | void EmailClient::enqueMail(const Email &mail) | 216 | void EmailClient::enqueMail(const Email &mail) |
216 | { | 217 | { |
218 | if (accountList.count() == 0) { | ||
219 | QMessageBox::warning(qApp->activeWindow(), | ||
220 | tr("No account selected"), tr("You must create an account"), "OK\n"); | ||
221 | return; | ||
222 | } | ||
223 | |||
217 | if (accountList.count() > 0) { | 224 | if (accountList.count() > 0) { |
218 | currentAccount = accountList.first(); | 225 | currentAccount = accountList.first(); |
219 | qWarning("using account " + currentAccount->name); | 226 | qWarning("using account " + currentAccount->name); |
220 | } | 227 | } |
221 | 228 | ||
222 | Email addMail = mail; | 229 | Email addMail = mail; |
223 | addMail.from = currentAccount->name; | 230 | addMail.from = currentAccount->name; |
224 | addMail.fromMail = currentAccount->emailAddress; | 231 | addMail.fromMail = currentAccount->emailAddress; |
225 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); | 232 | addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); |
226 | item = new EmailListItem(outboxView, addMail, false); | 233 | item = new EmailListItem(outboxView, addMail, false); |
227 | 234 | ||
228 | } | 235 | } |
229 | 236 | ||
230 | void EmailClient::sendQuedMail() | 237 | void EmailClient::sendQuedMail() |
231 | { | 238 | { |
232 | int count = 0; | 239 | int count = 0; |
233 | 240 | ||
234 | if (accountList.count() == 0) { | 241 | if (accountList.count() == 0) { |
235 | QMessageBox::warning(qApp->activeWindow(), | 242 | QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); |
236 | "No account selected", "You must create an account", "OK\n"); | ||
237 | return; | 243 | return; |
238 | } | 244 | } |
239 | //traverse listview, find messages to send | 245 | //traverse listview, find messages to send |
240 | if (! sending) { | 246 | if (! sending) { |
241 | item = (EmailListItem *) outboxView->firstChild(); | 247 | item = (EmailListItem *) outboxView->firstChild(); |
242 | if (item != NULL) { | 248 | if (item != NULL) { |
243 | while (item != NULL) { | 249 | while (item != NULL) { |
244 | quedMessages.append(item->getMail()); | 250 | quedMessages.append(item->getMail()); |
245 | item = (EmailListItem *) item->nextSibling(); | 251 | item = (EmailListItem *) item->nextSibling(); |
246 | count++; | 252 | count++; |
247 | } | 253 | } |
248 | setMailAccount(); | 254 | setMailAccount(); |
249 | emailHandler->sendMail(&quedMessages); | 255 | emailHandler->sendMail(&quedMessages); |
250 | sending = TRUE; | 256 | sending = TRUE; |
251 | sendMailButton->setEnabled(FALSE); | 257 | sendMailButton->setEnabled(FALSE); |
252 | cancelButton->setEnabled(TRUE); | 258 | cancelButton->setEnabled(TRUE); |
253 | } else { | 259 | } else { |
254 | qWarning("sendQuedMail(): no messages to send"); | 260 | qWarning("sendQuedMail(): no messages to send"); |
255 | } | 261 | } |
256 | } | 262 | } |
257 | } | 263 | } |
258 | 264 | ||
259 | void EmailClient::setMailAccount() | 265 | void EmailClient::setMailAccount() |
260 | { | 266 | { |
261 | emailHandler->setAccount(*currentAccount); | 267 | emailHandler->setAccount(*currentAccount); |
262 | } | 268 | } |
263 | 269 | ||
264 | void EmailClient::mailSent() | 270 | void EmailClient::mailSent() |
265 | { | 271 | { |
266 | sending = FALSE; | 272 | sending = FALSE; |
267 | sendMailButton->setEnabled(TRUE); | 273 | sendMailButton->setEnabled(TRUE); |
268 | 274 | ||
269 | quedMessages.clear(); | 275 | quedMessages.clear(); |
270 | outboxView->clear(); //should be moved to an sentBox | 276 | outboxView->clear(); //should be moved to an sentBox |
271 | } | 277 | } |
272 | 278 | ||
273 | void EmailClient::getNewMail() { | 279 | void EmailClient::getNewMail() { |
274 | 280 | ||
275 | if (accountList.count() == 0) { | 281 | if (accountList.count() == 0) { |
276 | QMessageBox::warning(qApp->activeWindow(),"No account selected", | 282 | QMessageBox::warning(qApp->activeWindow(),"No account selected", |
277 | "You must create an account", "OK\n"); | 283 | "You must create an account", "OK\n"); |
278 | return; | 284 | return; |
279 | } | 285 | } |
280 | 286 | ||
281 | setMailAccount(); | 287 | setMailAccount(); |
282 | 288 | ||
283 | receiving = TRUE; | 289 | receiving = TRUE; |
284 | previewingMail = TRUE; | 290 | previewingMail = TRUE; |
285 | getMailButton->setEnabled(FALSE); | 291 | getMailButton->setEnabled(FALSE); |
286 | cancelButton->setEnabled(TRUE); | 292 | cancelButton->setEnabled(TRUE); |
287 | selectAccountMenu->setEnabled(FALSE); | 293 | selectAccountMenu->setEnabled(FALSE); |
288 | 294 | ||
289 | status1Label->setText(currentAccount->accountName + " headers"); | 295 | status1Label->setText(currentAccount->accountName + " headers"); |
290 | progressBar->reset(); | 296 | progressBar->reset(); |
291 | 297 | ||
292 | //get any previous mails not downloaded and add to queue | 298 | //get any previous mails not downloaded and add to queue |
293 | mailDownloadList.clear(); | 299 | mailDownloadList.clear(); |
294 | Email *mailPtr; | 300 | Email *mailPtr; |
295 | item = (EmailListItem *) inboxView->firstChild(); | 301 | item = (EmailListItem *) inboxView->firstChild(); |
296 | while (item != NULL) { | 302 | while (item != NULL) { |
297 | mailPtr = item->getMail(); | 303 | mailPtr = item->getMail(); |
298 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { | 304 | if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { |
299 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); | 305 | mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); |
300 | } | 306 | } |
301 | item = (EmailListItem *) item->nextSibling(); | 307 | item = (EmailListItem *) item->nextSibling(); |
302 | } | 308 | } |
303 | 309 | ||
304 | emailHandler->getMailHeaders(); | 310 | emailHandler->getMailHeaders(); |
305 | } | 311 | } |
306 | 312 | ||
307 | void EmailClient::getAllNewMail() | 313 | void EmailClient::getAllNewMail() |
308 | { | 314 | { |
309 | allAccounts = TRUE; | 315 | allAccounts = TRUE; |
310 | currentAccount = accountList.first(); | 316 | currentAccount = accountList.first(); |
311 | getNewMail(); | 317 | getNewMail(); |
312 | } | 318 | } |
313 | 319 | ||
314 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) | 320 | void EmailClient::mailArrived(const Email &mail, bool fromDisk) |
315 | { | 321 | { |
316 | Enclosure *ePtr; | 322 | Enclosure *ePtr; |
317 | Email newMail; | 323 | Email newMail; |
318 | int thisMailId; | 324 | int thisMailId; |
319 | emailHandler->parse(mail.rawMail, lineShift, &newMail); | 325 | emailHandler->parse(mail.rawMail, lineShift, &newMail); |
320 | 326 | ||
321 | mailconf->setGroup(newMail.id); | 327 | mailconf->setGroup(newMail.id); |
322 | 328 | ||
323 | if (fromDisk) { | 329 | if (fromDisk) { |
324 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); | 330 | newMail.downloaded = mailconf->readBoolEntry("downloaded"); |
325 | newMail.size = mailconf->readNumEntry("size"); | 331 | newMail.size = mailconf->readNumEntry("size"); |
326 | newMail.serverId = mailconf->readNumEntry("serverid"); | 332 | newMail.serverId = mailconf->readNumEntry("serverid"); |
327 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); | 333 | newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); |
328 | } else { //mail arrived from server | 334 | } else { //mail arrived from server |
329 | newMail.serverId = mail.serverId; | 335 | newMail.serverId = mail.serverId; |
330 | newMail.size = mail.size; | 336 | newMail.size = mail.size; |
331 | newMail.downloaded = mail.downloaded; | 337 | newMail.downloaded = mail.downloaded; |
332 | 338 | ||
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 2144899..1be16d4 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -319,198 +319,201 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
319 | } | 319 | } |
320 | return TRUE; | 320 | return TRUE; |
321 | } | 321 | } |
322 | 322 | ||
323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) | 323 | bool EmailHandler::getEnclosure(Enclosure *ePtr) |
324 | { | 324 | { |
325 | QFile f(ePtr->path + ePtr->name); | 325 | QFile f(ePtr->path + ePtr->name); |
326 | char src[4]; | 326 | char src[4]; |
327 | char *destPtr; | 327 | char *destPtr; |
328 | QByteArray buffer; | 328 | QByteArray buffer; |
329 | uint bufCount, pos, decodedCount, size, x; | 329 | uint bufCount, pos, decodedCount, size, x; |
330 | 330 | ||
331 | if (! f.open(IO_WriteOnly) ) { | 331 | if (! f.open(IO_WriteOnly) ) { |
332 | qWarning("could not save: " + ePtr->path + ePtr->name); | 332 | qWarning("could not save: " + ePtr->path + ePtr->name); |
333 | return FALSE; | 333 | return FALSE; |
334 | } | 334 | } |
335 | 335 | ||
336 | if (ePtr->encoding.upper() == "BASE64") { | 336 | if (ePtr->encoding.upper() == "BASE64") { |
337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) | 337 | size = (ePtr->body.length() * 3 / 4); //approximate size (always above) |
338 | buffer.resize(size); | 338 | buffer.resize(size); |
339 | bufCount = 0; | 339 | bufCount = 0; |
340 | pos = 0; | 340 | pos = 0; |
341 | destPtr = buffer.data(); | 341 | destPtr = buffer.data(); |
342 | 342 | ||
343 | while (pos < ePtr->body.length()) { | 343 | while (pos < ePtr->body.length()) { |
344 | decodedCount = 4; | 344 | decodedCount = 4; |
345 | x = 0; | 345 | x = 0; |
346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { | 346 | while ( (x < 4) && (pos < ePtr->body.length()) ) { |
347 | src[x] = ePtr->body[pos].latin1(); | 347 | src[x] = ePtr->body[pos].latin1(); |
348 | pos++; | 348 | pos++; |
349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') | 349 | if (src[x] == '\r' || src[x] == '\n' || src[x] == ' ') |
350 | x--; | 350 | x--; |
351 | x++; | 351 | x++; |
352 | } | 352 | } |
353 | if (x > 1) { | 353 | if (x > 1) { |
354 | decodedCount = parse64base(src, destPtr); | 354 | decodedCount = parse64base(src, destPtr); |
355 | destPtr += decodedCount; | 355 | destPtr += decodedCount; |
356 | bufCount += decodedCount; | 356 | bufCount += decodedCount; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | buffer.resize(bufCount); //set correct length of file | 360 | buffer.resize(bufCount); //set correct length of file |
361 | f.writeBlock(buffer); | 361 | f.writeBlock(buffer); |
362 | } else { | 362 | } else { |
363 | QTextStream t(&f); | 363 | QTextStream t(&f); |
364 | t << ePtr->body; | 364 | t << ePtr->body; |
365 | } | 365 | } |
366 | return TRUE; | 366 | return TRUE; |
367 | } | 367 | } |
368 | 368 | ||
369 | int EmailHandler::parse64base(char *src, char *bufOut) { | 369 | int EmailHandler::parse64base(char *src, char *bufOut) { |
370 | 370 | ||
371 | char c, z; | 371 | char c, z; |
372 | char li[4]; | 372 | char li[4]; |
373 | int processed; | 373 | int processed; |
374 | 374 | ||
375 | //conversion table withouth table... | 375 | //conversion table withouth table... |
376 | for (int x = 0; x < 4; x++) { | 376 | for (int x = 0; x < 4; x++) { |
377 | c = src[x]; | 377 | c = src[x]; |
378 | 378 | ||
379 | if ( (int) c >= 'A' && (int) c <= 'Z') | 379 | if ( (int) c >= 'A' && (int) c <= 'Z') |
380 | li[x] = (int) c - (int) 'A'; | 380 | li[x] = (int) c - (int) 'A'; |
381 | if ( (int) c >= 'a' && (int) c <= 'z') | 381 | if ( (int) c >= 'a' && (int) c <= 'z') |
382 | li[x] = (int) c - (int) 'a' + 26; | 382 | li[x] = (int) c - (int) 'a' + 26; |
383 | if ( (int) c >= '0' && (int) c <= '9') | 383 | if ( (int) c >= '0' && (int) c <= '9') |
384 | li[x] = (int) c - (int) '0' + 52; | 384 | li[x] = (int) c - (int) '0' + 52; |
385 | if (c == '+') | 385 | if (c == '+') |
386 | li[x] = 62; | 386 | li[x] = 62; |
387 | if (c == '/') | 387 | if (c == '/') |
388 | li[x] = 63; | 388 | li[x] = 63; |
389 | } | 389 | } |
390 | 390 | ||
391 | processed = 1; | 391 | processed = 1; |
392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits | 392 | bufOut[0] = (char) li[0] & (32+16+8+4+2+1); //mask out top 2 bits |
393 | bufOut[0] <<= 2; | 393 | bufOut[0] <<= 2; |
394 | z = li[1] >> 4; | 394 | z = li[1] >> 4; |
395 | bufOut[0] = bufOut[0] | z; //first byte retrived | 395 | bufOut[0] = bufOut[0] | z; //first byte retrived |
396 | 396 | ||
397 | if (src[2] != '=') { | 397 | if (src[2] != '=') { |
398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits | 398 | bufOut[1] = (char) li[1] & (8+4+2+1); //mask out top 4 bits |
399 | bufOut[1] <<= 4; | 399 | bufOut[1] <<= 4; |
400 | z = li[2] >> 2; | 400 | z = li[2] >> 2; |
401 | bufOut[1] = bufOut[1] | z; //second byte retrived | 401 | bufOut[1] = bufOut[1] | z; //second byte retrived |
402 | processed++; | 402 | processed++; |
403 | 403 | ||
404 | if (src[3] != '=') { | 404 | if (src[3] != '=') { |
405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits | 405 | bufOut[2] = (char) li[2] & (2+1); //mask out top 6 bits |
406 | bufOut[2] <<= 6; | 406 | bufOut[2] <<= 6; |
407 | z = li[3]; | 407 | z = li[3]; |
408 | bufOut[2] = bufOut[2] | z; //third byte retrieved | 408 | bufOut[2] = bufOut[2] | z; //third byte retrieved |
409 | processed++; | 409 | processed++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | return processed; | 412 | return processed; |
413 | } | 413 | } |
414 | 414 | ||
415 | int EmailHandler::encodeMime(Email *mail) { | 415 | int EmailHandler::encodeMime(Email *mail) |
416 | { | ||
417 | |||
416 | QString fileName, fileType, contentType, newBody, boundary; | 418 | QString fileName, fileType, contentType, newBody, boundary; |
417 | Enclosure *ePtr; | 419 | Enclosure *ePtr; |
418 | 420 | ||
419 | QString userName = mailAccount.name; | 421 | QString userName = mailAccount.name; |
420 | userName += " <" + mailAccount.emailAddress + ">"; | 422 | if (userName.length()>0)//only embrace it if there is a user name |
423 | userName += " <" + mailAccount.emailAddress + ">"; | ||
421 | 424 | ||
422 | //add standard headers | 425 | //add standard headers |
423 | newBody = "From: " + userName + "\r\nTo: "; | 426 | newBody = "From: " + userName + "\r\nTo: "; |
424 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { | 427 | for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { |
425 | newBody += *it + " "; | 428 | newBody += *it + " "; |
426 | } | 429 | } |
427 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; | 430 | newBody += "\r\nSubject: " + mail->subject + "\r\n"; |
428 | 431 | ||
429 | if (mail->files.count() == 0) { //just a simple mail | 432 | if (mail->files.count() == 0) { //just a simple mail |
430 | newBody += "\r\n" + mail->body; | 433 | newBody += "\r\n" + mail->body; |
431 | mail->rawMail = newBody; | 434 | mail->rawMail = newBody; |
432 | return 0; | 435 | return 0; |
433 | } | 436 | } |
434 | 437 | ||
435 | //Build mime encoded mail | 438 | //Build mime encoded mail |
436 | boundary = "-----4345=next_bound=0495----"; | 439 | boundary = "-----4345=next_bound=0495----"; |
437 | 440 | ||
438 | newBody += "Mime-Version: 1.0\r\n"; | 441 | newBody += "Mime-Version: 1.0\r\n"; |
439 | newBody += "Content-Type: multipart/mixed; boundary=\"" + | 442 | newBody += "Content-Type: multipart/mixed; boundary=\"" + |
440 | boundary + "\"\r\n\r\n"; | 443 | boundary + "\"\r\n\r\n"; |
441 | 444 | ||
442 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; | 445 | newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n"; |
443 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; | 446 | newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n"; |
444 | newBody += mail->body; | 447 | newBody += mail->body; |
445 | 448 | ||
446 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 449 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
447 | fileName = ePtr->originalName; | 450 | fileName = ePtr->originalName; |
448 | fileType = ePtr->contentType; | 451 | fileType = ePtr->contentType; |
449 | QFileInfo fi(fileName); | 452 | QFileInfo fi(fileName); |
450 | 453 | ||
451 | // This specification of contentType is temporary | 454 | // This specification of contentType is temporary |
452 | contentType = ""; | 455 | contentType = ""; |
453 | if (fileType == "Picture") { | 456 | if (fileType == "Picture") { |
454 | contentType = "image/x-image"; | 457 | contentType = "image/x-image"; |
455 | } else if (fileType == "Document") { | 458 | } else if (fileType == "Document") { |
456 | contentType = "text/plain"; | 459 | contentType = "text/plain"; |
457 | } else if (fileType == "Sound") { | 460 | } else if (fileType == "Sound") { |
458 | contentType = "audio/x-wav"; | 461 | contentType = "audio/x-wav"; |
459 | } else if (fileType == "Movie") { | 462 | } else if (fileType == "Movie") { |
460 | contentType = "video/mpeg"; | 463 | contentType = "video/mpeg"; |
461 | } else { | 464 | } else { |
462 | contentType = "application/octet-stream"; | 465 | contentType = "application/octet-stream"; |
463 | } | 466 | } |
464 | 467 | ||
465 | newBody += "\r\n\r\n--" + boundary + "\r\n"; | 468 | newBody += "\r\n\r\n--" + boundary + "\r\n"; |
466 | newBody += "Content-Type: " + contentType + "; name=\"" + | 469 | newBody += "Content-Type: " + contentType + "; name=\"" + |
467 | fi.fileName() + "\"\r\n"; | 470 | fi.fileName() + "\"\r\n"; |
468 | newBody += "Content-Transfer-Encoding: base64\r\n"; | 471 | newBody += "Content-Transfer-Encoding: base64\r\n"; |
469 | newBody += "Content-Disposition: inline; filename=\"" + | 472 | newBody += "Content-Disposition: inline; filename=\"" + |
470 | fi.fileName() + "\"\r\n\r\n"; | 473 | fi.fileName() + "\"\r\n\r\n"; |
471 | 474 | ||
472 | if (encodeFile(fileName, &newBody) == -1) //file not found? | 475 | if (encodeFile(fileName, &newBody) == -1) //file not found? |
473 | return -1; | 476 | return -1; |
474 | } | 477 | } |
475 | 478 | ||
476 | newBody += "\r\n\r\n--" + boundary + "--"; | 479 | newBody += "\r\n\r\n--" + boundary + "--"; |
477 | mail->rawMail = newBody; | 480 | mail->rawMail = newBody; |
478 | 481 | ||
479 | return 0; | 482 | return 0; |
480 | } | 483 | } |
481 | 484 | ||
482 | int EmailHandler::encodeFile(QString fileName, QString *toBody) | 485 | int EmailHandler::encodeFile(QString fileName, QString *toBody) |
483 | { | 486 | { |
484 | char *fileData; | 487 | char *fileData; |
485 | char *dataPtr; | 488 | char *dataPtr; |
486 | QString temp; | 489 | QString temp; |
487 | uint dataSize, count; | 490 | uint dataSize, count; |
488 | QFile f(fileName); | 491 | QFile f(fileName); |
489 | 492 | ||
490 | if (! f.open(IO_ReadOnly) ) { | 493 | if (! f.open(IO_ReadOnly) ) { |
491 | qWarning("could not open file: " + fileName); | 494 | qWarning("could not open file: " + fileName); |
492 | return -1; | 495 | return -1; |
493 | } | 496 | } |
494 | QTextStream s(&f); | 497 | QTextStream s(&f); |
495 | dataSize = f.size(); | 498 | dataSize = f.size(); |
496 | fileData = (char *) malloc(dataSize + 3); | 499 | fileData = (char *) malloc(dataSize + 3); |
497 | s.readRawBytes(fileData, dataSize); | 500 | s.readRawBytes(fileData, dataSize); |
498 | 501 | ||
499 | temp = ""; | 502 | temp = ""; |
500 | dataPtr = fileData; | 503 | dataPtr = fileData; |
501 | count = 0; | 504 | count = 0; |
502 | while (dataSize > 0) { | 505 | while (dataSize > 0) { |
503 | if (dataSize < 3) { | 506 | if (dataSize < 3) { |
504 | encode64base(dataPtr, &temp, dataSize); | 507 | encode64base(dataPtr, &temp, dataSize); |
505 | dataSize = 0; | 508 | dataSize = 0; |
506 | } else { | 509 | } else { |
507 | encode64base(dataPtr, &temp, 3); | 510 | encode64base(dataPtr, &temp, 3); |
508 | dataSize -= 3; | 511 | dataSize -= 3; |
509 | dataPtr += 3; | 512 | dataPtr += 3; |
510 | count += 4; | 513 | count += 4; |
511 | } | 514 | } |
512 | if (count > 72) { | 515 | if (count > 72) { |
513 | count = 0; | 516 | count = 0; |
514 | temp += "\r\n"; | 517 | temp += "\r\n"; |
515 | } | 518 | } |
516 | } | 519 | } |
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index 1a7185e..70332a9 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp | |||
@@ -1,272 +1,270 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include "writemail.h" | 21 | #include "writemail.h" |
22 | #include "resource.h" | 22 | #include "resource.h" |
23 | 23 | ||
24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) | 24 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) |
25 | : QMainWindow( parent, name, fl ) | 25 | : QMainWindow( parent, name, fl ) |
26 | { | 26 | { |
27 | showingAddressList = FALSE; | 27 | showingAddressList = FALSE; |
28 | init(); | 28 | init(); |
29 | 29 | ||
30 | addAtt = new AddAtt(0, "Add Attatchments"); | 30 | addAtt = new AddAtt(0, "Add Attatchments"); |
31 | } | 31 | } |
32 | 32 | ||
33 | WriteMail::~WriteMail() | 33 | WriteMail::~WriteMail() |
34 | { | 34 | { |
35 | delete addAtt; | 35 | delete addAtt; |
36 | } | 36 | } |
37 | 37 | ||
38 | void WriteMail::setAddressList(AddressList *list) | 38 | void WriteMail::setAddressList(AddressList *list) |
39 | { | 39 | { |
40 | Contact *cPtr; | 40 | Contact *cPtr; |
41 | 41 | ||
42 | addressList = list; | 42 | addressList = list; |
43 | 43 | ||
44 | addressView->clear(); | 44 | addressView->clear(); |
45 | QList<Contact> *cListPtr = addressList->getContactList(); | 45 | QList<Contact> *cListPtr = addressList->getContactList(); |
46 | QListViewItem *item; | 46 | QListViewItem *item; |
47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
48 | item = new QListViewItem(addressView, cPtr->email, cPtr->name); | 48 | item = new QListViewItem(addressView, cPtr->email, cPtr->name); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void WriteMail::init() | 52 | void WriteMail::init() |
53 | { | 53 | { |
54 | setToolBarsMovable(FALSE); | 54 | setToolBarsMovable(FALSE); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
58 | 58 | ||
59 | menu = new QMenuBar( bar ); | 59 | menu = new QMenuBar( bar ); |
60 | 60 | ||
61 | mailMenu = new QPopupMenu(menu); | 61 | mailMenu = new QPopupMenu(menu); |
62 | menu->insertItem( tr( "&Mail" ), mailMenu); | 62 | menu->insertItem( tr( "&Mail" ), mailMenu); |
63 | addMenu = new QPopupMenu(menu); | 63 | addMenu = new QPopupMenu(menu); |
64 | menu->insertItem( tr( "&Add" ), addMenu); | 64 | menu->insertItem( tr( "&Add" ), addMenu); |
65 | 65 | ||
66 | bar = new QToolBar(this); | 66 | bar = new QToolBar(this); |
67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("fileopen"), QString::null, 0, this, 0); | 67 | attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
68 | attatchButton->addTo(bar); | 68 | attatchButton->addTo(bar); |
69 | attatchButton->addTo(addMenu); | 69 | attatchButton->addTo(addMenu); |
70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); | 70 | connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); |
71 | 71 | ||
72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 72 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
73 | confirmButton->addTo(bar); | 73 | confirmButton->addTo(bar); |
74 | confirmButton->addTo(mailMenu); | 74 | confirmButton->addTo(mailMenu); |
75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 75 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
76 | 76 | ||
77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 77 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
78 | newButton->addTo(mailMenu); | 78 | newButton->addTo(mailMenu); |
79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 79 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
80 | 80 | ||
81 | widget = new QWidget(this, "widget"); | 81 | widget = new QWidget(this, "widget"); |
82 | grid = new QGridLayout( widget ); | 82 | grid = new QGridLayout( widget ); |
83 | 83 | ||
84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 84 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
85 | recipientsBox->insertItem( tr( "To:" ) ); | 85 | recipientsBox->insertItem( tr( "To:" ) ); |
86 | recipientsBox->insertItem( tr( "CC:" ) ); | 86 | recipientsBox->insertItem( tr( "CC:" ) ); |
87 | recipientsBox->setCurrentItem(0); | 87 | recipientsBox->setCurrentItem(0); |
88 | grid->addWidget( recipientsBox, 0, 0 ); | 88 | grid->addWidget( recipientsBox, 0, 0 ); |
89 | 89 | ||
90 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 90 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
91 | subjetLabel->setText( tr( "Subject:" ) ); | 91 | subjetLabel->setText( tr( "Subject:" ) ); |
92 | 92 | ||
93 | grid->addWidget( subjetLabel, 1, 0 ); | 93 | grid->addWidget( subjetLabel, 1, 0 ); |
94 | 94 | ||
95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 95 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
96 | ToolButton13_2->setText( tr( "..." ) ); | 96 | ToolButton13_2->setText( tr( "..." ) ); |
97 | grid->addWidget( ToolButton13_2, 1, 2 ); | 97 | grid->addWidget( ToolButton13_2, 1, 2 ); |
98 | 98 | ||
99 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 99 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
100 | grid->addWidget( subjectInput, 1, 1 ); | 100 | grid->addWidget( subjectInput, 1, 1 ); |
101 | 101 | ||
102 | toInput = new QLineEdit( widget, "toInput" ); | 102 | toInput = new QLineEdit( widget, "toInput" ); |
103 | grid->addWidget( toInput, 0, 1 ); | 103 | grid->addWidget( toInput, 0, 1 ); |
104 | 104 | ||
105 | addressButton = new QToolButton( widget, "addressButton" ); | 105 | addressButton = new QToolButton( widget, "addressButton" ); |
106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 106 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
107 | addressButton->setToggleButton(TRUE); | 107 | addressButton->setToggleButton(TRUE); |
108 | grid->addWidget( addressButton, 0, 2 ); | 108 | grid->addWidget( addressButton, 0, 2 ); |
109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 109 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
110 | 110 | ||
111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 111 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 112 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
113 | 113 | ||
114 | addressView = new QListView( widget, "addressView"); | 114 | addressView = new QListView( widget, "addressView"); |
115 | addressView->addColumn("Email"); | 115 | addressView->addColumn("Email"); |
116 | addressView->addColumn("Name"); | 116 | addressView->addColumn("Name"); |
117 | addressView->setAllColumnsShowFocus(TRUE); | 117 | addressView->setAllColumnsShowFocus(TRUE); |
118 | addressView->setMultiSelection(TRUE); | 118 | addressView->setMultiSelection(TRUE); |
119 | addressView->hide(); | 119 | addressView->hide(); |
120 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 120 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
121 | 121 | ||
122 | okButton = new QToolButton(bar, "ok"); | 122 | okButton = new QToolButton(bar, "ok"); |
123 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 123 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
124 | okButton->hide(); | 124 | okButton->hide(); |
125 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 125 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
126 | 126 | ||
127 | setCentralWidget(widget); | 127 | setCentralWidget(widget); |
128 | } | 128 | } |
129 | 129 | ||
130 | void WriteMail::reject() | 130 | void WriteMail::reject() |
131 | { | 131 | { |
132 | emit cancelMail(); | 132 | emit cancelMail(); |
133 | } | 133 | } |
134 | 134 | ||
135 | // need to insert date | 135 | // need to insert date |
136 | void WriteMail::accept() | 136 | void WriteMail::accept() |
137 | { | 137 | { |
138 | QStringList attatchedFiles, attatchmentsType; | 138 | QStringList attatchedFiles, attatchmentsType; |
139 | int idCount = 0; | 139 | int idCount = 0; |
140 | 140 | ||
141 | if (toInput->text() == "") { | 141 | if (toInput->text() == "") { |
142 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); | 142 | QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | if (! getRecipients() ) { | 145 | if (! getRecipients() ) { |
146 | QMessageBox::warning(this,"Incorrect recipient separator", | 146 | QMessageBox::warning(this,"Incorrect recipient separator", |
147 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); | 147 | "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | mail.subject = subjectInput->text(); | 150 | mail.subject = subjectInput->text(); |
151 | mail.body = emailInput->text(); | 151 | mail.body = emailInput->text(); |
152 | mail.sent = false; | 152 | mail.sent = false; |
153 | mail.received = false; | 153 | mail.received = false; |
154 | mail.rawMail = "To: "; | 154 | mail.rawMail = "To: "; |
155 | 155 | ||
156 | for (QStringList::Iterator it = mail.recipients.begin(); | 156 | for (QStringList::Iterator it = mail.recipients.begin(); |
157 | it != mail.recipients.end(); ++it) { | 157 | it != mail.recipients.end(); ++it) { |
158 | 158 | ||
159 | mail.rawMail += (*it); | 159 | mail.rawMail += (*it); |
160 | mail.rawMail += ",\n"; | 160 | mail.rawMail += ",\n"; |
161 | } | 161 | } |
162 | mail.rawMail.truncate(mail.rawMail.length()-2); | 162 | mail.rawMail.truncate(mail.rawMail.length()-2); |
163 | mail.rawMail += mail.from; | 163 | mail.rawMail += mail.from; |
164 | mail.rawMail += "\nSubject: "; | 164 | mail.rawMail += "\nSubject: "; |
165 | mail.rawMail += mail.subject; | 165 | mail.rawMail += mail.subject; |
166 | mail.rawMail += "\n\n"; | 166 | mail.rawMail += "\n\n"; |
167 | 167 | ||
168 | attatchedFiles = addAtt->returnAttatchedFiles(); | 168 | attatchedFiles = addAtt->returnAttatchedFiles(); |
169 | attatchmentsType = addAtt->returnFileTypes(); | 169 | attatchmentsType = addAtt->returnFileTypes(); |
170 | 170 | ||
171 | QStringList::Iterator itType = attatchmentsType.begin(); | 171 | QStringList::Iterator itType = attatchmentsType.begin(); |
172 | 172 | ||
173 | Enclosure e; | 173 | Enclosure e; |
174 | for ( QStringList::Iterator it = attatchedFiles.begin(); | 174 | for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { |
175 | it != attatchedFiles.end(); ++it ) { | ||
176 | |||
177 | e.id = idCount; | 175 | e.id = idCount; |
178 | e.originalName = (*it).latin1(); | 176 | e.originalName = (*it).latin1(); |
179 | e.contentType = (*itType).latin1(); | 177 | e.contentType = (*itType).latin1(); |
180 | e.contentAttribute = (*itType).latin1(); | 178 | e.contentAttribute = (*itType).latin1(); |
181 | e.saved = TRUE; | 179 | e.saved = TRUE; |
182 | mail.addEnclosure(&e); | 180 | mail.addEnclosure(&e); |
183 | 181 | ||
184 | itType++; | 182 | itType++; |
185 | idCount++; | 183 | idCount++; |
186 | } | 184 | } |
187 | mail.rawMail += mail.body; | 185 | mail.rawMail += mail.body; |
188 | mail.rawMail += "\n"; | 186 | mail.rawMail += "\n"; |
189 | mail.rawMail += ".\n"; | 187 | mail.rawMail += ".\n"; |
190 | emit sendMailRequested(mail); | 188 | emit sendMailRequested(mail); |
191 | addAtt->clear(); | 189 | addAtt->clear(); |
192 | } | 190 | } |
193 | 191 | ||
194 | void WriteMail::getAddress() | 192 | void WriteMail::getAddress() |
195 | { | 193 | { |
196 | showingAddressList = !showingAddressList; | 194 | showingAddressList = !showingAddressList; |
197 | 195 | ||
198 | if (showingAddressList) { | 196 | if (showingAddressList) { |
199 | emailInput->hide(); | 197 | emailInput->hide(); |
200 | addressView->show(); | 198 | addressView->show(); |
201 | okButton->show(); | 199 | okButton->show(); |
202 | 200 | ||
203 | } else { | 201 | } else { |
204 | addressView->hide(); | 202 | addressView->hide(); |
205 | okButton->hide(); | 203 | okButton->hide(); |
206 | emailInput->show(); | 204 | emailInput->show(); |
207 | } | 205 | } |
208 | } | 206 | } |
209 | 207 | ||
210 | void WriteMail::attatchFile() | 208 | void WriteMail::attatchFile() |
211 | { | 209 | { |
212 | addAtt->showMaximized(); | 210 | addAtt->showMaximized(); |
213 | } | 211 | } |
214 | 212 | ||
215 | void WriteMail::reply(Email replyMail) | 213 | void WriteMail::reply(Email replyMail) |
216 | { | 214 | { |
217 | int pos; | 215 | int pos; |
218 | 216 | ||
219 | mail = replyMail; | 217 | mail = replyMail; |
220 | mail.files.clear(); | 218 | mail.files.clear(); |
221 | 219 | ||
222 | toInput->setText(mail.fromMail); | 220 | toInput->setText(mail.fromMail); |
223 | subjectInput->setText("Re: " + mail.subject); | 221 | subjectInput->setText("Re: " + mail.subject); |
224 | 222 | ||
225 | pos = 0; | 223 | pos = 0; |
226 | mail.body.insert(pos, ">>"); | 224 | mail.body.insert(pos, ">>"); |
227 | while (pos != -1) { | 225 | while (pos != -1) { |
228 | pos = mail.body.find('\n', pos); | 226 | pos = mail.body.find('\n', pos); |
229 | if (pos != -1) | 227 | if (pos != -1) |
230 | mail.body.insert(++pos, ">>"); | 228 | mail.body.insert(++pos, ">>"); |
231 | } | 229 | } |
232 | 230 | ||
233 | emailInput->setText(mail.body); | 231 | emailInput->setText(mail.body); |
234 | } | 232 | } |
235 | 233 | ||
236 | bool WriteMail::getRecipients() | 234 | bool WriteMail::getRecipients() |
237 | { | 235 | { |
238 | QString str, temp; | 236 | QString str, temp; |
239 | int pos = 0; | 237 | int pos = 0; |
240 | 238 | ||
241 | mail.recipients.clear(); | 239 | mail.recipients.clear(); |
242 | 240 | ||
243 | temp = toInput->text(); | 241 | temp = toInput->text(); |
244 | while ( (pos = temp.find(';')) != -1) { | 242 | while ( (pos = temp.find(';')) != -1) { |
245 | str = temp.left(pos).stripWhiteSpace(); | 243 | str = temp.left(pos).stripWhiteSpace(); |
246 | temp = temp.right(temp.length() - (pos + 1)); | 244 | temp = temp.right(temp.length() - (pos + 1)); |
247 | if ( str.find('@') == -1) | 245 | if ( str.find('@') == -1) |
248 | return false; | 246 | return false; |
249 | mail.recipients.append(str); | 247 | mail.recipients.append(str); |
250 | addressList->addContact(str, ""); | 248 | addressList->addContact(str, ""); |
251 | } | 249 | } |
252 | temp = temp.stripWhiteSpace(); | 250 | temp = temp.stripWhiteSpace(); |
253 | if ( temp.find('@') == -1) | 251 | if ( temp.find('@') == -1) |
254 | return false; | 252 | return false; |
255 | mail.recipients.append(temp); | 253 | mail.recipients.append(temp); |
256 | addressList->addContact(temp, ""); | 254 | addressList->addContact(temp, ""); |
257 | 255 | ||
258 | return TRUE; | 256 | return TRUE; |
259 | } | 257 | } |
260 | 258 | ||
261 | 259 | ||
262 | void WriteMail::addRecipients() | 260 | void WriteMail::addRecipients() |
263 | { | 261 | { |
264 | QString recipients = ""; | 262 | QString recipients = ""; |
265 | 263 | ||
266 | mail.recipients.clear(); | 264 | mail.recipients.clear(); |
267 | QListViewItem *item = addressView->firstChild(); | 265 | QListViewItem *item = addressView->firstChild(); |
268 | while (item != NULL) { | 266 | while (item != NULL) { |
269 | if ( item->isSelected() ) { | 267 | if ( item->isSelected() ) { |
270 | if (recipients == "") { | 268 | if (recipients == "") { |
271 | recipients = item->text(0); | 269 | recipients = item->text(0); |
272 | } else { | 270 | } else { |