summaryrefslogtreecommitdiff
path: root/noncore/net/mail
Unidiff
Diffstat (limited to 'noncore/net/mail') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp309
-rw-r--r--noncore/net/mail/accountview.cpp48
-rw-r--r--noncore/net/mail/addresspicker.cpp120
-rw-r--r--noncore/net/mail/editaccounts.cpp183
-rw-r--r--noncore/net/mail/opiemail.cpp113
-rw-r--r--noncore/net/mail/viewmail.cpp513
6 files changed, 763 insertions, 523 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 2d3cd4b..c8f6ec4 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,28 +1,37 @@
1
1#include "accountitem.h" 2#include "accountitem.h"
2#include "accountview.h" 3#include "accountview.h"
3#include <qpopupmenu.h>
4#include <qmessagebox.h>
5#include "selectstore.h" 4#include "selectstore.h"
6#include "newmaildir.h" 5#include "newmaildir.h"
6#include "defines.h"
7
8/* OPIE */
7#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
8#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
9#include <libmailwrapper/mailwrapper.h> 11#include <libmailwrapper/mailwrapper.h>
10#include "defines.h" 12#include <qpe/qpeapplication.h>
13
14/* QT */
15#include <qpopupmenu.h>
16#include <qmessagebox.h>
11 17
12#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} 18#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
13/** 19/**
14 * POP3 Account stuff 20 * POP3 Account stuff
15 */ 21 */
16POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 22POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
17 : AccountViewItem( parent ) 23 : AccountViewItem( parent )
18{ 24{
19 account = a; 25 account = a;
20 wrapper = AbstractMail::getWrapper( account ); 26 wrapper = AbstractMail::getWrapper( account );
21 SETPIX(PIXMAP_POP3FOLDER); 27 SETPIX(PIXMAP_POP3FOLDER);
22#if 0 28#if 0
23 if (!account->getOffline()) { 29 if (!account->getOffline())
30 {
24 setPixmap( 0, ); 31 setPixmap( 0, );
25 } else { 32 }
33 else
34 {
26 setPixmap( 0, PIXMAP_OFFLINE ); 35 setPixmap( 0, PIXMAP_OFFLINE );
27 } 36 }
28#endif 37#endif
@@ -50,14 +59,16 @@ void POP3viewItem::refresh()
50 if (account->getOffline()) return; 59 if (account->getOffline()) return;
51 QList<Folder> *folders = wrapper->listFolders(); 60 QList<Folder> *folders = wrapper->listFolders();
52 QListViewItem *child = firstChild(); 61 QListViewItem *child = firstChild();
53 while ( child ) { 62 while ( child )
63 {
54 QListViewItem *tmp = child; 64 QListViewItem *tmp = child;
55 child = child->nextSibling(); 65 child = child->nextSibling();
56 delete tmp; 66 delete tmp;
57 } 67 }
58 Folder *it; 68 Folder *it;
59 QListViewItem*item = 0; 69 QListViewItem*item = 0;
60 for ( it = folders->first(); it; it = folders->next() ) { 70 for ( it = folders->first(); it; it = folders->next() )
71 {
61 item = new POP3folderItem( it, this , item ); 72 item = new POP3folderItem( it, this , item );
62 item->setSelectable(it->may_select()); 73 item->setSelectable(it->may_select());
63 } 74 }
@@ -75,11 +86,15 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail )
75QPopupMenu * POP3viewItem::getContextMenu() 86QPopupMenu * POP3viewItem::getContextMenu()
76{ 87{
77 QPopupMenu *m = new QPopupMenu(0); 88 QPopupMenu *m = new QPopupMenu(0);
78 if (m) { 89 if (m)
79 if (!account->getOffline()) { 90 {
91 if (!account->getOffline())
92 {
80 m->insertItem(QObject::tr("Disconnect",contextName),0); 93 m->insertItem(QObject::tr("Disconnect",contextName),0);
81 m->insertItem(QObject::tr("Set offline",contextName),1); 94 m->insertItem(QObject::tr("Set offline",contextName),1);
82 } else { 95 }
96 else
97 {
83 m->insertItem(QObject::tr("Set online",contextName),1); 98 m->insertItem(QObject::tr("Set online",contextName),1);
84 } 99 }
85 } 100 }
@@ -89,7 +104,8 @@ QPopupMenu * POP3viewItem::getContextMenu()
89void POP3viewItem::disconnect() 104void POP3viewItem::disconnect()
90{ 105{
91 QListViewItem *child = firstChild(); 106 QListViewItem *child = firstChild();
92 while ( child ) { 107 while ( child )
108 {
93 QListViewItem *tmp = child; 109 QListViewItem *tmp = child;
94 child = child->nextSibling(); 110 child = child->nextSibling();
95 delete tmp; 111 delete tmp;
@@ -99,7 +115,8 @@ void POP3viewItem::disconnect()
99 115
100void POP3viewItem::setOnOffline() 116void POP3viewItem::setOnOffline()
101{ 117{
102 if (!account->getOffline()) { 118 if (!account->getOffline())
119 {
103 disconnect(); 120 disconnect();
104 } 121 }
105 account->setOffline(!account->getOffline()); 122 account->setOffline(!account->getOffline());
@@ -110,7 +127,8 @@ void POP3viewItem::setOnOffline()
110 127
111void POP3viewItem::contextMenuSelected(int which) 128void POP3viewItem::contextMenuSelected(int which)
112{ 129{
113 switch (which) { 130 switch (which)
131 {
114 case 0: 132 case 0:
115 disconnect(); 133 disconnect();
116 break; 134 break;
@@ -121,17 +139,19 @@ void POP3viewItem::contextMenuSelected(int which)
121} 139}
122 140
123POP3folderItem::~POP3folderItem() 141POP3folderItem::~POP3folderItem()
124{ 142{}
125}
126 143
127POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) 144POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
128 : AccountViewItem( parent,after ) 145 : AccountViewItem( parent,after )
129{ 146{
130 folder = folderInit; 147 folder = folderInit;
131 pop3 = parent; 148 pop3 = parent;
132 if (folder->getDisplayName().lower()!="inbox") { 149 if (folder->getDisplayName().lower()!="inbox")
150 {
133 setPixmap( 0, PIXMAP_POP3FOLDER ); 151 setPixmap( 0, PIXMAP_POP3FOLDER );
134 } else { 152 }
153 else
154 {
135 setPixmap( 0, PIXMAP_INBOXFOLDER); 155 setPixmap( 0, PIXMAP_INBOXFOLDER);
136 } 156 }
137 setText( 0, folder->getDisplayName() ); 157 setText( 0, folder->getDisplayName() );
@@ -151,7 +171,8 @@ RecBody POP3folderItem::fetchBody(const RecMail&aMail)
151QPopupMenu * POP3folderItem::getContextMenu() 171QPopupMenu * POP3folderItem::getContextMenu()
152{ 172{
153 QPopupMenu *m = new QPopupMenu(0); 173 QPopupMenu *m = new QPopupMenu(0);
154 if (m) { 174 if (m)
175 {
155 m->insertItem(QObject::tr("Refresh header list",contextName),0); 176 m->insertItem(QObject::tr("Refresh header list",contextName),0);
156 m->insertItem(QObject::tr("Delete all mails",contextName),1); 177 m->insertItem(QObject::tr("Delete all mails",contextName),1);
157 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 178 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
@@ -169,7 +190,8 @@ void POP3folderItem::downloadMails()
169void POP3folderItem::contextMenuSelected(int which) 190void POP3folderItem::contextMenuSelected(int which)
170{ 191{
171 AccountView * view = (AccountView*)listView(); 192 AccountView * view = (AccountView*)listView();
172 switch (which) { 193 switch (which)
194 {
173 case 0: 195 case 0:
174 /* must be 'cause pop3 lists are cached */ 196 /* must be 'cause pop3 lists are cached */
175 pop3->getWrapper()->logout(); 197 pop3->getWrapper()->logout();
@@ -190,7 +212,7 @@ void POP3folderItem::contextMenuSelected(int which)
190 * IMAP Account stuff 212 * IMAP Account stuff
191 */ 213 */
192IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 214IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
193 : AccountViewItem( parent ) 215 : AccountViewItem( parent )
194{ 216{
195 account = a; 217 account = a;
196 wrapper = AbstractMail::getWrapper( account ); 218 wrapper = AbstractMail::getWrapper( account );
@@ -222,7 +244,7 @@ const QStringList&IMAPviewItem::subFolders()
222void IMAPviewItem::refreshFolders(bool force) 244void IMAPviewItem::refreshFolders(bool force)
223{ 245{
224 if (childCount()>0 && force==false) return; 246 if (childCount()>0 && force==false) return;
225 if (account->getOffline()) return; 247 if (account->getOffline()) return;
226 248
227 removeChilds(); 249 removeChilds();
228 currentFolders.clear(); 250 currentFolders.clear();
@@ -236,29 +258,36 @@ void IMAPviewItem::refreshFolders(bool force)
236 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 258 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
237 folders->setAutoDelete(false); 259 folders->setAutoDelete(false);
238 260
239 for ( it = folders->first(); it; it = folders->next() ) { 261 for ( it = folders->first(); it; it = folders->next() )
240 if (it->getDisplayName().lower()=="inbox") { 262 {
263 if (it->getDisplayName().lower()=="inbox")
264 {
241 item = new IMAPfolderItem( it, this , item ); 265 item = new IMAPfolderItem( it, this , item );
242 folders->remove(it); 266 folders->remove(it);
243 qDebug("inbox found"); 267 qDebug("inbox found");
244 break; 268 break;
245 } 269 }
246 } 270 }
247 for ( it = folders->first(); it; it = folders->next() ) { 271 for ( it = folders->first(); it; it = folders->next() )
272 {
248 fname = it->getDisplayName(); 273 fname = it->getDisplayName();
249 currentFolders.append(it->getName()); 274 currentFolders.append(it->getName());
250 pos = fname.findRev(it->Separator()); 275 pos = fname.findRev(it->Separator());
251 if (pos != -1) { 276 if (pos != -1)
277 {
252 fname = fname.left(pos); 278 fname = fname.left(pos);
253 } 279 }
254 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 280 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
255 if (pitem) { 281 if (pitem)
282 {
256 titem = item; 283 titem = item;
257 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); 284 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
258 /* setup the short name */ 285 /* setup the short name */
259 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); 286 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
260 item = titem; 287 item = titem;
261 } else { 288 }
289 else
290 {
262 item = new IMAPfolderItem( it, this , item ); 291 item = new IMAPfolderItem( it, this , item );
263 } 292 }
264 } 293 }
@@ -268,14 +297,18 @@ void IMAPviewItem::refreshFolders(bool force)
268QPopupMenu * IMAPviewItem::getContextMenu() 297QPopupMenu * IMAPviewItem::getContextMenu()
269{ 298{
270 QPopupMenu *m = new QPopupMenu(0); 299 QPopupMenu *m = new QPopupMenu(0);
271 if (m) { 300 if (m)
272 if (!account->getOffline()) { 301 {
302 if (!account->getOffline())
303 {
273 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 304 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
274 m->insertItem(QObject::tr("Create new folder",contextName),1); 305 m->insertItem(QObject::tr("Create new folder",contextName),1);
275 m->insertSeparator(); 306 m->insertSeparator();
276 m->insertItem(QObject::tr("Disconnect",contextName),2); 307 m->insertItem(QObject::tr("Disconnect",contextName),2);
277 m->insertItem(QObject::tr("Set offline",contextName),3); 308 m->insertItem(QObject::tr("Set offline",contextName),3);
278 } else { 309 }
310 else
311 {
279 m->insertItem(QObject::tr("Set online",contextName),3); 312 m->insertItem(QObject::tr("Set online",contextName),3);
280 } 313 }
281 } 314 }
@@ -285,16 +318,18 @@ QPopupMenu * IMAPviewItem::getContextMenu()
285void IMAPviewItem::createNewFolder() 318void IMAPviewItem::createNewFolder()
286{ 319{
287 Newmdirdlg ndirdlg; 320 Newmdirdlg ndirdlg;
288 ndirdlg.showMaximized(); 321 if ( QPEApplication::execDialog( &ndirdlg ))
289 if (ndirdlg.exec()) { 322 {
290 QString ndir = ndirdlg.Newdir(); 323 QString ndir = ndirdlg.Newdir();
291 bool makesubs = ndirdlg.subpossible(); 324 bool makesubs = ndirdlg.subpossible();
292 QString delemiter = "/"; 325 QString delemiter = "/";
293 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 326 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
294 if (item) { 327 if (item)
328 {
295 delemiter = item->Delemiter(); 329 delemiter = item->Delemiter();
296 } 330 }
297 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { 331 if (wrapper->createMbox(ndir,0,delemiter,makesubs))
332 {
298 refreshFolders(true); 333 refreshFolders(true);
299 } 334 }
300 } 335 }
@@ -303,7 +338,8 @@ void IMAPviewItem::createNewFolder()
303void IMAPviewItem::contextMenuSelected(int id) 338void IMAPviewItem::contextMenuSelected(int id)
304{ 339{
305 qDebug("Id selected: %i",id); 340 qDebug("Id selected: %i",id);
306 switch (id) { 341 switch (id)
342 {
307 case 0: 343 case 0:
308 refreshFolders(true); 344 refreshFolders(true);
309 break; 345 break;
@@ -315,7 +351,8 @@ void IMAPviewItem::contextMenuSelected(int id)
315 wrapper->logout(); 351 wrapper->logout();
316 break; 352 break;
317 case 3: 353 case 3:
318 if (account->getOffline()==false) { 354 if (account->getOffline()==false)
355 {
319 removeChilds(); 356 removeChilds();
320 wrapper->logout(); 357 wrapper->logout();
321 } 358 }
@@ -323,7 +360,7 @@ void IMAPviewItem::contextMenuSelected(int id)
323 account->save(); 360 account->save();
324 SETPIX(PIXMAP_IMAPFOLDER); 361 SETPIX(PIXMAP_IMAPFOLDER);
325 refreshFolders(false); 362 refreshFolders(false);
326 break; 363 break;
327 default: 364 default:
328 break; 365 break;
329 } 366 }
@@ -340,34 +377,39 @@ bool IMAPviewItem::offline()
340} 377}
341 378
342IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 379IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
343 : AccountViewItem( parent , after ) 380 : AccountViewItem( parent , after )
344{ 381{
345 folder = folderInit; 382 folder = folderInit;
346 imap = parent; 383 imap = parent;
347 if (folder->getDisplayName().lower()!="inbox") { 384 if (folder->getDisplayName().lower()!="inbox")
385 {
348 setPixmap( 0, PIXMAP_IMAPFOLDER ); 386 setPixmap( 0, PIXMAP_IMAPFOLDER );
349 } else { 387 }
388 else
389 {
350 setPixmap( 0, PIXMAP_INBOXFOLDER); 390 setPixmap( 0, PIXMAP_INBOXFOLDER);
351 } 391 }
352 setText( 0, folder->getDisplayName() ); 392 setText( 0, folder->getDisplayName() );
353} 393}
354 394
355IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 395IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
356 : AccountViewItem( parent,after ) 396 : AccountViewItem( parent,after )
357{ 397{
358 folder = folderInit; 398 folder = folderInit;
359 imap = master; 399 imap = master;
360 if (folder->getDisplayName().lower()!="inbox") { 400 if (folder->getDisplayName().lower()!="inbox")
401 {
361 setPixmap( 0, PIXMAP_IMAPFOLDER ); 402 setPixmap( 0, PIXMAP_IMAPFOLDER );
362 } else { 403 }
404 else
405 {
363 setPixmap( 0, PIXMAP_INBOXFOLDER); 406 setPixmap( 0, PIXMAP_INBOXFOLDER);
364 } 407 }
365 setText( 0, folder->getDisplayName() ); 408 setText( 0, folder->getDisplayName() );
366} 409}
367 410
368IMAPfolderItem::~IMAPfolderItem() 411IMAPfolderItem::~IMAPfolderItem()
369{ 412{}
370}
371 413
372const QString& IMAPfolderItem::Delemiter()const 414const QString& IMAPfolderItem::Delemiter()const
373{ 415{
@@ -376,9 +418,12 @@ const QString& IMAPfolderItem::Delemiter()const
376 418
377void IMAPfolderItem::refresh(QList<RecMail>&target) 419void IMAPfolderItem::refresh(QList<RecMail>&target)
378{ 420{
379 if (folder->may_select()) { 421 if (folder->may_select())
422 {
380 imap->getWrapper()->listMessages( folder->getName(),target ); 423 imap->getWrapper()->listMessages( folder->getName(),target );
381 } else { 424 }
425 else
426 {
382 target.clear(); 427 target.clear();
383 } 428 }
384} 429}
@@ -391,16 +436,20 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
391QPopupMenu * IMAPfolderItem::getContextMenu() 436QPopupMenu * IMAPfolderItem::getContextMenu()
392{ 437{
393 QPopupMenu *m = new QPopupMenu(0); 438 QPopupMenu *m = new QPopupMenu(0);
394 if (m) { 439 if (m)
395 if (folder->may_select()) { 440 {
441 if (folder->may_select())
442 {
396 m->insertItem(QObject::tr("Refresh header list",contextName),0); 443 m->insertItem(QObject::tr("Refresh header list",contextName),0);
397 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); 444 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
398 m->insertItem(QObject::tr("Delete all mails",contextName),1); 445 m->insertItem(QObject::tr("Delete all mails",contextName),1);
399 } 446 }
400 if (folder->no_inferior()==false) { 447 if (folder->no_inferior()==false)
448 {
401 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 449 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
402 } 450 }
403 if (folder->getDisplayName().lower()!="inbox") { 451 if (folder->getDisplayName().lower()!="inbox")
452 {
404 m->insertItem(QObject::tr("Delete folder",contextName),3); 453 m->insertItem(QObject::tr("Delete folder",contextName),3);
405 } 454 }
406 } 455 }
@@ -410,12 +459,13 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
410void IMAPfolderItem::createNewFolder() 459void IMAPfolderItem::createNewFolder()
411{ 460{
412 Newmdirdlg ndirdlg; 461 Newmdirdlg ndirdlg;
413 ndirdlg.showMaximized(); 462 if ( QPEApplication::execDialog( &ndirdlg ) )
414 if (ndirdlg.exec()) { 463 {
415 QString ndir = ndirdlg.Newdir(); 464 QString ndir = ndirdlg.Newdir();
416 bool makesubs = ndirdlg.subpossible(); 465 bool makesubs = ndirdlg.subpossible();
417 QString delemiter = Delemiter(); 466 QString delemiter = Delemiter();
418 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { 467 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
468 {
419 imap->refreshFolders(true); 469 imap->refreshFolders(true);
420 } 470 }
421 } 471 }
@@ -424,18 +474,21 @@ void IMAPfolderItem::createNewFolder()
424void IMAPfolderItem::deleteFolder() 474void IMAPfolderItem::deleteFolder()
425{ 475{
426 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 476 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
427 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 477 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
428 QObject::tr("Yes",contextName), 478 QObject::tr("Yes",contextName),
429 QObject::tr("No",contextName),QString::null,1,1); 479 QObject::tr("No",contextName),QString::null,1,1);
430 qDebug("Auswahl: %i",yesno); 480 qDebug("Auswahl: %i",yesno);
431 if (yesno == 0) { 481 if (yesno == 0)
432 if (imap->getWrapper()->deleteMbox(folder)) { 482 {
483 if (imap->getWrapper()->deleteMbox(folder))
484 {
433 QListView*v=listView(); 485 QListView*v=listView();
434 IMAPviewItem * box = imap; 486 IMAPviewItem * box = imap;
435 /* be carefull - after that this object is destroyd so don't use 487 /* be carefull - after that this object is destroyd so don't use
436 * any member of it after that call!!*/ 488 * any member of it after that call!!*/
437 imap->refreshFolders(true); 489 imap->refreshFolders(true);
438 if (v) { 490 if (v)
491 {
439 v->setSelected(box,true); 492 v->setSelected(box,true);
440 } 493 }
441 } 494 }
@@ -453,7 +506,8 @@ void IMAPfolderItem::contextMenuSelected(int id)
453{ 506{
454 qDebug("Selected id: %i",id); 507 qDebug("Selected id: %i",id);
455 AccountView * view = (AccountView*)listView(); 508 AccountView * view = (AccountView*)listView();
456 switch(id) { 509 switch(id)
510 {
457 case 0: 511 case 0:
458 view->refreshCurrent(); 512 view->refreshCurrent();
459 break; 513 break;
@@ -480,7 +534,7 @@ void IMAPfolderItem::contextMenuSelected(int id)
480/* MH is a little bit different - the top folder can contains messages other than in IMAP and 534/* MH is a little bit different - the top folder can contains messages other than in IMAP and
481 POP3 and MBOX */ 535 POP3 and MBOX */
482MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 536MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
483 : AccountViewItem( parent ) 537 : AccountViewItem( parent )
484{ 538{
485 m_Path = aPath; 539 m_Path = aPath;
486 /* be carefull - the space within settext is wanted - thats why the string twice */ 540 /* be carefull - the space within settext is wanted - thats why the string twice */
@@ -518,25 +572,33 @@ void MHviewItem::refresh(bool force)
518 MHfolderItem*pmaster = 0; 572 MHfolderItem*pmaster = 0;
519 QString fname = ""; 573 QString fname = "";
520 int pos; 574 int pos;
521 for ( it = folders->first(); it; it = folders->next() ) { 575 for ( it = folders->first(); it; it = folders->next() )
576 {
522 fname = it->getDisplayName(); 577 fname = it->getDisplayName();
523 /* this folder itself */ 578 /* this folder itself */
524 if (fname=="/") { 579 if (fname=="/")
580 {
525 currentFolders.append(fname); 581 currentFolders.append(fname);
526 folder = it; 582 folder = it;
527 continue; 583 continue;
528 } 584 }
529 currentFolders.append(fname); 585 currentFolders.append(fname);
530 pos = fname.findRev("/"); 586 pos = fname.findRev("/");
531 if (pos > 0) { 587 if (pos > 0)
588 {
532 fname = fname.left(pos); 589 fname = fname.left(pos);
533 pmaster = (MHfolderItem*)findSubItem(fname); 590 pmaster = (MHfolderItem*)findSubItem(fname);
534 } else { 591 }
592 else
593 {
535 pmaster = 0; 594 pmaster = 0;
536 } 595 }
537 if (pmaster) { 596 if (pmaster)
597 {
538 item = new MHfolderItem( it, pmaster, item, this ); 598 item = new MHfolderItem( it, pmaster, item, this );
539 } else { 599 }
600 else
601 {
540 item = new MHfolderItem( it, this , item ); 602 item = new MHfolderItem( it, this , item );
541 } 603 }
542 item->setSelectable(it->may_select()); 604 item->setSelectable(it->may_select());
@@ -555,7 +617,8 @@ RecBody MHviewItem::fetchBody( const RecMail &mail )
555QPopupMenu * MHviewItem::getContextMenu() 617QPopupMenu * MHviewItem::getContextMenu()
556{ 618{
557 QPopupMenu *m = new QPopupMenu(0); 619 QPopupMenu *m = new QPopupMenu(0);
558 if (m) { 620 if (m)
621 {
559 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 622 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
560 m->insertItem(QObject::tr("Create new folder",contextName),1); 623 m->insertItem(QObject::tr("Create new folder",contextName),1);
561 m->insertItem(QObject::tr("Delete all mails",contextName),2); 624 m->insertItem(QObject::tr("Delete all mails",contextName),2);
@@ -567,10 +630,11 @@ QPopupMenu * MHviewItem::getContextMenu()
567void MHviewItem::createFolder() 630void MHviewItem::createFolder()
568{ 631{
569 Newmdirdlg ndirdlg(0,0,true); 632 Newmdirdlg ndirdlg(0,0,true);
570 ndirdlg.showMaximized(); 633 if ( QPEApplication::execDialog( &ndirdlg ) )
571 if (ndirdlg.exec()) { 634 {
572 QString ndir = ndirdlg.Newdir(); 635 QString ndir = ndirdlg.Newdir();
573 if (wrapper->createMbox(ndir)) { 636 if (wrapper->createMbox(ndir))
637 {
574 refresh(true); 638 refresh(true);
575 } 639 }
576 } 640 }
@@ -590,7 +654,8 @@ QStringList MHviewItem::subFolders()
590 654
591void MHviewItem::contextMenuSelected(int which) 655void MHviewItem::contextMenuSelected(int which)
592{ 656{
593 switch (which) { 657 switch (which)
658 {
594 case 0: 659 case 0:
595 refresh(true); 660 refresh(true);
596 break; 661 break;
@@ -609,11 +674,10 @@ void MHviewItem::contextMenuSelected(int which)
609} 674}
610 675
611MHfolderItem::~MHfolderItem() 676MHfolderItem::~MHfolderItem()
612{ 677{}
613}
614 678
615MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) 679MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
616 : AccountViewItem( parent,after ) 680 : AccountViewItem( parent,after )
617{ 681{
618 folder = folderInit; 682 folder = folderInit;
619 mbox = parent; 683 mbox = parent;
@@ -621,7 +685,7 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewIt
621} 685}
622 686
623MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 687MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
624 : AccountViewItem( parent,after ) 688 : AccountViewItem( parent,after )
625{ 689{
626 folder = folderInit; 690 folder = folderInit;
627 mbox = master; 691 mbox = master;
@@ -631,20 +695,27 @@ MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewI
631void MHfolderItem::initName() 695void MHfolderItem::initName()
632{ 696{
633 QString bName = folder->getDisplayName(); 697 QString bName = folder->getDisplayName();
634 if (bName.startsWith("/")&&bName.length()>1) { 698 if (bName.startsWith("/")&&bName.length()>1)
699 {
635 bName.replace(0,1,""); 700 bName.replace(0,1,"");
636 } 701 }
637 int pos = bName.findRev("/"); 702 int pos = bName.findRev("/");
638 if (pos > 0) { 703 if (pos > 0)
704 {
639 bName.replace(0,pos+1,""); 705 bName.replace(0,pos+1,"");
640 } 706 }
641 if (bName.lower() == "outgoing") { 707 if (bName.lower() == "outgoing")
708 {
642 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 709 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
643 } else if (bName.lower() == "inbox") { 710 }
711 else if (bName.lower() == "inbox")
712 {
644 setPixmap( 0, PIXMAP_INBOXFOLDER); 713 setPixmap( 0, PIXMAP_INBOXFOLDER);
645 } else { 714 }
715 else
716 {
646 setPixmap( 0, PIXMAP_MBOXFOLDER ); 717 setPixmap( 0, PIXMAP_MBOXFOLDER );
647 } 718 }
648 setText( 0, bName ); 719 setText( 0, bName );
649} 720}
650 721
@@ -667,18 +738,21 @@ RecBody MHfolderItem::fetchBody(const RecMail&aMail)
667void MHfolderItem::deleteFolder() 738void MHfolderItem::deleteFolder()
668{ 739{
669 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 740 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
670 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 741 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
671 QObject::tr("Yes",contextName), 742 QObject::tr("Yes",contextName),
672 QObject::tr("No",contextName),QString::null,1,1); 743 QObject::tr("No",contextName),QString::null,1,1);
673 qDebug("Auswahl: %i",yesno); 744 qDebug("Auswahl: %i",yesno);
674 if (yesno == 0) { 745 if (yesno == 0)
675 if (mbox->getWrapper()->deleteMbox(folder)) { 746 {
747 if (mbox->getWrapper()->deleteMbox(folder))
748 {
676 QListView*v=listView(); 749 QListView*v=listView();
677 MHviewItem * box = mbox; 750 MHviewItem * box = mbox;
678 /* be carefull - after that this object is destroyd so don't use 751 /* be carefull - after that this object is destroyd so don't use
679 * any member of it after that call!!*/ 752 * any member of it after that call!!*/
680 mbox->refresh(true); 753 mbox->refresh(true);
681 if (v) { 754 if (v)
755 {
682 v->setSelected(box,true); 756 v->setSelected(box,true);
683 } 757 }
684 } 758 }
@@ -688,7 +762,8 @@ void MHfolderItem::deleteFolder()
688QPopupMenu * MHfolderItem::getContextMenu() 762QPopupMenu * MHfolderItem::getContextMenu()
689{ 763{
690 QPopupMenu *m = new QPopupMenu(0); 764 QPopupMenu *m = new QPopupMenu(0);
691 if (m) { 765 if (m)
766 {
692 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 767 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
693 m->insertItem(QObject::tr("Delete all mails",contextName),0); 768 m->insertItem(QObject::tr("Delete all mails",contextName),0);
694 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 769 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
@@ -707,16 +782,18 @@ void MHfolderItem::downloadMails()
707void MHfolderItem::createFolder() 782void MHfolderItem::createFolder()
708{ 783{
709 Newmdirdlg ndirdlg(0,0,true); 784 Newmdirdlg ndirdlg(0,0,true);
710 ndirdlg.showMaximized(); 785 if ( QPEApplication::execDialog( &ndirdlg ) )
711 if (ndirdlg.exec()) { 786 {
712 QString ndir = ndirdlg.Newdir(); 787 QString ndir = ndirdlg.Newdir();
713 if (mbox->getWrapper()->createMbox(ndir,folder)) { 788 if (mbox->getWrapper()->createMbox(ndir,folder))
789 {
714 QListView*v=listView(); 790 QListView*v=listView();
715 MHviewItem * box = mbox; 791 MHviewItem * box = mbox;
716 /* be carefull - after that this object is destroyd so don't use 792 /* be carefull - after that this object is destroyd so don't use
717 * any member of it after that call!!*/ 793 * any member of it after that call!!*/
718 mbox->refresh(true); 794 mbox->refresh(true);
719 if (v) { 795 if (v)
796 {
720 v->setSelected(box,true); 797 v->setSelected(box,true);
721 } 798 }
722 } 799 }
@@ -725,7 +802,8 @@ void MHfolderItem::createFolder()
725 802
726void MHfolderItem::contextMenuSelected(int which) 803void MHfolderItem::contextMenuSelected(int which)
727{ 804{
728 switch(which) { 805 switch(which)
806 {
729 case 0: 807 case 0:
730 deleteAllMail(mbox->getWrapper(),folder); 808 deleteAllMail(mbox->getWrapper(),folder);
731 break; 809 break;
@@ -749,21 +827,21 @@ void MHfolderItem::contextMenuSelected(int which)
749 827
750const QString AccountViewItem::contextName="AccountViewItem"; 828const QString AccountViewItem::contextName="AccountViewItem";
751 829
752AccountViewItem::AccountViewItem( AccountView *parent ) 830AccountViewItem::AccountViewItem( AccountView *parent )
753 : QListViewItem( parent ) 831 : QListViewItem( parent )
754{ 832{
755 init(); 833 init();
756 m_Backlink = parent; 834 m_Backlink = parent;
757} 835}
758 836
759AccountViewItem::AccountViewItem( QListViewItem *parent) 837AccountViewItem::AccountViewItem( QListViewItem *parent)
760 : QListViewItem( parent) 838 : QListViewItem( parent)
761{ 839{
762 init(); 840 init();
763} 841}
764 842
765AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 843AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
766 :QListViewItem( parent,after ) 844 :QListViewItem( parent,after )
767{ 845{
768 init(); 846 init();
769} 847}
@@ -790,13 +868,15 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
790 QString fname=""; 868 QString fname="";
791 if (folder) fname = folder->getDisplayName(); 869 if (folder) fname = folder->getDisplayName();
792 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 870 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
793 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 871 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
794 arg(fname), 872 arg(fname),
795 QObject::tr("Yes",contextName), 873 QObject::tr("Yes",contextName),
796 QObject::tr("No",contextName),QString::null,1,1); 874 QObject::tr("No",contextName),QString::null,1,1);
797 qDebug("Auswahl: %i",yesno); 875 qDebug("Auswahl: %i",yesno);
798 if (yesno == 0) { 876 if (yesno == 0)
799 if (wrapper->deleteAllMail(folder)) { 877 {
878 if (wrapper->deleteAllMail(folder))
879 {
800 AccountView * view = (AccountView*)listView(); 880 AccountView * view = (AccountView*)listView();
801 if (view) view->refreshCurrent(); 881 if (view) view->refreshCurrent();
802 } 882 }
@@ -806,7 +886,8 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
806void AccountViewItem::removeChilds() 886void AccountViewItem::removeChilds()
807{ 887{
808 QListViewItem *child = firstChild(); 888 QListViewItem *child = firstChild();
809 while ( child ) { 889 while ( child )
890 {
810 QListViewItem *tmp = child; 891 QListViewItem *tmp = child;
811 child = child->nextSibling(); 892 child = child->nextSibling();
812 delete tmp; 893 delete tmp;
@@ -825,13 +906,17 @@ AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*
825 AccountViewItem*pitem,*sitem; 906 AccountViewItem*pitem,*sitem;
826 if (!start) pitem = (AccountViewItem*)firstChild(); 907 if (!start) pitem = (AccountViewItem*)firstChild();
827 else pitem = (AccountViewItem*)start->firstChild(); 908 else pitem = (AccountViewItem*)start->firstChild();
828 while (pitem) { 909 while (pitem)
829 if (pitem->matchName(path)) { 910 {
911 if (pitem->matchName(path))
912 {
830 break; 913 break;
831 } 914 }
832 if (pitem->childCount()>0) { 915 if (pitem->childCount()>0)
916 {
833 sitem = findSubItem(path,pitem); 917 sitem = findSubItem(path,pitem);
834 if (sitem) { 918 if (sitem)
919 {
835 pitem = sitem; 920 pitem = sitem;
836 break; 921 break;
837 } 922 }
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index d9792d4..2ddf834 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,21 +1,26 @@
1
1#include "accountview.h" 2#include "accountview.h"
2#include "accountitem.h" 3#include "accountitem.h"
3#include "selectstore.h" 4#include "selectstore.h"
4#include <qmessagebox.h> 5
5#include <qpopupmenu.h> 6/* OPIE */
6#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <qpe/qpeapplication.h>
10 12
13/* QT */
14#include <qmessagebox.h>
15#include <qpopupmenu.h>
11 16
12AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
13 : QListView( parent, name, flags ) 18 : QListView( parent, name, flags )
14{ 19{
15 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 20 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
16 SLOT( refresh( QListViewItem * ) ) ); 21 SLOT( refresh( QListViewItem * ) ) );
17 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 22 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
18 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 23 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
19 setSorting(0); 24 setSorting(0);
20} 25}
21 26
@@ -55,12 +60,16 @@ void AccountView::populate( QList<Account> list )
55 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
56 61
57 Account *it; 62 Account *it;
58 for ( it = list.first(); it; it = list.next() ) { 63 for ( it = list.first(); it; it = list.next() )
59 if ( it->getType().compare( "IMAP" ) == 0 ) { 64 {
65 if ( it->getType().compare( "IMAP" ) == 0 )
66 {
60 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 67 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
61 qDebug( "added IMAP " + imap->getAccountName() ); 68 qDebug( "added IMAP " + imap->getAccountName() );
62 imapAccounts.append(new IMAPviewItem( imap, this )); 69 imapAccounts.append(new IMAPviewItem( imap, this ));
63 } else if ( it->getType().compare( "POP3" ) == 0 ) { 70 }
71 else if ( it->getType().compare( "POP3" ) == 0 )
72 {
64 POP3account *pop3 = static_cast<POP3account *>(it); 73 POP3account *pop3 = static_cast<POP3account *>(it);
65 qDebug( "added POP3 " + pop3->getAccountName() ); 74 qDebug( "added POP3 " + pop3->getAccountName() );
66 /* must not be hold 'cause it isn't required */ 75 /* must not be hold 'cause it isn't required */
@@ -69,10 +78,12 @@ void AccountView::populate( QList<Account> list )
69 } 78 }
70} 79}
71 80
72void AccountView::refresh(QListViewItem *item) { 81void AccountView::refresh(QListViewItem *item)
82{
73 83
74 qDebug("AccountView refresh..."); 84 qDebug("AccountView refresh...");
75 if ( item ) { 85 if ( item )
86 {
76 m_currentItem = item; 87 m_currentItem = item;
77 QList<RecMail> headerlist; 88 QList<RecMail> headerlist;
78 headerlist.setAutoDelete(true); 89 headerlist.setAutoDelete(true);
@@ -95,7 +106,6 @@ void AccountView::refreshCurrent()
95 106
96void AccountView::refreshAll() 107void AccountView::refreshAll()
97{ 108{
98
99} 109}
100 110
101RecBody AccountView::fetchBody(const RecMail&aMail) 111RecBody AccountView::fetchBody(const RecMail&aMail)
@@ -108,15 +118,17 @@ RecBody AccountView::fetchBody(const RecMail&aMail)
108 118
109void AccountView::setupFolderselect(Selectstore*sels) 119void AccountView::setupFolderselect(Selectstore*sels)
110{ 120{
111 sels->showMaximized(); 121 QPEApplication::showDialog( sels );
112 QStringList sFolders; 122 QStringList sFolders;
113 unsigned int i = 0; 123 unsigned int i = 0;
114 for (i=0; i < mhAccounts.count();++i) { 124 for (i=0; i < mhAccounts.count();++i)
125 {
115 mhAccounts[i]->refresh(false); 126 mhAccounts[i]->refresh(false);
116 sFolders = mhAccounts[i]->subFolders(); 127 sFolders = mhAccounts[i]->subFolders();
117 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 128 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
118 } 129 }
119 for (i=0; i < imapAccounts.count();++i) { 130 for (i=0; i < imapAccounts.count();++i)
131 {
120 if (imapAccounts[i]->offline()) 132 if (imapAccounts[i]->offline())
121 continue; 133 continue;
122 imapAccounts[i]->refreshFolders(false); 134 imapAccounts[i]->refreshFolders(false);
@@ -134,12 +146,14 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
134 targetMail = sels.currentMail(); 146 targetMail = sels.currentMail();
135 targetFolder = sels.currentFolder(); 147 targetFolder = sels.currentFolder();
136 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 148 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
137 targetFolder.isEmpty()) { 149 targetFolder.isEmpty())
150 {
138 return; 151 return;
139 } 152 }
140 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 153 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
154 {
141 QMessageBox::critical(0,tr("Error creating new Folder"), 155 QMessageBox::critical(0,tr("Error creating new Folder"),
142 tr("<center>Error while creating<br>new folder - breaking.</center>")); 156 tr("<center>Error while creating<br>new folder - breaking.</center>"));
143 return; 157 return;
144 } 158 }
145 qDebug("Targetfolder: %s",targetFolder.latin1()); 159 qDebug("Targetfolder: %s",targetFolder.latin1());
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp
index f4f4cea..8cdabde 100644
--- a/noncore/net/mail/addresspicker.cpp
+++ b/noncore/net/mail/addresspicker.cpp
@@ -1,20 +1,24 @@
1
2#include "composemail.h"
3
4/* OPIE */
5#include <opie2/ocontactaccess.h>
6#include <opie2/ocontact.h>
7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h>
9
10/* QT */
1#include <qpushbutton.h> 11#include <qpushbutton.h>
2#include <qmessagebox.h> 12#include <qmessagebox.h>
3#include <qtextstream.h> 13#include <qtextstream.h>
4#include <qlistbox.h> 14#include <qlistbox.h>
5#include <qfile.h> 15#include <qfile.h>
6 16
7#include <qpe/resource.h> 17/* STD */
8#include <opie2/ocontactaccess.h>
9#include <opie2/ocontact.h>
10
11
12#include <stdlib.h> 18#include <stdlib.h>
13 19
14#include "composemail.h" 20AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
15 21 : AddressPickerUI( parent, name, modal, flags )
16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
17 : AddressPickerUI( parent, name, modal, flags )
18{ 22{
19 okButton->setIconSet( Resource::loadPixmap( "enter" ) ); 23 okButton->setIconSet( Resource::loadPixmap( "enter" ) );
20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); 24 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
@@ -26,75 +30,85 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
26 QString lineEmail, lineName, contactLine; 30 QString lineEmail, lineName, contactLine;
27 /* what name has to set here???? */ 31 /* what name has to set here???? */
28 Opie::OContactAccess m_contactdb("opiemail"); 32 Opie::OContactAccess m_contactdb("opiemail");
29 33
30 QStringList mails; 34 QStringList mails;
31 QString pre,suf; 35 QString pre,suf;
32 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 36 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
33 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 37 for ( it = m_list.begin(); it != m_list.end(); ++it )
34 if ((*it).defaultEmail().length()!=0) { 38 {
39 if ((*it).defaultEmail().length()!=0)
40 {
35 mails = (*it).emailList(); 41 mails = (*it).emailList();
36 if ((*it).fileAs().length()>0) { 42 if ((*it).fileAs().length()>0)
43 {
37 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; 44 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <";
38 suf = ">"; 45 suf = ">";
39 } else { 46 }
47 else
48 {
40 pre = ""; 49 pre = "";
41 suf = ""; 50 suf = "";
42 } 51 }
43 QStringList::ConstIterator sit = mails.begin(); 52 QStringList::ConstIterator sit = mails.begin();
44 for (;sit!=mails.end();++sit) { 53 for (;sit!=mails.end();++sit)
54 {
45 contactLine=pre+(*sit)+suf; 55 contactLine=pre+(*sit)+suf;
46 addressList->insertItem(contactLine); 56 addressList->insertItem(contactLine);
47 } 57 }
48 } 58 }
49 } 59 }
50 if ( addressList->count() <= 0 ) { 60 if ( addressList->count() <= 0 )
61 {
51#if 0 62#if 0
52 // makes this realy sense?? 63 // makes this realy sense??
53 addressList->insertItem( 64 addressList->insertItem(
54 tr( "There are no entries in the addressbook." ) ); 65 tr( "There are no entries in the addressbook." ) );
55#endif 66#endif
56 addressList->setEnabled( false ); 67 addressList->setEnabled( false );
57 okButton->setEnabled( false ); 68 okButton->setEnabled( false );
58 } else { 69 }
59// addressList->sort(); 70 else
71 {
72 // addressList->sort();
60 } 73 }
61} 74}
62 75
63void AddressPicker::accept() 76void AddressPicker::accept()
64{ 77{
65 QListBoxItem *item = addressList->firstItem(); 78 QListBoxItem *item = addressList->firstItem();
66 QString names; 79 QString names;
67 80
68 while ( item ) { 81 while ( item )
69 if ( item->selected() ) 82 {
70 names += item->text() + ", "; 83 if ( item->selected() )
71 item = item->next(); 84 names += item->text() + ", ";
72 } 85 item = item->next();
73 names.replace( names.length() - 2, 2, "" ); 86 }
74 87 names.replace( names.length() - 2, 2, "" );
75 if ( names.isEmpty() ) { 88
76 QMessageBox::information(this, tr("Error"), tr("<p>You have to select" 89 if ( names.isEmpty() )
77 " at least one address entry.</p>"), tr("Ok")); 90 {
78 return; 91 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
79 } 92 " at least one address entry.</p>"), tr("Ok"));
80 93 return;
81 selectedNames = names; 94 }
82 QDialog::accept(); 95
96 selectedNames = names;
97 QDialog::accept();
83} 98}
84 99
85QString AddressPicker::getNames() 100QString AddressPicker::getNames()
86{ 101{
87 QString names = 0; 102 QString names = 0;
88 103
89 AddressPicker picker(0, 0, true); 104 AddressPicker picker(0, 0, true);
90 picker.showMaximized(); 105
91 picker.show(); 106 int ret = QPEApplication::execDialog( &picker );
92 107 if ( QDialog::Accepted == ret )
93 int ret = picker.exec(); 108 {
94 if ( QDialog::Accepted == ret ) { 109 return picker.selectedNames;
95 return picker.selectedNames; 110 }
96 } 111
97 112 return 0;
98 return 0;
99} 113}
100 114
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 1cb202e..60bffa5 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,10 +1,15 @@
1#include <qt.h>
2 1
3#include "defines.h" 2#include "defines.h"
4#include "editaccounts.h" 3#include "editaccounts.h"
5 4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
9#include <qt.h>
10
6AccountListItem::AccountListItem( QListView *parent, Account *a) 11AccountListItem::AccountListItem( QListView *parent, Account *a)
7 : QListViewItem( parent ) 12 : QListViewItem( parent )
8{ 13{
9 account = a; 14 account = a;
10 setText( 0, account->getAccountName() ); 15 setText( 0, account->getAccountName() );
@@ -12,7 +17,7 @@ AccountListItem::AccountListItem( QListView *parent, Account *a)
12} 17}
13 18
14EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 19EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
15 : EditAccountsUI( parent, name, modal, flags ) 20 : EditAccountsUI( parent, name, modal, flags )
16{ 21{
17 qDebug( "New Account Configuration Widget" ); 22 qDebug( "New Account Configuration Widget" );
18 settings = s; 23 settings = s;
@@ -39,10 +44,14 @@ void EditAccounts::slotFillLists()
39 44
40 QList<Account> accounts = settings->getAccounts(); 45 QList<Account> accounts = settings->getAccounts();
41 Account *it; 46 Account *it;
42 for ( it = accounts.first(); it; it = accounts.next() ) { 47 for ( it = accounts.first(); it; it = accounts.next() )
43 if ( it->getType().compare( "NNTP" ) == 0 ) { 48 {
49 if ( it->getType().compare( "NNTP" ) == 0 )
50 {
44 (void) new AccountListItem( newsList, it ); 51 (void) new AccountListItem( newsList, it );
45 } else { 52 }
53 else
54 {
46 (void) new AccountListItem( mailList, it ); 55 (void) new AccountListItem( mailList, it );
47 } 56 }
48 } 57 }
@@ -54,60 +63,76 @@ void EditAccounts::slotNewMail()
54 QString *selection = new QString(); 63 QString *selection = new QString();
55 SelectMailType selType( selection, this, 0, true ); 64 SelectMailType selType( selection, this, 0, true );
56 selType.show(); 65 selType.show();
57 if ( QDialog::Accepted == selType.exec() ) { 66 if ( QDialog::Accepted == selType.exec() )
67 {
58 slotNewAccount( *selection ); 68 slotNewAccount( *selection );
59 } 69 }
60} 70}
61 71
62void EditAccounts::slotNewAccount( const QString &type ) 72void EditAccounts::slotNewAccount( const QString &type )
63{ 73{
64 if ( type.compare( "IMAP" ) == 0 ) { 74 if ( type.compare( "IMAP" ) == 0 )
75 {
65 qDebug( "-> config IMAP" ); 76 qDebug( "-> config IMAP" );
66 IMAPaccount *account = new IMAPaccount(); 77 IMAPaccount *account = new IMAPaccount();
67 IMAPconfig imap( account, this, 0, true ); 78 IMAPconfig imap( account, this, 0, true );
68 imap.showMaximized(); 79 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
69 if ( QDialog::Accepted == imap.exec() ) { 80 {
70 settings->addAccount( account ); 81 settings->addAccount( account );
71 account->save(); 82 account->save();
72 slotFillLists(); 83 slotFillLists();
73 } else { 84 }
85 else
86 {
74 account->remove(); 87 account->remove();
75 } 88 }
76 } else if ( type.compare( "POP3" ) == 0 ) { 89 }
90 else if ( type.compare( "POP3" ) == 0 )
91 {
77 qDebug( "-> config POP3" ); 92 qDebug( "-> config POP3" );
78 POP3account *account = new POP3account(); 93 POP3account *account = new POP3account();
79 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 94 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
80 pop3.showMaximized(); 95 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
81 if ( QDialog::Accepted == pop3.exec() ) { 96 {
82 settings->addAccount( account ); 97 settings->addAccount( account );
83 account->save(); 98 account->save();
84 slotFillLists(); 99 slotFillLists();
85 } else { 100 }
101 else
102 {
86 account->remove(); 103 account->remove();
87 } 104 }
88 } else if ( type.compare( "SMTP" ) == 0 ) { 105 }
106 else if ( type.compare( "SMTP" ) == 0 )
107 {
89 qDebug( "-> config SMTP" ); 108 qDebug( "-> config SMTP" );
90 SMTPaccount *account = new SMTPaccount(); 109 SMTPaccount *account = new SMTPaccount();
91 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 110 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
92 smtp.showMaximized(); 111 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
93 if ( QDialog::Accepted == smtp.exec() ) { 112 {
94 settings->addAccount( account ); 113 settings->addAccount( account );
95 account->save(); 114 account->save();
96 slotFillLists(); 115 slotFillLists();
97 116
98 } else { 117 }
118 else
119 {
99 account->remove(); 120 account->remove();
100 } 121 }
101 } else if ( type.compare( "NNTP" ) == 0 ) { 122 }
123 else if ( type.compare( "NNTP" ) == 0 )
124 {
102 qDebug( "-> config NNTP" ); 125 qDebug( "-> config NNTP" );
103 NNTPaccount *account = new NNTPaccount(); 126 NNTPaccount *account = new NNTPaccount();
104 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 127 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
105 nntp.showMaximized(); 128 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
106 if ( QDialog::Accepted == nntp.exec() ) { 129 {
107 settings->addAccount( account ); 130 settings->addAccount( account );
108 account->save(); 131 account->save();
109 slotFillLists(); 132 slotFillLists();
110 } else { 133 }
134 else
135 {
111 account->remove(); 136 account->remove();
112 } 137 }
113 } 138 }
@@ -115,33 +140,40 @@ void EditAccounts::slotNewAccount( const QString &type )
115 140
116void EditAccounts::slotEditAccount( Account *account ) 141void EditAccounts::slotEditAccount( Account *account )
117{ 142{
118 if ( account->getType().compare( "IMAP" ) == 0 ) { 143 if ( account->getType().compare( "IMAP" ) == 0 )
144 {
119 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 145 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
120 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 146 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
121 imap.showMaximized(); 147 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
122 if ( QDialog::Accepted == imap.exec() ) { 148 {
123 slotFillLists(); 149 slotFillLists();
124 } 150 }
125 } else if ( account->getType().compare( "POP3" ) == 0 ) { 151 }
152 else if ( account->getType().compare( "POP3" ) == 0 )
153 {
126 POP3account *pop3Acc = static_cast<POP3account *>(account); 154 POP3account *pop3Acc = static_cast<POP3account *>(account);
127 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 155 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
128 pop3.showMaximized(); 156 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
129 if ( QDialog::Accepted == pop3.exec() ) { 157 {
130 slotFillLists(); 158 slotFillLists();
131 } 159 }
132 } else if ( account->getType().compare( "SMTP" ) == 0 ) { 160 }
161 else if ( account->getType().compare( "SMTP" ) == 0 )
162 {
133 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 163 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
134 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 164 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
135 smtp.showMaximized(); 165 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
136 if ( QDialog::Accepted == smtp.exec() ) { 166 {
137 slotFillLists(); 167 slotFillLists();
138 } 168 }
139 } else if ( account->getType().compare( "NNTP" ) == 0 ) { 169 }
170 else if ( account->getType().compare( "NNTP" ) == 0 )
171 {
140 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 172 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
141 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 173 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
142 nntp.showMaximized(); 174 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
143 if ( QDialog::Accepted == nntp.exec() ) { 175 {
144 slotFillLists(); 176 slotFillLists();
145 } 177 }
146 } 178 }
147} 179}
@@ -149,8 +181,9 @@ void EditAccounts::slotEditAccount( Account *account )
149void EditAccounts::slotDeleteAccount( Account *account ) 181void EditAccounts::slotDeleteAccount( Account *account )
150{ 182{
151 if ( QMessageBox::information( this, tr( "Question" ), 183 if ( QMessageBox::information( this, tr( "Question" ),
152 tr( "<p>Do you really want to delete the selected Account?</p>" ), 184 tr( "<p>Do you really want to delete the selected Account?</p>" ),
153 tr( "Yes" ), tr( "No" ) ) == 0 ) { 185 tr( "Yes" ), tr( "No" ) ) == 0 )
186 {
154 settings->delAccount( account ); 187 settings->delAccount( account );
155 slotFillLists(); 188 slotFillLists();
156 } 189 }
@@ -159,7 +192,8 @@ void EditAccounts::slotDeleteAccount( Account *account )
159void EditAccounts::slotEditMail() 192void EditAccounts::slotEditMail()
160{ 193{
161 qDebug( "Edit Mail Account" ); 194 qDebug( "Edit Mail Account" );
162 if ( !mailList->currentItem() ) { 195 if ( !mailList->currentItem() )
196 {
163 QMessageBox::information( this, tr( "Error" ), 197 QMessageBox::information( this, tr( "Error" ),
164 tr( "<p>Please select an account.</p>" ), 198 tr( "<p>Please select an account.</p>" ),
165 tr( "Ok" ) ); 199 tr( "Ok" ) );
@@ -172,7 +206,8 @@ void EditAccounts::slotEditMail()
172 206
173void EditAccounts::slotDeleteMail() 207void EditAccounts::slotDeleteMail()
174{ 208{
175 if ( !mailList->currentItem() ) { 209 if ( !mailList->currentItem() )
210 {
176 QMessageBox::information( this, tr( "Error" ), 211 QMessageBox::information( this, tr( "Error" ),
177 tr( "<p>Please select an account.</p>" ), 212 tr( "<p>Please select an account.</p>" ),
178 tr( "Ok" ) ); 213 tr( "Ok" ) );
@@ -192,7 +227,8 @@ void EditAccounts::slotNewNews()
192void EditAccounts::slotEditNews() 227void EditAccounts::slotEditNews()
193{ 228{
194 qDebug( "Edit News Account" ); 229 qDebug( "Edit News Account" );
195 if ( !newsList->currentItem() ) { 230 if ( !newsList->currentItem() )
231 {
196 QMessageBox::information( this, tr( "Error" ), 232 QMessageBox::information( this, tr( "Error" ),
197 tr( "<p>Please select an account.</p>" ), 233 tr( "<p>Please select an account.</p>" ),
198 tr( "Ok" ) ); 234 tr( "Ok" ) );
@@ -206,7 +242,8 @@ void EditAccounts::slotEditNews()
206void EditAccounts::slotDeleteNews() 242void EditAccounts::slotDeleteNews()
207{ 243{
208 qDebug( "Delete News Account" ); 244 qDebug( "Delete News Account" );
209 if ( !newsList->currentItem() ) { 245 if ( !newsList->currentItem() )
246 {
210 QMessageBox::information( this, tr( "Error" ), 247 QMessageBox::information( this, tr( "Error" ),
211 tr( "<p>Please select an account.</p>" ), 248 tr( "<p>Please select an account.</p>" ),
212 tr( "Ok" ) ); 249 tr( "Ok" ) );
@@ -243,7 +280,7 @@ void EditAccounts::accept()
243 */ 280 */
244 281
245SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 282SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
246 : SelectMailTypeUI( parent, name, modal, flags ) 283 : SelectMailTypeUI( parent, name, modal, flags )
247{ 284{
248 selected = selection; 285 selected = selection;
249 selected->replace( 0, selected->length(), typeBox->currentText() ); 286 selected->replace( 0, selected->length(), typeBox->currentText() );
@@ -260,7 +297,7 @@ void SelectMailType::slotSelection( const QString &sel )
260 */ 297 */
261 298
262IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 299IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
263 : IMAPconfigUI( parent, name, modal, flags ) 300 : IMAPconfigUI( parent, name, modal, flags )
264{ 301{
265 data = account; 302 data = account;
266 303
@@ -277,12 +314,17 @@ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name,
277 314
278void IMAPconfig::slotConnectionToggle( int index ) 315void IMAPconfig::slotConnectionToggle( int index )
279{ 316{
280 if ( index == 2 ) { 317 if ( index == 2 )
281 portLine->setText( IMAP_SSL_PORT ); 318 {
282 } else if ( index == 3 ) { 319 portLine->setText( IMAP_SSL_PORT );
320 }
321 else if ( index == 3 )
322 {
283 portLine->setText( IMAP_PORT ); 323 portLine->setText( IMAP_PORT );
284 CommandEdit->show(); 324 CommandEdit->show();
285 } else { 325 }
326 else
327 {
286 portLine->setText( IMAP_PORT ); 328 portLine->setText( IMAP_PORT );
287 } 329 }
288} 330}
@@ -316,7 +358,7 @@ void IMAPconfig::accept()
316 */ 358 */
317 359
318POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 360POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
319 : POP3configUI( parent, name, modal, flags ) 361 : POP3configUI( parent, name, modal, flags )
320{ 362{
321 data = account; 363 data = account;
322 fillValues(); 364 fillValues();
@@ -333,12 +375,17 @@ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name,
333void POP3config::slotConnectionToggle( int index ) 375void POP3config::slotConnectionToggle( int index )
334{ 376{
335 // 2 is ssl connection 377 // 2 is ssl connection
336 if ( index == 2 ) { 378 if ( index == 2 )
337 portLine->setText( POP3_SSL_PORT ); 379 {
338 } else if ( index == 3 ) { 380 portLine->setText( POP3_SSL_PORT );
381 }
382 else if ( index == 3 )
383 {
339 portLine->setText( POP3_PORT ); 384 portLine->setText( POP3_PORT );
340 CommandEdit->show(); 385 CommandEdit->show();
341 } else { 386 }
387 else
388 {
342 portLine->setText( POP3_PORT ); 389 portLine->setText( POP3_PORT );
343 } 390 }
344} 391}
@@ -370,7 +417,7 @@ void POP3config::accept()
370 */ 417 */
371 418
372SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 419SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
373 : SMTPconfigUI( parent, name, modal, flags ) 420 : SMTPconfigUI( parent, name, modal, flags )
374{ 421{
375 data = account; 422 data = account;
376 423
@@ -391,12 +438,17 @@ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name,
391void SMTPconfig::slotConnectionToggle( int index ) 438void SMTPconfig::slotConnectionToggle( int index )
392{ 439{
393 // 2 is ssl connection 440 // 2 is ssl connection
394 if ( index == 2 ) { 441 if ( index == 2 )
395 portLine->setText( SMTP_SSL_PORT ); 442 {
396 } else if ( index == 3 ) { 443 portLine->setText( SMTP_SSL_PORT );
444 }
445 else if ( index == 3 )
446 {
397 portLine->setText( SMTP_PORT ); 447 portLine->setText( SMTP_PORT );
398 CommandEdit->show(); 448 CommandEdit->show();
399 } else { 449 }
450 else
451 {
400 portLine->setText( SMTP_PORT ); 452 portLine->setText( SMTP_PORT );
401 } 453 }
402} 454}
@@ -430,7 +482,7 @@ void SMTPconfig::accept()
430 */ 482 */
431 483
432NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 484NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
433 : NNTPconfigUI( parent, name, modal, flags ) 485 : NNTPconfigUI( parent, name, modal, flags )
434{ 486{
435 data = account; 487 data = account;
436 488
@@ -444,9 +496,12 @@ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name,
444 496
445void NNTPconfig::slotSSL( bool enabled ) 497void NNTPconfig::slotSSL( bool enabled )
446{ 498{
447 if ( enabled ) { 499 if ( enabled )
500 {
448 portLine->setText( NNTP_SSL_PORT ); 501 portLine->setText( NNTP_SSL_PORT );
449 } else { 502 }
503 else
504 {
450 portLine->setText( NNTP_PORT ); 505 portLine->setText( NNTP_PORT );
451 } 506 }
452} 507}
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 0795436..abf93dc 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,22 +1,28 @@
1#include <qmessagebox.h> 1
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 "mailistviewitem.h"
7#include "viewmail.h"
8#include "selectstore.h"
9#include "selectsmtp.h"
10
11/* OPIE */
6#include <libmailwrapper/smtpwrapper.h> 12#include <libmailwrapper/smtpwrapper.h>
13#include <libmailwrapper/mailtypes.h>
14#include <libmailwrapper/abstractmail.h>
7#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
8#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h>
18
19/* QT */
20#include <qmessagebox.h>
9#include <qaction.h> 21#include <qaction.h>
10#include <qapplication.h> 22#include <qapplication.h>
11#include <libmailwrapper/mailtypes.h>
12#include <libmailwrapper/abstractmail.h>
13#include "mailistviewitem.h"
14#include "viewmail.h"
15#include "selectstore.h"
16#include "selectsmtp.h"
17 23
18OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 24OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
19 : MainWindow( parent, name, WStyle_ContextHelp ) 25 : MainWindow( parent, name, WStyle_ContextHelp )
20{ 26{
21 settings = new Settings(); 27 settings = new Settings();
22 28
@@ -31,13 +37,16 @@ OpieMail::~OpieMail()
31void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 37void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
32{ 38{
33 // copied from old mail2 39 // copied from old mail2
34 if (msg == "writeMail(QString,QString)") { 40 if (msg == "writeMail(QString,QString)")
41 {
35 QDataStream stream(data,IO_ReadOnly); 42 QDataStream stream(data,IO_ReadOnly);
36 QString name, email; 43 QString name, email;
37 stream >> name >> email; 44 stream >> name >> email;
38 // removing the whitespaces at beginning and end is needed! 45 // removing the whitespaces at beginning and end is needed!
39 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 46 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
40 } else if (msg == "newMail()") { 47 }
48 else if (msg == "newMail()")
49 {
41 slotComposeMail(); 50 slotComposeMail();
42 } 51 }
43} 52}
@@ -45,16 +54,19 @@ void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
45void OpieMail::slotwriteMail(const QString&name,const QString&email) 54void OpieMail::slotwriteMail(const QString&name,const QString&email)
46{ 55{
47 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 56 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
48 if (!email.isEmpty()) { 57 if (!email.isEmpty())
49 if (!name.isEmpty()) { 58 {
59 if (!name.isEmpty())
60 {
50 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 61 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
51 } else { 62 }
63 else
64 {
52 compose.setTo(email); 65 compose.setTo(email);
53 } 66 }
54 } 67 }
55 compose.showMaximized();
56 compose.slotAdjustColumns(); 68 compose.slotAdjustColumns();
57 compose.exec(); 69 QPEApplication::execDialog( &compose );
58} 70}
59 71
60void OpieMail::slotComposeMail() 72void OpieMail::slotComposeMail()
@@ -72,30 +84,38 @@ void OpieMail::slotSendQueued()
72 QList<SMTPaccount> smtpList; 84 QList<SMTPaccount> smtpList;
73 smtpList.setAutoDelete(false); 85 smtpList.setAutoDelete(false);
74 Account *it; 86 Account *it;
75 for ( it = list.first(); it; it = list.next() ) { 87 for ( it = list.first(); it; it = list.next() )
76 if ( it->getType().compare( "SMTP" ) == 0 ) { 88 {
89 if ( it->getType().compare( "SMTP" ) == 0 )
90 {
77 smtp = static_cast<SMTPaccount *>(it); 91 smtp = static_cast<SMTPaccount *>(it);
78 smtpList.append(smtp); 92 smtpList.append(smtp);
79 } 93 }
80 } 94 }
81 if (smtpList.count()==0) { 95 if (smtpList.count()==0)
96 {
82 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 97 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
83 return; 98 return;
84 } 99 }
85 if (smtpList.count()==1) { 100 if (smtpList.count()==1)
101 {
86 smtp = smtpList.at(0); 102 smtp = smtpList.at(0);
87 } else { 103 }
104 else
105 {
88 smtp = 0; 106 smtp = 0;
89 selectsmtp selsmtp; 107 selectsmtp selsmtp;
90 selsmtp.setSelectionlist(&smtpList); 108 selsmtp.setSelectionlist(&smtpList);
91 selsmtp.showMaximized(); 109 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
92 if (selsmtp.exec()==QDialog::Accepted) { 110 {
93 smtp = selsmtp.selected_smtp(); 111 smtp = selsmtp.selected_smtp();
94 } 112 }
95 } 113 }
96 if (smtp) { 114 if (smtp)
115 {
97 SMTPwrapper * wrap = new SMTPwrapper(smtp); 116 SMTPwrapper * wrap = new SMTPwrapper(smtp);
98 if ( wrap->flushOutbox() ) { 117 if ( wrap->flushOutbox() )
118 {
99 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 119 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
100 } 120 }
101 delete wrap; 121 delete wrap;
@@ -110,17 +130,15 @@ void OpieMail::slotSearchMails()
110void OpieMail::slotEditSettings() 130void OpieMail::slotEditSettings()
111{ 131{
112 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 132 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
113 settingsDialog.showMaximized(); 133 QPEApplication::execDialog( &settingsDialog );
114 settingsDialog.exec();
115} 134}
116 135
117void OpieMail::slotEditAccounts() 136void OpieMail::slotEditAccounts()
118{ 137{
119 qDebug( "Edit Accounts" ); 138 qDebug( "Edit Accounts" );
120 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 139 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
121 eaDialog.showMaximized();
122 eaDialog.slotAdjustColumns(); 140 eaDialog.slotAdjustColumns();
123 eaDialog.exec(); 141 QPEApplication::execDialog( &eaDialog );
124 if ( settings ) delete settings; 142 if ( settings ) delete settings;
125 settings = new Settings(); 143 settings = new Settings();
126 144
@@ -139,9 +157,12 @@ void OpieMail::displayMail()
139 readMail.showMaximized(); 157 readMail.showMaximized();
140 readMail.exec(); 158 readMail.exec();
141 159
142 if ( readMail.deleted ) { 160 if ( readMail.deleted )
143 folderView->refreshCurrent(); 161 {
144 } else { 162 folderView->refreshCurrent();
163 }
164 else
165 {
145 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 166 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
146 } 167 }
147} 168}
@@ -150,9 +171,10 @@ void OpieMail::slotDeleteMail()
150{ 171{
151 if (!mailView->currentItem()) return; 172 if (!mailView->currentItem()) return;
152 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 173 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
153 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 ) { 174 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 )
154 mail.Wrapper()->deleteMail( mail ); 175 {
155 folderView->refreshCurrent(); 176 mail.Wrapper()->deleteMail( mail );
177 folderView->refreshCurrent();
156 } 178 }
157} 179}
158 180
@@ -163,7 +185,8 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
163 qDebug("Event right/hold"); 185 qDebug("Event right/hold");
164 if (!item) return; 186 if (!item) return;
165 QPopupMenu *m = new QPopupMenu(0); 187 QPopupMenu *m = new QPopupMenu(0);
166 if (m) { 188 if (m)
189 {
167 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 190 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
168 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 191 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
169 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 192 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
@@ -175,11 +198,14 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
175 198
176void OpieMail::slotShowFolders( bool show ) 199void OpieMail::slotShowFolders( bool show )
177{ 200{
178 qDebug( "Show Folders" ); 201 qDebug( "Show Folders" );
179 if ( show && folderView->isHidden() ) { 202 if ( show && folderView->isHidden() )
203 {
180 qDebug( "-> showing" ); 204 qDebug( "-> showing" );
181 folderView->show(); 205 folderView->show();
182 } else if ( !show && !folderView->isHidden() ) { 206 }
207 else if ( !show && !folderView->isHidden() )
208 {
183 qDebug( "-> hiding" ); 209 qDebug( "-> hiding" );
184 folderView->hide(); 210 folderView->hide();
185 } 211 }
@@ -189,7 +215,8 @@ void OpieMail::refreshMailView(QList<RecMail>*list)
189{ 215{
190 MailListViewItem*item = 0; 216 MailListViewItem*item = 0;
191 mailView->clear(); 217 mailView->clear();
192 for (unsigned int i = 0; i < list->count();++i) { 218 for (unsigned int i = 0; i < list->count();++i)
219 {
193 item = new MailListViewItem(mailView,item); 220 item = new MailListViewItem(mailView,item);
194 item->storeData(*(list->at(i))); 221 item->storeData(*(list->at(i)));
195 item->showEntry(); 222 item->showEntry();
@@ -216,12 +243,14 @@ void OpieMail::slotMoveCopyMail()
216 targetMail = sels.currentMail(); 243 targetMail = sels.currentMail();
217 targetFolder = sels.currentFolder(); 244 targetFolder = sels.currentFolder();
218 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || 245 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
219 targetFolder.isEmpty()) { 246 targetFolder.isEmpty())
247 {
220 return; 248 return;
221 } 249 }
222 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 250 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
251 {
223 QMessageBox::critical(0,tr("Error creating new Folder"), 252 QMessageBox::critical(0,tr("Error creating new Folder"),
224 tr("<center>Error while creating<br>new folder - breaking.</center>")); 253 tr("<center>Error while creating<br>new folder - breaking.</center>"));
225 return; 254 return;
226 } 255 }
227 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 256 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 99965d4..f015228 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,3 +1,17 @@
1#include "composemail.h"
2#include "viewmail.h"
3#include "accountview.h"
4
5/* OPIE */
6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h>
9
10#include <opie2/ofiledialog.h>
11#include <qpe/config.h>
12#include <qpe/qpeapplication.h>
13
14/* QT */
1#include <qtextbrowser.h> 15#include <qtextbrowser.h>
2#include <qmessagebox.h> 16#include <qmessagebox.h>
3#include <qtextstream.h> 17#include <qtextstream.h>
@@ -7,36 +21,25 @@
7#include <qapplication.h> 21#include <qapplication.h>
8#include <qvaluelist.h> 22#include <qvaluelist.h>
9 23
10#include <qpe/config.h>
11
12#include <opie2/ofiledialog.h>
13
14#include <libmailwrapper/settings.h>
15#include "composemail.h"
16#include "viewmail.h"
17#include <libmailwrapper/abstractmail.h>
18#include "accountview.h"
19#include <libmailwrapper/mailtypes.h>
20
21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 24AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path) 25 const QString&fsize,int num,const QValueList<int>&path)
23 : QListViewItem(parent,after),_partNum(num) 26 : QListViewItem(parent,after),_partNum(num)
24{ 27{
25 _path=path; 28 _path=path;
26 setText(0, mime); 29 setText(0, mime);
27 setText(1, desc); 30 setText(1, desc);
28 setText(2, file); 31 setText(2, file);
29 setText(3, fsize); 32 setText(3, fsize);
30} 33}
31 34
32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 35AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 36 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 37 : QListViewItem(parent,after),_partNum(num)
35{ 38{
36 _path=path; 39 _path=path;
37 setText(0, mime); 40 setText(0, mime);
38 setText(1, desc); 41 setText(1, desc);
39 setText(2, file); 42 setText(2, file);
40 setText(3, fsize); 43 setText(3, fsize);
41} 44}
42 45
@@ -46,7 +49,8 @@ bool AttachItem::isParentof(const QValueList<int>&path)
46 if (path.count()==0||_path.count()==0) return false; 49 if (path.count()==0||_path.count()==0) return false;
47 /* the parent must have one digit less then a child */ 50 /* the parent must have one digit less then a child */
48 if (path.count()!=_path.count()+1) return false; 51 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) { 52 for (unsigned int i=0; i < _path.count();++i)
53 {
50 if (_path[i]!=path[i]) return false; 54 if (_path[i]!=path[i]) return false;
51 } 55 }
52 return true; 56 return true;
@@ -55,7 +59,8 @@ bool AttachItem::isParentof(const QValueList<int>&path)
55AttachItem* ViewMail::searchParent(const QValueList<int>&path) 59AttachItem* ViewMail::searchParent(const QValueList<int>&path)
56{ 60{
57 QListViewItemIterator it( attachments ); 61 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) { 62 for ( ; it.current(); ++it )
63 {
59 AttachItem*ati = (AttachItem*)it.current(); 64 AttachItem*ati = (AttachItem*)it.current();
60 if (ati->isParentof(path)) return ati; 65 if (ati->isParentof(path)) return ati;
61 } 66 }
@@ -68,79 +73,42 @@ AttachItem* ViewMail::lastChild(AttachItem*parent)
68 AttachItem* item = (AttachItem*)parent->firstChild(); 73 AttachItem* item = (AttachItem*)parent->firstChild();
69 if (!item) return item; 74 if (!item) return item;
70 AttachItem*temp=0; 75 AttachItem*temp=0;
71 while( (temp=(AttachItem*)item->nextSibling())) { 76 while( (temp=(AttachItem*)item->nextSibling()))
77 {
72 item = temp; 78 item = temp;
73 } 79 }
74 return item; 80 return item;
75} 81}
76 82
77void ViewMail::setBody( RecBody body ) { 83void ViewMail::setBody( RecBody body )
78
79m_body = body;
80m_mail[2] = body.Bodytext();
81attachbutton->setEnabled(body.Parts().count()>0);
82attachments->setEnabled(body.Parts().count()>0);
83if (body.Parts().count()==0) {
84 return;
85}
86AttachItem * curItem=0;
87AttachItem * parentItem = 0;
88QString type=body.Description().Type()+"/"+body.Description().Subtype();
89QString desc,fsize;
90double s = body.Description().Size();
91int w;
92w=0;
93
94while (s>1024) {
95 s/=1024;
96 ++w;
97 if (w>=2) break;
98}
99
100QString q="";
101switch(w) {
102case 1:
103 q="k";
104 break;
105case 2:
106 q="M";
107 break;
108default:
109 break;
110}
111
112{ 84{
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
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.
117 */
118 QTextOStream o(&fsize);
119 if (w>0) o.precision(2); else o.precision(0);
120 o.setf(QTextStream::fixed);
121 o << s << " " << q << "Byte";
122}
123
124curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
125QString filename = "";
126 85
127for (unsigned int i = 0; i < body.Parts().count();++i) { 86 m_body = body;
128 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 87 m_mail[2] = body.Bodytext();
129 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 88 attachbutton->setEnabled(body.Parts().count()>0);
130 for (;it!=body.Parts()[i].Parameters().end();++it) { 89 attachments->setEnabled(body.Parts().count()>0);
131 qDebug(it.key()); 90 if (body.Parts().count()==0)
132 if (it.key().lower()=="name") { 91 {
133 filename=it.data(); 92 return;
134 }
135 } 93 }
136 s = body.Parts()[i].Size(); 94 AttachItem * curItem=0;
137 w = 0; 95 AttachItem * parentItem = 0;
138 while (s>1024) { 96 QString type=body.Description().Type()+"/"+body.Description().Subtype();
97 QString desc,fsize;
98 double s = body.Description().Size();
99 int w;
100 w=0;
101
102 while (s>1024)
103 {
139 s/=1024; 104 s/=1024;
140 ++w; 105 ++w;
141 if (w>=2) break; 106 if (w>=2) break;
142 } 107 }
143 switch(w) { 108
109 QString q="";
110 switch(w)
111 {
144 case 1: 112 case 1:
145 q="k"; 113 q="k";
146 break; 114 break;
@@ -148,87 +116,150 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
148 q="M"; 116 q="M";
149 break; 117 break;
150 default: 118 default:
151 q="";
152 break; 119 break;
153 } 120 }
154 QTextOStream o(&fsize); 121
155 if (w>0) o.precision(2); else o.precision(0); 122 {
156 o.setf(QTextStream::fixed); 123 /* I did not found a method to make a CONTENT reset on a QTextStream
157 o << s << " " << q << "Byte"; 124 so I use this construct that the stream will re-constructed in each
158 desc = body.Parts()[i].Description(); 125 loop. To let it work, the textstream is packed into a own area of
159 parentItem = searchParent(body.Parts()[i].Positionlist()); 126 code is it will be destructed after finishing its small job.
160 if (parentItem) { 127 */
161 AttachItem*temp = lastChild(parentItem); 128 QTextOStream o(&fsize);
162 if (temp) curItem = temp; 129 if (w>0) o.precision(2); else o.precision(0);
163 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 130 o.setf(QTextStream::fixed);
164 attachments->setRootIsDecorated(true); 131 o << s << " " << q << "Byte";
165 curItem = parentItem; 132 }
166 } else { 133
167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 134 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
135 QString filename = "";
136
137 for (unsigned int i = 0; i < body.Parts().count();++i)
138 {
139 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
140 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
141 for (;it!=body.Parts()[i].Parameters().end();++it)
142 {
143 qDebug(it.key());
144 if (it.key().lower()=="name")
145 {
146 filename=it.data();
147 }
148 }
149 s = body.Parts()[i].Size();
150 w = 0;
151 while (s>1024)
152 {
153 s/=1024;
154 ++w;
155 if (w>=2) break;
156 }
157 switch(w)
158 {
159 case 1:
160 q="k";
161 break;
162 case 2:
163 q="M";
164 break;
165 default:
166 q="";
167 break;
168 }
169 QTextOStream o(&fsize);
170 if (w>0) o.precision(2); else o.precision(0);
171 o.setf(QTextStream::fixed);
172 o << s << " " << q << "Byte";
173 desc = body.Parts()[i].Description();
174 parentItem = searchParent(body.Parts()[i].Positionlist());
175 if (parentItem)
176 {
177 AttachItem*temp = lastChild(parentItem);
178 if (temp) curItem = temp;
179 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
180 attachments->setRootIsDecorated(true);
181 curItem = parentItem;
182 }
183 else
184 {
185 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
186 }
168 } 187 }
169}
170} 188}
171 189
172 190
173void ViewMail::slotShowHtml( bool state ) { 191void ViewMail::slotShowHtml( bool state )
192{
174 m_showHtml = state; 193 m_showHtml = state;
175 setText(); 194 setText();
176} 195}
177 196
178void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { 197void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
198{
179 if (!item ) 199 if (!item )
180 return; 200 return;
181 201
182 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 202 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
203 {
183 setText(); 204 setText();
184 return; 205 return;
185 } 206 }
186 QPopupMenu *menu = new QPopupMenu(); 207 QPopupMenu *menu = new QPopupMenu();
187 int ret=0; 208 int ret=0;
188 209
189 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { 210 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
190 menu->insertItem( tr( "Show Text" ), 1 ); 211 {
191 } 212 menu->insertItem( tr( "Show Text" ), 1 );
192 menu->insertItem( tr( "Save Attachment" ), 0 ); 213 }
193 menu->insertSeparator(1); 214 menu->insertItem( tr( "Save Attachment" ), 0 );
194 215 menu->insertSeparator(1);
195 ret = menu->exec( point, 0 ); 216
196 217 ret = menu->exec( point, 0 );
197 switch(ret) { 218
198 case 0: 219 switch(ret)
199 { MimeTypes types; 220 {
200 types.insert( "all", "*" ); 221 case 0:
201 QString str = Opie::OFileDialog::getSaveFileName( 1, 222 {
202 "/", item->text( 2 ) , types, 0 ); 223 MimeTypes types;
203 224 types.insert( "all", "*" );
204 if( !str.isEmpty() ) { 225 QString str = Opie::OFileDialog::getSaveFileName( 1,
205 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 226 "/", item->text( 2 ) , types, 0 );
206 if (content) { 227
207 QFile output(str); 228 if( !str.isEmpty() )
208 output.open(IO_WriteOnly); 229 {
209 output.writeBlock(content->Content(),content->Length()); 230 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
210 output.close(); 231 if (content)
211 delete content; 232 {
212 } 233 QFile output(str);
213 } 234 output.open(IO_WriteOnly);
214 } 235 output.writeBlock(content->Content(),content->Length());
236 output.close();
237 delete content;
238 }
239 }
240 }
215 break ; 241 break ;
216 242
217 case 1: 243 case 1:
218 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 244 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
219 setText(); 245 {
220 } else { 246 setText();
221 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 247 }
248 else
249 {
250 if ( m_recMail.Wrapper() != 0l )
251 { // 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() ] ) ); 252 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
223 } 253 }
224 } 254 }
225 break; 255 break;
226 } 256 }
227 delete menu; 257 delete menu;
228} 258}
229 259
230 260
231void ViewMail::setMail( RecMail mail ) { 261void ViewMail::setMail( RecMail mail )
262{
232 263
233 m_recMail = mail; 264 m_recMail = mail;
234 265
@@ -247,24 +278,25 @@ void ViewMail::setMail( RecMail mail ) {
247 278
248 279
249ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 280ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
250 : ViewMailBase(parent, name, fl), _inLoop(false) 281 : ViewMailBase(parent, name, fl), _inLoop(false)
251{ 282{
252 m_gotBody = false; 283 m_gotBody = false;
253 deleted = false; 284 deleted = false;
254 285
255 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 286 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
256 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 287 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
257 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); 288 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) );
258 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); 289 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) );
259 290
260 attachments->setEnabled(m_gotBody); 291 attachments->setEnabled(m_gotBody);
261 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); 292 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
262 293
263 readConfig(); 294 readConfig();
264 attachments->setSorting(-1); 295 attachments->setSorting(-1);
265} 296}
266 297
267void ViewMail::readConfig() { 298void ViewMail::readConfig()
299{
268 Config cfg( "mail" ); 300 Config cfg( "mail" );
269 cfg.setGroup( "Settings" ); 301 cfg.setGroup( "Settings" );
270 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 302 m_showHtml = cfg.readBoolEntry( "showHtml", false );
@@ -278,13 +310,16 @@ void ViewMail::setText()
278 QString ccString; 310 QString ccString;
279 QString bccString; 311 QString bccString;
280 312
281 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 313 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
314 {
282 toString += (*it); 315 toString += (*it);
283 } 316 }
284 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 317 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
318 {
285 ccString += (*it); 319 ccString += (*it);
286 } 320 }
287 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 321 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
322 {
288 bccString += (*it); 323 bccString += (*it);
289 } 324 }
290 325
@@ -300,10 +335,13 @@ void ViewMail::setText()
300 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 335 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
301 "</td></tr></table><font face=fixed>"; 336 "</td></tr></table><font face=fixed>";
302 337
303 if ( !m_showHtml ) { 338 if ( !m_showHtml )
304 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 339 {
305 } else { 340 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
306 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 341 }
342 else
343 {
344 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
307 } 345 }
308 // remove later in favor of a real handling 346 // remove later in favor of a real handling
309 m_gotBody = true; 347 m_gotBody = true;
@@ -313,115 +351,120 @@ void ViewMail::setText()
313ViewMail::~ViewMail() 351ViewMail::~ViewMail()
314{ 352{
315 m_recMail.Wrapper()->cleanMimeCache(); 353 m_recMail.Wrapper()->cleanMimeCache();
316 hide(); 354 hide();
317} 355}
318 356
319void ViewMail::hide() 357void ViewMail::hide()
320{ 358{
321 QWidget::hide(); 359 QWidget::hide();
322 360
323 if (_inLoop) { 361 if (_inLoop)
324 _inLoop = false; 362 {
325 qApp->exit_loop(); 363 _inLoop = false;
364 qApp->exit_loop();
326 365
327 } 366 }
328 367
329} 368}
330 369
331void ViewMail::exec() 370void ViewMail::exec()
332{ 371{
333 show(); 372 show();
334 373
335 if (!_inLoop) { 374 if (!_inLoop)
336 _inLoop = true; 375 {
337 qApp->enter_loop(); 376 _inLoop = true;
338 } 377 qApp->enter_loop();
378 }
339 379
340} 380}
341 381
342QString ViewMail::deHtml(const QString &string) 382QString ViewMail::deHtml(const QString &string)
343{ 383{
344 QString string_ = string; 384 QString string_ = string;
345 string_.replace(QRegExp("&"), "&amp;"); 385 string_.replace(QRegExp("&"), "&amp;");
346 string_.replace(QRegExp("<"), "&lt;"); 386 string_.replace(QRegExp("<"), "&lt;");
347 string_.replace(QRegExp(">"), "&gt;"); 387 string_.replace(QRegExp(">"), "&gt;");
348 string_.replace(QRegExp("\\n"), "<br>"); 388 string_.replace(QRegExp("\\n"), "<br>");
349 return string_; 389 return string_;
350} 390}
351 391
352void ViewMail::slotReply() 392void ViewMail::slotReply()
353{ 393{
354 if (!m_gotBody) { 394 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")); 395 {
356 return; 396 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
357 } 397 return;
358 398 }
359 QString rtext; 399
360 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 400 QString rtext;
361 .arg( m_mail[0] ) 401 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
362 .arg( m_mail[3] ); 402 .arg( m_mail[0] )
363 403 .arg( m_mail[3] );
364 QString text = m_mail[2]; 404
365 QStringList lines = QStringList::split(QRegExp("\\n"), text); 405 QString text = m_mail[2];
366 QStringList::Iterator it; 406 QStringList lines = QStringList::split(QRegExp("\\n"), text);
367 for (it = lines.begin(); it != lines.end(); it++) { 407 QStringList::Iterator it;
368 rtext += "> " + *it + "\n"; 408 for (it = lines.begin(); it != lines.end(); it++)
369 } 409 {
370 rtext += "\n"; 410 rtext += "> " + *it + "\n";
371 411 }
372 QString prefix; 412 rtext += "\n";
373 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 413
374 else prefix = "Re: "; // no i18n on purpose 414 QString prefix;
375 415 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
376 Settings *settings = new Settings(); 416 else prefix = "Re: "; // no i18n on purpose
377 ComposeMail composer( settings ,this, 0, true); 417
378 composer.setTo( m_mail[0] ); 418 Settings *settings = new Settings();
379 composer.setSubject( "Re: " + m_mail[1] ); 419 ComposeMail composer( settings ,this, 0, true);
380 composer.setMessage( rtext ); 420 composer.setTo( m_mail[0] );
381 composer.showMaximized(); 421 composer.setSubject( "Re: " + m_mail[1] );
382 if ( QDialog::Accepted==composer.exec()) { 422 composer.setMessage( rtext );
423 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
424 {
383 m_recMail.Wrapper()->answeredMail(m_recMail); 425 m_recMail.Wrapper()->answeredMail(m_recMail);
384 } 426 }
385} 427}
386 428
387void ViewMail::slotForward() 429void ViewMail::slotForward()
388{ 430{
389 if (!m_gotBody) { 431 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")); 432 {
391 return; 433 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
392 } 434 return;
393 435 }
394 QString ftext;
395 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
396 .arg( m_mail[0] );
397 if (!m_mail[3].isNull())
398 ftext += QString("Date: %1\n")
399 .arg( m_mail[3] );
400 if (!m_mail[0].isNull())
401 ftext += QString("From: %1\n")
402 .arg( m_mail[0] );
403 if (!m_mail[1].isNull())
404 ftext += QString("Subject: %1\n")
405 .arg( m_mail[1] );
406
407 ftext += QString("\n%1\n")
408 .arg( m_mail[2]);
409
410 ftext += QString("----- End forwarded message -----\n");
411
412 Settings *settings = new Settings();
413 ComposeMail composer( settings ,this, 0, true);
414 composer.setSubject( "Fwd: " + m_mail[1] );
415 composer.setMessage( ftext );
416 composer.showMaximized();
417 if ( QDialog::Accepted==composer.exec()) {
418 436
437 QString ftext;
438 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
439 .arg( m_mail[0] );
440 if (!m_mail[3].isNull())
441 ftext += QString("Date: %1\n")
442 .arg( m_mail[3] );
443 if (!m_mail[0].isNull())
444 ftext += QString("From: %1\n")
445 .arg( m_mail[0] );
446 if (!m_mail[1].isNull())
447 ftext += QString("Subject: %1\n")
448 .arg( m_mail[1] );
449
450 ftext += QString("\n%1\n")
451 .arg( m_mail[2]);
452
453 ftext += QString("----- End forwarded message -----\n");
454
455 Settings *settings = new Settings();
456 ComposeMail composer( settings ,this, 0, true);
457 composer.setSubject( "Fwd: " + m_mail[1] );
458 composer.setMessage( ftext );
459 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ))
460 {
419 } 461 }
420} 462}
421 463
422void ViewMail::slotDeleteMail( ) 464void ViewMail::slotDeleteMail( )
423{ 465{
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 ) { 466 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 )
467 {
425 m_recMail.Wrapper()->deleteMail( m_recMail ); 468 m_recMail.Wrapper()->deleteMail( m_recMail );
426 hide(); 469 hide();
427 deleted = true; 470 deleted = true;