summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountitem.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp
index 1698b40..7b9b881 100644
--- a/kmicromail/accountitem.cpp
+++ b/kmicromail/accountitem.cpp
@@ -63,109 +63,112 @@ void POP3viewItem::refresh()
63 QListViewItem *child = firstChild(); 63 QListViewItem *child = firstChild();
64 while ( child ) 64 while ( child )
65 { 65 {
66 QListViewItem *tmp = child; 66 QListViewItem *tmp = child;
67 child = child->nextSibling(); 67 child = child->nextSibling();
68 delete tmp; 68 delete tmp;
69 } 69 }
70 QValueList<FolderP>::ConstIterator it; 70 QValueList<FolderP>::ConstIterator it;
71 QListViewItem*item = 0; 71 QListViewItem*item = 0;
72 for ( it = folders->begin(); it!=folders->end(); ++it) 72 for ( it = folders->begin(); it!=folders->end(); ++it)
73 { 73 {
74 item = new POP3folderItem( (*it), this , item ); 74 item = new POP3folderItem( (*it), this , item );
75 item->setSelectable( (*it)->may_select()); 75 item->setSelectable( (*it)->may_select());
76 } 76 }
77 delete folders; 77 delete folders;
78} 78}
79 79
80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
81{ 81{
82 82
83 return wrapper->fetchBody( mail ); 83 return wrapper->fetchBody( mail );
84} 84}
85 85
86QPopupMenu * POP3viewItem::getContextMenu() 86QPopupMenu * POP3viewItem::getContextMenu()
87{ 87{
88 QPopupMenu *m = new QPopupMenu(0); 88 QPopupMenu *m = new QPopupMenu(0);
89 if (m) 89 if (m)
90 { 90 {
91 if (!account->getOffline()) 91 if (!account->getOffline())
92 { 92 {
93 m->insertItem(QObject::tr("Disconnect",contextName),0); 93 m->insertItem(QObject::tr("Disconnect",contextName),0);
94 m->insertItem(QObject::tr("Set offline",contextName),1); 94 m->insertItem(QObject::tr("Set offline",contextName),1);
95 m->insertItem(QObject::tr("Download messages",contextName),2); 95 m->insertItem(QObject::tr("Download new INBOX messages",contextName),2);
96 } 96 }
97 else 97 else
98 { 98 {
99 m->insertItem(QObject::tr("Set online",contextName),1); 99 m->insertItem(QObject::tr("Set online",contextName),1);
100 m->insertItem(QObject::tr("Download new INBOX messages",contextName),2);
100 } 101 }
101 } 102 }
102 return m; 103 return m;
103} 104}
104 105
105void POP3viewItem::disconnect() 106void POP3viewItem::disconnect()
106{ 107{
107 QListViewItem *child = firstChild(); 108 QListViewItem *child = firstChild();
108 while ( child ) 109 while ( child )
109 { 110 {
110 QListViewItem *tmp = child; 111 QListViewItem *tmp = child;
111 child = child->nextSibling(); 112 child = child->nextSibling();
112 delete tmp; 113 delete tmp;
113 } 114 }
114 wrapper->logout(); 115 wrapper->logout();
115} 116}
116 117
117void POP3viewItem::setOnOffline() 118void POP3viewItem::setOnOffline()
118{ 119{
119 if (!account->getOffline()) 120 if (!account->getOffline())
120 { 121 {
121 disconnect(); 122 disconnect();
122 } 123 }
123 account->setOffline(!account->getOffline()); 124 account->setOffline(!account->getOffline());
124 account->save(); 125 account->save();
125 SETPIX(PIXMAP_POP3FOLDER); 126 SETPIX(PIXMAP_POP3FOLDER);
126 refresh(); 127 refresh();
127} 128}
128 129
129void POP3viewItem::contextMenuSelected(int which) 130void POP3viewItem::contextMenuSelected(int which)
130{ 131{
131 switch (which) 132 switch (which)
132 { 133 {
133 case 0: 134 case 0:
134 disconnect(); 135 disconnect();
135 break; 136 break;
136 case 1: 137 case 1:
137 setOnOffline(); 138 setOnOffline();
138 break; 139 break;
139 case 2: // daunlood 140 case 2: // daunlood
141 if (account->getOffline())
142 setOnOffline();
140 AccountView*bl = accountView(); 143 AccountView*bl = accountView();
141 if (!bl) return; 144 if (!bl) return;
142 AccountViewItem* in = findSubItem( "inbox" , 0); 145 AccountViewItem* in = findSubItem( "inbox" , 0);
143 if ( ! in ) 146 if ( ! in )
144 return; 147 return;
145 bl->downloadMailsInbox(in->getFolder() ,getWrapper()); 148 bl->downloadMailsInbox(in->getFolder() ,getWrapper());
146 setOnOffline(); 149 setOnOffline();
147 break; 150 break;
148 } 151 }
149} 152}
150 153
151POP3folderItem::~POP3folderItem() 154POP3folderItem::~POP3folderItem()
152{} 155{}
153 156
154POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 157POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after )
155 : AccountViewItem(folderInit,parent,after ) 158 : AccountViewItem(folderInit,parent,after )
156{ 159{
157 pop3 = parent; 160 pop3 = parent;
158 if (folder->getDisplayName().lower()!="inbox") 161 if (folder->getDisplayName().lower()!="inbox")
159 { 162 {
160 setPixmap( 0, PIXMAP_POP3FOLDER ); 163 setPixmap( 0, PIXMAP_POP3FOLDER );
161 } 164 }
162 else 165 else
163 { 166 {
164 setPixmap( 0, PIXMAP_INBOXFOLDER); 167 setPixmap( 0, PIXMAP_INBOXFOLDER);
165 } 168 }
166 setText( 0, folder->getDisplayName() ); 169 setText( 0, folder->getDisplayName() );
167} 170}
168 171
169void POP3folderItem::refresh(QValueList<RecMailP>&target) 172void POP3folderItem::refresh(QValueList<RecMailP>&target)
170{ 173{
171 if (folder->may_select()) 174 if (folder->may_select())
@@ -484,121 +487,138 @@ void IMAPviewItem::refreshFolders(bool force)
484 { 487 {
485 fname = fname.left(pos); 488 fname = fname.left(pos);
486 } 489 }
487 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 490 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
488 if (pitem) 491 if (pitem)
489 { 492 {
490 titem = item; 493 titem = item;
491 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); 494 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
492 /* setup the short name */ 495 /* setup the short name */
493 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); 496 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1));
494 item = titem; 497 item = titem;
495 } 498 }
496 else 499 else
497 { 500 {
498 item = new IMAPfolderItem( (*it), this , item ); 501 item = new IMAPfolderItem( (*it), this , item );
499 } 502 }
500 } 503 }
501 delete folders; 504 delete folders;
502} 505}
503 506
504QPopupMenu * IMAPviewItem::getContextMenu() 507QPopupMenu * IMAPviewItem::getContextMenu()
505{ 508{
506 QPopupMenu *m = new QPopupMenu(0); 509 QPopupMenu *m = new QPopupMenu(0);
507 if (m) 510 if (m)
508 { 511 {
509 if (!account->getOffline()) 512 if (!account->getOffline())
510 { 513 {
511 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 514 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
512 m->insertItem(QObject::tr("Create new folder",contextName),1); 515 m->insertItem(QObject::tr("Create new folder",contextName),1);
513 m->insertSeparator(); 516 m->insertSeparator();
514 m->insertItem(QObject::tr("Disconnect",contextName),2); 517 m->insertItem(QObject::tr("Disconnect",contextName),2);
515 m->insertItem(QObject::tr("Set offline",contextName),3); 518 m->insertItem(QObject::tr("Set offline",contextName),3);
519 m->insertSeparator();
520 m->insertItem(QObject::tr("Download new INBOX messages",contextName),4);
516 } 521 }
517 else 522 else
518 { 523 {
519 m->insertItem(QObject::tr("Set online",contextName),3); 524 m->insertItem(QObject::tr("Set online",contextName),3);
525 m->insertSeparator();
526 m->insertItem(QObject::tr("Download new INBOX messages",contextName),4);
520 } 527 }
521 } 528 }
522 return m; 529 return m;
523} 530}
524 531
525void IMAPviewItem::createNewFolder() 532void IMAPviewItem::createNewFolder()
526{ 533{
527 Newmdirdlg ndirdlg; 534 Newmdirdlg ndirdlg;
528 535
529 ndirdlg.showMaximized(); 536 ndirdlg.showMaximized();
530 if ( ndirdlg.exec() ) 537 if ( ndirdlg.exec() )
531 { 538 {
532 QString ndir = ndirdlg.Newdir(); 539 QString ndir = ndirdlg.Newdir();
533 bool makesubs = ndirdlg.subpossible(); 540 bool makesubs = ndirdlg.subpossible();
534 QString delemiter = "/"; 541 QString delemiter = "/";
535 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 542 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
536 if (item) 543 if (item)
537 { 544 {
538 delemiter = item->Delemiter(); 545 delemiter = item->Delemiter();
539 } 546 }
540 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) 547 if (wrapper->createMbox(ndir,0,delemiter,makesubs))
541 { 548 {
542 refreshFolders(true); 549 refreshFolders(true);
543 } 550 }
544 } 551 }
545} 552}
546 553
547void IMAPviewItem::contextMenuSelected(int id) 554void IMAPviewItem::contextMenuSelected(int id)
548{ 555{
549 556
550 switch (id) 557 switch (id)
551 { 558 {
552 case 0: 559 case 0:
553 refreshFolders(true); 560 refreshFolders(true);
554 break; 561 break;
555 case 1: 562 case 1:
556 createNewFolder(); 563 createNewFolder();
557 break; 564 break;
558 case 2: 565 case 2:
559 removeChilds(); 566 removeChilds();
560 wrapper->logout(); 567 wrapper->logout();
561 break; 568 break;
562 case 3: 569 case 3:
563 if (account->getOffline()==false) 570 if (account->getOffline()==false)
564 { 571 {
565 removeChilds(); 572 removeChilds();
566 wrapper->logout(); 573 wrapper->logout();
567 } 574 }
568 account->setOffline(!account->getOffline()); 575 account->setOffline(!account->getOffline());
569 account->save(); 576 account->save();
570 SETPIX(PIXMAP_IMAPFOLDER); 577 SETPIX(PIXMAP_IMAPFOLDER);
571 refreshFolders(false); 578 refreshFolders(false);
572 break; 579 break;
580 case 4: // daunlood
581 {
582 if (account->getOffline()) {
583 contextMenuSelected( 3 );
584 }
585 AccountView*bl = accountView();
586 if (!bl) return;
587 AccountViewItem* in = findSubItem( "inbox" , 0);
588 if ( ! in )
589 return;
590 bl->downloadMailsInbox(in->getFolder(),getWrapper());
591 }
592 break;
573 default: 593 default:
574 break; 594 break;
575 } 595 }
576} 596}
577 597
578RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 598RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
579{ 599{
580 return new RecBody(); 600 return new RecBody();
581} 601}
582 602
583bool IMAPviewItem::offline() 603bool IMAPviewItem::offline()
584{ 604{
585 return account->getOffline(); 605 return account->getOffline();
586} 606}
587 607
588IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 608IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
589 : AccountViewItem( folderInit, parent , after ) 609 : AccountViewItem( folderInit, parent , after )
590{ 610{
591 imap = parent; 611 imap = parent;
592 if (folder->getDisplayName().lower()!="inbox") 612 if (folder->getDisplayName().lower()!="inbox")
593 { 613 {
594 setPixmap( 0, PIXMAP_IMAPFOLDER ); 614 setPixmap( 0, PIXMAP_IMAPFOLDER );
595 } 615 }
596 else 616 else
597 { 617 {
598 setPixmap( 0, PIXMAP_INBOXFOLDER); 618 setPixmap( 0, PIXMAP_INBOXFOLDER);
599 } 619 }
600 setText( 0, folder->getDisplayName() ); 620 setText( 0, folder->getDisplayName() );
601} 621}
602 622
603IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 623IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
604 : AccountViewItem(folderInit, parent,after ) 624 : AccountViewItem(folderInit, parent,after )