author | alwin <alwin> | 2004-01-07 19:27:47 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-07 19:27:47 (UTC) |
commit | 24a62e8789083f446138aebfa11409b73886aa88 (patch) (unidiff) | |
tree | 177bd3de4ad46fd29e93b87c6a0423a4ca132682 /noncore/net/mail/accountview.cpp | |
parent | 7fdc50c5ff3fe42aba6d940165e99ed7150df4f1 (diff) | |
download | opie-24a62e8789083f446138aebfa11409b73886aa88.zip opie-24a62e8789083f446138aebfa11409b73886aa88.tar.gz opie-24a62e8789083f446138aebfa11409b73886aa88.tar.bz2 |
download mail mostly finished
accounts can be switched "offline"
Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 212 |
1 files changed, 199 insertions, 13 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index faa6982..eea021f 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -7,13 +7,13 @@ | |||
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * POP3 Account stuff | 11 | * POP3 Account stuff |
12 | */ | 12 | */ |
13 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 13 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
14 | : AccountViewItem( parent ) | 14 | : AccountViewItem( parent ) |
15 | { | 15 | { |
16 | account = a; | 16 | account = a; |
17 | wrapper = AbstractMail::getWrapper( account ); | 17 | wrapper = AbstractMail::getWrapper( account ); |
18 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 18 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
19 | setText( 0, account->getAccountName() ); | 19 | setText( 0, account->getAccountName() ); |
@@ -29,12 +29,13 @@ AbstractMail *POP3viewItem::getWrapper() | |||
29 | { | 29 | { |
30 | return wrapper; | 30 | return wrapper; |
31 | } | 31 | } |
32 | 32 | ||
33 | void POP3viewItem::refresh( QList<RecMail> & ) | 33 | void POP3viewItem::refresh( QList<RecMail> & ) |
34 | { | 34 | { |
35 | if (account->getOffline()) return; | ||
35 | QList<Folder> *folders = wrapper->listFolders(); | 36 | QList<Folder> *folders = wrapper->listFolders(); |
36 | QListViewItem *child = firstChild(); | 37 | QListViewItem *child = firstChild(); |
37 | while ( child ) { | 38 | while ( child ) { |
38 | QListViewItem *tmp = child; | 39 | QListViewItem *tmp = child; |
39 | child = child->nextSibling(); | 40 | child = child->nextSibling(); |
40 | delete tmp; | 41 | delete tmp; |
@@ -53,12 +54,58 @@ void POP3viewItem::refresh( QList<RecMail> & ) | |||
53 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 54 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
54 | { | 55 | { |
55 | qDebug( "POP3 fetchBody" ); | 56 | qDebug( "POP3 fetchBody" ); |
56 | return wrapper->fetchBody( mail ); | 57 | return wrapper->fetchBody( mail ); |
57 | } | 58 | } |
58 | 59 | ||
60 | QPopupMenu * POP3viewItem::getContextMenu() | ||
61 | { | ||
62 | QPopupMenu *m = new QPopupMenu(0); | ||
63 | if (m) { | ||
64 | if (!account->getOffline()) { | ||
65 | m->insertItem(QObject::tr("Disconnect",contextName),0); | ||
66 | m->insertItem(QObject::tr("Set offline",contextName),1); | ||
67 | } else { | ||
68 | m->insertItem(QObject::tr("Set online",contextName),1); | ||
69 | } | ||
70 | } | ||
71 | return m; | ||
72 | } | ||
73 | |||
74 | void POP3viewItem::disconnect() | ||
75 | { | ||
76 | QListViewItem *child = firstChild(); | ||
77 | while ( child ) { | ||
78 | QListViewItem *tmp = child; | ||
79 | child = child->nextSibling(); | ||
80 | delete tmp; | ||
81 | } | ||
82 | wrapper->logout(); | ||
83 | } | ||
84 | |||
85 | void POP3viewItem::setOnOffline() | ||
86 | { | ||
87 | if (!account->getOffline()) { | ||
88 | disconnect(); | ||
89 | } | ||
90 | account->setOffline(!account->getOffline()); | ||
91 | account->save(); | ||
92 | } | ||
93 | |||
94 | void POP3viewItem::contextMenuSelected(int which) | ||
95 | { | ||
96 | switch (which) { | ||
97 | case 0: | ||
98 | disconnect(); | ||
99 | break; | ||
100 | case 1: | ||
101 | setOnOffline(); | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | |||
59 | POP3folderItem::~POP3folderItem() | 106 | POP3folderItem::~POP3folderItem() |
60 | { | 107 | { |
61 | delete folder; | 108 | delete folder; |
62 | } | 109 | } |
63 | 110 | ||
64 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 111 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
@@ -88,22 +135,22 @@ RecBody POP3folderItem::fetchBody(const RecMail&aMail) | |||
88 | QPopupMenu * POP3folderItem::getContextMenu() | 135 | QPopupMenu * POP3folderItem::getContextMenu() |
89 | { | 136 | { |
90 | QPopupMenu *m = new QPopupMenu(0); | 137 | QPopupMenu *m = new QPopupMenu(0); |
91 | if (m) { | 138 | if (m) { |
92 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 139 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
93 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 140 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
94 | m->insertItem(QObject::tr("Download all mails",contextName),2); | 141 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
95 | } | 142 | } |
96 | return m; | 143 | return m; |
97 | } | 144 | } |
98 | 145 | ||
99 | void POP3folderItem::downloadMails() | 146 | void POP3folderItem::downloadMails() |
100 | { | 147 | { |
101 | Selectstore sels; | 148 | AccountView*bl = pop3->accountView(); |
102 | sels.showMaximized(); | 149 | if (!bl) return; |
103 | sels.exec(); | 150 | bl->downloadMails(folder,pop3->getWrapper()); |
104 | } | 151 | } |
105 | 152 | ||
106 | void POP3folderItem::contextMenuSelected(int which) | 153 | void POP3folderItem::contextMenuSelected(int which) |
107 | { | 154 | { |
108 | AccountView * view = (AccountView*)listView(); | 155 | AccountView * view = (AccountView*)listView(); |
109 | switch (which) { | 156 | switch (which) { |
@@ -123,13 +170,13 @@ void POP3folderItem::contextMenuSelected(int which) | |||
123 | } | 170 | } |
124 | } | 171 | } |
125 | 172 | ||
126 | /** | 173 | /** |
127 | * IMAP Account stuff | 174 | * IMAP Account stuff |
128 | */ | 175 | */ |
129 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 176 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
130 | : AccountViewItem( parent ) | 177 | : AccountViewItem( parent ) |
131 | { | 178 | { |
132 | account = a; | 179 | account = a; |
133 | wrapper = AbstractMail::getWrapper( account ); | 180 | wrapper = AbstractMail::getWrapper( account ); |
134 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 181 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
135 | setText( 0, account->getAccountName() ); | 182 | setText( 0, account->getAccountName() ); |
@@ -180,18 +227,24 @@ void IMAPviewItem::removeChilds() | |||
180 | child = child->nextSibling(); | 227 | child = child->nextSibling(); |
181 | delete tmp; | 228 | delete tmp; |
182 | } | 229 | } |
183 | 230 | ||
184 | } | 231 | } |
185 | 232 | ||
233 | const QStringList&IMAPviewItem::subFolders() | ||
234 | { | ||
235 | return currentFolders; | ||
236 | } | ||
237 | |||
186 | void IMAPviewItem::refreshFolders(bool force) | 238 | void IMAPviewItem::refreshFolders(bool force) |
187 | { | 239 | { |
188 | if (childCount()>0 && force==false) return; | 240 | if (childCount()>0 && force==false) return; |
241 | if (account->getOffline()) return; | ||
189 | 242 | ||
190 | removeChilds(); | 243 | removeChilds(); |
191 | 244 | currentFolders.clear(); | |
192 | QList<Folder> *folders = wrapper->listFolders(); | 245 | QList<Folder> *folders = wrapper->listFolders(); |
193 | 246 | ||
194 | Folder *it; | 247 | Folder *it; |
195 | QListViewItem*item = 0; | 248 | QListViewItem*item = 0; |
196 | QListViewItem*titem = 0; | 249 | QListViewItem*titem = 0; |
197 | QString fname,del,search; | 250 | QString fname,del,search; |
@@ -206,12 +259,13 @@ void IMAPviewItem::refreshFolders(bool force) | |||
206 | qDebug("inbox found"); | 259 | qDebug("inbox found"); |
207 | break; | 260 | break; |
208 | } | 261 | } |
209 | } | 262 | } |
210 | for ( it = folders->first(); it; it = folders->next() ) { | 263 | for ( it = folders->first(); it; it = folders->next() ) { |
211 | fname = it->getDisplayName(); | 264 | fname = it->getDisplayName(); |
265 | currentFolders.append(it->getName()); | ||
212 | pos = fname.findRev(it->Separator()); | 266 | pos = fname.findRev(it->Separator()); |
213 | if (pos != -1) { | 267 | if (pos != -1) { |
214 | fname = fname.left(pos); | 268 | fname = fname.left(pos); |
215 | } | 269 | } |
216 | IMAPfolderItem*pitem = findSubItem(fname); | 270 | IMAPfolderItem*pitem = findSubItem(fname); |
217 | if (pitem) { | 271 | if (pitem) { |
@@ -228,16 +282,21 @@ void IMAPviewItem::refreshFolders(bool force) | |||
228 | } | 282 | } |
229 | 283 | ||
230 | QPopupMenu * IMAPviewItem::getContextMenu() | 284 | QPopupMenu * IMAPviewItem::getContextMenu() |
231 | { | 285 | { |
232 | QPopupMenu *m = new QPopupMenu(0); | 286 | QPopupMenu *m = new QPopupMenu(0); |
233 | if (m) { | 287 | if (m) { |
288 | if (!account->getOffline()) { | ||
234 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 289 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
235 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 290 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
236 | m->insertSeparator(); | 291 | m->insertSeparator(); |
237 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 292 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
293 | m->insertItem(QObject::tr("Set offline",contextName),3); | ||
294 | } else { | ||
295 | m->insertItem(QObject::tr("Set online",contextName),3); | ||
296 | } | ||
238 | } | 297 | } |
239 | return m; | 298 | return m; |
240 | } | 299 | } |
241 | 300 | ||
242 | void IMAPviewItem::createNewFolder() | 301 | void IMAPviewItem::createNewFolder() |
243 | { | 302 | { |
@@ -268,25 +327,34 @@ void IMAPviewItem::contextMenuSelected(int id) | |||
268 | createNewFolder(); | 327 | createNewFolder(); |
269 | break; | 328 | break; |
270 | case 2: | 329 | case 2: |
271 | removeChilds(); | 330 | removeChilds(); |
272 | wrapper->logout(); | 331 | wrapper->logout(); |
273 | break; | 332 | break; |
333 | case 3: | ||
334 | if (account->getOffline()==false) { | ||
335 | removeChilds(); | ||
336 | wrapper->logout(); | ||
337 | } | ||
338 | account->setOffline(!account->getOffline()); | ||
339 | account->save(); | ||
340 | refreshFolders(false); | ||
341 | break; | ||
274 | default: | 342 | default: |
275 | break; | 343 | break; |
276 | } | 344 | } |
277 | } | 345 | } |
278 | 346 | ||
279 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 347 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
280 | { | 348 | { |
281 | return RecBody(); | 349 | return RecBody(); |
282 | } | 350 | } |
283 | 351 | ||
284 | IMAPfolderItem::~IMAPfolderItem() | 352 | bool IMAPviewItem::offline() |
285 | { | 353 | { |
286 | delete folder; | 354 | return account->getOffline(); |
287 | } | 355 | } |
288 | 356 | ||
289 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 357 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
290 | : AccountViewItem( parent , after ) | 358 | : AccountViewItem( parent , after ) |
291 | { | 359 | { |
292 | folder = folderInit; | 360 | folder = folderInit; |
@@ -309,12 +377,17 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi | |||
309 | } else { | 377 | } else { |
310 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 378 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
311 | } | 379 | } |
312 | setText( 0, folder->getDisplayName() ); | 380 | setText( 0, folder->getDisplayName() ); |
313 | } | 381 | } |
314 | 382 | ||
383 | IMAPfolderItem::~IMAPfolderItem() | ||
384 | { | ||
385 | delete folder; | ||
386 | } | ||
387 | |||
315 | const QString& IMAPfolderItem::Delemiter()const | 388 | const QString& IMAPfolderItem::Delemiter()const |
316 | { | 389 | { |
317 | return folder->Separator(); | 390 | return folder->Separator(); |
318 | } | 391 | } |
319 | 392 | ||
320 | bool IMAPfolderItem::matchName(const QString&name)const | 393 | bool IMAPfolderItem::matchName(const QString&name)const |
@@ -339,12 +412,13 @@ RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | |||
339 | QPopupMenu * IMAPfolderItem::getContextMenu() | 412 | QPopupMenu * IMAPfolderItem::getContextMenu() |
340 | { | 413 | { |
341 | QPopupMenu *m = new QPopupMenu(0); | 414 | QPopupMenu *m = new QPopupMenu(0); |
342 | if (m) { | 415 | if (m) { |
343 | if (folder->may_select()) { | 416 | if (folder->may_select()) { |
344 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 417 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
418 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | ||
345 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 419 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
346 | } | 420 | } |
347 | if (folder->no_inferior()==false) { | 421 | if (folder->no_inferior()==false) { |
348 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 422 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
349 | } | 423 | } |
350 | if (folder->getDisplayName().lower()!="inbox") { | 424 | if (folder->getDisplayName().lower()!="inbox") { |
@@ -386,12 +460,19 @@ void IMAPfolderItem::deleteFolder() | |||
386 | v->setSelected(box,true); | 460 | v->setSelected(box,true); |
387 | } | 461 | } |
388 | } | 462 | } |
389 | } | 463 | } |
390 | } | 464 | } |
391 | 465 | ||
466 | void IMAPfolderItem::downloadMails() | ||
467 | { | ||
468 | AccountView*bl = imap->accountView(); | ||
469 | if (!bl) return; | ||
470 | bl->downloadMails(folder,imap->getWrapper()); | ||
471 | } | ||
472 | |||
392 | void IMAPfolderItem::contextMenuSelected(int id) | 473 | void IMAPfolderItem::contextMenuSelected(int id) |
393 | { | 474 | { |
394 | qDebug("Selected id: %i",id); | 475 | qDebug("Selected id: %i",id); |
395 | AccountView * view = (AccountView*)listView(); | 476 | AccountView * view = (AccountView*)listView(); |
396 | switch(id) { | 477 | switch(id) { |
397 | case 0: | 478 | case 0: |
@@ -403,23 +484,53 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
403 | case 2: | 484 | case 2: |
404 | createNewFolder(); | 485 | createNewFolder(); |
405 | break; | 486 | break; |
406 | case 3: | 487 | case 3: |
407 | deleteFolder(); | 488 | deleteFolder(); |
408 | break; | 489 | break; |
490 | case 4: | ||
491 | downloadMails(); | ||
492 | break; | ||
409 | default: | 493 | default: |
410 | break; | 494 | break; |
411 | } | 495 | } |
412 | } | 496 | } |
413 | 497 | ||
414 | /** | 498 | /** |
415 | * Generic stuff | 499 | * Generic stuff |
416 | */ | 500 | */ |
417 | 501 | ||
418 | const QString AccountViewItem::contextName="AccountViewItem"; | 502 | const QString AccountViewItem::contextName="AccountViewItem"; |
419 | 503 | ||
504 | AccountViewItem::AccountViewItem( AccountView *parent ) | ||
505 | : QListViewItem( parent ) | ||
506 | { | ||
507 | m_Backlink = parent; | ||
508 | } | ||
509 | |||
510 | AccountViewItem::AccountViewItem( QListViewItem *parent) | ||
511 | : QListViewItem( parent) | ||
512 | { | ||
513 | m_Backlink = 0; | ||
514 | } | ||
515 | |||
516 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | ||
517 | :QListViewItem( parent,after ) | ||
518 | { | ||
519 | m_Backlink = 0; | ||
520 | } | ||
521 | |||
522 | AccountViewItem::~AccountViewItem() | ||
523 | { | ||
524 | } | ||
525 | |||
526 | AccountView*AccountViewItem::accountView() | ||
527 | { | ||
528 | return m_Backlink; | ||
529 | } | ||
530 | |||
420 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | 531 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) |
421 | { | 532 | { |
422 | if (!wrapper) return; | 533 | if (!wrapper) return; |
423 | QString fname=""; | 534 | QString fname=""; |
424 | if (folder) fname = folder->getDisplayName(); | 535 | if (folder) fname = folder->getDisplayName(); |
425 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 536 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
@@ -444,12 +555,18 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
444 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 555 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
445 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 556 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
446 | 557 | ||
447 | setSorting(0); | 558 | setSorting(0); |
448 | } | 559 | } |
449 | 560 | ||
561 | AccountView::~AccountView() | ||
562 | { | ||
563 | imapAccounts.clear(); | ||
564 | mboxAccounts.clear(); | ||
565 | } | ||
566 | |||
450 | void AccountView::slotContextMenu(int id) | 567 | void AccountView::slotContextMenu(int id) |
451 | { | 568 | { |
452 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 569 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
453 | if (!view) return; | 570 | if (!view) return; |
454 | view->contextMenuSelected(id); | 571 | view->contextMenuSelected(id); |
455 | } | 572 | } |
@@ -468,23 +585,27 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | |||
468 | } | 585 | } |
469 | 586 | ||
470 | void AccountView::populate( QList<Account> list ) | 587 | void AccountView::populate( QList<Account> list ) |
471 | { | 588 | { |
472 | clear(); | 589 | clear(); |
473 | 590 | ||
474 | (void) new MBOXviewItem(AbstractMail::defaultLocalfolder(),this); | 591 | imapAccounts.clear(); |
592 | mboxAccounts.clear(); | ||
593 | |||
594 | mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this)); | ||
475 | 595 | ||
476 | Account *it; | 596 | Account *it; |
477 | for ( it = list.first(); it; it = list.next() ) { | 597 | for ( it = list.first(); it; it = list.next() ) { |
478 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 598 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
479 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 599 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
480 | qDebug( "added IMAP " + imap->getAccountName() ); | 600 | qDebug( "added IMAP " + imap->getAccountName() ); |
481 | (void) new IMAPviewItem( imap, this ); | 601 | imapAccounts.append(new IMAPviewItem( imap, this )); |
482 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 602 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
483 | POP3account *pop3 = static_cast<POP3account *>(it); | 603 | POP3account *pop3 = static_cast<POP3account *>(it); |
484 | qDebug( "added POP3 " + pop3->getAccountName() ); | 604 | qDebug( "added POP3 " + pop3->getAccountName() ); |
605 | /* must not be hold 'cause it isn't required */ | ||
485 | (void) new POP3viewItem( pop3, this ); | 606 | (void) new POP3viewItem( pop3, this ); |
486 | } | 607 | } |
487 | } | 608 | } |
488 | } | 609 | } |
489 | 610 | ||
490 | void AccountView::refresh(QListViewItem *item) { | 611 | void AccountView::refresh(QListViewItem *item) { |
@@ -521,21 +642,68 @@ RecBody AccountView::fetchBody(const RecMail&aMail) | |||
521 | QListViewItem*item = selectedItem (); | 642 | QListViewItem*item = selectedItem (); |
522 | if (!item) return RecBody(); | 643 | if (!item) return RecBody(); |
523 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 644 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
524 | return view->fetchBody(aMail); | 645 | return view->fetchBody(aMail); |
525 | } | 646 | } |
526 | 647 | ||
648 | void AccountView::setupFolderselect(Selectstore*sels) | ||
649 | { | ||
650 | sels->showMaximized(); | ||
651 | QStringList sFolders; | ||
652 | unsigned int i = 0; | ||
653 | for (i=0; i < mboxAccounts.count();++i) { | ||
654 | mboxAccounts[i]->refresh(false); | ||
655 | sFolders = mboxAccounts[i]->subFolders(); | ||
656 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); | ||
657 | } | ||
658 | for (i=0; i < imapAccounts.count();++i) { | ||
659 | if (imapAccounts[i]->offline()) | ||
660 | continue; | ||
661 | imapAccounts[i]->refreshFolders(false); | ||
662 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | ||
663 | } | ||
664 | } | ||
665 | |||
666 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | ||
667 | { | ||
668 | unsigned int i = 0; | ||
669 | AbstractMail*targetMail = 0; | ||
670 | QString targetFolder = ""; | ||
671 | Selectstore sels; | ||
672 | setupFolderselect(&sels); | ||
673 | if (!sels.exec()) return; | ||
674 | targetMail = sels.currentMail(); | ||
675 | targetFolder = sels.currentFolder(); | ||
676 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | ||
677 | targetFolder.isEmpty()) { | ||
678 | return; | ||
679 | } | ||
680 | |||
681 | QList<RecMail> t; | ||
682 | fromWrapper->listMessages(fromFolder->getName(),t); | ||
683 | encodedString*st = 0; | ||
684 | for (i = 0; i < t.count();++i) { | ||
685 | RecMail*r = t.at(i); | ||
686 | st = fromWrapper->fetchRawBody(*r); | ||
687 | if (st) { | ||
688 | targetMail->storeMessage(st->Content(),st->Length(),targetFolder); | ||
689 | delete st; | ||
690 | } | ||
691 | } | ||
692 | } | ||
693 | |||
527 | /** | 694 | /** |
528 | * MBOX Account stuff | 695 | * MBOX Account stuff |
529 | */ | 696 | */ |
530 | 697 | ||
531 | MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) | 698 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) |
532 | : AccountViewItem( parent ) | 699 | : AccountViewItem( parent ) |
533 | { | 700 | { |
534 | m_Path = aPath; | 701 | m_Path = aPath; |
535 | wrapper = AbstractMail::getWrapper( m_Path ); | 702 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
703 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | ||
536 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 704 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
537 | setText( 0, " Local Folders" ); | 705 | setText( 0, " Local Folders" ); |
538 | setOpen( true ); | 706 | setOpen( true ); |
539 | } | 707 | } |
540 | 708 | ||
541 | MBOXviewItem::~MBOXviewItem() | 709 | MBOXviewItem::~MBOXviewItem() |
@@ -599,12 +767,25 @@ void MBOXviewItem::createFolder() | |||
599 | if (wrapper->createMbox(ndir)) { | 767 | if (wrapper->createMbox(ndir)) { |
600 | refresh(true); | 768 | refresh(true); |
601 | } | 769 | } |
602 | } | 770 | } |
603 | } | 771 | } |
604 | 772 | ||
773 | QStringList MBOXviewItem::subFolders() | ||
774 | { | ||
775 | QStringList result; | ||
776 | QListViewItem *child = firstChild(); | ||
777 | while ( child ) { | ||
778 | MBOXfolderItem *tmp = (MBOXfolderItem*)child; | ||
779 | child = child->nextSibling(); | ||
780 | result.append(tmp->getFolder()->getName()); | ||
781 | } | ||
782 | qDebug("Size of result: %i",result.count()); | ||
783 | return result; | ||
784 | } | ||
785 | |||
605 | void MBOXviewItem::contextMenuSelected(int which) | 786 | void MBOXviewItem::contextMenuSelected(int which) |
606 | { | 787 | { |
607 | switch (which) { | 788 | switch (which) { |
608 | case 0: | 789 | case 0: |
609 | refresh(true); | 790 | refresh(true); |
610 | break; | 791 | break; |
@@ -633,12 +814,17 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList | |||
633 | } else { | 814 | } else { |
634 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 815 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
635 | } | 816 | } |
636 | setText( 0, folder->getDisplayName() ); | 817 | setText( 0, folder->getDisplayName() ); |
637 | } | 818 | } |
638 | 819 | ||
820 | Folder*MBOXfolderItem::getFolder() | ||
821 | { | ||
822 | return folder; | ||
823 | } | ||
824 | |||
639 | void MBOXfolderItem::refresh(QList<RecMail>&target) | 825 | void MBOXfolderItem::refresh(QList<RecMail>&target) |
640 | { | 826 | { |
641 | if (folder->may_select()) | 827 | if (folder->may_select()) |
642 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 828 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
643 | } | 829 | } |
644 | 830 | ||