summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountitem.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp128
1 files changed, 65 insertions, 63 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp
index 985a762..9b1ea2f 100644
--- a/kmicromail/accountitem.cpp
+++ b/kmicromail/accountitem.cpp
@@ -3,26 +3,28 @@
3#include "accountview.h" 3#include "accountview.h"
4#include "newmaildir.h" 4#include "newmaildir.h"
5#include "nntpgroupsdlg.h" 5#include "nntpgroupsdlg.h"
6#include "defines.h" 6#include "defines.h"
7 7
8#include <libmailwrapper/mailtypes.h> 8#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 9#include <libmailwrapper/abstractmail.h>
10#include <libmailwrapper/mailwrapper.h> 10#include <libmailwrapper/mailwrapper.h>
11/* OPIE */ 11/* OPIE */
12//#include <qpe/qpeapplication.h> 12//#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qpopupmenu.h> 15#include <q3popupmenu.h>
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17//Added by qt3to4:
18#include <Q3ValueList>
17#include <kiconloader.h> 19#include <kiconloader.h>
18#include <klocale.h> 20#include <klocale.h>
19 21
20#define GET_NEW_MAILS 101 22#define GET_NEW_MAILS 101
21 23
22using namespace Opie::Core; 24using namespace Opie::Core;
23#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} 25#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
24/** 26/**
25 * POP3 Account stuff 27 * POP3 Account stuff
26 */ 28 */
27POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 29POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
28 : AccountViewItem( parent ) 30 : AccountViewItem( parent )
@@ -45,82 +47,82 @@ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
45} 47}
46 48
47POP3viewItem::~POP3viewItem() 49POP3viewItem::~POP3viewItem()
48{ 50{
49 delete wrapper; 51 delete wrapper;
50} 52}
51 53
52AbstractMail *POP3viewItem::getWrapper() 54AbstractMail *POP3viewItem::getWrapper()
53{ 55{
54 return wrapper; 56 return wrapper;
55} 57}
56 58
57void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) 59void POP3viewItem::refresh(Q3ValueList<Opie::Core::OSmartPointer<RecMail> > & )
58{ 60{
59 refresh(); 61 refresh();
60} 62}
61 63
62void POP3viewItem::refresh() 64void POP3viewItem::refresh()
63{ 65{
64 if (account->getOffline()) return; 66 if (account->getOffline()) return;
65 QValueList<FolderP> *folders = wrapper->listFolders(); 67 Q3ValueList<FolderP> *folders = wrapper->listFolders();
66 QListViewItem *child = firstChild(); 68 Q3ListViewItem *child = firstChild();
67 while ( child ) 69 while ( child )
68 { 70 {
69 QListViewItem *tmp = child; 71 Q3ListViewItem *tmp = child;
70 child = child->nextSibling(); 72 child = child->nextSibling();
71 delete tmp; 73 delete tmp;
72 } 74 }
73 QValueList<FolderP>::ConstIterator it; 75 Q3ValueList<FolderP>::ConstIterator it;
74 QListViewItem*item = 0; 76 Q3ListViewItem*item = 0;
75 for ( it = folders->begin(); it!=folders->end(); ++it) 77 for ( it = folders->begin(); it!=folders->end(); ++it)
76 { 78 {
77 item = new POP3folderItem( (*it), this , item ); 79 item = new POP3folderItem( (*it), this , item );
78 item->setSelectable( (*it)->may_select()); 80 item->setSelectable( (*it)->may_select());
79 } 81 }
80 delete folders; 82 delete folders;
81} 83}
82 84
83RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 85RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
84{ 86{
85 87
86 return wrapper->fetchBody( mail ); 88 return wrapper->fetchBody( mail );
87} 89}
88 90
89QPopupMenu * POP3viewItem::getContextMenu() 91Q3PopupMenu * POP3viewItem::getContextMenu()
90{ 92{
91 QPopupMenu *m = new QPopupMenu(0); 93 Q3PopupMenu *m = new Q3PopupMenu(0);
92 if (m) 94 if (m)
93 { 95 {
94 if (!account->getOffline()) 96 if (!account->getOffline())
95 { 97 {
96 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); 98 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS);
97 m->insertItem(i18n("Disconnect"),0); 99 m->insertItem(i18n("Disconnect"),0);
98 m->insertItem(i18n("Set offline"),1); 100 m->insertItem(i18n("Set offline"),1);
99 } 101 }
100 else 102 else
101 { 103 {
102 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); 104 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS);
103 m->insertItem(i18n("Set online"),1); 105 m->insertItem(i18n("Set online"),1);
104 } 106 }
105 } 107 }
106 return m; 108 return m;
107} 109}
108 110
109void POP3viewItem::disconnect() 111void POP3viewItem::disconnect()
110{ 112{
111 QListViewItem *child = firstChild(); 113 Q3ListViewItem *child = firstChild();
112 while ( child ) 114 while ( child )
113 { 115 {
114 QListViewItem *tmp = child; 116 Q3ListViewItem *tmp = child;
115 child = child->nextSibling(); 117 child = child->nextSibling();
116 delete tmp; 118 delete tmp;
117 } 119 }
118 wrapper->logout(); 120 wrapper->logout();
119} 121}
120 122
121void POP3viewItem::setOnOffline() 123void POP3viewItem::setOnOffline()
122{ 124{
123 if (!account->getOffline()) 125 if (!account->getOffline())
124 { 126 {
125 disconnect(); 127 disconnect();
126 } 128 }
@@ -148,53 +150,53 @@ void POP3viewItem::contextMenuSelected(int which)
148 AccountViewItem* in = findSubItem( "inbox" , 0); 150 AccountViewItem* in = findSubItem( "inbox" , 0);
149 if ( ! in ) 151 if ( ! in )
150 return; 152 return;
151 bl->downloadMailsInbox(in->getFolder() ,getWrapper()); 153 bl->downloadMailsInbox(in->getFolder() ,getWrapper());
152 setOnOffline(); 154 setOnOffline();
153 break; 155 break;
154 } 156 }
155} 157}
156 158
157POP3folderItem::~POP3folderItem() 159POP3folderItem::~POP3folderItem()
158{} 160{}
159 161
160POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 162POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , Q3ListViewItem*after )
161 : AccountViewItem(folderInit,parent,after ) 163 : AccountViewItem(folderInit,parent,after )
162{ 164{
163 pop3 = parent; 165 pop3 = parent;
164 if (folder->getDisplayName().lower()!="inbox") 166 if (folder->getDisplayName().lower()!="inbox")
165 { 167 {
166 setPixmap( 0, PIXMAP_POP3FOLDER ); 168 setPixmap( 0, PIXMAP_POP3FOLDER );
167 } 169 }
168 else 170 else
169 { 171 {
170 setPixmap( 0, PIXMAP_INBOXFOLDER); 172 setPixmap( 0, PIXMAP_INBOXFOLDER);
171 } 173 }
172 setText( 0, folder->getDisplayName() ); 174 setText( 0, folder->getDisplayName() );
173} 175}
174 176
175void POP3folderItem::refresh(QValueList<RecMailP>&target) 177void POP3folderItem::refresh(Q3ValueList<RecMailP>&target)
176{ 178{
177 if (folder->may_select()) 179 if (folder->may_select())
178 pop3->getWrapper()->listMessages( folder->getName(),target ); 180 pop3->getWrapper()->listMessages( folder->getName(),target );
179} 181}
180 182
181RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 183RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
182{ 184{
183 return pop3->getWrapper()->fetchBody(aMail); 185 return pop3->getWrapper()->fetchBody(aMail);
184} 186}
185 187
186QPopupMenu * POP3folderItem::getContextMenu() 188Q3PopupMenu * POP3folderItem::getContextMenu()
187{ 189{
188 QPopupMenu *m = new QPopupMenu(0); 190 Q3PopupMenu *m = new Q3PopupMenu(0);
189 if (m) 191 if (m)
190 { 192 {
191 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); 193 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS);
192 m->insertItem(i18n("Refresh header list"),0); 194 m->insertItem(i18n("Refresh header list"),0);
193 m->insertItem(i18n("Delete all mails"),1); 195 m->insertItem(i18n("Delete all mails"),1);
194 m->insertItem(i18n("Move/Copie all mails"),2); 196 m->insertItem(i18n("Move/Copie all mails"),2);
195 } 197 }
196 return m; 198 return m;
197} 199}
198 200
199void POP3folderItem::downloadMails() 201void POP3folderItem::downloadMails()
200{ 202{
@@ -252,60 +254,60 @@ NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
252} 254}
253 255
254NNTPviewItem::~NNTPviewItem() 256NNTPviewItem::~NNTPviewItem()
255{ 257{
256 delete wrapper; 258 delete wrapper;
257} 259}
258 260
259AbstractMail *NNTPviewItem::getWrapper() 261AbstractMail *NNTPviewItem::getWrapper()
260{ 262{
261 return wrapper; 263 return wrapper;
262} 264}
263 265
264void NNTPviewItem::refresh( QValueList<RecMailP> & ) 266void NNTPviewItem::refresh( Q3ValueList<RecMailP> & )
265{ 267{
266 refresh(); 268 refresh();
267} 269}
268 270
269void NNTPviewItem::refresh() 271void NNTPviewItem::refresh()
270{ 272{
271 if (account->getOffline()) return; 273 if (account->getOffline()) return;
272 QValueList<FolderP> *folders = wrapper->listFolders(); 274 Q3ValueList<FolderP> *folders = wrapper->listFolders();
273 275
274 QListViewItem *child = firstChild(); 276 Q3ListViewItem *child = firstChild();
275 while ( child ) 277 while ( child )
276 { 278 {
277 QListViewItem *tmp = child; 279 Q3ListViewItem *tmp = child;
278 child = child->nextSibling(); 280 child = child->nextSibling();
279 delete tmp; 281 delete tmp;
280 } 282 }
281 QValueList<FolderP>::ConstIterator it; 283 Q3ValueList<FolderP>::ConstIterator it;
282 QListViewItem*item = 0; 284 Q3ListViewItem*item = 0;
283 for ( it = folders->begin(); it!=folders->end(); ++it) 285 for ( it = folders->begin(); it!=folders->end(); ++it)
284 { 286 {
285 item = new NNTPfolderItem( (*it), this , item ); 287 item = new NNTPfolderItem( (*it), this , item );
286 item->setSelectable( (*it)->may_select()); 288 item->setSelectable( (*it)->may_select());
287 } 289 }
288 delete folders; 290 delete folders;
289} 291}
290 292
291RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) 293RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
292{ 294{
293 295
294 return wrapper->fetchBody( mail ); 296 return wrapper->fetchBody( mail );
295} 297}
296 298
297QPopupMenu * NNTPviewItem::getContextMenu() 299Q3PopupMenu * NNTPviewItem::getContextMenu()
298{ 300{
299 QPopupMenu *m = new QPopupMenu(0); 301 Q3PopupMenu *m = new Q3PopupMenu(0);
300 if (m) 302 if (m)
301 { 303 {
302 if (!account->getOffline()) 304 if (!account->getOffline())
303 { 305 {
304 m->insertItem(i18n("Disconnect"),0); 306 m->insertItem(i18n("Disconnect"),0);
305 m->insertItem(i18n("Set offline"),1); 307 m->insertItem(i18n("Set offline"),1);
306 //m->insertItem(i18n("(Un-)Subscribe groups"),2); 308 //m->insertItem(i18n("(Un-)Subscribe groups"),2);
307 } 309 }
308 else 310 else
309 { 311 {
310 m->insertItem(i18n("Set online"),1); 312 m->insertItem(i18n("Set online"),1);
311 } 313 }
@@ -317,28 +319,28 @@ void NNTPviewItem::subscribeGroups()
317{ 319{
318 NNTPGroupsDlg dlg(account); 320 NNTPGroupsDlg dlg(account);
319#ifndef DESKTOP_VERSION 321#ifndef DESKTOP_VERSION
320 dlg.showMaximized(); 322 dlg.showMaximized();
321#endif 323#endif
322 if ( dlg.exec()== QDialog::Accepted ){ 324 if ( dlg.exec()== QDialog::Accepted ){
323 refresh(); 325 refresh();
324 } 326 }
325} 327}
326 328
327void NNTPviewItem::disconnect() 329void NNTPviewItem::disconnect()
328{ 330{
329 QListViewItem *child = firstChild(); 331 Q3ListViewItem *child = firstChild();
330 while ( child ) 332 while ( child )
331 { 333 {
332 QListViewItem *tmp = child; 334 Q3ListViewItem *tmp = child;
333 child = child->nextSibling(); 335 child = child->nextSibling();
334 delete tmp; 336 delete tmp;
335 } 337 }
336 wrapper->logout(); 338 wrapper->logout();
337} 339}
338 340
339void NNTPviewItem::setOnOffline() 341void NNTPviewItem::setOnOffline()
340{ 342{
341 if (!account->getOffline()) 343 if (!account->getOffline())
342 { 344 {
343 disconnect(); 345 disconnect();
344 } 346 }
@@ -359,53 +361,53 @@ void NNTPviewItem::contextMenuSelected(int which)
359 case 1: 361 case 1:
360 setOnOffline(); 362 setOnOffline();
361 break; 363 break;
362 case 2: 364 case 2:
363 subscribeGroups(); 365 subscribeGroups();
364 break; 366 break;
365 } 367 }
366} 368}
367 369
368NNTPfolderItem::~NNTPfolderItem() 370NNTPfolderItem::~NNTPfolderItem()
369{} 371{}
370 372
371NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) 373NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , Q3ListViewItem*after )
372 : AccountViewItem( folderInit, parent,after ) 374 : AccountViewItem( folderInit, parent,after )
373{ 375{
374 nntp = parent; 376 nntp = parent;
375 if (folder->getDisplayName().lower()!="inbox") 377 if (folder->getDisplayName().lower()!="inbox")
376 { 378 {
377 setPixmap( 0, PIXMAP_POP3FOLDER ); 379 setPixmap( 0, PIXMAP_POP3FOLDER );
378 } 380 }
379 else 381 else
380 { 382 {
381 setPixmap( 0, PIXMAP_INBOXFOLDER); 383 setPixmap( 0, PIXMAP_INBOXFOLDER);
382 } 384 }
383 setText( 0, folder->getDisplayName() ); 385 setText( 0, folder->getDisplayName() );
384} 386}
385 387
386void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 388void NNTPfolderItem::refresh(Q3ValueList<RecMailP>&target)
387{ 389{
388 if (folder->may_select()) 390 if (folder->may_select())
389 nntp->getWrapper()->listMessages( folder->getName(),target ); 391 nntp->getWrapper()->listMessages( folder->getName(),target );
390} 392}
391 393
392RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) 394RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
393{ 395{
394 return nntp->getWrapper()->fetchBody(aMail); 396 return nntp->getWrapper()->fetchBody(aMail);
395} 397}
396 398
397QPopupMenu * NNTPfolderItem::getContextMenu() 399Q3PopupMenu * NNTPfolderItem::getContextMenu()
398{ 400{
399 QPopupMenu *m = new QPopupMenu(0); 401 Q3PopupMenu *m = new Q3PopupMenu(0);
400 if (m) 402 if (m)
401 { 403 {
402 m->insertItem(i18n("Refresh header list"),0); 404 m->insertItem(i18n("Refresh header list"),0);
403 m->insertItem(i18n("Copy all postings"),1); 405 m->insertItem(i18n("Copy all postings"),1);
404 } 406 }
405 return m; 407 return m;
406} 408}
407 409
408void NNTPfolderItem::downloadMails() 410void NNTPfolderItem::downloadMails()
409{ 411{
410 AccountView*bl = nntp->accountView(); 412 AccountView*bl = nntp->accountView();
411 if (!bl) return; 413 if (!bl) return;
@@ -444,46 +446,46 @@ IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
444} 446}
445 447
446IMAPviewItem::~IMAPviewItem() 448IMAPviewItem::~IMAPviewItem()
447{ 449{
448 delete wrapper; 450 delete wrapper;
449} 451}
450 452
451AbstractMail *IMAPviewItem::getWrapper() 453AbstractMail *IMAPviewItem::getWrapper()
452{ 454{
453 return wrapper; 455 return wrapper;
454} 456}
455 457
456void IMAPviewItem::refresh(QValueList<RecMailP>&) 458void IMAPviewItem::refresh(Q3ValueList<RecMailP>&)
457{ 459{
458 refreshFolders(false); 460 refreshFolders(false);
459} 461}
460 462
461const QStringList&IMAPviewItem::subFolders() 463const QStringList&IMAPviewItem::subFolders()
462{ 464{
463 return currentFolders; 465 return currentFolders;
464} 466}
465 467
466void IMAPviewItem::refreshFolders(bool force) 468void IMAPviewItem::refreshFolders(bool force)
467{ 469{
468 if (childCount()>0 && force==false) return; 470 if (childCount()>0 && force==false) return;
469 if (account->getOffline()) return; 471 if (account->getOffline()) return;
470 472
471 removeChilds(); 473 removeChilds();
472 currentFolders.clear(); 474 currentFolders.clear();
473 QValueList<FolderP> * folders = wrapper->listFolders(); 475 Q3ValueList<FolderP> * folders = wrapper->listFolders();
474 476
475 QValueList<FolderP>::Iterator it; 477 Q3ValueList<FolderP>::Iterator it;
476 QListViewItem*item = 0; 478 Q3ListViewItem*item = 0;
477 QListViewItem*titem = 0; 479 Q3ListViewItem*titem = 0;
478 QString fname,del,search; 480 QString fname,del,search;
479 int pos; 481 int pos;
480 482
481 for ( it = folders->begin(); it!=folders->end(); ++it) 483 for ( it = folders->begin(); it!=folders->end(); ++it)
482 { 484 {
483 if ((*it)->getDisplayName().lower()=="inbox") 485 if ((*it)->getDisplayName().lower()=="inbox")
484 { 486 {
485 item = new IMAPfolderItem( (*it), this , item ); 487 item = new IMAPfolderItem( (*it), this , item );
486 folders->remove(it); 488 folders->remove(it);
487 break; 489 break;
488 } 490 }
489 } 491 }
@@ -504,27 +506,27 @@ void IMAPviewItem::refreshFolders(bool force)
504 /* setup the short name */ 506 /* setup the short name */
505 item->setText(0,(*it)->getDisplayName().mid(pos+1)); 507 item->setText(0,(*it)->getDisplayName().mid(pos+1));
506 item = titem; 508 item = titem;
507 } 509 }
508 else 510 else
509 { 511 {
510 item = new IMAPfolderItem( (*it), this , item ); 512 item = new IMAPfolderItem( (*it), this , item );
511 } 513 }
512 } 514 }
513 delete folders; 515 delete folders;
514} 516}
515 517
516QPopupMenu * IMAPviewItem::getContextMenu() 518Q3PopupMenu * IMAPviewItem::getContextMenu()
517{ 519{
518 QPopupMenu *m = new QPopupMenu(0); 520 Q3PopupMenu *m = new Q3PopupMenu(0);
519 if (m) 521 if (m)
520 { 522 {
521 if (!account->getOffline()) 523 if (!account->getOffline())
522 { 524 {
523 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); 525 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS);
524 m->insertItem(i18n("Refresh folder list"),0); 526 m->insertItem(i18n("Refresh folder list"),0);
525 m->insertItem(i18n("Create new folder"),1); 527 m->insertItem(i18n("Create new folder"),1);
526 m->insertSeparator(); 528 m->insertSeparator();
527 m->insertItem(i18n("Disconnect"),2); 529 m->insertItem(i18n("Disconnect"),2);
528 m->insertItem(i18n("Set offline"),3); 530 m->insertItem(i18n("Set offline"),3);
529 m->insertSeparator(); 531 m->insertSeparator();
530 } 532 }
@@ -606,82 +608,82 @@ void IMAPviewItem::contextMenuSelected(int id)
606} 608}
607 609
608RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 610RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
609{ 611{
610 return new RecBody(); 612 return new RecBody();
611} 613}
612 614
613bool IMAPviewItem::offline() 615bool IMAPviewItem::offline()
614{ 616{
615 return account->getOffline(); 617 return account->getOffline();
616} 618}
617 619
618IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 620IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , Q3ListViewItem*after )
619 : AccountViewItem( folderInit, parent , after ) 621 : AccountViewItem( folderInit, parent , after )
620{ 622{
621 imap = parent; 623 imap = parent;
622 if (folder->getDisplayName().lower()!="inbox") 624 if (folder->getDisplayName().lower()!="inbox")
623 { 625 {
624 setPixmap( 0, PIXMAP_IMAPFOLDER ); 626 setPixmap( 0, PIXMAP_IMAPFOLDER );
625 } 627 }
626 else 628 else
627 { 629 {
628 setPixmap( 0, PIXMAP_INBOXFOLDER); 630 setPixmap( 0, PIXMAP_INBOXFOLDER);
629 } 631 }
630 setText( 0, folder->getDisplayName() ); 632 setText( 0, folder->getDisplayName() );
631} 633}
632 634
633IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 635IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , Q3ListViewItem*after, IMAPviewItem *master )
634 : AccountViewItem(folderInit, parent,after ) 636 : AccountViewItem(folderInit, parent,after )
635{ 637{
636 imap = master; 638 imap = master;
637 if (folder->getDisplayName().lower()!="inbox") 639 if (folder->getDisplayName().lower()!="inbox")
638 { 640 {
639 setPixmap( 0, PIXMAP_IMAPFOLDER ); 641 setPixmap( 0, PIXMAP_IMAPFOLDER );
640 } 642 }
641 else 643 else
642 { 644 {
643 setPixmap( 0, PIXMAP_INBOXFOLDER); 645 setPixmap( 0, PIXMAP_INBOXFOLDER);
644 } 646 }
645 setText( 0, folder->getDisplayName() ); 647 setText( 0, folder->getDisplayName() );
646} 648}
647 649
648IMAPfolderItem::~IMAPfolderItem() 650IMAPfolderItem::~IMAPfolderItem()
649{} 651{}
650 652
651const QString& IMAPfolderItem::Delemiter()const 653const QString& IMAPfolderItem::Delemiter()const
652{ 654{
653 return folder->Separator(); 655 return folder->Separator();
654} 656}
655 657
656void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 658void IMAPfolderItem::refresh(Q3ValueList<RecMailP>&target)
657{ 659{
658 if (folder->may_select()) 660 if (folder->may_select())
659 { 661 {
660 imap->getWrapper()->listMessages( folder->getName(),target ); 662 imap->getWrapper()->listMessages( folder->getName(),target );
661 } 663 }
662 else 664 else
663 { 665 {
664 target.clear(); 666 target.clear();
665 } 667 }
666} 668}
667 669
668RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 670RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
669{ 671{
670 return imap->getWrapper()->fetchBody(aMail); 672 return imap->getWrapper()->fetchBody(aMail);
671} 673}
672 674
673QPopupMenu * IMAPfolderItem::getContextMenu() 675Q3PopupMenu * IMAPfolderItem::getContextMenu()
674{ 676{
675 QPopupMenu *m = new QPopupMenu(0); 677 Q3PopupMenu *m = new Q3PopupMenu(0);
676 if (m) 678 if (m)
677 { 679 {
678 if (folder->may_select()) 680 if (folder->may_select())
679 { 681 {
680 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS); 682 m->insertItem(i18n("Get new messages"),GET_NEW_MAILS);
681 m->insertItem(i18n("Refresh header list"),0); 683 m->insertItem(i18n("Refresh header list"),0);
682 m->insertItem(i18n("Move/Copie all mails"),4); 684 m->insertItem(i18n("Move/Copie all mails"),4);
683 m->insertItem(i18n("Delete all mails"),1); 685 m->insertItem(i18n("Delete all mails"),1);
684 } 686 }
685 if (folder->no_inferior()==false) 687 if (folder->no_inferior()==false)
686 { 688 {
687 m->insertItem(i18n("Create new subfolder"),2); 689 m->insertItem(i18n("Create new subfolder"),2);
@@ -712,25 +714,25 @@ void IMAPfolderItem::createNewFolder()
712 714
713void IMAPfolderItem::deleteFolder() 715void IMAPfolderItem::deleteFolder()
714{ 716{
715 int yesno = QMessageBox::warning(0,i18n("Delete folder"), 717 int yesno = QMessageBox::warning(0,i18n("Delete folder"),
716 i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), 718 i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()),
717 i18n("Yes"), 719 i18n("Yes"),
718 i18n("No"),QString::null,1,1); 720 i18n("No"),QString::null,1,1);
719 721
720 if (yesno == 0) 722 if (yesno == 0)
721 { 723 {
722 if (imap->getWrapper()->deleteMbox(folder)) 724 if (imap->getWrapper()->deleteMbox(folder))
723 { 725 {
724 QListView*v=listView(); 726 Q3ListView*v=listView();
725 IMAPviewItem * box = imap; 727 IMAPviewItem * box = imap;
726 /* be carefull - after that this object is destroyd so don't use 728 /* be carefull - after that this object is destroyd so don't use
727 * any member of it after that call!!*/ 729 * any member of it after that call!!*/
728 imap->refreshFolders(true); 730 imap->refreshFolders(true);
729 if (v) 731 if (v)
730 { 732 {
731 v->setSelected(box,true); 733 v->setSelected(box,true);
732 } 734 }
733 } 735 }
734 } 736 }
735} 737}
736 738
@@ -791,37 +793,37 @@ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
791} 793}
792 794
793MHviewItem::~MHviewItem() 795MHviewItem::~MHviewItem()
794{ 796{
795 delete wrapper; 797 delete wrapper;
796} 798}
797 799
798AbstractMail *MHviewItem::getWrapper() 800AbstractMail *MHviewItem::getWrapper()
799{ 801{
800 return wrapper; 802 return wrapper;
801} 803}
802 804
803void MHviewItem::refresh( QValueList<RecMailP> & target) 805void MHviewItem::refresh( Q3ValueList<RecMailP> & target)
804{ 806{
805 refresh(false); 807 refresh(false);
806 getWrapper()->listMessages( "",target ); 808 getWrapper()->listMessages( "",target );
807} 809}
808 810
809void MHviewItem::refresh(bool force) 811void MHviewItem::refresh(bool force)
810{ 812{
811 if (childCount()>0 && force==false) return; 813 if (childCount()>0 && force==false) return;
812 removeChilds(); 814 removeChilds();
813 currentFolders.clear(); 815 currentFolders.clear();
814 QValueList<FolderP> *folders = wrapper->listFolders(); 816 Q3ValueList<FolderP> *folders = wrapper->listFolders();
815 QValueList<FolderP>::ConstIterator it; 817 Q3ValueList<FolderP>::ConstIterator it;
816 MHfolderItem*item = 0; 818 MHfolderItem*item = 0;
817 MHfolderItem*pmaster = 0; 819 MHfolderItem*pmaster = 0;
818 QString fname = ""; 820 QString fname = "";
819 int pos; 821 int pos;
820 for ( it = folders->begin(); it!=folders->end(); ++it) 822 for ( it = folders->begin(); it!=folders->end(); ++it)
821 { 823 {
822 fname = (*it)->getDisplayName(); 824 fname = (*it)->getDisplayName();
823 /* this folder itself */ 825 /* this folder itself */
824 if (fname=="/") 826 if (fname=="/")
825 { 827 {
826 currentFolders.append(fname); 828 currentFolders.append(fname);
827 folder = (*it); 829 folder = (*it);
@@ -848,27 +850,27 @@ void MHviewItem::refresh(bool force)
848 } 850 }
849 item->setSelectable((*it)->may_select()); 851 item->setSelectable((*it)->may_select());
850 } 852 }
851 delete folders; 853 delete folders;
852} 854}
853 855
854RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) 856RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
855{ 857{
856 858
857 return wrapper->fetchBody( mail ); 859 return wrapper->fetchBody( mail );
858} 860}
859 861
860QPopupMenu * MHviewItem::getContextMenu() 862Q3PopupMenu * MHviewItem::getContextMenu()
861{ 863{
862 QPopupMenu *m = new QPopupMenu(0); 864 Q3PopupMenu *m = new Q3PopupMenu(0);
863 if (m) 865 if (m)
864 { 866 {
865 m->insertItem(i18n("Refresh folder list"),0); 867 m->insertItem(i18n("Refresh folder list"),0);
866 m->insertItem(i18n("Create new folder"),1); 868 m->insertItem(i18n("Create new folder"),1);
867 m->insertItem(i18n("Delete all mails"),2); 869 m->insertItem(i18n("Delete all mails"),2);
868 m->insertItem(i18n("Move/Copie all mails"),3); 870 m->insertItem(i18n("Move/Copie all mails"),3);
869 } 871 }
870 return m; 872 return m;
871} 873}
872 874
873void MHviewItem::createFolder() 875void MHviewItem::createFolder()
874{ 876{
@@ -911,32 +913,32 @@ void MHviewItem::contextMenuSelected(int which)
911 break; 913 break;
912 case 3: 914 case 3:
913 downloadMails(); 915 downloadMails();
914 break; 916 break;
915 default: 917 default:
916 break; 918 break;
917 } 919 }
918} 920}
919 921
920MHfolderItem::~MHfolderItem() 922MHfolderItem::~MHfolderItem()
921{} 923{}
922 924
923MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) 925MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , Q3ListViewItem*after )
924 : AccountViewItem(folderInit, parent,after ) 926 : AccountViewItem(folderInit, parent,after )
925{ 927{
926 mbox = parent; 928 mbox = parent;
927 initName(); 929 initName();
928} 930}
929 931
930MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 932MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, Q3ListViewItem*after, MHviewItem*master)
931 : AccountViewItem(folderInit, parent,after ) 933 : AccountViewItem(folderInit, parent,after )
932{ 934{
933 folder = folderInit; 935 folder = folderInit;
934 mbox = master; 936 mbox = master;
935 initName(); 937 initName();
936} 938}
937 939
938void MHfolderItem::initName() 940void MHfolderItem::initName()
939{ 941{
940 QString bName = folder->getDisplayName(); 942 QString bName = folder->getDisplayName();
941 if (bName.startsWith("/")&&bName.length()>1) 943 if (bName.startsWith("/")&&bName.length()>1)
942 { 944 {
@@ -958,62 +960,62 @@ void MHfolderItem::initName()
958 setPixmap(0, SmallIcon ("edit")); 960 setPixmap(0, SmallIcon ("edit"));
959 } else { 961 } else {
960 setPixmap( 0, PIXMAP_MBOXFOLDER ); 962 setPixmap( 0, PIXMAP_MBOXFOLDER );
961 } 963 }
962 setText( 0, bName ); 964 setText( 0, bName );
963} 965}
964 966
965const FolderP&MHfolderItem::getFolder()const 967const FolderP&MHfolderItem::getFolder()const
966{ 968{
967 return folder; 969 return folder;
968} 970}
969 971
970void MHfolderItem::refresh(QValueList<RecMailP>&target) 972void MHfolderItem::refresh(Q3ValueList<RecMailP>&target)
971{ 973{
972 if (folder->may_select()) 974 if (folder->may_select())
973 mbox->getWrapper()->listMessages( folder->getName(),target ); 975 mbox->getWrapper()->listMessages( folder->getName(),target );
974} 976}
975 977
976RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) 978RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
977{ 979{
978 return mbox->getWrapper()->fetchBody(aMail); 980 return mbox->getWrapper()->fetchBody(aMail);
979} 981}
980 982
981void MHfolderItem::deleteFolder() 983void MHfolderItem::deleteFolder()
982{ 984{
983 int yesno = QMessageBox::warning(0,i18n("Delete folder"), 985 int yesno = QMessageBox::warning(0,i18n("Delete folder"),
984 i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()), 986 i18n("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>").arg(folder->getDisplayName()),
985 i18n("Yes"), 987 i18n("Yes"),
986 i18n("No"),QString::null,1,1); 988 i18n("No"),QString::null,1,1);
987 989
988 if (yesno == 0) 990 if (yesno == 0)
989 { 991 {
990 if (mbox->getWrapper()->deleteMbox(folder)) 992 if (mbox->getWrapper()->deleteMbox(folder))
991 { 993 {
992 QListView*v=listView(); 994 Q3ListView*v=listView();
993 MHviewItem * box = mbox; 995 MHviewItem * box = mbox;
994 /* be carefull - after that this object is destroyd so don't use 996 /* be carefull - after that this object is destroyd so don't use
995 * any member of it after that call!!*/ 997 * any member of it after that call!!*/
996 mbox->refresh(true); 998 mbox->refresh(true);
997 if (v) 999 if (v)
998 { 1000 {
999 v->setSelected(box,true); 1001 v->setSelected(box,true);
1000 } 1002 }
1001 } 1003 }
1002 } 1004 }
1003} 1005}
1004 1006
1005QPopupMenu * MHfolderItem::getContextMenu() 1007Q3PopupMenu * MHfolderItem::getContextMenu()
1006{ 1008{
1007 QPopupMenu *m = new QPopupMenu(0); 1009 Q3PopupMenu *m = new Q3PopupMenu(0);
1008 if (m) 1010 if (m)
1009 { 1011 {
1010 m->insertItem(i18n("Move/Copie all mails"),2); 1012 m->insertItem(i18n("Move/Copie all mails"),2);
1011 m->insertItem(i18n("Delete all mails"),0); 1013 m->insertItem(i18n("Delete all mails"),0);
1012 m->insertItem(i18n("Create new subfolder"),3); 1014 m->insertItem(i18n("Create new subfolder"),3);
1013 m->insertItem(i18n("Delete folder"),1); 1015 m->insertItem(i18n("Delete folder"),1);
1014 } 1016 }
1015 return m; 1017 return m;
1016} 1018}
1017 1019
1018void MHfolderItem::downloadMails() 1020void MHfolderItem::downloadMails()
1019{ 1021{
@@ -1022,25 +1024,25 @@ void MHfolderItem::downloadMails()
1022 bl->downloadMails(folder,mbox->getWrapper()); 1024 bl->downloadMails(folder,mbox->getWrapper());
1023} 1025}
1024 1026
1025void MHfolderItem::createFolder() 1027void MHfolderItem::createFolder()
1026{ 1028{
1027 Newmdirdlg ndirdlg(0,0,true); 1029 Newmdirdlg ndirdlg(0,0,true);
1028 //ndirdlg.showMaximized(); 1030 //ndirdlg.showMaximized();
1029 if (ndirdlg.exec() ) 1031 if (ndirdlg.exec() )
1030 { 1032 {
1031 QString ndir = ndirdlg.Newdir(); 1033 QString ndir = ndirdlg.Newdir();
1032 if (mbox->getWrapper()->createMbox(ndir,folder)) 1034 if (mbox->getWrapper()->createMbox(ndir,folder))
1033 { 1035 {
1034 QListView*v=listView(); 1036 Q3ListView*v=listView();
1035 MHviewItem * box = mbox; 1037 MHviewItem * box = mbox;
1036 /* be carefull - after that this object is destroyd so don't use 1038 /* be carefull - after that this object is destroyd so don't use
1037 * any member of it after that call!!*/ 1039 * any member of it after that call!!*/
1038 mbox->refresh(true); 1040 mbox->refresh(true);
1039 if (v) 1041 if (v)
1040 { 1042 {
1041 v->setSelected(box,true); 1043 v->setSelected(box,true);
1042 } 1044 }
1043 } 1045 }
1044 } 1046 }
1045} 1047}
1046 1048
@@ -1069,44 +1071,44 @@ bool MHfolderItem::isDraftfolder()
1069{ 1071{
1070 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; 1072 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1071 return false; 1073 return false;
1072} 1074}
1073 1075
1074/** 1076/**
1075 * Generic stuff 1077 * Generic stuff
1076 */ 1078 */
1077 1079
1078const QString AccountViewItem::contextName="AccountViewItem"; 1080const QString AccountViewItem::contextName="AccountViewItem";
1079 1081
1080AccountViewItem::AccountViewItem( AccountView *parent ) 1082AccountViewItem::AccountViewItem( AccountView *parent )
1081 : QListViewItem( parent ) 1083 : Q3ListViewItem( parent )
1082{ 1084{
1083 init(); 1085 init();
1084 m_Backlink = parent; 1086 m_Backlink = parent;
1085} 1087}
1086 1088
1087AccountViewItem::AccountViewItem( QListViewItem *parent) 1089AccountViewItem::AccountViewItem( Q3ListViewItem *parent)
1088 : QListViewItem( parent),folder(0) 1090 : Q3ListViewItem( parent),folder(0)
1089{ 1091{
1090 init(); 1092 init();
1091} 1093}
1092 1094
1093AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1095AccountViewItem::AccountViewItem( Q3ListViewItem *parent , Q3ListViewItem*after )
1094 :QListViewItem( parent,after ),folder(0) 1096 :Q3ListViewItem( parent,after ),folder(0)
1095{ 1097{
1096 init(); 1098 init();
1097} 1099}
1098 1100
1099AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) 1101AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,Q3ListViewItem *parent , Q3ListViewItem*after )
1100 :QListViewItem( parent,after ),folder(folderInit) 1102 :Q3ListViewItem( parent,after ),folder(folderInit)
1101{ 1103{
1102 init(); 1104 init();
1103} 1105}
1104 1106
1105void AccountViewItem::init() 1107void AccountViewItem::init()
1106{ 1108{
1107 m_Backlink = 0; 1109 m_Backlink = 0;
1108} 1110}
1109 1111
1110AccountViewItem::~AccountViewItem() 1112AccountViewItem::~AccountViewItem()
1111{ 1113{
1112 folder = 0; 1114 folder = 0;
@@ -1131,28 +1133,28 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder)
1131 if (yesno == 0) 1133 if (yesno == 0)
1132 { 1134 {
1133 if (wrapper->deleteAllMail(folder)) 1135 if (wrapper->deleteAllMail(folder))
1134 { 1136 {
1135 AccountView * view = (AccountView*)listView(); 1137 AccountView * view = (AccountView*)listView();
1136 if (view) view->refreshCurrent(); 1138 if (view) view->refreshCurrent();
1137 } 1139 }
1138 } 1140 }
1139} 1141}
1140 1142
1141void AccountViewItem::removeChilds() 1143void AccountViewItem::removeChilds()
1142{ 1144{
1143 QListViewItem *child = firstChild(); 1145 Q3ListViewItem *child = firstChild();
1144 while ( child ) 1146 while ( child )
1145 { 1147 {
1146 QListViewItem *tmp = child; 1148 Q3ListViewItem *tmp = child;
1147 child = child->nextSibling(); 1149 child = child->nextSibling();
1148 delete tmp; 1150 delete tmp;
1149 } 1151 }
1150} 1152}
1151 1153
1152bool AccountViewItem::matchName(const QString&name)const 1154bool AccountViewItem::matchName(const QString&name)const
1153{ 1155{
1154 if (!folder) return false; 1156 if (!folder) return false;
1155 return folder->getDisplayName().lower()==name.lower(); 1157 return folder->getDisplayName().lower()==name.lower();
1156} 1158}
1157 1159
1158 1160