Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index eea021f..b7de7b9 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,46 +1,59 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include <libmailwrapper/mailtypes.h> | 2 | #include <libmailwrapper/mailtypes.h> |
3 | #include <libmailwrapper/abstractmail.h> | 3 | #include <libmailwrapper/abstractmail.h> |
4 | #include "defines.h" | 4 | #include "defines.h" |
5 | #include "newmaildir.h" | 5 | #include "newmaildir.h" |
6 | #include "selectstore.h" | 6 | #include "selectstore.h" |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
9 | 9 | ||
10 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | ||
10 | /** | 11 | /** |
11 | * POP3 Account stuff | 12 | * POP3 Account stuff |
12 | */ | 13 | */ |
13 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 14 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
14 | : AccountViewItem( parent ) | 15 | : AccountViewItem( parent ) |
15 | { | 16 | { |
16 | account = a; | 17 | account = a; |
17 | wrapper = AbstractMail::getWrapper( account ); | 18 | wrapper = AbstractMail::getWrapper( account ); |
18 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 19 | SETPIX(PIXMAP_POP3FOLDER); |
20 | #if 0 | ||
21 | if (!account->getOffline()) { | ||
22 | setPixmap( 0, ); | ||
23 | } else { | ||
24 | setPixmap( 0, PIXMAP_OFFLINE ); | ||
25 | } | ||
26 | #endif | ||
19 | setText( 0, account->getAccountName() ); | 27 | setText( 0, account->getAccountName() ); |
20 | setOpen( true ); | 28 | setOpen( true ); |
21 | } | 29 | } |
22 | 30 | ||
23 | POP3viewItem::~POP3viewItem() | 31 | POP3viewItem::~POP3viewItem() |
24 | { | 32 | { |
25 | delete wrapper; | 33 | delete wrapper; |
26 | } | 34 | } |
27 | 35 | ||
28 | AbstractMail *POP3viewItem::getWrapper() | 36 | AbstractMail *POP3viewItem::getWrapper() |
29 | { | 37 | { |
30 | return wrapper; | 38 | return wrapper; |
31 | } | 39 | } |
32 | 40 | ||
33 | void POP3viewItem::refresh( QList<RecMail> & ) | 41 | void POP3viewItem::refresh( QList<RecMail> & ) |
34 | { | 42 | { |
43 | refresh(); | ||
44 | } | ||
45 | |||
46 | void POP3viewItem::refresh() | ||
47 | { | ||
35 | if (account->getOffline()) return; | 48 | if (account->getOffline()) return; |
36 | QList<Folder> *folders = wrapper->listFolders(); | 49 | QList<Folder> *folders = wrapper->listFolders(); |
37 | QListViewItem *child = firstChild(); | 50 | QListViewItem *child = firstChild(); |
38 | while ( child ) { | 51 | while ( child ) { |
39 | QListViewItem *tmp = child; | 52 | QListViewItem *tmp = child; |
40 | child = child->nextSibling(); | 53 | child = child->nextSibling(); |
41 | delete tmp; | 54 | delete tmp; |
42 | } | 55 | } |
43 | Folder *it; | 56 | Folder *it; |
44 | QListViewItem*item = 0; | 57 | QListViewItem*item = 0; |
45 | for ( it = folders->first(); it; it = folders->next() ) { | 58 | for ( it = folders->first(); it; it = folders->next() ) { |
46 | item = new POP3folderItem( it, this , item ); | 59 | item = new POP3folderItem( it, this , item ); |
@@ -80,24 +93,26 @@ void POP3viewItem::disconnect() | |||
80 | delete tmp; | 93 | delete tmp; |
81 | } | 94 | } |
82 | wrapper->logout(); | 95 | wrapper->logout(); |
83 | } | 96 | } |
84 | 97 | ||
85 | void POP3viewItem::setOnOffline() | 98 | void POP3viewItem::setOnOffline() |
86 | { | 99 | { |
87 | if (!account->getOffline()) { | 100 | if (!account->getOffline()) { |
88 | disconnect(); | 101 | disconnect(); |
89 | } | 102 | } |
90 | account->setOffline(!account->getOffline()); | 103 | account->setOffline(!account->getOffline()); |
91 | account->save(); | 104 | account->save(); |
105 | SETPIX(PIXMAP_POP3FOLDER); | ||
106 | refresh(); | ||
92 | } | 107 | } |
93 | 108 | ||
94 | void POP3viewItem::contextMenuSelected(int which) | 109 | void POP3viewItem::contextMenuSelected(int which) |
95 | { | 110 | { |
96 | switch (which) { | 111 | switch (which) { |
97 | case 0: | 112 | case 0: |
98 | disconnect(); | 113 | disconnect(); |
99 | break; | 114 | break; |
100 | case 1: | 115 | case 1: |
101 | setOnOffline(); | 116 | setOnOffline(); |
102 | break; | 117 | break; |
103 | } | 118 | } |
@@ -169,25 +184,25 @@ void POP3folderItem::contextMenuSelected(int which) | |||
169 | break; | 184 | break; |
170 | } | 185 | } |
171 | } | 186 | } |
172 | 187 | ||
173 | /** | 188 | /** |
174 | * IMAP Account stuff | 189 | * IMAP Account stuff |
175 | */ | 190 | */ |
176 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 191 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
177 | : AccountViewItem( parent ) | 192 | : AccountViewItem( parent ) |
178 | { | 193 | { |
179 | account = a; | 194 | account = a; |
180 | wrapper = AbstractMail::getWrapper( account ); | 195 | wrapper = AbstractMail::getWrapper( account ); |
181 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 196 | SETPIX(PIXMAP_IMAPFOLDER); |
182 | setText( 0, account->getAccountName() ); | 197 | setText( 0, account->getAccountName() ); |
183 | setOpen( true ); | 198 | setOpen( true ); |
184 | } | 199 | } |
185 | 200 | ||
186 | IMAPviewItem::~IMAPviewItem() | 201 | IMAPviewItem::~IMAPviewItem() |
187 | { | 202 | { |
188 | delete wrapper; | 203 | delete wrapper; |
189 | } | 204 | } |
190 | 205 | ||
191 | AbstractMail *IMAPviewItem::getWrapper() | 206 | AbstractMail *IMAPviewItem::getWrapper() |
192 | { | 207 | { |
193 | return wrapper; | 208 | return wrapper; |
@@ -328,24 +343,25 @@ void IMAPviewItem::contextMenuSelected(int id) | |||
328 | break; | 343 | break; |
329 | case 2: | 344 | case 2: |
330 | removeChilds(); | 345 | removeChilds(); |
331 | wrapper->logout(); | 346 | wrapper->logout(); |
332 | break; | 347 | break; |
333 | case 3: | 348 | case 3: |
334 | if (account->getOffline()==false) { | 349 | if (account->getOffline()==false) { |
335 | removeChilds(); | 350 | removeChilds(); |
336 | wrapper->logout(); | 351 | wrapper->logout(); |
337 | } | 352 | } |
338 | account->setOffline(!account->getOffline()); | 353 | account->setOffline(!account->getOffline()); |
339 | account->save(); | 354 | account->save(); |
355 | SETPIX(PIXMAP_IMAPFOLDER); | ||
340 | refreshFolders(false); | 356 | refreshFolders(false); |
341 | break; | 357 | break; |
342 | default: | 358 | default: |
343 | break; | 359 | break; |
344 | } | 360 | } |
345 | } | 361 | } |
346 | 362 | ||
347 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 363 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
348 | { | 364 | { |
349 | return RecBody(); | 365 | return RecBody(); |
350 | } | 366 | } |
351 | 367 | ||
@@ -656,48 +672,44 @@ void AccountView::setupFolderselect(Selectstore*sels) | |||
656 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); | 672 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); |
657 | } | 673 | } |
658 | for (i=0; i < imapAccounts.count();++i) { | 674 | for (i=0; i < imapAccounts.count();++i) { |
659 | if (imapAccounts[i]->offline()) | 675 | if (imapAccounts[i]->offline()) |
660 | continue; | 676 | continue; |
661 | imapAccounts[i]->refreshFolders(false); | 677 | imapAccounts[i]->refreshFolders(false); |
662 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 678 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
663 | } | 679 | } |
664 | } | 680 | } |
665 | 681 | ||
666 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | 682 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) |
667 | { | 683 | { |
668 | unsigned int i = 0; | ||
669 | AbstractMail*targetMail = 0; | 684 | AbstractMail*targetMail = 0; |
670 | QString targetFolder = ""; | 685 | QString targetFolder = ""; |
671 | Selectstore sels; | 686 | Selectstore sels; |
672 | setupFolderselect(&sels); | 687 | setupFolderselect(&sels); |
673 | if (!sels.exec()) return; | 688 | if (!sels.exec()) return; |
674 | targetMail = sels.currentMail(); | 689 | targetMail = sels.currentMail(); |
675 | targetFolder = sels.currentFolder(); | 690 | targetFolder = sels.currentFolder(); |
676 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | 691 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || |
677 | targetFolder.isEmpty()) { | 692 | targetFolder.isEmpty()) { |
678 | return; | 693 | return; |
679 | } | 694 | } |
680 | 695 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { | |
681 | QList<RecMail> t; | 696 | QMessageBox::critical(0,tr("Error creating new Folder"), |
682 | fromWrapper->listMessages(fromFolder->getName(),t); | 697 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
683 | encodedString*st = 0; | 698 | return; |
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 | } | 699 | } |
700 | qDebug("Targetfolder: %s",targetFolder.latin1()); | ||
701 | qDebug("Fromfolder: %s",fromFolder->getName().latin1()); | ||
702 | fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); | ||
703 | refreshCurrent(); | ||
692 | } | 704 | } |
693 | 705 | ||
694 | /** | 706 | /** |
695 | * MBOX Account stuff | 707 | * MBOX Account stuff |
696 | */ | 708 | */ |
697 | 709 | ||
698 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) | 710 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) |
699 | : AccountViewItem( parent ) | 711 | : AccountViewItem( parent ) |
700 | { | 712 | { |
701 | m_Path = aPath; | 713 | m_Path = aPath; |
702 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 714 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
703 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 715 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |