author | alwin <alwin> | 2004-01-08 02:52:13 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-08 02:52:13 (UTC) |
commit | 05d47b2603adfab0e16f7395e34b7aa56ce6d8de (patch) (side-by-side diff) | |
tree | 4253654acb70b859fd0d32981132dffd35092b9f | |
parent | dfa1477a28ecd90e08cf09aeecbe816e94bec0b5 (diff) | |
download | opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.zip opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.gz opie-05d47b2603adfab0e16f7395e34b7aa56ce6d8de.tar.bz2 |
move/copy mails to another folder resides inside wrappers so we can
use special funs of libetpan and/or mailserver itself (eg. imap)
libetpan 0.32 requires for that feature a patch! (see libetpanstuff/)
accounts marked as "offline" get a new icon
TODO:
- when creating a new folder while copy/move on imap-server, get the
real resulting foldername when using prefix
- implement usage of copy/move inside one mbox using special etpan funs
-rw-r--r-- | noncore/net/mail/accountview.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 19 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 |
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 @@ #include "defines.h" #include "newmaildir.h" #include "selectstore.h" #include <qmessagebox.h> #include <qpopupmenu.h> +#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} /** * POP3 Account stuff */ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); - setPixmap( 0, PIXMAP_POP3FOLDER ); + SETPIX(PIXMAP_POP3FOLDER); +#if 0 + if (!account->getOffline()) { + setPixmap( 0, ); + } else { + setPixmap( 0, PIXMAP_OFFLINE ); + } +#endif setText( 0, account->getAccountName() ); setOpen( true ); } POP3viewItem::~POP3viewItem() { @@ -29,12 +37,17 @@ AbstractMail *POP3viewItem::getWrapper() { return wrapper; } void POP3viewItem::refresh( QList<RecMail> & ) { + refresh(); +} + +void POP3viewItem::refresh() +{ if (account->getOffline()) return; QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); @@ -86,12 +99,14 @@ void POP3viewItem::setOnOffline() { if (!account->getOffline()) { disconnect(); } account->setOffline(!account->getOffline()); account->save(); + SETPIX(PIXMAP_POP3FOLDER); + refresh(); } void POP3viewItem::contextMenuSelected(int which) { switch (which) { case 0: @@ -175,13 +190,13 @@ void POP3folderItem::contextMenuSelected(int which) */ IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); - setPixmap( 0, PIXMAP_IMAPFOLDER ); + SETPIX(PIXMAP_IMAPFOLDER); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { @@ -334,12 +349,13 @@ void IMAPviewItem::contextMenuSelected(int id) if (account->getOffline()==false) { removeChilds(); wrapper->logout(); } account->setOffline(!account->getOffline()); account->save(); + SETPIX(PIXMAP_IMAPFOLDER); refreshFolders(false); break; default: break; } } @@ -662,36 +678,32 @@ void AccountView::setupFolderselect(Selectstore*sels) sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); } } void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) { - unsigned int i = 0; AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || targetFolder.isEmpty()) { return; } - - QList<RecMail> t; - fromWrapper->listMessages(fromFolder->getName(),t); - encodedString*st = 0; - for (i = 0; i < t.count();++i) { - RecMail*r = t.at(i); - st = fromWrapper->fetchRawBody(*r); - if (st) { - targetMail->storeMessage(st->Content(),st->Length(),targetFolder); - delete st; - } + if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { + QMessageBox::critical(0,tr("Error creating new Folder"), + tr("<center>Error while creating<br>new folder - breaking.</center>")); + return; } + qDebug("Targetfolder: %s",targetFolder.latin1()); + qDebug("Fromfolder: %s",fromFolder->getName().latin1()); + fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); + refreshCurrent(); } /** * MBOX Account stuff */ 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: AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: POP3account *account; + virtual void refresh(); AbstractMail *wrapper; void disconnect(); void setOnOffline(); }; class 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 @@ #define PIC_MBOXFOLDER "mail/mboxfolder" #define PIC_POP3FOLDER "mail/pop3folder" #define PIC_INBOXFOLDER "mail/inbox" #define PIC_OUTBOXFOLDER "mail/outbox" #define PIC_LOCALFOLDER "mail/localfolder" +#define PIC_OFFLINE "mail/notconnected" + #define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) #define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) #define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) #define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) #define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) #define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) @@ -27,12 +29,13 @@ #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) #define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) #define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) #define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) #define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) +#define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) ) #define IMAP_PORT "143" #define IMAP_SSL_PORT "993" #define SMTP_PORT "25" #define SMTP_SSL_PORT "465" #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() } /* temporary - will be removed when implemented in all classes */ void AbstractMail::deleteMails(const QString &,QList<RecMail> &) { } + +void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) +{ + QList<RecMail> t; + listMessages(fromFolder->getName(),t); + encodedString*st = 0; + while (t.count()>0) { + RecMail*r = t.at(0); + st = fetchRawBody(*r); + if (st) { + targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); + delete st; + } + t.removeFirst(); + } + if (moveit) { + deleteAllMail(fromFolder); + } +} 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: virtual void answeredMail(const RecMail&mail)=0; virtual int deleteAllMail(const Folder*)=0; virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteMbox(const Folder*)=0; virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; + virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); + virtual void cleanMimeCache(){}; /* mail box methods */ /* parameter is the box to create. * if the implementing subclass has prefixes, * them has to be appended automatic. */ 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 { return account->getType(); } const QString&IMAPwrapper::getName()const { + qDebug("Get name: %s",account->getAccountName().latin1()); return account->getAccountName(); } encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) { // dummy QValueList<int> path; return fetchRawPart(mail,path,false); } + +void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) +{ + qDebug("mvcp mail imap"); + if (targetWrapper != this) { + AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); + qDebug("Using generic"); + return; + } + qDebug("Using internal"); + mailimap_set *set = 0; + + int err = mailimap_select( m_imap, fromFolder->getName().latin1()); + if ( err != MAILIMAP_NO_ERROR ) { + Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); + return; + } + + int last = m_imap->imap_selection_info->sel_exists; + set = mailimap_set_new_interval( 1, last ); + err = mailimap_copy(m_imap,set,targetFolder.latin1()); + if ( err != MAILIMAP_NO_ERROR ) { + Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response)); + return; + } + mailimap_set_free( set ); + if (moveit) { + deleteAllMail(fromFolder); + } +} 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: virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*folder); virtual void storeMessage(const char*msg,size_t length, const QString&folder); + virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual RecBody fetchBody(const RecMail&mail); virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawBody(const RecMail&mail); |