summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp40
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/defines.h3
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp31
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
7 files changed, 83 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
@@ -4,21 +4,29 @@
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 */
13POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 14POP3viewItem::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
23POP3viewItem::~POP3viewItem() 31POP3viewItem::~POP3viewItem()
24{ 32{
@@ -29,12 +37,17 @@ AbstractMail *POP3viewItem::getWrapper()
29{ 37{
30 return wrapper; 38 return wrapper;
31} 39}
32 40
33void POP3viewItem::refresh( QList<RecMail> & ) 41void POP3viewItem::refresh( QList<RecMail> & )
34{ 42{
43 refresh();
44}
45
46void 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();
@@ -86,12 +99,14 @@ 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
94void POP3viewItem::contextMenuSelected(int which) 109void POP3viewItem::contextMenuSelected(int which)
95{ 110{
96 switch (which) { 111 switch (which) {
97 case 0: 112 case 0:
@@ -175,13 +190,13 @@ void POP3folderItem::contextMenuSelected(int which)
175 */ 190 */
176IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 191IMAPviewItem::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
186IMAPviewItem::~IMAPviewItem() 201IMAPviewItem::~IMAPviewItem()
187{ 202{
@@ -334,12 +349,13 @@ void IMAPviewItem::contextMenuSelected(int id)
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}
@@ -662,36 +678,32 @@ void AccountView::setupFolderselect(Selectstore*sels)
662 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 678 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
663 } 679 }
664} 680}
665 681
666void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) 682void 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
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 48f52c7..df916c1 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -45,12 +45,13 @@ public:
45 AbstractMail *getWrapper(); 45 AbstractMail *getWrapper();
46 virtual QPopupMenu * getContextMenu(); 46 virtual QPopupMenu * getContextMenu();
47 virtual void contextMenuSelected(int); 47 virtual void contextMenuSelected(int);
48 48
49protected: 49protected:
50 POP3account *account; 50 POP3account *account;
51 virtual void refresh();
51 AbstractMail *wrapper; 52 AbstractMail *wrapper;
52 void disconnect(); 53 void disconnect();
53 void setOnOffline(); 54 void setOnOffline();
54}; 55};
55 56
56class POP3folderItem : public AccountViewItem 57class POP3folderItem : public AccountViewItem
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h
index ebe8e08..d840f09 100644
--- a/noncore/net/mail/defines.h
+++ b/noncore/net/mail/defines.h
@@ -13,12 +13,14 @@
13#define PIC_MBOXFOLDER "mail/mboxfolder" 13#define PIC_MBOXFOLDER "mail/mboxfolder"
14#define PIC_POP3FOLDER "mail/pop3folder" 14#define PIC_POP3FOLDER "mail/pop3folder"
15#define PIC_INBOXFOLDER "mail/inbox" 15#define PIC_INBOXFOLDER "mail/inbox"
16#define PIC_OUTBOXFOLDER "mail/outbox" 16#define PIC_OUTBOXFOLDER "mail/outbox"
17#define PIC_LOCALFOLDER "mail/localfolder" 17#define PIC_LOCALFOLDER "mail/localfolder"
18 18
19#define PIC_OFFLINE "mail/notconnected"
20
19#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) 21#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) )
20#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) 22#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) )
21#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) 23#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) )
22#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) 24#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) )
23#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) 25#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) )
24#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) 26#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) )
@@ -27,12 +29,13 @@
27#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) 29#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) )
28#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) 30#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) )
29#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) 31#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) )
30#define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) 32#define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) )
31#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) 33#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) )
32#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) 34#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) )
35#define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) )
33 36
34#define IMAP_PORT "143" 37#define IMAP_PORT "143"
35#define IMAP_SSL_PORT "993" 38#define IMAP_SSL_PORT "993"
36#define SMTP_PORT "25" 39#define SMTP_PORT "25"
37#define SMTP_SSL_PORT "465" 40#define SMTP_SSL_PORT "465"
38#define POP3_PORT "110" 41#define POP3_PORT "110"
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 3dd2fce..4b4c728 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -101,6 +101,25 @@ QString AbstractMail::defaultLocalfolder()
101} 101}
102 102
103/* temporary - will be removed when implemented in all classes */ 103/* temporary - will be removed when implemented in all classes */
104void AbstractMail::deleteMails(const QString &,QList<RecMail> &) 104void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
105{ 105{
106} 106}
107
108void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
109{
110 QList<RecMail> t;
111 listMessages(fromFolder->getName(),t);
112 encodedString*st = 0;
113 while (t.count()>0) {
114 RecMail*r = t.at(0);
115 st = fetchRawBody(*r);
116 if (st) {
117 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
118 delete st;
119 }
120 t.removeFirst();
121 }
122 if (moveit) {
123 deleteAllMail(fromFolder);
124 }
125}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 15d83cb..8debaae 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -32,12 +32,14 @@ public:
32 virtual void answeredMail(const RecMail&mail)=0; 32 virtual void answeredMail(const RecMail&mail)=0;
33 virtual int deleteAllMail(const Folder*)=0; 33 virtual int deleteAllMail(const Folder*)=0;
34 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); 34 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
35 virtual int deleteMbox(const Folder*)=0; 35 virtual int deleteMbox(const Folder*)=0;
36 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 36 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
37 37
38 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
39
38 virtual void cleanMimeCache(){}; 40 virtual void cleanMimeCache(){};
39 /* mail box methods */ 41 /* mail box methods */
40 /* parameter is the box to create. 42 /* parameter is the box to create.
41 * if the implementing subclass has prefixes, 43 * if the implementing subclass has prefixes,
42 * them has to be appended automatic. 44 * them has to be appended automatic.
43 */ 45 */
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index bb74de9..23c678b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1006,15 +1006,46 @@ const QString&IMAPwrapper::getType()const
1006{ 1006{
1007 return account->getType(); 1007 return account->getType();
1008} 1008}
1009 1009
1010const QString&IMAPwrapper::getName()const 1010const QString&IMAPwrapper::getName()const
1011{ 1011{
1012 qDebug("Get name: %s",account->getAccountName().latin1());
1012 return account->getAccountName(); 1013 return account->getAccountName();
1013} 1014}
1014 1015
1015encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) 1016encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
1016{ 1017{
1017 // dummy 1018 // dummy
1018 QValueList<int> path; 1019 QValueList<int> path;
1019 return fetchRawPart(mail,path,false); 1020 return fetchRawPart(mail,path,false);
1020} 1021}
1022
1023void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1024{
1025 qDebug("mvcp mail imap");
1026 if (targetWrapper != this) {
1027 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
1028 qDebug("Using generic");
1029 return;
1030 }
1031 qDebug("Using internal");
1032 mailimap_set *set = 0;
1033
1034 int err = mailimap_select( m_imap, fromFolder->getName().latin1());
1035 if ( err != MAILIMAP_NO_ERROR ) {
1036 Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
1037 return;
1038 }
1039
1040 int last = m_imap->imap_selection_info->sel_exists;
1041 set = mailimap_set_new_interval( 1, last );
1042 err = mailimap_copy(m_imap,set,targetFolder.latin1());
1043 if ( err != MAILIMAP_NO_ERROR ) {
1044 Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response));
1045 return;
1046 }
1047 mailimap_set_free( set );
1048 if (moveit) {
1049 deleteAllMail(fromFolder);
1050 }
1051}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index b2bd7e9..07c6210 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -28,12 +28,13 @@ public:
28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 29
30 virtual void deleteMail(const RecMail&mail); 30 virtual void deleteMail(const RecMail&mail);
31 virtual void answeredMail(const RecMail&mail); 31 virtual void answeredMail(const RecMail&mail);
32 virtual int deleteAllMail(const Folder*folder); 32 virtual int deleteAllMail(const Folder*folder);
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
34 35
35 virtual RecBody fetchBody(const RecMail&mail); 36 virtual RecBody fetchBody(const RecMail&mail);
36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 37 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
37 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 38 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
38 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 39 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
39 virtual encodedString* fetchRawBody(const RecMail&mail); 40 virtual encodedString* fetchRawBody(const RecMail&mail);