summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp10
-rw-r--r--noncore/net/mail/accountview.h6
-rw-r--r--noncore/net/mail/composemail.cpp11
-rw-r--r--noncore/net/mail/composemail.h5
-rw-r--r--noncore/net/mail/editaccounts.h3
-rw-r--r--noncore/net/mail/mail.pro4
-rw-r--r--noncore/net/mail/mailistviewitem.h3
-rw-r--r--noncore/net/mail/mainwindow.cpp3
-rw-r--r--noncore/net/mail/opiemail.cpp2
-rw-r--r--noncore/net/mail/opiemail.h3
-rw-r--r--noncore/net/mail/viewmail.cpp6
-rw-r--r--noncore/net/mail/viewmail.h3
12 files changed, 33 insertions, 26 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 9f07f56..2ce89db 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,669 +1,669 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include "accountview.h" 2#include "accountview.h"
3#include "mailtypes.h" 3#include <libmailwrapper/mailtypes.h>
4#include "defines.h" 4#include "defines.h"
5#include "newmaildir.h" 5#include "newmaildir.h"
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qpopupmenu.h> 7#include <qpopupmenu.h>
8 8
9/** 9/**
10 * POP3 Account stuff 10 * POP3 Account stuff
11 */ 11 */
12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) 12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
13 : AccountViewItem( parent ) 13 : AccountViewItem( parent )
14{ 14{
15 account = a; 15 account = a;
16 wrapper = AbstractMail::getWrapper( account ); 16 wrapper = AbstractMail::getWrapper( account );
17 setPixmap( 0, PIXMAP_POP3FOLDER ); 17 setPixmap( 0, PIXMAP_POP3FOLDER );
18 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
19 setOpen( true ); 19 setOpen( true );
20} 20}
21 21
22POP3viewItem::~POP3viewItem() 22POP3viewItem::~POP3viewItem()
23{ 23{
24 delete wrapper; 24 delete wrapper;
25} 25}
26 26
27AbstractMail *POP3viewItem::getWrapper() 27AbstractMail *POP3viewItem::getWrapper()
28{ 28{
29 return wrapper; 29 return wrapper;
30} 30}
31 31
32void POP3viewItem::refresh( QList<RecMail> & ) 32void POP3viewItem::refresh( QList<RecMail> & )
33{ 33{
34 QList<Folder> *folders = wrapper->listFolders(); 34 QList<Folder> *folders = wrapper->listFolders();
35 QListViewItem *child = firstChild(); 35 QListViewItem *child = firstChild();
36 while ( child ) { 36 while ( child ) {
37 QListViewItem *tmp = child; 37 QListViewItem *tmp = child;
38 child = child->nextSibling(); 38 child = child->nextSibling();
39 delete tmp; 39 delete tmp;
40 } 40 }
41 Folder *it; 41 Folder *it;
42 QListViewItem*item = 0; 42 QListViewItem*item = 0;
43 for ( it = folders->first(); it; it = folders->next() ) { 43 for ( it = folders->first(); it; it = folders->next() ) {
44 item = new POP3folderItem( it, this , item ); 44 item = new POP3folderItem( it, this , item );
45 item->setSelectable(it->may_select()); 45 item->setSelectable(it->may_select());
46 } 46 }
47 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 47 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
48 folders->setAutoDelete(false); 48 folders->setAutoDelete(false);
49 delete folders; 49 delete folders;
50} 50}
51 51
52RecBody POP3viewItem::fetchBody( const RecMail &mail ) 52RecBody POP3viewItem::fetchBody( const RecMail &mail )
53{ 53{
54 qDebug( "POP3 fetchBody" ); 54 qDebug( "POP3 fetchBody" );
55 return wrapper->fetchBody( mail ); 55 return wrapper->fetchBody( mail );
56} 56}
57 57
58POP3folderItem::~POP3folderItem() 58POP3folderItem::~POP3folderItem()
59{ 59{
60 delete folder; 60 delete folder;
61} 61}
62 62
63POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) 63POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
64 : AccountViewItem( parent,after ) 64 : AccountViewItem( parent,after )
65{ 65{
66 folder = folderInit; 66 folder = folderInit;
67 pop3 = parent; 67 pop3 = parent;
68 if (folder->getDisplayName().lower()!="inbox") { 68 if (folder->getDisplayName().lower()!="inbox") {
69 setPixmap( 0, PIXMAP_POP3FOLDER ); 69 setPixmap( 0, PIXMAP_POP3FOLDER );
70 } else { 70 } else {
71 setPixmap( 0, PIXMAP_INBOXFOLDER); 71 setPixmap( 0, PIXMAP_INBOXFOLDER);
72 } 72 }
73 setText( 0, folder->getDisplayName() ); 73 setText( 0, folder->getDisplayName() );
74} 74}
75 75
76void POP3folderItem::refresh(QList<RecMail>&target) 76void POP3folderItem::refresh(QList<RecMail>&target)
77{ 77{
78 if (folder->may_select()) 78 if (folder->may_select())
79 pop3->getWrapper()->listMessages( folder->getName(),target ); 79 pop3->getWrapper()->listMessages( folder->getName(),target );
80} 80}
81 81
82RecBody POP3folderItem::fetchBody(const RecMail&aMail) 82RecBody POP3folderItem::fetchBody(const RecMail&aMail)
83{ 83{
84 return pop3->getWrapper()->fetchBody(aMail); 84 return pop3->getWrapper()->fetchBody(aMail);
85} 85}
86 86
87QPopupMenu * POP3folderItem::getContextMenu() 87QPopupMenu * POP3folderItem::getContextMenu()
88{ 88{
89 QPopupMenu *m = new QPopupMenu(0); 89 QPopupMenu *m = new QPopupMenu(0);
90 if (m) { 90 if (m) {
91 m->insertItem(QObject::tr("Refresh header list",contextName),0); 91 m->insertItem(QObject::tr("Refresh header list",contextName),0);
92 m->insertItem(QObject::tr("Delete all mails",contextName),1); 92 m->insertItem(QObject::tr("Delete all mails",contextName),1);
93 } 93 }
94 return m; 94 return m;
95} 95}
96 96
97void POP3folderItem::contextMenuSelected(int which) 97void POP3folderItem::contextMenuSelected(int which)
98{ 98{
99 AccountView * view = (AccountView*)listView(); 99 AccountView * view = (AccountView*)listView();
100 switch (which) { 100 switch (which) {
101 case 0: 101 case 0:
102 view->refreshCurrent(); 102 view->refreshCurrent();
103 break; 103 break;
104 case 1: 104 case 1:
105 deleteAllMail(pop3->getWrapper(),folder); 105 deleteAllMail(pop3->getWrapper(),folder);
106 break; 106 break;
107 default: 107 default:
108 break; 108 break;
109 } 109 }
110} 110}
111 111
112/** 112/**
113 * IMAP Account stuff 113 * IMAP Account stuff
114 */ 114 */
115IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) 115IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
116 : AccountViewItem( parent ) 116 : AccountViewItem( parent )
117{ 117{
118 account = a; 118 account = a;
119 wrapper = AbstractMail::getWrapper( account ); 119 wrapper = AbstractMail::getWrapper( account );
120 setPixmap( 0, PIXMAP_IMAPFOLDER ); 120 setPixmap( 0, PIXMAP_IMAPFOLDER );
121 setText( 0, account->getAccountName() ); 121 setText( 0, account->getAccountName() );
122 setOpen( true ); 122 setOpen( true );
123} 123}
124 124
125IMAPviewItem::~IMAPviewItem() 125IMAPviewItem::~IMAPviewItem()
126{ 126{
127 delete wrapper; 127 delete wrapper;
128} 128}
129 129
130AbstractMail *IMAPviewItem::getWrapper() 130AbstractMail *IMAPviewItem::getWrapper()
131{ 131{
132 return wrapper; 132 return wrapper;
133} 133}
134 134
135IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) 135IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start)
136{ 136{
137 IMAPfolderItem*pitem,*sitem; 137 IMAPfolderItem*pitem,*sitem;
138 if (!start) pitem = (IMAPfolderItem*)firstChild(); 138 if (!start) pitem = (IMAPfolderItem*)firstChild();
139 else pitem = (IMAPfolderItem*)start->firstChild(); 139 else pitem = (IMAPfolderItem*)start->firstChild();
140 while (pitem) { 140 while (pitem) {
141 if (pitem->matchName(path)) { 141 if (pitem->matchName(path)) {
142 break; 142 break;
143 } 143 }
144 if (pitem->childCount()>0) { 144 if (pitem->childCount()>0) {
145 sitem = findSubItem(path,pitem); 145 sitem = findSubItem(path,pitem);
146 if (sitem) { 146 if (sitem) {
147 pitem = sitem; 147 pitem = sitem;
148 break; 148 break;
149 } 149 }
150 } 150 }
151 pitem=(IMAPfolderItem*)pitem->nextSibling(); 151 pitem=(IMAPfolderItem*)pitem->nextSibling();
152 } 152 }
153 return pitem; 153 return pitem;
154} 154}
155 155
156void IMAPviewItem::refresh(QList<RecMail>&) 156void IMAPviewItem::refresh(QList<RecMail>&)
157{ 157{
158 refreshFolders(false); 158 refreshFolders(false);
159} 159}
160 160
161void IMAPviewItem::refreshFolders(bool force) 161void IMAPviewItem::refreshFolders(bool force)
162{ 162{
163 if (childCount()>0 && force==false) return; 163 if (childCount()>0 && force==false) return;
164 QList<Folder> *folders = wrapper->listFolders(); 164 QList<Folder> *folders = wrapper->listFolders();
165 165
166 QListViewItem *child = firstChild(); 166 QListViewItem *child = firstChild();
167 while ( child ) { 167 while ( child ) {
168 QListViewItem *tmp = child; 168 QListViewItem *tmp = child;
169 child = child->nextSibling(); 169 child = child->nextSibling();
170 delete tmp; 170 delete tmp;
171 } 171 }
172 172
173 Folder *it; 173 Folder *it;
174 QListViewItem*item = 0; 174 QListViewItem*item = 0;
175 QListViewItem*titem = 0; 175 QListViewItem*titem = 0;
176 QString fname,del,search; 176 QString fname,del,search;
177 int pos; 177 int pos;
178 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 178 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179 folders->setAutoDelete(false); 179 folders->setAutoDelete(false);
180 180
181 for ( it = folders->first(); it; it = folders->next() ) { 181 for ( it = folders->first(); it; it = folders->next() ) {
182 if (it->getDisplayName().lower()=="inbox") { 182 if (it->getDisplayName().lower()=="inbox") {
183 item = new IMAPfolderItem( it, this , item ); 183 item = new IMAPfolderItem( it, this , item );
184 folders->remove(it); 184 folders->remove(it);
185 qDebug("inbox found"); 185 qDebug("inbox found");
186 break; 186 break;
187 } 187 }
188 } 188 }
189 for ( it = folders->first(); it; it = folders->next() ) { 189 for ( it = folders->first(); it; it = folders->next() ) {
190 fname = it->getDisplayName(); 190 fname = it->getDisplayName();
191 pos = fname.findRev(it->Separator()); 191 pos = fname.findRev(it->Separator());
192 if (pos != -1) { 192 if (pos != -1) {
193 fname = fname.left(pos); 193 fname = fname.left(pos);
194 } 194 }
195 IMAPfolderItem*pitem = findSubItem(fname); 195 IMAPfolderItem*pitem = findSubItem(fname);
196 if (pitem) { 196 if (pitem) {
197 titem = item; 197 titem = item;
198 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); 198 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
199 /* setup the short name */ 199 /* setup the short name */
200 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); 200 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
201 item = titem; 201 item = titem;
202 } else { 202 } else {
203 item = new IMAPfolderItem( it, this , item ); 203 item = new IMAPfolderItem( it, this , item );
204 } 204 }
205 } 205 }
206 delete folders; 206 delete folders;
207} 207}
208 208
209QPopupMenu * IMAPviewItem::getContextMenu() 209QPopupMenu * IMAPviewItem::getContextMenu()
210{ 210{
211 QPopupMenu *m = new QPopupMenu(0); 211 QPopupMenu *m = new QPopupMenu(0);
212 if (m) { 212 if (m) {
213 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 213 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
214 m->insertItem(QObject::tr("Create new folder",contextName),1); 214 m->insertItem(QObject::tr("Create new folder",contextName),1);
215 m->insertSeparator(); 215 m->insertSeparator();
216 m->insertItem(QObject::tr("Disconnect",contextName),2); 216 m->insertItem(QObject::tr("Disconnect",contextName),2);
217 } 217 }
218 return m; 218 return m;
219} 219}
220 220
221void IMAPviewItem::createNewFolder() 221void IMAPviewItem::createNewFolder()
222{ 222{
223 Newmdirdlg ndirdlg; 223 Newmdirdlg ndirdlg;
224 ndirdlg.showMaximized(); 224 ndirdlg.showMaximized();
225 if (ndirdlg.exec()) { 225 if (ndirdlg.exec()) {
226 QString ndir = ndirdlg.Newdir(); 226 QString ndir = ndirdlg.Newdir();
227 bool makesubs = ndirdlg.subpossible(); 227 bool makesubs = ndirdlg.subpossible();
228 QString delemiter = "/"; 228 QString delemiter = "/";
229 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 229 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
230 if (item) { 230 if (item) {
231 delemiter = item->Delemiter(); 231 delemiter = item->Delemiter();
232 } 232 }
233 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { 233 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
234 refreshFolders(true); 234 refreshFolders(true);
235 } 235 }
236 } 236 }
237} 237}
238 238
239void IMAPviewItem::contextMenuSelected(int id) 239void IMAPviewItem::contextMenuSelected(int id)
240{ 240{
241 qDebug("Id selected: %i",id); 241 qDebug("Id selected: %i",id);
242 switch (id) { 242 switch (id) {
243 case 0: 243 case 0:
244 refreshFolders(true); 244 refreshFolders(true);
245 break; 245 break;
246 case 1: 246 case 1:
247 createNewFolder(); 247 createNewFolder();
248 break; 248 break;
249 default: 249 default:
250 break; 250 break;
251 } 251 }
252} 252}
253 253
254RecBody IMAPviewItem::fetchBody(const RecMail&) 254RecBody IMAPviewItem::fetchBody(const RecMail&)
255{ 255{
256 return RecBody(); 256 return RecBody();
257} 257}
258 258
259IMAPfolderItem::~IMAPfolderItem() 259IMAPfolderItem::~IMAPfolderItem()
260{ 260{
261 delete folder; 261 delete folder;
262} 262}
263 263
264IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 264IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
265 : AccountViewItem( parent , after ) 265 : AccountViewItem( parent , after )
266{ 266{
267 folder = folderInit; 267 folder = folderInit;
268 imap = parent; 268 imap = parent;
269 if (folder->getDisplayName().lower()!="inbox") { 269 if (folder->getDisplayName().lower()!="inbox") {
270 setPixmap( 0, PIXMAP_IMAPFOLDER ); 270 setPixmap( 0, PIXMAP_IMAPFOLDER );
271 } else { 271 } else {
272 setPixmap( 0, PIXMAP_INBOXFOLDER); 272 setPixmap( 0, PIXMAP_INBOXFOLDER);
273 } 273 }
274 setText( 0, folder->getDisplayName() ); 274 setText( 0, folder->getDisplayName() );
275} 275}
276 276
277IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 277IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
278 : AccountViewItem( parent,after ) 278 : AccountViewItem( parent,after )
279{ 279{
280 folder = folderInit; 280 folder = folderInit;
281 imap = master; 281 imap = master;
282 if (folder->getDisplayName().lower()!="inbox") { 282 if (folder->getDisplayName().lower()!="inbox") {
283 setPixmap( 0, PIXMAP_IMAPFOLDER ); 283 setPixmap( 0, PIXMAP_IMAPFOLDER );
284 } else { 284 } else {
285 setPixmap( 0, PIXMAP_INBOXFOLDER); 285 setPixmap( 0, PIXMAP_INBOXFOLDER);
286 } 286 }
287 setText( 0, folder->getDisplayName() ); 287 setText( 0, folder->getDisplayName() );
288} 288}
289 289
290const QString& IMAPfolderItem::Delemiter()const 290const QString& IMAPfolderItem::Delemiter()const
291{ 291{
292 return folder->Separator(); 292 return folder->Separator();
293} 293}
294 294
295bool IMAPfolderItem::matchName(const QString&name)const 295bool IMAPfolderItem::matchName(const QString&name)const
296{ 296{
297 return folder->getDisplayName()==name; 297 return folder->getDisplayName()==name;
298} 298}
299 299
300void IMAPfolderItem::refresh(QList<RecMail>&target) 300void IMAPfolderItem::refresh(QList<RecMail>&target)
301{ 301{
302 if (folder->may_select()) { 302 if (folder->may_select()) {
303 imap->getWrapper()->listMessages( folder->getName(),target ); 303 imap->getWrapper()->listMessages( folder->getName(),target );
304 } else { 304 } else {
305 target.clear(); 305 target.clear();
306 } 306 }
307} 307}
308 308
309RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 309RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
310{ 310{
311 return imap->getWrapper()->fetchBody(aMail); 311 return imap->getWrapper()->fetchBody(aMail);
312} 312}
313 313
314QPopupMenu * IMAPfolderItem::getContextMenu() 314QPopupMenu * IMAPfolderItem::getContextMenu()
315{ 315{
316 QPopupMenu *m = new QPopupMenu(0); 316 QPopupMenu *m = new QPopupMenu(0);
317 if (m) { 317 if (m) {
318 if (folder->may_select()) { 318 if (folder->may_select()) {
319 m->insertItem(QObject::tr("Refresh header list",contextName),0); 319 m->insertItem(QObject::tr("Refresh header list",contextName),0);
320 m->insertItem(QObject::tr("Delete all mails",contextName),1); 320 m->insertItem(QObject::tr("Delete all mails",contextName),1);
321 } 321 }
322 if (folder->no_inferior()==false) { 322 if (folder->no_inferior()==false) {
323 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 323 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
324 } 324 }
325 if (folder->getDisplayName().lower()!="inbox") { 325 if (folder->getDisplayName().lower()!="inbox") {
326 m->insertItem(QObject::tr("Delete folder",contextName),3); 326 m->insertItem(QObject::tr("Delete folder",contextName),3);
327 } 327 }
328 } 328 }
329 return m; 329 return m;
330} 330}
331 331
332void IMAPfolderItem::createNewFolder() 332void IMAPfolderItem::createNewFolder()
333{ 333{
334 Newmdirdlg ndirdlg; 334 Newmdirdlg ndirdlg;
335 ndirdlg.showMaximized(); 335 ndirdlg.showMaximized();
336 if (ndirdlg.exec()) { 336 if (ndirdlg.exec()) {
337 QString ndir = ndirdlg.Newdir(); 337 QString ndir = ndirdlg.Newdir();
338 bool makesubs = ndirdlg.subpossible(); 338 bool makesubs = ndirdlg.subpossible();
339 QString delemiter = Delemiter(); 339 QString delemiter = Delemiter();
340 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { 340 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) {
341 imap->refreshFolders(true); 341 imap->refreshFolders(true);
342 } 342 }
343 } 343 }
344} 344}
345 345
346void IMAPfolderItem::deleteFolder() 346void IMAPfolderItem::deleteFolder()
347{ 347{
348 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 348 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
349 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 349 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
350 QObject::tr("Yes",contextName), 350 QObject::tr("Yes",contextName),
351 QObject::tr("No",contextName),QString::null,1,1); 351 QObject::tr("No",contextName),QString::null,1,1);
352 qDebug("Auswahl: %i",yesno); 352 qDebug("Auswahl: %i",yesno);
353 if (yesno == 0) { 353 if (yesno == 0) {
354 if (imap->getWrapper()->deleteMbox(folder)) { 354 if (imap->getWrapper()->deleteMbox(folder)) {
355 QListView*v=listView(); 355 QListView*v=listView();
356 IMAPviewItem * box = imap; 356 IMAPviewItem * box = imap;
357 /* be carefull - after that this object is destroyd so don't use 357 /* be carefull - after that this object is destroyd so don't use
358 * any member of it after that call!!*/ 358 * any member of it after that call!!*/
359 imap->refreshFolders(true); 359 imap->refreshFolders(true);
360 if (v) { 360 if (v) {
361 v->setSelected(box,true); 361 v->setSelected(box,true);
362 } 362 }
363 } 363 }
364 } 364 }
365} 365}
366 366
367void IMAPfolderItem::contextMenuSelected(int id) 367void IMAPfolderItem::contextMenuSelected(int id)
368{ 368{
369 qDebug("Selected id: %i",id); 369 qDebug("Selected id: %i",id);
370 AccountView * view = (AccountView*)listView(); 370 AccountView * view = (AccountView*)listView();
371 switch(id) { 371 switch(id) {
372 case 0: 372 case 0:
373 view->refreshCurrent(); 373 view->refreshCurrent();
374 break; 374 break;
375 case 1: 375 case 1:
376 deleteAllMail(imap->getWrapper(),folder); 376 deleteAllMail(imap->getWrapper(),folder);
377 break; 377 break;
378 case 2: 378 case 2:
379 createNewFolder(); 379 createNewFolder();
380 break; 380 break;
381 case 3: 381 case 3:
382 deleteFolder(); 382 deleteFolder();
383 break; 383 break;
384 default: 384 default:
385 break; 385 break;
386 } 386 }
387} 387}
388 388
389/** 389/**
390 * Generic stuff 390 * Generic stuff
391 */ 391 */
392 392
393const QString AccountViewItem::contextName="AccountViewItem"; 393const QString AccountViewItem::contextName="AccountViewItem";
394 394
395void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) 395void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
396{ 396{
397 if (!wrapper) return; 397 if (!wrapper) return;
398 QString fname=""; 398 QString fname="";
399 if (folder) fname = folder->getDisplayName(); 399 if (folder) fname = folder->getDisplayName();
400 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 400 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
401 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 401 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
402 arg(fname), 402 arg(fname),
403 QObject::tr("Yes",contextName), 403 QObject::tr("Yes",contextName),
404 QObject::tr("No",contextName),QString::null,1,1); 404 QObject::tr("No",contextName),QString::null,1,1);
405 qDebug("Auswahl: %i",yesno); 405 qDebug("Auswahl: %i",yesno);
406 if (yesno == 0) { 406 if (yesno == 0) {
407 if (wrapper->deleteAllMail(folder)) { 407 if (wrapper->deleteAllMail(folder)) {
408 AccountView * view = (AccountView*)listView(); 408 AccountView * view = (AccountView*)listView();
409 if (view) view->refreshCurrent(); 409 if (view) view->refreshCurrent();
410 } 410 }
411 } 411 }
412} 412}
413 413
414AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 414AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
415 : QListView( parent, name, flags ) 415 : QListView( parent, name, flags )
416{ 416{
417 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 417 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
418 SLOT( refresh( QListViewItem * ) ) ); 418 SLOT( refresh( QListViewItem * ) ) );
419 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 419 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
420 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 420 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
421 421
422 setSorting(0); 422 setSorting(0);
423} 423}
424 424
425void AccountView::slotContextMenu(int id) 425void AccountView::slotContextMenu(int id)
426{ 426{
427 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 427 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
428 if (!view) return; 428 if (!view) return;
429 view->contextMenuSelected(id); 429 view->contextMenuSelected(id);
430} 430}
431 431
432void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 432void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
433{ 433{
434 if (button==1) {return;} 434 if (button==1) {return;}
435 if (!item) return; 435 if (!item) return;
436 AccountViewItem *view = static_cast<AccountViewItem *>(item); 436 AccountViewItem *view = static_cast<AccountViewItem *>(item);
437 QPopupMenu*m = view->getContextMenu(); 437 QPopupMenu*m = view->getContextMenu();
438 if (!m) return; 438 if (!m) return;
439 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 439 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
440 m->setFocus(); 440 m->setFocus();
441 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 441 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
442 delete m; 442 delete m;
443} 443}
444 444
445void AccountView::populate( QList<Account> list ) 445void AccountView::populate( QList<Account> list )
446{ 446{
447 clear(); 447 clear();
448 448
449 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 449 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
450 (void) new MBOXviewItem(localfolders,this); 450 (void) new MBOXviewItem(localfolders,this);
451 451
452 Account *it; 452 Account *it;
453 for ( it = list.first(); it; it = list.next() ) { 453 for ( it = list.first(); it; it = list.next() ) {
454 if ( it->getType().compare( "IMAP" ) == 0 ) { 454 if ( it->getType().compare( "IMAP" ) == 0 ) {
455 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 455 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
456 qDebug( "added IMAP " + imap->getAccountName() ); 456 qDebug( "added IMAP " + imap->getAccountName() );
457 (void) new IMAPviewItem( imap, this ); 457 (void) new IMAPviewItem( imap, this );
458 } else if ( it->getType().compare( "POP3" ) == 0 ) { 458 } else if ( it->getType().compare( "POP3" ) == 0 ) {
459 POP3account *pop3 = static_cast<POP3account *>(it); 459 POP3account *pop3 = static_cast<POP3account *>(it);
460 qDebug( "added POP3 " + pop3->getAccountName() ); 460 qDebug( "added POP3 " + pop3->getAccountName() );
461 (void) new POP3viewItem( pop3, this ); 461 (void) new POP3viewItem( pop3, this );
462 } 462 }
463 } 463 }
464} 464}
465 465
466void AccountView::refresh(QListViewItem *item) { 466void AccountView::refresh(QListViewItem *item) {
467 467
468 qDebug("AccountView refresh..."); 468 qDebug("AccountView refresh...");
469 if ( item ) { 469 if ( item ) {
470 m_currentItem = item; 470 m_currentItem = item;
471 QList<RecMail> headerlist; 471 QList<RecMail> headerlist;
472 headerlist.setAutoDelete(true); 472 headerlist.setAutoDelete(true);
473 AccountViewItem *view = static_cast<AccountViewItem *>(item); 473 AccountViewItem *view = static_cast<AccountViewItem *>(item);
474 view->refresh(headerlist); 474 view->refresh(headerlist);
475 emit refreshMailview(&headerlist); 475 emit refreshMailview(&headerlist);
476 } 476 }
477} 477}
478 478
479void AccountView::refreshCurrent() 479void AccountView::refreshCurrent()
480{ 480{
481 m_currentItem = currentItem(); 481 m_currentItem = currentItem();
482 if ( !m_currentItem ) return; 482 if ( !m_currentItem ) return;
483 QList<RecMail> headerlist; 483 QList<RecMail> headerlist;
484 headerlist.setAutoDelete(true); 484 headerlist.setAutoDelete(true);
485 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 485 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
486 view->refresh(headerlist); 486 view->refresh(headerlist);
487 emit refreshMailview(&headerlist); 487 emit refreshMailview(&headerlist);
488} 488}
489 489
490void AccountView::refreshAll() 490void AccountView::refreshAll()
491{ 491{
492 492
493} 493}
494 494
495RecBody AccountView::fetchBody(const RecMail&aMail) 495RecBody AccountView::fetchBody(const RecMail&aMail)
496{ 496{
497 QListViewItem*item = selectedItem (); 497 QListViewItem*item = selectedItem ();
498 if (!item) return RecBody(); 498 if (!item) return RecBody();
499 AccountViewItem *view = static_cast<AccountViewItem *>(item); 499 AccountViewItem *view = static_cast<AccountViewItem *>(item);
500 return view->fetchBody(aMail); 500 return view->fetchBody(aMail);
501} 501}
502 502
503/** 503/**
504 * MBOX Account stuff 504 * MBOX Account stuff
505 */ 505 */
506 506
507MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) 507MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent )
508 : AccountViewItem( parent ) 508 : AccountViewItem( parent )
509{ 509{
510 m_Path = aPath; 510 m_Path = aPath;
511 wrapper = AbstractMail::getWrapper( m_Path ); 511 wrapper = AbstractMail::getWrapper( m_Path );
512 setPixmap( 0, PIXMAP_LOCALFOLDER ); 512 setPixmap( 0, PIXMAP_LOCALFOLDER );
513 setText( 0, " Local Folders" ); 513 setText( 0, " Local Folders" );
514 setOpen( true ); 514 setOpen( true );
515} 515}
516 516
517MBOXviewItem::~MBOXviewItem() 517MBOXviewItem::~MBOXviewItem()
518{ 518{
519 delete wrapper; 519 delete wrapper;
520} 520}
521 521
522AbstractMail *MBOXviewItem::getWrapper() 522AbstractMail *MBOXviewItem::getWrapper()
523{ 523{
524 return wrapper; 524 return wrapper;
525} 525}
526 526
527void MBOXviewItem::refresh( QList<RecMail> & ) 527void MBOXviewItem::refresh( QList<RecMail> & )
528{ 528{
529 refresh(false); 529 refresh(false);
530} 530}
531 531
532void MBOXviewItem::refresh(bool force) 532void MBOXviewItem::refresh(bool force)
533{ 533{
534 if (childCount()>0 && force==false) return; 534 if (childCount()>0 && force==false) return;
535 QList<Folder> *folders = wrapper->listFolders(); 535 QList<Folder> *folders = wrapper->listFolders();
536 QListViewItem *child = firstChild(); 536 QListViewItem *child = firstChild();
537 while ( child ) { 537 while ( child ) {
538 QListViewItem *tmp = child; 538 QListViewItem *tmp = child;
539 child = child->nextSibling(); 539 child = child->nextSibling();
540 delete tmp; 540 delete tmp;
541 } 541 }
542 Folder *it; 542 Folder *it;
543 QListViewItem*item = 0; 543 QListViewItem*item = 0;
544 for ( it = folders->first(); it; it = folders->next() ) { 544 for ( it = folders->first(); it; it = folders->next() ) {
545 item = new MBOXfolderItem( it, this , item ); 545 item = new MBOXfolderItem( it, this , item );
546 item->setSelectable(it->may_select()); 546 item->setSelectable(it->may_select());
547 } 547 }
548 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 548 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
549 folders->setAutoDelete(false); 549 folders->setAutoDelete(false);
550 delete folders; 550 delete folders;
551} 551}
552 552
553RecBody MBOXviewItem::fetchBody( const RecMail &mail ) 553RecBody MBOXviewItem::fetchBody( const RecMail &mail )
554{ 554{
555 qDebug( "MBOX fetchBody" ); 555 qDebug( "MBOX fetchBody" );
556 return wrapper->fetchBody( mail ); 556 return wrapper->fetchBody( mail );
557} 557}
558 558
559QPopupMenu * MBOXviewItem::getContextMenu() 559QPopupMenu * MBOXviewItem::getContextMenu()
560{ 560{
561 QPopupMenu *m = new QPopupMenu(0); 561 QPopupMenu *m = new QPopupMenu(0);
562 if (m) { 562 if (m) {
563 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 563 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
564 m->insertItem(QObject::tr("Create new folder",contextName),1); 564 m->insertItem(QObject::tr("Create new folder",contextName),1);
565 } 565 }
566 return m; 566 return m;
567} 567}
568 568
569void MBOXviewItem::createFolder() 569void MBOXviewItem::createFolder()
570{ 570{
571 Newmdirdlg ndirdlg(0,0,true); 571 Newmdirdlg ndirdlg(0,0,true);
572 ndirdlg.showMaximized(); 572 ndirdlg.showMaximized();
573 if (ndirdlg.exec()) { 573 if (ndirdlg.exec()) {
574 QString ndir = ndirdlg.Newdir(); 574 QString ndir = ndirdlg.Newdir();
575 if (wrapper->createMbox(ndir)) { 575 if (wrapper->createMbox(ndir)) {
576 refresh(true); 576 refresh(true);
577 } 577 }
578 } 578 }
579} 579}
580 580
581void MBOXviewItem::contextMenuSelected(int which) 581void MBOXviewItem::contextMenuSelected(int which)
582{ 582{
583 switch (which) { 583 switch (which) {
584 case 0: 584 case 0:
585 refresh(true); 585 refresh(true);
586 break; 586 break;
587 case 1: 587 case 1:
588 createFolder(); 588 createFolder();
589 break; 589 break;
590 default: 590 default:
591 break; 591 break;
592 } 592 }
593} 593}
594 594
595MBOXfolderItem::~MBOXfolderItem() 595MBOXfolderItem::~MBOXfolderItem()
596{ 596{
597 delete folder; 597 delete folder;
598} 598}
599 599
600MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) 600MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after )
601 : AccountViewItem( parent,after ) 601 : AccountViewItem( parent,after )
602{ 602{
603 folder = folderInit; 603 folder = folderInit;
604 mbox = parent; 604 mbox = parent;
605 if (folder->getDisplayName().lower() == "outgoing") { 605 if (folder->getDisplayName().lower() == "outgoing") {
606 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 606 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
607 } else if (folder->getDisplayName().lower() == "inbox") { 607 } else if (folder->getDisplayName().lower() == "inbox") {
608 setPixmap( 0, PIXMAP_INBOXFOLDER); 608 setPixmap( 0, PIXMAP_INBOXFOLDER);
609 } else { 609 } else {
610 setPixmap( 0, PIXMAP_MBOXFOLDER ); 610 setPixmap( 0, PIXMAP_MBOXFOLDER );
611 } 611 }
612 setText( 0, folder->getDisplayName() ); 612 setText( 0, folder->getDisplayName() );
613} 613}
614 614
615void MBOXfolderItem::refresh(QList<RecMail>&target) 615void MBOXfolderItem::refresh(QList<RecMail>&target)
616{ 616{
617 if (folder->may_select()) 617 if (folder->may_select())
618 mbox->getWrapper()->listMessages( folder->getName(),target ); 618 mbox->getWrapper()->listMessages( folder->getName(),target );
619} 619}
620 620
621RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) 621RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
622{ 622{
623 return mbox->getWrapper()->fetchBody(aMail); 623 return mbox->getWrapper()->fetchBody(aMail);
624} 624}
625 625
626void MBOXfolderItem::deleteFolder() 626void MBOXfolderItem::deleteFolder()
627{ 627{
628 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 628 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
629 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 629 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
630 QObject::tr("Yes",contextName), 630 QObject::tr("Yes",contextName),
631 QObject::tr("No",contextName),QString::null,1,1); 631 QObject::tr("No",contextName),QString::null,1,1);
632 qDebug("Auswahl: %i",yesno); 632 qDebug("Auswahl: %i",yesno);
633 if (yesno == 0) { 633 if (yesno == 0) {
634 if (mbox->getWrapper()->deleteMbox(folder)) { 634 if (mbox->getWrapper()->deleteMbox(folder)) {
635 QListView*v=listView(); 635 QListView*v=listView();
636 MBOXviewItem * box = mbox; 636 MBOXviewItem * box = mbox;
637 /* be carefull - after that this object is destroyd so don't use 637 /* be carefull - after that this object is destroyd so don't use
638 * any member of it after that call!!*/ 638 * any member of it after that call!!*/
639 mbox->refresh(true); 639 mbox->refresh(true);
640 if (v) { 640 if (v) {
641 v->setSelected(box,true); 641 v->setSelected(box,true);
642 } 642 }
643 } 643 }
644 } 644 }
645} 645}
646 646
647QPopupMenu * MBOXfolderItem::getContextMenu() 647QPopupMenu * MBOXfolderItem::getContextMenu()
648{ 648{
649 QPopupMenu *m = new QPopupMenu(0); 649 QPopupMenu *m = new QPopupMenu(0);
650 if (m) { 650 if (m) {
651 m->insertItem(QObject::tr("Delete all mails",contextName),0); 651 m->insertItem(QObject::tr("Delete all mails",contextName),0);
652 m->insertItem(QObject::tr("Delete folder",contextName),1); 652 m->insertItem(QObject::tr("Delete folder",contextName),1);
653 } 653 }
654 return m; 654 return m;
655} 655}
656 656
657void MBOXfolderItem::contextMenuSelected(int which) 657void MBOXfolderItem::contextMenuSelected(int which)
658{ 658{
659 switch(which) { 659 switch(which) {
660 case 0: 660 case 0:
661 deleteAllMail(mbox->getWrapper(),folder); 661 deleteAllMail(mbox->getWrapper(),folder);
662 break; 662 break;
663 case 1: 663 case 1:
664 deleteFolder(); 664 deleteFolder();
665 break; 665 break;
666 default: 666 default:
667 break; 667 break;
668 } 668 }
669} 669}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 361dd86..1d2bf19 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,175 +1,175 @@
1#ifndef ACCOUNTVIEW_H 1#ifndef ACCOUNTVIEW_H
2#define ACCOUNTVIEW_H 2#define ACCOUNTVIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "settings.h" 7#include <libmailwrapper/settings.h>
8#include "mailwrapper.h" 8#include <libmailwrapper/mailwrapper.h>
9#include "abstractmail.h" 9#include <libmailwrapper/abstractmail.h>
10 10
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14class QPopupMenu; 14class QPopupMenu;
15 15
16class AccountViewItem : public QListViewItem 16class AccountViewItem : public QListViewItem
17{ 17{
18 18
19public: 19public:
20 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} 20 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
21 AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} 21 AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
22 AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} 22 AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
23 virtual void refresh(QList<RecMail>&)=0; 23 virtual void refresh(QList<RecMail>&)=0;
24 virtual RecBody fetchBody(const RecMail&)=0; 24 virtual RecBody fetchBody(const RecMail&)=0;
25 virtual QPopupMenu * getContextMenu(){return 0;}; 25 virtual QPopupMenu * getContextMenu(){return 0;};
26 virtual void contextMenuSelected(int){} 26 virtual void contextMenuSelected(int){}
27protected: 27protected:
28 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); 28 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
29 static const QString contextName; 29 static const QString contextName;
30}; 30};
31 31
32class POP3viewItem : public AccountViewItem 32class POP3viewItem : public AccountViewItem
33{ 33{
34 34
35public: 35public:
36 POP3viewItem( POP3account *a, QListView *parent ); 36 POP3viewItem( POP3account *a, QListView *parent );
37 ~POP3viewItem(); 37 ~POP3viewItem();
38 virtual void refresh( QList<RecMail> &target ); 38 virtual void refresh( QList<RecMail> &target );
39 virtual RecBody fetchBody( const RecMail &mail ); 39 virtual RecBody fetchBody( const RecMail &mail );
40 AbstractMail *getWrapper(); 40 AbstractMail *getWrapper();
41private: 41private:
42 POP3account *account; 42 POP3account *account;
43 AbstractMail *wrapper; 43 AbstractMail *wrapper;
44 44
45}; 45};
46 46
47class POP3folderItem : public AccountViewItem 47class POP3folderItem : public AccountViewItem
48{ 48{
49 49
50public: 50public:
51 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); 51 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
52 ~POP3folderItem(); 52 ~POP3folderItem();
53 virtual void refresh(QList<RecMail>&); 53 virtual void refresh(QList<RecMail>&);
54 virtual RecBody fetchBody(const RecMail&); 54 virtual RecBody fetchBody(const RecMail&);
55 virtual QPopupMenu * getContextMenu(); 55 virtual QPopupMenu * getContextMenu();
56 virtual void contextMenuSelected(int); 56 virtual void contextMenuSelected(int);
57 57
58private: 58private:
59 Folder *folder; 59 Folder *folder;
60 POP3viewItem *pop3; 60 POP3viewItem *pop3;
61}; 61};
62 62
63class IMAPfolderItem; 63class IMAPfolderItem;
64 64
65class IMAPviewItem : public AccountViewItem 65class IMAPviewItem : public AccountViewItem
66{ 66{
67 friend class IMAPfolderItem; 67 friend class IMAPfolderItem;
68public: 68public:
69 IMAPviewItem( IMAPaccount *a, QListView *parent ); 69 IMAPviewItem( IMAPaccount *a, QListView *parent );
70 ~IMAPviewItem(); 70 ~IMAPviewItem();
71 virtual void refresh(QList<RecMail>&); 71 virtual void refresh(QList<RecMail>&);
72 virtual RecBody fetchBody(const RecMail&); 72 virtual RecBody fetchBody(const RecMail&);
73 AbstractMail *getWrapper(); 73 AbstractMail *getWrapper();
74 virtual QPopupMenu * getContextMenu(); 74 virtual QPopupMenu * getContextMenu();
75 virtual void contextMenuSelected(int); 75 virtual void contextMenuSelected(int);
76 76
77protected: 77protected:
78 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); 78 IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
79 virtual void refreshFolders(bool force=false); 79 virtual void refreshFolders(bool force=false);
80 virtual void createNewFolder(); 80 virtual void createNewFolder();
81 81
82private: 82private:
83 IMAPaccount *account; 83 IMAPaccount *account;
84 AbstractMail *wrapper; 84 AbstractMail *wrapper;
85}; 85};
86 86
87class IMAPfolderItem : public AccountViewItem 87class IMAPfolderItem : public AccountViewItem
88{ 88{
89 89
90public: 90public:
91 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); 91 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
92 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); 92 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
93 ~IMAPfolderItem(); 93 ~IMAPfolderItem();
94 virtual void refresh(QList<RecMail>&); 94 virtual void refresh(QList<RecMail>&);
95 virtual RecBody fetchBody(const RecMail&); 95 virtual RecBody fetchBody(const RecMail&);
96 bool matchName(const QString&name)const; 96 bool matchName(const QString&name)const;
97 virtual QPopupMenu * getContextMenu(); 97 virtual QPopupMenu * getContextMenu();
98 virtual void contextMenuSelected(int); 98 virtual void contextMenuSelected(int);
99 virtual const QString& Delemiter()const; 99 virtual const QString& Delemiter()const;
100protected: 100protected:
101 virtual void createNewFolder(); 101 virtual void createNewFolder();
102 virtual void deleteFolder(); 102 virtual void deleteFolder();
103 103
104private: 104private:
105 Folder *folder; 105 Folder *folder;
106 IMAPviewItem *imap; 106 IMAPviewItem *imap;
107}; 107};
108 108
109class MBOXviewItem : public AccountViewItem 109class MBOXviewItem : public AccountViewItem
110{ 110{
111 friend class MBOXfolderItem; 111 friend class MBOXfolderItem;
112 112
113public: 113public:
114// MBOXviewItem( MBOXaccount *a, QListView *parent ); 114// MBOXviewItem( MBOXaccount *a, QListView *parent );
115 MBOXviewItem( const QString&aMboxPath, QListView *parent ); 115 MBOXviewItem( const QString&aMboxPath, QListView *parent );
116 ~MBOXviewItem(); 116 ~MBOXviewItem();
117 virtual void refresh( QList<RecMail> &target ); 117 virtual void refresh( QList<RecMail> &target );
118 virtual RecBody fetchBody( const RecMail &mail ); 118 virtual RecBody fetchBody( const RecMail &mail );
119 AbstractMail *getWrapper(); 119 AbstractMail *getWrapper();
120 virtual QPopupMenu * getContextMenu(); 120 virtual QPopupMenu * getContextMenu();
121 virtual void contextMenuSelected(int); 121 virtual void contextMenuSelected(int);
122 122
123protected: 123protected:
124 virtual void refresh(bool force=false); 124 virtual void refresh(bool force=false);
125 virtual void createFolder(); 125 virtual void createFolder();
126 126
127private: 127private:
128// MBOXaccount *account; 128// MBOXaccount *account;
129 QString m_Path; 129 QString m_Path;
130 AbstractMail *wrapper; 130 AbstractMail *wrapper;
131 131
132}; 132};
133 133
134class MBOXfolderItem : public AccountViewItem 134class MBOXfolderItem : public AccountViewItem
135{ 135{
136 136
137public: 137public:
138 MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); 138 MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after );
139 ~MBOXfolderItem(); 139 ~MBOXfolderItem();
140 virtual void refresh(QList<RecMail>&); 140 virtual void refresh(QList<RecMail>&);
141 virtual RecBody fetchBody(const RecMail&); 141 virtual RecBody fetchBody(const RecMail&);
142 virtual QPopupMenu * getContextMenu(); 142 virtual QPopupMenu * getContextMenu();
143 virtual void contextMenuSelected(int); 143 virtual void contextMenuSelected(int);
144 144
145protected: 145protected:
146 virtual void deleteFolder(); 146 virtual void deleteFolder();
147private: 147private:
148 Folder *folder; 148 Folder *folder;
149 MBOXviewItem *mbox; 149 MBOXviewItem *mbox;
150}; 150};
151 151
152class AccountView : public QListView 152class AccountView : public QListView
153{ 153{
154 Q_OBJECT 154 Q_OBJECT
155 155
156public: 156public:
157 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 157 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
158 void populate( QList<Account> list ); 158 void populate( QList<Account> list );
159 RecBody fetchBody(const RecMail&aMail); 159 RecBody fetchBody(const RecMail&aMail);
160 160
161public slots: 161public slots:
162 virtual void refreshAll(); 162 virtual void refreshAll();
163 virtual void refresh(QListViewItem *item); 163 virtual void refresh(QListViewItem *item);
164 virtual void refreshCurrent(); 164 virtual void refreshCurrent();
165 virtual void slotHold(int, QListViewItem *,const QPoint&,int); 165 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
166 virtual void slotContextMenu(int id); 166 virtual void slotContextMenu(int id);
167 167
168signals: 168signals:
169 void refreshMailview(QList<RecMail>*); 169 void refreshMailview(QList<RecMail>*);
170 170
171private: 171private:
172 QListViewItem* m_currentItem; 172 QListViewItem* m_currentItem;
173}; 173};
174 174
175#endif 175#endif
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 13c7900..5e823e8 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -1,239 +1,240 @@
1#include <qt.h> 1#include <qt.h>
2 2
3#include <opie/ofiledialog.h> 3#include <opie/ofiledialog.h>
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <qpe/contact.h> 7#include <qpe/contact.h>
8 8
9#include "composemail.h" 9#include "composemail.h"
10#include "smtpwrapper.h" 10
11#include <libmailwrapper/smtpwrapper.h>
11 12
12ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 13ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
13 : ComposeMailUI( parent, name, modal, flags ) 14 : ComposeMailUI( parent, name, modal, flags )
14{ 15{
15 settings = s; 16 settings = s;
16 17
17 QString vfilename = Global::applicationFileName("addressbook", 18 QString vfilename = Global::applicationFileName("addressbook",
18 "businesscard.vcf"); 19 "businesscard.vcf");
19 Contact c; 20 Contact c;
20 if (QFile::exists(vfilename)) { 21 if (QFile::exists(vfilename)) {
21 c = Contact::readVCard( vfilename )[0]; 22 c = Contact::readVCard( vfilename )[0];
22 } 23 }
23 24
24 QStringList mails = c.emailList(); 25 QStringList mails = c.emailList();
25 QString defmail = c.defaultEmail(); 26 QString defmail = c.defaultEmail();
26 27
27 if (defmail.length()!=0) { 28 if (defmail.length()!=0) {
28 fromBox->insertItem(defmail); 29 fromBox->insertItem(defmail);
29 } 30 }
30 QStringList::ConstIterator sit = mails.begin(); 31 QStringList::ConstIterator sit = mails.begin();
31 for (;sit!=mails.end();++sit) { 32 for (;sit!=mails.end();++sit) {
32 if ( (*sit)==defmail) 33 if ( (*sit)==defmail)
33 continue; 34 continue;
34 fromBox->insertItem((*sit)); 35 fromBox->insertItem((*sit));
35 } 36 }
36 senderNameEdit->setText(c.firstName()+" "+c.lastName()); 37 senderNameEdit->setText(c.firstName()+" "+c.lastName());
37 Config cfg( "mail" ); 38 Config cfg( "mail" );
38 cfg.setGroup( "Compose" ); 39 cfg.setGroup( "Compose" );
39 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 40 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
40 41
41 attList->addColumn( tr( "Name" ) ); 42 attList->addColumn( tr( "Name" ) );
42 attList->addColumn( tr( "Size" ) ); 43 attList->addColumn( tr( "Size" ) );
43 44
44 QList<Account> accounts = settings->getAccounts(); 45 QList<Account> accounts = settings->getAccounts();
45 46
46 Account *it; 47 Account *it;
47 for ( it = accounts.first(); it; it = accounts.next() ) { 48 for ( it = accounts.first(); it; it = accounts.next() ) {
48 if ( it->getType().compare( "SMTP" ) == 0 ) { 49 if ( it->getType().compare( "SMTP" ) == 0 ) {
49 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 50 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
50 smtpAccountBox->insertItem( smtp->getAccountName() ); 51 smtpAccountBox->insertItem( smtp->getAccountName() );
51 smtpAccounts.append( smtp ); 52 smtpAccounts.append( smtp );
52 } 53 }
53 } 54 }
54 55
55 if ( smtpAccounts.count() > 0 ) { 56 if ( smtpAccounts.count() > 0 ) {
56 fillValues( smtpAccountBox->currentItem() ); 57 fillValues( smtpAccountBox->currentItem() );
57 } else { 58 } else {
58 QMessageBox::information( this, tr( "Problem" ), 59 QMessageBox::information( this, tr( "Problem" ),
59 tr( "<p>Please create an SMTP account first.</p>" ), 60 tr( "<p>Please create an SMTP account first.</p>" ),
60 tr( "Ok" ) ); 61 tr( "Ok" ) );
61 return; 62 return;
62 } 63 }
63 64
64 connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); 65 connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) );
65 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 66 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
66 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 67 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
67 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 68 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
68 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 69 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
69 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 70 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
70 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 71 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
71} 72}
72 73
73void ComposeMail::pickAddress( QLineEdit *line ) 74void ComposeMail::pickAddress( QLineEdit *line )
74{ 75{
75 QString names = AddressPicker::getNames(); 76 QString names = AddressPicker::getNames();
76 if ( line->text().isEmpty() ) { 77 if ( line->text().isEmpty() ) {
77 line->setText( names ); 78 line->setText( names );
78 } else if ( !names.isEmpty() ) { 79 } else if ( !names.isEmpty() ) {
79 line->setText( line->text() + ", " + names ); 80 line->setText( line->text() + ", " + names );
80 } 81 }
81} 82}
82 83
83 84
84void ComposeMail::setTo( const QString & to ) 85void ComposeMail::setTo( const QString & to )
85{ 86{
86/* QString toline; 87/* QString toline;
87 QStringList toEntry = to; 88 QStringList toEntry = to;
88 for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { 89 for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) {
89 toline += (*it); 90 toline += (*it);
90 } 91 }
91 toLine->setText( toline ); 92 toLine->setText( toline );
92*/ 93*/
93toLine->setText( to ); 94toLine->setText( to );
94} 95}
95 96
96void ComposeMail::setSubject( const QString & subject ) 97void ComposeMail::setSubject( const QString & subject )
97{ 98{
98 subjectLine->setText( subject ); 99 subjectLine->setText( subject );
99} 100}
100 101
101void ComposeMail::setInReplyTo( const QString & messageId ) 102void ComposeMail::setInReplyTo( const QString & messageId )
102{ 103{
103 104
104} 105}
105 106
106void ComposeMail::setMessage( const QString & text ) 107void ComposeMail::setMessage( const QString & text )
107{ 108{
108 message->setText( text ); 109 message->setText( text );
109} 110}
110 111
111 112
112void ComposeMail::pickAddressTo() 113void ComposeMail::pickAddressTo()
113{ 114{
114 pickAddress( toLine ); 115 pickAddress( toLine );
115} 116}
116 117
117void ComposeMail::pickAddressCC() 118void ComposeMail::pickAddressCC()
118{ 119{
119 pickAddress( ccLine ); 120 pickAddress( ccLine );
120} 121}
121 122
122void ComposeMail::pickAddressBCC() 123void ComposeMail::pickAddressBCC()
123{ 124{
124 pickAddress( bccLine ); 125 pickAddress( bccLine );
125} 126}
126 127
127void ComposeMail::pickAddressReply() 128void ComposeMail::pickAddressReply()
128{ 129{
129 pickAddress( replyLine ); 130 pickAddress( replyLine );
130} 131}
131 132
132void ComposeMail::fillValues( int current ) 133void ComposeMail::fillValues( int current )
133{ 134{
134#if 0 135#if 0
135 SMTPaccount *smtp = smtpAccounts.at( current ); 136 SMTPaccount *smtp = smtpAccounts.at( current );
136 ccLine->clear(); 137 ccLine->clear();
137 if ( smtp->getUseCC() ) { 138 if ( smtp->getUseCC() ) {
138 ccLine->setText( smtp->getCC() ); 139 ccLine->setText( smtp->getCC() );
139 } 140 }
140 bccLine->clear(); 141 bccLine->clear();
141 if ( smtp->getUseBCC() ) { 142 if ( smtp->getUseBCC() ) {
142 bccLine->setText( smtp->getBCC() ); 143 bccLine->setText( smtp->getBCC() );
143 } 144 }
144 replyLine->clear(); 145 replyLine->clear();
145 if ( smtp->getUseReply() ) { 146 if ( smtp->getUseReply() ) {
146 replyLine->setText( smtp->getReply() ); 147 replyLine->setText( smtp->getReply() );
147 } 148 }
148 sigMultiLine->setText( smtp->getSignature() ); 149 sigMultiLine->setText( smtp->getSignature() );
149#endif 150#endif
150} 151}
151 152
152void ComposeMail::slotAdjustColumns() 153void ComposeMail::slotAdjustColumns()
153{ 154{
154 int currPage = tabWidget->currentPageIndex(); 155 int currPage = tabWidget->currentPageIndex();
155 156
156 tabWidget->showPage( attachTab ); 157 tabWidget->showPage( attachTab );
157 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 158 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
158 attList->setColumnWidth( 1, 80 ); 159 attList->setColumnWidth( 1, 80 );
159 160
160 tabWidget->setCurrentPage( currPage ); 161 tabWidget->setCurrentPage( currPage );
161} 162}
162 163
163void ComposeMail::addAttachment() 164void ComposeMail::addAttachment()
164{ 165{
165 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); 166 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" );
166 if ( !lnk.name().isEmpty() ) { 167 if ( !lnk.name().isEmpty() ) {
167 Attachment *att = new Attachment( lnk ); 168 Attachment *att = new Attachment( lnk );
168 (void) new AttachViewItem( attList, att ); 169 (void) new AttachViewItem( attList, att );
169 } 170 }
170} 171}
171 172
172void ComposeMail::removeAttachment() 173void ComposeMail::removeAttachment()
173{ 174{
174 if ( !attList->currentItem() ) { 175 if ( !attList->currentItem() ) {
175 QMessageBox::information( this, tr( "Error" ), 176 QMessageBox::information( this, tr( "Error" ),
176 tr( "<p>Please select a File.</p>" ), 177 tr( "<p>Please select a File.</p>" ),
177 tr( "Ok" ) ); 178 tr( "Ok" ) );
178 } else { 179 } else {
179 attList->takeItem( attList->currentItem() ); 180 attList->takeItem( attList->currentItem() );
180 } 181 }
181} 182}
182 183
183void ComposeMail::accept() 184void ComposeMail::accept()
184{ 185{
185 if ( checkBoxLater->isChecked() ) { 186 if ( checkBoxLater->isChecked() ) {
186 qDebug( "Send later" ); 187 qDebug( "Send later" );
187 } 188 }
188 189
189#if 0 190#if 0
190 qDebug( "Sending Mail with " + 191 qDebug( "Sending Mail with " +
191 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); 192 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
192#endif 193#endif
193 Mail *mail = new Mail(); 194 Mail *mail = new Mail();
194 195
195 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 196 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
196 mail->setMail(fromBox->currentText()); 197 mail->setMail(fromBox->currentText());
197 198
198 if ( !toLine->text().isEmpty() ) { 199 if ( !toLine->text().isEmpty() ) {
199 mail->setTo( toLine->text() ); 200 mail->setTo( toLine->text() );
200 } else { 201 } else {
201 qDebug( "No Reciever spezified -> returning" ); 202 qDebug( "No Reciever spezified -> returning" );
202 return; 203 return;
203 } 204 }
204 mail->setName(senderNameEdit->text()); 205 mail->setName(senderNameEdit->text());
205 mail->setCC( ccLine->text() ); 206 mail->setCC( ccLine->text() );
206 mail->setBCC( bccLine->text() ); 207 mail->setBCC( bccLine->text() );
207 mail->setReply( replyLine->text() ); 208 mail->setReply( replyLine->text() );
208 mail->setSubject( subjectLine->text() ); 209 mail->setSubject( subjectLine->text() );
209 QString txt = message->text(); 210 QString txt = message->text();
210 if ( !sigMultiLine->text().isEmpty() ) { 211 if ( !sigMultiLine->text().isEmpty() ) {
211 txt.append( "\n--\n" ); 212 txt.append( "\n--\n" );
212 txt.append( sigMultiLine->text() ); 213 txt.append( sigMultiLine->text() );
213 } 214 }
214 qDebug(txt); 215 qDebug(txt);
215 mail->setMessage( txt ); 216 mail->setMessage( txt );
216 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 217 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
217 while ( it != NULL ) { 218 while ( it != NULL ) {
218 mail->addAttachment( it->getAttachment() ); 219 mail->addAttachment( it->getAttachment() );
219 it = (AttachViewItem *) it->nextSibling(); 220 it = (AttachViewItem *) it->nextSibling();
220 } 221 }
221 222
222 SMTPwrapper wrapper( settings ); 223 SMTPwrapper wrapper( settings );
223 wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() ); 224 wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() );
224 225
225 QDialog::accept(); 226 QDialog::accept();
226} 227}
227 228
228AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 229AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
229 : QListViewItem( parent ) 230 : QListViewItem( parent )
230{ 231{
231 attachment = att; 232 attachment = att;
232 qDebug( att->getMimeType() ); 233 qDebug( att->getMimeType() );
233 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? 234 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
234 Resource::loadPixmap( "UnknownDocument-14" ) : 235 Resource::loadPixmap( "UnknownDocument-14" ) :
235 attachment->getDocLnk().pixmap() ); 236 attachment->getDocLnk().pixmap() );
236 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 237 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
237 setText( 1, QString::number( att->getSize() ) ); 238 setText( 1, QString::number( att->getSize() ) );
238} 239}
239 240
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h
index 230e397..604c862 100644
--- a/noncore/net/mail/composemail.h
+++ b/noncore/net/mail/composemail.h
@@ -1,75 +1,76 @@
1#ifndef COMPOSEMAIL_H 1#ifndef COMPOSEMAIL_H
2#define COMPOSEMAIL_H 2#define COMPOSEMAIL_H
3 3
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "composemailui.h" 7#include "composemailui.h"
8#include "addresspickerui.h" 8#include "addresspickerui.h"
9#include "settings.h" 9#include <libmailwrapper/settings.h>
10#include "mailwrapper.h" 10#include <libmailwrapper/mailwrapper.h>
11
11 12
12 13
13class AddressPicker : public AddressPickerUI 14class AddressPicker : public AddressPickerUI
14{ 15{
15 Q_OBJECT 16 Q_OBJECT
16 17
17public: 18public:
18 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 19 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
19 static QString getNames(); 20 static QString getNames();
20 21
21protected: 22protected:
22 QString selectedNames; 23 QString selectedNames;
23 void accept(); 24 void accept();
24 25
25}; 26};
26 27
27 28
28class ComposeMail : public ComposeMailUI 29class ComposeMail : public ComposeMailUI
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31 32
32public: 33public:
33 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 34 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
34 35
35public slots: 36public slots:
36 void slotAdjustColumns(); 37 void slotAdjustColumns();
37 38
38 void setTo( const QString & to ); 39 void setTo( const QString & to );
39 void setSubject( const QString & subject ); 40 void setSubject( const QString & subject );
40 void setInReplyTo( const QString & messageId ); 41 void setInReplyTo( const QString & messageId );
41 void setMessage( const QString & text ); 42 void setMessage( const QString & text );
42 43
43protected slots: 44protected slots:
44 void accept(); 45 void accept();
45 46
46private slots: 47private slots:
47 void fillValues( int current ); 48 void fillValues( int current );
48 void pickAddress( QLineEdit *line ); 49 void pickAddress( QLineEdit *line );
49 void pickAddressTo(); 50 void pickAddressTo();
50 void pickAddressCC(); 51 void pickAddressCC();
51 void pickAddressBCC(); 52 void pickAddressBCC();
52 void pickAddressReply(); 53 void pickAddressReply();
53 void addAttachment(); 54 void addAttachment();
54 void removeAttachment(); 55 void removeAttachment();
55 56
56 57
57 58
58private: 59private:
59 Settings *settings; 60 Settings *settings;
60 QList<SMTPaccount> smtpAccounts; 61 QList<SMTPaccount> smtpAccounts;
61 62
62}; 63};
63 64
64class AttachViewItem : public QListViewItem 65class AttachViewItem : public QListViewItem
65{ 66{
66 public: 67 public:
67 AttachViewItem( QListView *parent, Attachment *att ); 68 AttachViewItem( QListView *parent, Attachment *att );
68 Attachment *getAttachment() { return attachment; } 69 Attachment *getAttachment() { return attachment; }
69 70
70private: 71private:
71 Attachment *attachment; 72 Attachment *attachment;
72 73
73}; 74};
74 75
75#endif 76#endif
diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h
index 10ed8b8..6022eef 100644
--- a/noncore/net/mail/editaccounts.h
+++ b/noncore/net/mail/editaccounts.h
@@ -1,146 +1,147 @@
1#ifndef EDITACCOUNTS_H 1#ifndef EDITACCOUNTS_H
2#define EDITACCOUNTS_H 2#define EDITACCOUNTS_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "editaccountsui.h" 7#include "editaccountsui.h"
8#include "selectmailtypeui.h" 8#include "selectmailtypeui.h"
9#include "imapconfigui.h" 9#include "imapconfigui.h"
10#include "pop3configui.h" 10#include "pop3configui.h"
11#include "smtpconfigui.h" 11#include "smtpconfigui.h"
12#include "nntpconfigui.h" 12#include "nntpconfigui.h"
13#include "settings.h" 13#include <libmailwrapper/settings.h>
14
14 15
15class AccountListItem : public QListViewItem 16class AccountListItem : public QListViewItem
16{ 17{
17 18
18public: 19public:
19 AccountListItem( QListView *parent, Account *a); 20 AccountListItem( QListView *parent, Account *a);
20 Account *getAccount() { return account; } 21 Account *getAccount() { return account; }
21 22
22private: 23private:
23 Account *account; 24 Account *account;
24 25
25}; 26};
26 27
27class EditAccounts : public EditAccountsUI 28class EditAccounts : public EditAccountsUI
28{ 29{
29 Q_OBJECT 30 Q_OBJECT
30 31
31public: 32public:
32 EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 33 EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
33 34
34public slots: 35public slots:
35 void slotNewAccount( const QString &type ); 36 void slotNewAccount( const QString &type );
36 void slotEditAccount( Account *account ); 37 void slotEditAccount( Account *account );
37 void slotDeleteAccount( Account * account ); 38 void slotDeleteAccount( Account * account );
38 void slotAdjustColumns(); 39 void slotAdjustColumns();
39 40
40protected slots: 41protected slots:
41 void slotFillLists(); 42 void slotFillLists();
42 void slotNewMail(); 43 void slotNewMail();
43 void slotEditMail(); 44 void slotEditMail();
44 void slotDeleteMail(); 45 void slotDeleteMail();
45 void slotNewNews(); 46 void slotNewNews();
46 void slotEditNews(); 47 void slotEditNews();
47 void slotDeleteNews(); 48 void slotDeleteNews();
48 void accept(); 49 void accept();
49 50
50private: 51private:
51 Settings *settings; 52 Settings *settings;
52 53
53}; 54};
54 55
55class SelectMailType : public SelectMailTypeUI 56class SelectMailType : public SelectMailTypeUI
56{ 57{
57 Q_OBJECT 58 Q_OBJECT
58 59
59public: 60public:
60 SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 61 SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
61 62
62private slots: 63private slots:
63 void slotSelection( const QString &sel ); 64 void slotSelection( const QString &sel );
64 65
65private: 66private:
66 QString *selected; 67 QString *selected;
67 68
68}; 69};
69 70
70class IMAPconfig : public IMAPconfigUI 71class IMAPconfig : public IMAPconfigUI
71{ 72{
72 Q_OBJECT 73 Q_OBJECT
73 74
74public: 75public:
75 IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 76 IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
76 77
77public slots: 78public slots:
78 void fillValues(); 79 void fillValues();
79 80
80protected slots: 81protected slots:
81 void slotSSL( bool enabled ); 82 void slotSSL( bool enabled );
82 void accept(); 83 void accept();
83 84
84private: 85private:
85 IMAPaccount *data; 86 IMAPaccount *data;
86 87
87}; 88};
88 89
89class POP3config : public POP3configUI 90class POP3config : public POP3configUI
90{ 91{
91 Q_OBJECT 92 Q_OBJECT
92 93
93public: 94public:
94 POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 95 POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
95 96
96public slots: 97public slots:
97 void fillValues(); 98 void fillValues();
98 99
99protected slots: 100protected slots:
100 void slotSSL( bool enabled ); 101 void slotSSL( bool enabled );
101 void accept(); 102 void accept();
102 103
103private: 104private:
104 POP3account *data; 105 POP3account *data;
105 106
106}; 107};
107 108
108class SMTPconfig : public SMTPconfigUI 109class SMTPconfig : public SMTPconfigUI
109{ 110{
110 Q_OBJECT 111 Q_OBJECT
111 112
112public: 113public:
113 SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 114 SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
114 115
115public slots: 116public slots:
116 void slotSSL( bool enabled ); 117 void slotSSL( bool enabled );
117 void fillValues(); 118 void fillValues();
118 119
119protected slots: 120protected slots:
120 void accept(); 121 void accept();
121 122
122private: 123private:
123 SMTPaccount *data; 124 SMTPaccount *data;
124 125
125}; 126};
126 127
127class NNTPconfig : public NNTPconfigUI 128class NNTPconfig : public NNTPconfigUI
128{ 129{
129 Q_OBJECT 130 Q_OBJECT
130 131
131public: 132public:
132 NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 133 NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
133 134
134public slots: 135public slots:
135 void fillValues(); 136 void fillValues();
136 137
137protected slots: 138protected slots:
138 void slotSSL( bool enabled ); 139 void slotSSL( bool enabled );
139 void accept(); 140 void accept();
140 141
141private: 142private:
142 NNTPaccount *data; 143 NNTPaccount *data;
143 144
144}; 145};
145 146
146#endif 147#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 69e1450..a96c88e 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,52 +1,52 @@
1CONFIG += qt warn_on debug quick-app 1CONFIG += qt warn_on debug quick-app
2 2
3HEADERS = defines.h \ 3HEADERS = defines.h \
4 editaccounts.h \ 4 editaccounts.h \
5 composemail.h \ 5 composemail.h \
6 accountview.h \ 6 accountview.h \
7 mainwindow.h \ 7 mainwindow.h \
8 viewmail.h \ 8 viewmail.h \
9 viewmailbase.h \ 9 viewmailbase.h \
10 opiemail.h \ 10 opiemail.h \
11 mailistviewitem.h \ 11 mailistviewitem.h \
12 settingsdialog.h \ 12 settingsdialog.h \
13 statuswidget.h \ 13 statuswidget.h \
14 newmaildir.h 14 newmaildir.h
15 15
16SOURCES = main.cpp \ 16SOURCES = main.cpp \
17 opiemail.cpp \ 17 opiemail.cpp \
18 mainwindow.cpp \ 18 mainwindow.cpp \
19 accountview.cpp \ 19 accountview.cpp \
20 composemail.cpp \ 20 composemail.cpp \
21 addresspicker.cpp \ 21 addresspicker.cpp \
22 editaccounts.cpp \ 22 editaccounts.cpp \
23 viewmail.cpp \ 23 viewmail.cpp \
24 viewmailbase.cpp \ 24 viewmailbase.cpp \
25 settingsdialog.cpp \ 25 settingsdialog.cpp \
26 statuswidget.cpp \ 26 statuswidget.cpp \
27 newmaildir.cpp 27 newmaildir.cpp
28 28
29INTERFACES = editaccountsui.ui \ 29INTERFACES = editaccountsui.ui \
30 selectmailtypeui.ui \ 30 selectmailtypeui.ui \
31 imapconfigui.ui \ 31 imapconfigui.ui \
32 pop3configui.ui \ 32 pop3configui.ui \
33 nntpconfigui.ui \ 33 nntpconfigui.ui \
34 smtpconfigui.ui \ 34 smtpconfigui.ui \
35 addresspickerui.ui \ 35 addresspickerui.ui \
36 composemailui.ui \ 36 composemailui.ui \
37 settingsdialogui.ui \ 37 settingsdialogui.ui \
38 statuswidgetui.ui \ 38 statuswidgetui.ui \
39 newmaildirui.ui 39 newmaildirui.ui
40 40
41INCLUDEPATH += $(OPIEDIR)/include 41INCLUDEPATH += $(OPIEDIR)/include
42 42
43CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 43CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
44contains( CONFTEST, y ){ 44contains( CONFTEST, y ){
45 LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv 45 LIBS += -lqpe -lopie -lmailwrapper -liconv
46}else{ 46}else{
47 LIBS += -lqpe -lopie -llibmailwrapper 47 LIBS += -lqpe -lopie -lmailwrapper
48} 48}
49 49
50TARGET = opiemail 50TARGET = opiemail
51 51
52include ( $(OPIEDIR)/include.pro ) 52include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index 60bfdda..271f616 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -1,21 +1,22 @@
1#ifndef __MAILLISTVIEWITEM_H 1#ifndef __MAILLISTVIEWITEM_H
2#define __MAILLISTVIEWITEM_H 2#define __MAILLISTVIEWITEM_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include "mailtypes.h" 5#include <libmailwrapper/mailtypes.h>
6
6 7
7class MailListViewItem:public QListViewItem 8class MailListViewItem:public QListViewItem
8{ 9{
9public: 10public:
10 MailListViewItem(QListView * parent, MailListViewItem * after ); 11 MailListViewItem(QListView * parent, MailListViewItem * after );
11 virtual ~MailListViewItem(){} 12 virtual ~MailListViewItem(){}
12 13
13 void storeData(const RecMail&data); 14 void storeData(const RecMail&data);
14 const RecMail&data()const; 15 const RecMail&data()const;
15 void showEntry(); 16 void showEntry();
16 17
17protected: 18protected:
18 RecMail mail_data; 19 RecMail mail_data;
19}; 20};
20 21
21#endif 22#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 6511b1f..43d02e7 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,300 +1,301 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qtextstream.h> 7#include <qtextstream.h>
8 8
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12
12#include "defines.h" 13#include "defines.h"
13#include "mainwindow.h" 14#include "mainwindow.h"
14#include "viewmail.h" 15#include "viewmail.h"
15#include "mailtypes.h" 16#include <libmailwrapper/mailtypes.h>
16#include "mailistviewitem.h" 17#include "mailistviewitem.h"
17 18
18 19
19MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 20MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
20 : QMainWindow( parent, name, flags ) 21 : QMainWindow( parent, name, flags )
21{ 22{
22 23
23 setCaption( tr( "Mail" ) ); 24 setCaption( tr( "Mail" ) );
24 setToolBarsMovable( false ); 25 setToolBarsMovable( false );
25 26
26 toolBar = new QToolBar( this ); 27 toolBar = new QToolBar( this );
27 menuBar = new QMenuBar( toolBar ); 28 menuBar = new QMenuBar( toolBar );
28 mailMenu = new QPopupMenu( menuBar ); 29 mailMenu = new QPopupMenu( menuBar );
29 menuBar->insertItem( tr( "Mail" ), mailMenu ); 30 menuBar->insertItem( tr( "Mail" ), mailMenu );
30 settingsMenu = new QPopupMenu( menuBar ); 31 settingsMenu = new QPopupMenu( menuBar );
31 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 32 menuBar->insertItem( tr( "Settings" ), settingsMenu );
32 33
33 addToolBar( toolBar ); 34 addToolBar( toolBar );
34 toolBar->setHorizontalStretchable( true ); 35 toolBar->setHorizontalStretchable( true );
35 36
36 QLabel *spacer = new QLabel( toolBar ); 37 QLabel *spacer = new QLabel( toolBar );
37 spacer->setBackgroundMode( QWidget::PaletteButton ); 38 spacer->setBackgroundMode( QWidget::PaletteButton );
38 toolBar->setStretchableWidget( spacer ); 39 toolBar->setStretchableWidget( spacer );
39 40
40 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 41 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
41 0, 0, this ); 42 0, 0, this );
42 composeMail->addTo( toolBar ); 43 composeMail->addTo( toolBar );
43 composeMail->addTo( mailMenu ); 44 composeMail->addTo( mailMenu );
44 45
45 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 46 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
46 0, 0, this ); 47 0, 0, this );
47 sendQueued->addTo( toolBar ); 48 sendQueued->addTo( toolBar );
48 sendQueued->addTo( mailMenu ); 49 sendQueued->addTo( mailMenu );
49 50
50 /* 51 /*
51 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 52 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
52 0, 0, this ); 53 0, 0, this );
53 syncFolders->addTo( toolBar ); 54 syncFolders->addTo( toolBar );
54 syncFolders->addTo( mailMenu ); 55 syncFolders->addTo( mailMenu );
55 */ 56 */
56 57
57 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 58 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
58 0, 0, this, 0, true ); 59 0, 0, this, 0, true );
59 showFolders->addTo( toolBar ); 60 showFolders->addTo( toolBar );
60 showFolders->addTo( mailMenu ); 61 showFolders->addTo( mailMenu );
61 showFolders->setOn( true ); 62 showFolders->setOn( true );
62 connect(showFolders, SIGNAL( toggled( bool ) ), 63 connect(showFolders, SIGNAL( toggled( bool ) ),
63 SLOT( slotShowFolders( bool ) ) ); 64 SLOT( slotShowFolders( bool ) ) );
64 65
65 /* 66 /*
66 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 67 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
67 0, 0, this ); 68 0, 0, this );
68 searchMails->addTo( toolBar ); 69 searchMails->addTo( toolBar );
69 searchMails->addTo( mailMenu ); 70 searchMails->addTo( mailMenu );
70 */ 71 */
71 72
72 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 73 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
73 deleteMails->addTo( toolBar ); 74 deleteMails->addTo( toolBar );
74 deleteMails->addTo( mailMenu ); 75 deleteMails->addTo( mailMenu );
75 connect( deleteMails, SIGNAL( activated() ), 76 connect( deleteMails, SIGNAL( activated() ),
76 SLOT( slotDeleteMail() ) ); 77 SLOT( slotDeleteMail() ) );
77 78
78 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 79 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
79 0, 0, this ); 80 0, 0, this );
80 editSettings->addTo( settingsMenu ); 81 editSettings->addTo( settingsMenu );
81 connect( editSettings, SIGNAL( activated() ), 82 connect( editSettings, SIGNAL( activated() ),
82 SLOT( slotEditSettings() ) ); 83 SLOT( slotEditSettings() ) );
83 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 84 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
84 0, 0, this ); 85 0, 0, this );
85 editAccounts->addTo( settingsMenu ); 86 editAccounts->addTo( settingsMenu );
86 87
87 //setCentralWidget( view ); 88 //setCentralWidget( view );
88 89
89 QVBox* wrapperBox = new QVBox( this ); 90 QVBox* wrapperBox = new QVBox( this );
90 setCentralWidget( wrapperBox ); 91 setCentralWidget( wrapperBox );
91 92
92 QWidget *view = new QWidget( wrapperBox ); 93 QWidget *view = new QWidget( wrapperBox );
93 94
94 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 95 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
95 96
96 folderView = new AccountView( view ); 97 folderView = new AccountView( view );
97 folderView->header()->hide(); 98 folderView->header()->hide();
98 folderView->setRootIsDecorated( true ); 99 folderView->setRootIsDecorated( true );
99 folderView->addColumn( tr( "Mailbox" ) ); 100 folderView->addColumn( tr( "Mailbox" ) );
100 101
101 layout->addWidget( folderView ); 102 layout->addWidget( folderView );
102 103
103 mailView = new QListView( view ); 104 mailView = new QListView( view );
104 mailView->addColumn( tr( "" ) ); 105 mailView->addColumn( tr( "" ) );
105 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 106 mailView->addColumn( tr( "Subject" ),QListView::Manual );
106 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 107 mailView->addColumn( tr( "Sender" ),QListView::Manual );
107 mailView->addColumn( tr( "Size" ),QListView::Manual); 108 mailView->addColumn( tr( "Size" ),QListView::Manual);
108 mailView->addColumn( tr( "Date" )); 109 mailView->addColumn( tr( "Date" ));
109 mailView->setAllColumnsShowFocus(true); 110 mailView->setAllColumnsShowFocus(true);
110 mailView->setSorting(-1); 111 mailView->setSorting(-1);
111 112
112 statusWidget = new StatusWidget( wrapperBox ); 113 statusWidget = new StatusWidget( wrapperBox );
113 statusWidget->hide(); 114 statusWidget->hide();
114 115
115 layout->addWidget( mailView ); 116 layout->addWidget( mailView );
116 layout->setStretchFactor( folderView, 1 ); 117 layout->setStretchFactor( folderView, 1 );
117 layout->setStretchFactor( mailView, 2 ); 118 layout->setStretchFactor( mailView, 2 );
118 119
119 slotAdjustLayout(); 120 slotAdjustLayout();
120 121
121 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
122 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 123 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
123 124
124 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this, 125 connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this,
125 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) ); 126 SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) );
126 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 127 connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
127 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) ); 128 SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) );
128 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 129 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
129 130
130 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 131 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
131} 132}
132 133
133 134
134void MainWindow::slotAdjustLayout() { 135void MainWindow::slotAdjustLayout() {
135 136
136 QWidget *d = QApplication::desktop(); 137 QWidget *d = QApplication::desktop();
137 138
138 if ( d->width() < d->height() ) { 139 if ( d->width() < d->height() ) {
139 layout->setDirection( QBoxLayout::TopToBottom ); 140 layout->setDirection( QBoxLayout::TopToBottom );
140 } else { 141 } else {
141 layout->setDirection( QBoxLayout::LeftToRight ); 142 layout->setDirection( QBoxLayout::LeftToRight );
142 } 143 }
143} 144}
144 145
145void MainWindow::slotAdjustColumns() 146void MainWindow::slotAdjustColumns()
146{ 147{
147 bool hidden = folderView->isHidden(); 148 bool hidden = folderView->isHidden();
148 if ( hidden ) folderView->show(); 149 if ( hidden ) folderView->show();
149 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 150 folderView->setColumnWidth( 0, folderView->visibleWidth() );
150 if ( hidden ) folderView->hide(); 151 if ( hidden ) folderView->hide();
151 152
152 mailView->setColumnWidth( 0, 10 ); 153 mailView->setColumnWidth( 0, 10 );
153 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 154 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
154 mailView->setColumnWidth( 2, 80 ); 155 mailView->setColumnWidth( 2, 80 );
155 mailView->setColumnWidth( 3, 50 ); 156 mailView->setColumnWidth( 3, 50 );
156 mailView->setColumnWidth( 4, 50 ); 157 mailView->setColumnWidth( 4, 50 );
157} 158}
158 159
159void MainWindow::slotEditSettings() 160void MainWindow::slotEditSettings()
160{ 161{
161} 162}
162 163
163void MainWindow::slotShowFolders( bool show ) 164void MainWindow::slotShowFolders( bool show )
164{ 165{
165 qDebug( "Show Folders" ); 166 qDebug( "Show Folders" );
166 if ( show && folderView->isHidden() ) { 167 if ( show && folderView->isHidden() ) {
167 qDebug( "-> showing" ); 168 qDebug( "-> showing" );
168 folderView->show(); 169 folderView->show();
169 } else if ( !show && !folderView->isHidden() ) { 170 } else if ( !show && !folderView->isHidden() ) {
170 qDebug( "-> hiding" ); 171 qDebug( "-> hiding" );
171 folderView->hide(); 172 folderView->hide();
172 } 173 }
173} 174}
174 175
175void MainWindow::refreshMailView(QList<RecMail>*list) 176void MainWindow::refreshMailView(QList<RecMail>*list)
176{ 177{
177 MailListViewItem*item = 0; 178 MailListViewItem*item = 0;
178 mailView->clear(); 179 mailView->clear();
179 for (unsigned int i = 0; i < list->count();++i) { 180 for (unsigned int i = 0; i < list->count();++i) {
180 item = new MailListViewItem(mailView,item); 181 item = new MailListViewItem(mailView,item);
181 item->storeData(*(list->at(i))); 182 item->storeData(*(list->at(i)));
182 item->showEntry(); 183 item->showEntry();
183 } 184 }
184} 185}
185void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 186void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
186{ 187{
187 /* just LEFT button - or tap with stylus on pda */ 188 /* just LEFT button - or tap with stylus on pda */
188 if (button!=1) return; 189 if (button!=1) return;
189 if (!item) return; 190 if (!item) return;
190 displayMail(); 191 displayMail();
191} 192}
192 193
193void MainWindow::displayMail() 194void MainWindow::displayMail()
194{ 195{
195 QListViewItem*item = mailView->currentItem(); 196 QListViewItem*item = mailView->currentItem();
196 if (!item) return; 197 if (!item) return;
197 RecMail mail = ((MailListViewItem*)item)->data(); 198 RecMail mail = ((MailListViewItem*)item)->data();
198 RecBody body = folderView->fetchBody(mail); 199 RecBody body = folderView->fetchBody(mail);
199 ViewMail readMail( this ); 200 ViewMail readMail( this );
200 readMail.setBody( body ); 201 readMail.setBody( body );
201 readMail.setMail( mail ); 202 readMail.setMail( mail );
202 readMail.showMaximized(); 203 readMail.showMaximized();
203 readMail.exec(); 204 readMail.exec();
204 205
205 if ( readMail.deleted ) { 206 if ( readMail.deleted ) {
206 folderView->refreshCurrent(); 207 folderView->refreshCurrent();
207 } else { 208 } else {
208 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); 209 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
209 } 210 }
210} 211}
211 212
212void MainWindow::slotDeleteMail() 213void MainWindow::slotDeleteMail()
213{ 214{
214 if (!mailView->currentItem()) return; 215 if (!mailView->currentItem()) return;
215 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 216 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
216 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 217 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
217 mail.Wrapper()->deleteMail( mail ); 218 mail.Wrapper()->deleteMail( mail );
218 folderView->refreshCurrent(); 219 folderView->refreshCurrent();
219 } 220 }
220} 221}
221 222
222void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int ) 223void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int )
223{ 224{
224 /* just the RIGHT button - or hold on pda */ 225 /* just the RIGHT button - or hold on pda */
225 if (button!=2) {return;} 226 if (button!=2) {return;}
226 qDebug("Event right/hold"); 227 qDebug("Event right/hold");
227 if (!item) return; 228 if (!item) return;
228 QPopupMenu *m = new QPopupMenu(0); 229 QPopupMenu *m = new QPopupMenu(0);
229 if (m) { 230 if (m) {
230 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 231 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
231 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 232 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
232 m->setFocus(); 233 m->setFocus();
233 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 234 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
234 delete m; 235 delete m;
235 } 236 }
236} 237}
237 238
238MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 239MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
239 :QListViewItem(parent,item),mail_data() 240 :QListViewItem(parent,item),mail_data()
240{ 241{
241} 242}
242 243
243void MailListViewItem::showEntry() 244void MailListViewItem::showEntry()
244{ 245{
245 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { 246 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
246 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); 247 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
247 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 248 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
248 /* I think it looks nicer if there are not such a log of icons but only on mails 249 /* I think it looks nicer if there are not such a log of icons but only on mails
249 replied or new - Alwin*/ 250 replied or new - Alwin*/
250 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); 251 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
251 } else { 252 } else {
252 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); 253 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
253 } 254 }
254 double s = mail_data.Msgsize(); 255 double s = mail_data.Msgsize();
255 int w; 256 int w;
256 w=0; 257 w=0;
257 258
258 while (s>1024) { 259 while (s>1024) {
259 s/=1024; 260 s/=1024;
260 ++w; 261 ++w;
261 if (w>=2) break; 262 if (w>=2) break;
262 } 263 }
263 264
264 QString q=""; 265 QString q="";
265 QString fsize=""; 266 QString fsize="";
266 switch(w) { 267 switch(w) {
267 case 1: 268 case 1:
268 q="k"; 269 q="k";
269 break; 270 break;
270 case 2: 271 case 2:
271 q="M"; 272 q="M";
272 break; 273 break;
273 default: 274 default:
274 break; 275 break;
275 } 276 }
276 277
277 { 278 {
278 QTextOStream o(&fsize); 279 QTextOStream o(&fsize);
279 if (w>0) o.precision(2); else o.precision(0); 280 if (w>0) o.precision(2); else o.precision(0);
280 o.setf(QTextStream::fixed); 281 o.setf(QTextStream::fixed);
281 o << s << " " << q << "Byte"; 282 o << s << " " << q << "Byte";
282 } 283 }
283 284
284 setText(1,mail_data.getSubject()); 285 setText(1,mail_data.getSubject());
285 setText(2,mail_data.getFrom()); 286 setText(2,mail_data.getFrom());
286 setText(3,fsize); 287 setText(3,fsize);
287 setText(4,mail_data.getDate()); 288 setText(4,mail_data.getDate());
288} 289}
289 290
290void MailListViewItem::storeData(const RecMail&data) 291void MailListViewItem::storeData(const RecMail&data)
291{ 292{
292 mail_data = data; 293 mail_data = data;
293} 294}
294 295
295const RecMail& MailListViewItem::data()const 296const RecMail& MailListViewItem::data()const
296{ 297{
297 return mail_data; 298 return mail_data;
298} 299}
299 300
300 301
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 54453b7..fcd48e2 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,115 +1,115 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include "smtpwrapper.h" 6#include <libmailwrapper/smtpwrapper.h>
7#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
8#include <qaction.h> 8#include <qaction.h>
9#include <qapplication.h> 9#include <qapplication.h>
10 10
11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 11OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
12 : MainWindow( parent, name, flags ) 12 : MainWindow( parent, name, flags )
13{ 13{
14 settings = new Settings(); 14 settings = new Settings();
15 15
16 folderView->populate( settings->getAccounts() ); 16 folderView->populate( settings->getAccounts() );
17 17
18 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 18 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
19 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 19 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
20// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 20// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 21 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
22 // Added by Stefan Eilers to allow starting by addressbook.. 22 // Added by Stefan Eilers to allow starting by addressbook..
23 // copied from old mail2 23 // copied from old mail2
24#if !defined(QT_NO_COP) 24#if !defined(QT_NO_COP)
25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), 25 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ),
26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 26 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
27#endif 27#endif
28 28
29 29
30 30
31} 31}
32 32
33void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 33void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
34{ 34{
35 // copied from old mail2 35 // copied from old mail2
36 if (msg == "writeMail(QString,QString)") { 36 if (msg == "writeMail(QString,QString)") {
37 QDataStream stream(data,IO_ReadOnly); 37 QDataStream stream(data,IO_ReadOnly);
38 QString name, email; 38 QString name, email;
39 stream >> name >> email; 39 stream >> name >> email;
40 // removing the whitespaces at beginning and end is needed! 40 // removing the whitespaces at beginning and end is needed!
41 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 41 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
42 } else if (msg == "newMail()") { 42 } else if (msg == "newMail()") {
43 slotComposeMail(); 43 slotComposeMail();
44 } 44 }
45} 45}
46 46
47void OpieMail::slotwriteMail(const QString&name,const QString&email) 47void OpieMail::slotwriteMail(const QString&name,const QString&email)
48{ 48{
49 ComposeMail compose( settings, this, 0 , true ); 49 ComposeMail compose( settings, this, 0 , true );
50 if (!email.isEmpty()) { 50 if (!email.isEmpty()) {
51 if (!name.isEmpty()) { 51 if (!name.isEmpty()) {
52 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 52 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
53 } else { 53 } else {
54 compose.setTo(email); 54 compose.setTo(email);
55 } 55 }
56 } 56 }
57 compose.showMaximized(); 57 compose.showMaximized();
58 compose.slotAdjustColumns(); 58 compose.slotAdjustColumns();
59 compose.exec(); 59 compose.exec();
60} 60}
61 61
62void OpieMail::slotComposeMail() 62void OpieMail::slotComposeMail()
63{ 63{
64 qDebug( "Compose Mail" ); 64 qDebug( "Compose Mail" );
65 slotwriteMail(0l,0l); 65 slotwriteMail(0l,0l);
66} 66}
67 67
68void OpieMail::slotSendQueued() 68void OpieMail::slotSendQueued()
69{ 69{
70 qDebug( "Send Queued" ); 70 qDebug( "Send Queued" );
71 SMTPaccount *smtp = 0; 71 SMTPaccount *smtp = 0;
72 72
73 QList<Account> list = settings->getAccounts(); 73 QList<Account> list = settings->getAccounts();
74 Account *it; 74 Account *it;
75// if (list.count()==1) { 75// if (list.count()==1) {
76 for ( it = list.first(); it; it = list.next() ) { 76 for ( it = list.first(); it; it = list.next() ) {
77 if ( it->getType().compare( "SMTP" ) == 0 ) { 77 if ( it->getType().compare( "SMTP" ) == 0 ) {
78 smtp = static_cast<SMTPaccount *>(it); 78 smtp = static_cast<SMTPaccount *>(it);
79 break; 79 break;
80 } 80 }
81 } 81 }
82// } 82// }
83 if (smtp) { 83 if (smtp) {
84 SMTPwrapper * wrap = new SMTPwrapper(settings); 84 SMTPwrapper * wrap = new SMTPwrapper(settings);
85 if ( wrap->flushOutbox(smtp) ) { 85 if ( wrap->flushOutbox(smtp) ) {
86 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 86 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
87 } 87 }
88 } 88 }
89} 89}
90 90
91void OpieMail::slotSearchMails() 91void OpieMail::slotSearchMails()
92{ 92{
93 qDebug( "Search Mails" ); 93 qDebug( "Search Mails" );
94} 94}
95 95
96void OpieMail::slotEditSettings() 96void OpieMail::slotEditSettings()
97{ 97{
98 SettingsDialog settingsDialog( this, 0, true ); 98 SettingsDialog settingsDialog( this, 0, true );
99 settingsDialog.showMaximized(); 99 settingsDialog.showMaximized();
100 settingsDialog.exec(); 100 settingsDialog.exec();
101} 101}
102 102
103void OpieMail::slotEditAccounts() 103void OpieMail::slotEditAccounts()
104{ 104{
105 qDebug( "Edit Accounts" ); 105 qDebug( "Edit Accounts" );
106 EditAccounts eaDialog( settings, this, 0, true ); 106 EditAccounts eaDialog( settings, this, 0, true );
107 eaDialog.showMaximized(); 107 eaDialog.showMaximized();
108 eaDialog.slotAdjustColumns(); 108 eaDialog.slotAdjustColumns();
109 eaDialog.exec(); 109 eaDialog.exec();
110 if ( settings ) delete settings; 110 if ( settings ) delete settings;
111 settings = new Settings(); 111 settings = new Settings();
112 112
113 folderView->populate( settings->getAccounts() ); 113 folderView->populate( settings->getAccounts() );
114} 114}
115 115
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 4e3c974..ebed5d8 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,29 +1,30 @@
1#ifndef OPIEMAIL_H 1#ifndef OPIEMAIL_H
2#define OPIEMAIL_H 2#define OPIEMAIL_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "settings.h" 5#include <libmailwrapper/settings.h>
6
6 7
7class OpieMail : public MainWindow 8class OpieMail : public MainWindow
8{ 9{
9 Q_OBJECT 10 Q_OBJECT
10 11
11public: 12public:
12 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 13 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
13 static QString appName() { return QString::fromLatin1("opiemail"); } 14 static QString appName() { return QString::fromLatin1("opiemail"); }
14 15
15public slots: 16public slots:
16 virtual void slotwriteMail(const QString&name,const QString&email); 17 virtual void slotwriteMail(const QString&name,const QString&email);
17 virtual void slotComposeMail(); 18 virtual void slotComposeMail();
18 virtual void appMessage(const QCString &msg, const QByteArray &data); 19 virtual void appMessage(const QCString &msg, const QByteArray &data);
19protected slots: 20protected slots:
20 virtual void slotSendQueued(); 21 virtual void slotSendQueued();
21 virtual void slotSearchMails(); 22 virtual void slotSearchMails();
22 virtual void slotEditSettings(); 23 virtual void slotEditSettings();
23 virtual void slotEditAccounts(); 24 virtual void slotEditAccounts();
24private: 25private:
25 Settings *settings; 26 Settings *settings;
26 27
27}; 28};
28 29
29#endif 30#endif
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index ed77eb5..9ca6383 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,429 +1,429 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qaction.h> 4#include <qaction.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qapplication.h> 7#include <qapplication.h>
8#include <qvaluelist.h> 8#include <qvaluelist.h>
9 9
10#include <qpe/config.h> 10#include <qpe/config.h>
11 11
12#include <opie/ofiledialog.h> 12#include <opie/ofiledialog.h>
13 13
14#include "settings.h" 14#include <libmailwrapper/settings.h>
15#include "composemail.h" 15#include "composemail.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "abstractmail.h" 17#include <libmailwrapper/abstractmail.h>
18#include "accountview.h" 18#include "accountview.h"
19#include "mailtypes.h" 19#include <libmailwrapper/mailtypes.h>
20 20
21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path) 22 const QString&fsize,int num,const QValueList<int>&path)
23 : QListViewItem(parent,after),_partNum(num) 23 : QListViewItem(parent,after),_partNum(num)
24{ 24{
25 _path=path; 25 _path=path;
26 setText(0, mime); 26 setText(0, mime);
27 setText(1, desc); 27 setText(1, desc);
28 setText(2, file); 28 setText(2, file);
29 setText(3, fsize); 29 setText(3, fsize);
30} 30}
31 31
32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 33 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 34 : QListViewItem(parent,after),_partNum(num)
35{ 35{
36 _path=path; 36 _path=path;
37 setText(0, mime); 37 setText(0, mime);
38 setText(1, desc); 38 setText(1, desc);
39 setText(2, file); 39 setText(2, file);
40 setText(3, fsize); 40 setText(3, fsize);
41} 41}
42 42
43bool AttachItem::isParentof(const QValueList<int>&path) 43bool AttachItem::isParentof(const QValueList<int>&path)
44{ 44{
45 /* if not set, then no parent */ 45 /* if not set, then no parent */
46 if (path.count()==0||_path.count()==0) return false; 46 if (path.count()==0||_path.count()==0) return false;
47 /* the parent must have one digit less then a child */ 47 /* the parent must have one digit less then a child */
48 if (path.count()!=_path.count()+1) return false; 48 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) { 49 for (unsigned int i=0; i < _path.count();++i) {
50 if (_path[i]!=path[i]) return false; 50 if (_path[i]!=path[i]) return false;
51 } 51 }
52 return true; 52 return true;
53} 53}
54 54
55AttachItem* ViewMail::searchParent(const QValueList<int>&path) 55AttachItem* ViewMail::searchParent(const QValueList<int>&path)
56{ 56{
57 QListViewItemIterator it( attachments ); 57 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) { 58 for ( ; it.current(); ++it ) {
59 AttachItem*ati = (AttachItem*)it.current(); 59 AttachItem*ati = (AttachItem*)it.current();
60 if (ati->isParentof(path)) return ati; 60 if (ati->isParentof(path)) return ati;
61 } 61 }
62 return 0; 62 return 0;
63} 63}
64 64
65AttachItem* ViewMail::lastChild(AttachItem*parent) 65AttachItem* ViewMail::lastChild(AttachItem*parent)
66{ 66{
67 if (!parent) return 0; 67 if (!parent) return 0;
68 AttachItem* item = (AttachItem*)parent->firstChild(); 68 AttachItem* item = (AttachItem*)parent->firstChild();
69 if (!item) return item; 69 if (!item) return item;
70 AttachItem*temp=0; 70 AttachItem*temp=0;
71 while( (temp=(AttachItem*)item->nextSibling())) { 71 while( (temp=(AttachItem*)item->nextSibling())) {
72 item = temp; 72 item = temp;
73 } 73 }
74 return item; 74 return item;
75} 75}
76 76
77void ViewMail::setBody( RecBody body ) { 77void ViewMail::setBody( RecBody body ) {
78 78
79m_body = body; 79m_body = body;
80m_mail[2] = body.Bodytext(); 80m_mail[2] = body.Bodytext();
81attachbutton->setEnabled(body.Parts().count()>0); 81attachbutton->setEnabled(body.Parts().count()>0);
82attachments->setEnabled(body.Parts().count()>0); 82attachments->setEnabled(body.Parts().count()>0);
83if (body.Parts().count()==0) { 83if (body.Parts().count()==0) {
84 return; 84 return;
85} 85}
86AttachItem * curItem=0; 86AttachItem * curItem=0;
87AttachItem * parentItem = 0; 87AttachItem * parentItem = 0;
88QString type=body.Description().Type()+"/"+body.Description().Subtype(); 88QString type=body.Description().Type()+"/"+body.Description().Subtype();
89QString desc,fsize; 89QString desc,fsize;
90double s = body.Description().Size(); 90double s = body.Description().Size();
91int w; 91int w;
92w=0; 92w=0;
93 93
94while (s>1024) { 94while (s>1024) {
95 s/=1024; 95 s/=1024;
96 ++w; 96 ++w;
97 if (w>=2) break; 97 if (w>=2) break;
98} 98}
99 99
100QString q=""; 100QString q="";
101switch(w) { 101switch(w) {
102case 1: 102case 1:
103 q="k"; 103 q="k";
104 break; 104 break;
105case 2: 105case 2:
106 q="M"; 106 q="M";
107 break; 107 break;
108default: 108default:
109 break; 109 break;
110} 110}
111 111
112{ 112{
113 /* I did not found a method to make a CONTENT reset on a QTextStream 113 /* I did not found a method to make a CONTENT reset on a QTextStream
114 so I use this construct that the stream will re-constructed in each 114 so I use this construct that the stream will re-constructed in each
115 loop. To let it work, the textstream is packed into a own area of 115 loop. To let it work, the textstream is packed into a own area of
116 code is it will be destructed after finishing its small job. 116 code is it will be destructed after finishing its small job.
117 */ 117 */
118 QTextOStream o(&fsize); 118 QTextOStream o(&fsize);
119 if (w>0) o.precision(2); else o.precision(0); 119 if (w>0) o.precision(2); else o.precision(0);
120 o.setf(QTextStream::fixed); 120 o.setf(QTextStream::fixed);
121 o << s << " " << q << "Byte"; 121 o << s << " " << q << "Byte";
122} 122}
123 123
124curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); 124curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
125QString filename = ""; 125QString filename = "";
126 126
127for (unsigned int i = 0; i < body.Parts().count();++i) { 127for (unsigned int i = 0; i < body.Parts().count();++i) {
128 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 128 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
129 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 129 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
130 for (;it!=body.Parts()[i].Parameters().end();++it) { 130 for (;it!=body.Parts()[i].Parameters().end();++it) {
131 qDebug(it.key()); 131 qDebug(it.key());
132 if (it.key().lower()=="name") { 132 if (it.key().lower()=="name") {
133 filename=it.data(); 133 filename=it.data();
134 } 134 }
135 } 135 }
136 s = body.Parts()[i].Size(); 136 s = body.Parts()[i].Size();
137 w = 0; 137 w = 0;
138 while (s>1024) { 138 while (s>1024) {
139 s/=1024; 139 s/=1024;
140 ++w; 140 ++w;
141 if (w>=2) break; 141 if (w>=2) break;
142 } 142 }
143 switch(w) { 143 switch(w) {
144 case 1: 144 case 1:
145 q="k"; 145 q="k";
146 break; 146 break;
147 case 2: 147 case 2:
148 q="M"; 148 q="M";
149 break; 149 break;
150 default: 150 default:
151 q=""; 151 q="";
152 break; 152 break;
153 } 153 }
154 QTextOStream o(&fsize); 154 QTextOStream o(&fsize);
155 if (w>0) o.precision(2); else o.precision(0); 155 if (w>0) o.precision(2); else o.precision(0);
156 o.setf(QTextStream::fixed); 156 o.setf(QTextStream::fixed);
157 o << s << " " << q << "Byte"; 157 o << s << " " << q << "Byte";
158 desc = body.Parts()[i].Description(); 158 desc = body.Parts()[i].Description();
159 parentItem = searchParent(body.Parts()[i].Positionlist()); 159 parentItem = searchParent(body.Parts()[i].Positionlist());
160 if (parentItem) { 160 if (parentItem) {
161 AttachItem*temp = lastChild(parentItem); 161 AttachItem*temp = lastChild(parentItem);
162 if (temp) curItem = temp; 162 if (temp) curItem = temp;
163 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 163 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
164 attachments->setRootIsDecorated(true); 164 attachments->setRootIsDecorated(true);
165 curItem = parentItem; 165 curItem = parentItem;
166 } else { 166 } else {
167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
168 } 168 }
169} 169}
170} 170}
171 171
172 172
173void ViewMail::slotShowHtml( bool state ) { 173void ViewMail::slotShowHtml( bool state ) {
174 m_showHtml = state; 174 m_showHtml = state;
175 setText(); 175 setText();
176} 176}
177 177
178void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { 178void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) {
179 if (!item ) 179 if (!item )
180 return; 180 return;
181 181
182 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 182 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
183 setText(); 183 setText();
184 return; 184 return;
185 } 185 }
186 QPopupMenu *menu = new QPopupMenu(); 186 QPopupMenu *menu = new QPopupMenu();
187 int ret=0; 187 int ret=0;
188 188
189 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { 189 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) {
190 menu->insertItem( tr( "Show Text" ), 1 ); 190 menu->insertItem( tr( "Show Text" ), 1 );
191 } 191 }
192 menu->insertItem( tr( "Save Attachment" ), 0 ); 192 menu->insertItem( tr( "Save Attachment" ), 0 );
193 menu->insertSeparator(1); 193 menu->insertSeparator(1);
194 194
195 ret = menu->exec( point, 0 ); 195 ret = menu->exec( point, 0 );
196 196
197 switch(ret) { 197 switch(ret) {
198 case 0: 198 case 0:
199 { MimeTypes types; 199 { MimeTypes types;
200 types.insert( "all", "*" ); 200 types.insert( "all", "*" );
201 QString str = OFileDialog::getSaveFileName( 1, 201 QString str = OFileDialog::getSaveFileName( 1,
202 "/", item->text( 2 ) , types, 0 ); 202 "/", item->text( 2 ) , types, 0 );
203 203
204 if( !str.isEmpty() ) { 204 if( !str.isEmpty() ) {
205 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 205 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
206 if (content) { 206 if (content) {
207 QFile output(str); 207 QFile output(str);
208 output.open(IO_WriteOnly); 208 output.open(IO_WriteOnly);
209 output.writeBlock(content->Content(),content->Length()); 209 output.writeBlock(content->Content(),content->Length());
210 output.close(); 210 output.close();
211 delete content; 211 delete content;
212 } 212 }
213 } 213 }
214 } 214 }
215 break ; 215 break ;
216 216
217 case 1: 217 case 1:
218 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 218 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
219 setText(); 219 setText();
220 } else { 220 } else {
221 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 221 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions
222 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 222 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
223 } 223 }
224 } 224 }
225 break; 225 break;
226 } 226 }
227 delete menu; 227 delete menu;
228} 228}
229 229
230 230
231void ViewMail::setMail( RecMail mail ) { 231void ViewMail::setMail( RecMail mail ) {
232 232
233 m_recMail = mail; 233 m_recMail = mail;
234 234
235 m_mail[0] = mail.getFrom(); 235 m_mail[0] = mail.getFrom();
236 m_mail[1] = mail.getSubject(); 236 m_mail[1] = mail.getSubject();
237 m_mail[3] = mail.getDate(); 237 m_mail[3] = mail.getDate();
238 m_mail[4] = mail.Msgid(); 238 m_mail[4] = mail.Msgid();
239 239
240 m_mail2[0] = mail.To(); 240 m_mail2[0] = mail.To();
241 m_mail2[1] = mail.CC(); 241 m_mail2[1] = mail.CC();
242 m_mail2[2] = mail.Bcc(); 242 m_mail2[2] = mail.Bcc();
243 243
244 setText(); 244 setText();
245} 245}
246 246
247 247
248 248
249ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 249ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
250 : ViewMailBase(parent, name, fl), _inLoop(false) 250 : ViewMailBase(parent, name, fl), _inLoop(false)
251{ 251{
252 m_gotBody = false; 252 m_gotBody = false;
253 deleted = false; 253 deleted = false;
254 254
255 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 255 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
256 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 256 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
257 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); 257 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) );
258 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); 258 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) );
259 259
260 attachments->setEnabled(m_gotBody); 260 attachments->setEnabled(m_gotBody);
261 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); 261 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
262 262
263 readConfig(); 263 readConfig();
264 attachments->setSorting(-1); 264 attachments->setSorting(-1);
265} 265}
266 266
267void ViewMail::readConfig() { 267void ViewMail::readConfig() {
268 Config cfg( "mail" ); 268 Config cfg( "mail" );
269 cfg.setGroup( "Settings" ); 269 cfg.setGroup( "Settings" );
270 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 270 m_showHtml = cfg.readBoolEntry( "showHtml", false );
271 showHtml->setOn( m_showHtml ); 271 showHtml->setOn( m_showHtml );
272} 272}
273 273
274void ViewMail::setText() 274void ViewMail::setText()
275{ 275{
276 276
277 QString toString; 277 QString toString;
278 QString ccString; 278 QString ccString;
279 QString bccString; 279 QString bccString;
280 280
281 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 281 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) {
282 toString += (*it); 282 toString += (*it);
283 } 283 }
284 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 284 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) {
285 ccString += (*it); 285 ccString += (*it);
286 } 286 }
287 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 287 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) {
288 bccString += (*it); 288 bccString += (*it);
289 } 289 }
290 290
291 setCaption( caption().arg( m_mail[0] ) ); 291 setCaption( caption().arg( m_mail[0] ) );
292 292
293 m_mailHtml = "<html><body>" 293 m_mailHtml = "<html><body>"
294 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 294 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
295 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 295 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
296 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 296 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
297 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 297 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
298 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 298 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
299 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 299 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
300 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 300 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
301 "</td></tr></table><font face=fixed>"; 301 "</td></tr></table><font face=fixed>";
302 302
303 if ( !m_showHtml ) { 303 if ( !m_showHtml ) {
304 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 304 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
305 } else { 305 } else {
306 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 306 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
307 } 307 }
308 // remove later in favor of a real handling 308 // remove later in favor of a real handling
309 m_gotBody = true; 309 m_gotBody = true;
310} 310}
311 311
312 312
313ViewMail::~ViewMail() 313ViewMail::~ViewMail()
314{ 314{
315 m_recMail.Wrapper()->cleanMimeCache(); 315 m_recMail.Wrapper()->cleanMimeCache();
316 hide(); 316 hide();
317} 317}
318 318
319void ViewMail::hide() 319void ViewMail::hide()
320{ 320{
321 QWidget::hide(); 321 QWidget::hide();
322 322
323 if (_inLoop) { 323 if (_inLoop) {
324 _inLoop = false; 324 _inLoop = false;
325 qApp->exit_loop(); 325 qApp->exit_loop();
326 326
327 } 327 }
328 328
329} 329}
330 330
331void ViewMail::exec() 331void ViewMail::exec()
332{ 332{
333 show(); 333 show();
334 334
335 if (!_inLoop) { 335 if (!_inLoop) {
336 _inLoop = true; 336 _inLoop = true;
337 qApp->enter_loop(); 337 qApp->enter_loop();
338 } 338 }
339 339
340} 340}
341 341
342QString ViewMail::deHtml(const QString &string) 342QString ViewMail::deHtml(const QString &string)
343{ 343{
344 QString string_ = string; 344 QString string_ = string;
345 string_.replace(QRegExp("&"), "&amp;"); 345 string_.replace(QRegExp("&"), "&amp;");
346 string_.replace(QRegExp("<"), "&lt;"); 346 string_.replace(QRegExp("<"), "&lt;");
347 string_.replace(QRegExp(">"), "&gt;"); 347 string_.replace(QRegExp(">"), "&gt;");
348 string_.replace(QRegExp("\\n"), "<br>"); 348 string_.replace(QRegExp("\\n"), "<br>");
349 return string_; 349 return string_;
350} 350}
351 351
352void ViewMail::slotReply() 352void ViewMail::slotReply()
353{ 353{
354 if (!m_gotBody) { 354 if (!m_gotBody) {
355 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 355 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
356 return; 356 return;
357 } 357 }
358 358
359 QString rtext; 359 QString rtext;
360 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 360 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
361 .arg( m_mail[0] ) 361 .arg( m_mail[0] )
362 .arg( m_mail[3] ); 362 .arg( m_mail[3] );
363 363
364 QString text = m_mail[2]; 364 QString text = m_mail[2];
365 QStringList lines = QStringList::split(QRegExp("\\n"), text); 365 QStringList lines = QStringList::split(QRegExp("\\n"), text);
366 QStringList::Iterator it; 366 QStringList::Iterator it;
367 for (it = lines.begin(); it != lines.end(); it++) { 367 for (it = lines.begin(); it != lines.end(); it++) {
368 rtext += "> " + *it + "\n"; 368 rtext += "> " + *it + "\n";
369 } 369 }
370 rtext += "\n"; 370 rtext += "\n";
371 371
372 QString prefix; 372 QString prefix;
373 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 373 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
374 else prefix = "Re: "; // no i18n on purpose 374 else prefix = "Re: "; // no i18n on purpose
375 375
376 Settings *settings = new Settings(); 376 Settings *settings = new Settings();
377 ComposeMail composer( settings ,this, 0, true); 377 ComposeMail composer( settings ,this, 0, true);
378 composer.setTo( m_mail[0] ); 378 composer.setTo( m_mail[0] );
379 composer.setSubject( "Re: " + m_mail[1] ); 379 composer.setSubject( "Re: " + m_mail[1] );
380 composer.setMessage( rtext ); 380 composer.setMessage( rtext );
381 composer.showMaximized(); 381 composer.showMaximized();
382 if ( QDialog::Accepted==composer.exec()) { 382 if ( QDialog::Accepted==composer.exec()) {
383 m_recMail.Wrapper()->answeredMail(m_recMail); 383 m_recMail.Wrapper()->answeredMail(m_recMail);
384 } 384 }
385} 385}
386 386
387void ViewMail::slotForward() 387void ViewMail::slotForward()
388{ 388{
389 if (!m_gotBody) { 389 if (!m_gotBody) {
390 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 390 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
391 return; 391 return;
392 } 392 }
393 393
394 QString ftext; 394 QString ftext;
395 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 395 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
396 .arg( m_mail[0] ); 396 .arg( m_mail[0] );
397 if (!m_mail[3].isNull()) 397 if (!m_mail[3].isNull())
398 ftext += QString("Date: %1\n") 398 ftext += QString("Date: %1\n")
399 .arg( m_mail[3] ); 399 .arg( m_mail[3] );
400 if (!m_mail[0].isNull()) 400 if (!m_mail[0].isNull())
401 ftext += QString("From: %1\n") 401 ftext += QString("From: %1\n")
402 .arg( m_mail[0] ); 402 .arg( m_mail[0] );
403 if (!m_mail[1].isNull()) 403 if (!m_mail[1].isNull())
404 ftext += QString("Subject: %1\n") 404 ftext += QString("Subject: %1\n")
405 .arg( m_mail[1] ); 405 .arg( m_mail[1] );
406 406
407 ftext += QString("\n%1\n") 407 ftext += QString("\n%1\n")
408 .arg( m_mail[2]); 408 .arg( m_mail[2]);
409 409
410 ftext += QString("----- End forwarded message -----\n"); 410 ftext += QString("----- End forwarded message -----\n");
411 411
412 Settings *settings = new Settings(); 412 Settings *settings = new Settings();
413 ComposeMail composer( settings ,this, 0, true); 413 ComposeMail composer( settings ,this, 0, true);
414 composer.setSubject( "Fwd: " + m_mail[1] ); 414 composer.setSubject( "Fwd: " + m_mail[1] );
415 composer.setMessage( ftext ); 415 composer.setMessage( ftext );
416 composer.showMaximized(); 416 composer.showMaximized();
417 if ( QDialog::Accepted==composer.exec()) { 417 if ( QDialog::Accepted==composer.exec()) {
418 418
419 } 419 }
420} 420}
421 421
422void ViewMail::slotDeleteMail( ) 422void ViewMail::slotDeleteMail( )
423{ 423{
424 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 424 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
425 m_recMail.Wrapper()->deleteMail( m_recMail ); 425 m_recMail.Wrapper()->deleteMail( m_recMail );
426 hide(); 426 hide();
427 deleted = true; 427 deleted = true;
428 } 428 }
429} 429}
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 29681cc..2d0e024 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -1,72 +1,73 @@
1#ifndef VIEWMAIL_H 1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H 2#define VIEWMAIL_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8 8
9#include "viewmailbase.h" 9#include "viewmailbase.h"
10#include "mailtypes.h" 10#include <libmailwrapper/mailtypes.h>
11
11 12
12class AttachItem : public QListViewItem 13class AttachItem : public QListViewItem
13{ 14{
14public: 15public:
15 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 16 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
16 const QString&fsize,int num,const QValueList<int>&path); 17 const QString&fsize,int num,const QValueList<int>&path);
17 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 18 AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
18 const QString&fsize,int num,const QValueList<int>&path); 19 const QString&fsize,int num,const QValueList<int>&path);
19 int Partnumber() { return _partNum; } 20 int Partnumber() { return _partNum; }
20 bool isParentof(const QValueList<int>&path); 21 bool isParentof(const QValueList<int>&path);
21 22
22private: 23private:
23 int _partNum; 24 int _partNum;
24 /* needed for a better display of attachments */ 25 /* needed for a better display of attachments */
25 QValueList<int> _path; 26 QValueList<int> _path;
26}; 27};
27 28
28class ViewMail : public ViewMailBase 29class ViewMail : public ViewMailBase
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31 32
32public: 33public:
33 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); 34 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
34 ~ViewMail(); 35 ~ViewMail();
35 36
36 void hide(); 37 void hide();
37 void exec(); 38 void exec();
38 void setMail( RecMail mail ); 39 void setMail( RecMail mail );
39 void setBody( RecBody body ); 40 void setBody( RecBody body );
40 bool deleted; 41 bool deleted;
41 42
42protected: 43protected:
43 QString deHtml(const QString &string); 44 QString deHtml(const QString &string);
44 AttachItem* searchParent(const QValueList<int>&path); 45 AttachItem* searchParent(const QValueList<int>&path);
45 AttachItem* lastChild(AttachItem*parent); 46 AttachItem* lastChild(AttachItem*parent);
46 47
47protected slots: 48protected slots:
48 void slotReply(); 49 void slotReply();
49 void slotForward(); 50 void slotForward();
50 void setText(); 51 void setText();
51 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 52 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
52 void slotDeleteMail( ); 53 void slotDeleteMail( );
53 void slotShowHtml( bool ); 54 void slotShowHtml( bool );
54 55
55private: 56private:
56 void readConfig(); 57 void readConfig();
57 58
58 bool _inLoop; 59 bool _inLoop;
59 QString m_mailHtml; 60 QString m_mailHtml;
60 bool m_gotBody; 61 bool m_gotBody;
61 RecBody m_body; 62 RecBody m_body;
62 RecMail m_recMail; 63 RecMail m_recMail;
63 bool m_showHtml; 64 bool m_showHtml;
64 65
65 // 0 from 1 subject 2 bodytext 3 date 66 // 0 from 1 subject 2 bodytext 3 date
66 QMap <int,QString> m_mail; 67 QMap <int,QString> m_mail;
67 // 0 to 1 cc 2 bcc 68 // 0 to 1 cc 2 bcc
68 QMap <int,QStringList> m_mail2; 69 QMap <int,QStringList> m_mail2;
69 70
70}; 71};
71 72
72#endif 73#endif