summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-10 03:22:16 (UTC)
committer alwin <alwin>2004-01-10 03:22:16 (UTC)
commitabf23602a446e30ec18d16d3495da5747a96072b (patch) (side-by-side diff)
tree80dd4d6089c3d7c5f45a8f0a4e6c2b53cfca2e9b
parent6248e82bf1b077c54e3e2b85801a99fa0f86434d (diff)
downloadopie-abf23602a446e30ec18d16d3495da5747a96072b.zip
opie-abf23602a446e30ec18d16d3495da5747a96072b.tar.gz
opie-abf23602a446e30ec18d16d3495da5747a96072b.tar.bz2
mh box fully functional
splitted the stuff of accountview list into seperate files so the other parts care about changes inside accountitems
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp842
-rw-r--r--noncore/net/mail/accountitem.h164
-rw-r--r--noncore/net/mail/accountview.cpp818
-rw-r--r--noncore/net/mail/accountview.h162
-rw-r--r--noncore/net/mail/mail.pro2
-rw-r--r--noncore/net/mail/opiemail.cpp1
6 files changed, 1020 insertions, 969 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
new file mode 100644
index 0000000..2d3cd4b
--- a/dev/null
+++ b/noncore/net/mail/accountitem.cpp
@@ -0,0 +1,842 @@
+#include "accountitem.h"
+#include "accountview.h"
+#include <qpopupmenu.h>
+#include <qmessagebox.h>
+#include "selectstore.h"
+#include "newmaildir.h"
+#include <libmailwrapper/mailtypes.h>
+#include <libmailwrapper/abstractmail.h>
+#include <libmailwrapper/mailwrapper.h>
+#include "defines.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 );
+ SETPIX(PIXMAP_POP3FOLDER);
+#if 0
+ if (!account->getOffline()) {
+ setPixmap( 0, );
+ } else {
+ setPixmap( 0, PIXMAP_OFFLINE );
+ }
+#endif
+ setText( 0, account->getAccountName() );
+ setOpen( true );
+}
+
+POP3viewItem::~POP3viewItem()
+{
+ delete wrapper;
+}
+
+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();
+ delete tmp;
+ }
+ Folder *it;
+ QListViewItem*item = 0;
+ for ( it = folders->first(); it; it = folders->next() ) {
+ item = new POP3folderItem( it, this , item );
+ item->setSelectable(it->may_select());
+ }
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ folders->setAutoDelete(false);
+ delete folders;
+}
+
+RecBody POP3viewItem::fetchBody( const RecMail &mail )
+{
+ qDebug( "POP3 fetchBody" );
+ return wrapper->fetchBody( mail );
+}
+
+QPopupMenu * POP3viewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ if (!account->getOffline()) {
+ m->insertItem(QObject::tr("Disconnect",contextName),0);
+ m->insertItem(QObject::tr("Set offline",contextName),1);
+ } else {
+ m->insertItem(QObject::tr("Set online",contextName),1);
+ }
+ }
+ return m;
+}
+
+void POP3viewItem::disconnect()
+{
+ QListViewItem *child = firstChild();
+ while ( child ) {
+ QListViewItem *tmp = child;
+ child = child->nextSibling();
+ delete tmp;
+ }
+ wrapper->logout();
+}
+
+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:
+ disconnect();
+ break;
+ case 1:
+ setOnOffline();
+ break;
+ }
+}
+
+POP3folderItem::~POP3folderItem()
+{
+}
+
+POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
+ : AccountViewItem( parent,after )
+{
+ folder = folderInit;
+ pop3 = parent;
+ if (folder->getDisplayName().lower()!="inbox") {
+ setPixmap( 0, PIXMAP_POP3FOLDER );
+ } else {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ }
+ setText( 0, folder->getDisplayName() );
+}
+
+void POP3folderItem::refresh(QList<RecMail>&target)
+{
+ if (folder->may_select())
+ pop3->getWrapper()->listMessages( folder->getName(),target );
+}
+
+RecBody POP3folderItem::fetchBody(const RecMail&aMail)
+{
+ return pop3->getWrapper()->fetchBody(aMail);
+}
+
+QPopupMenu * POP3folderItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Refresh header list",contextName),0);
+ m->insertItem(QObject::tr("Delete all mails",contextName),1);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
+ }
+ return m;
+}
+
+void POP3folderItem::downloadMails()
+{
+ AccountView*bl = pop3->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,pop3->getWrapper());
+}
+
+void POP3folderItem::contextMenuSelected(int which)
+{
+ AccountView * view = (AccountView*)listView();
+ switch (which) {
+ case 0:
+ /* must be 'cause pop3 lists are cached */
+ pop3->getWrapper()->logout();
+ view->refreshCurrent();
+ break;
+ case 1:
+ deleteAllMail(pop3->getWrapper(),folder);
+ break;
+ case 2:
+ downloadMails();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * IMAP Account stuff
+ */
+IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
+ : AccountViewItem( parent )
+{
+ account = a;
+ wrapper = AbstractMail::getWrapper( account );
+ SETPIX(PIXMAP_IMAPFOLDER);
+ setText( 0, account->getAccountName() );
+ setOpen( true );
+}
+
+IMAPviewItem::~IMAPviewItem()
+{
+ delete wrapper;
+}
+
+AbstractMail *IMAPviewItem::getWrapper()
+{
+ return wrapper;
+}
+
+void IMAPviewItem::refresh(QList<RecMail>&)
+{
+ refreshFolders(false);
+}
+
+const QStringList&IMAPviewItem::subFolders()
+{
+ return currentFolders;
+}
+
+void IMAPviewItem::refreshFolders(bool force)
+{
+ if (childCount()>0 && force==false) return;
+ if (account->getOffline()) return;
+
+ removeChilds();
+ currentFolders.clear();
+ QList<Folder> *folders = wrapper->listFolders();
+
+ Folder *it;
+ QListViewItem*item = 0;
+ QListViewItem*titem = 0;
+ QString fname,del,search;
+ int pos;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ folders->setAutoDelete(false);
+
+ for ( it = folders->first(); it; it = folders->next() ) {
+ if (it->getDisplayName().lower()=="inbox") {
+ item = new IMAPfolderItem( it, this , item );
+ folders->remove(it);
+ qDebug("inbox found");
+ break;
+ }
+ }
+ for ( it = folders->first(); it; it = folders->next() ) {
+ fname = it->getDisplayName();
+ currentFolders.append(it->getName());
+ pos = fname.findRev(it->Separator());
+ if (pos != -1) {
+ fname = fname.left(pos);
+ }
+ IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
+ if (pitem) {
+ titem = item;
+ item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
+ /* setup the short name */
+ item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
+ item = titem;
+ } else {
+ item = new IMAPfolderItem( it, this , item );
+ }
+ }
+ delete folders;
+}
+
+QPopupMenu * IMAPviewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ if (!account->getOffline()) {
+ m->insertItem(QObject::tr("Refresh folder list",contextName),0);
+ m->insertItem(QObject::tr("Create new folder",contextName),1);
+ m->insertSeparator();
+ m->insertItem(QObject::tr("Disconnect",contextName),2);
+ m->insertItem(QObject::tr("Set offline",contextName),3);
+ } else {
+ m->insertItem(QObject::tr("Set online",contextName),3);
+ }
+ }
+ return m;
+}
+
+void IMAPviewItem::createNewFolder()
+{
+ Newmdirdlg ndirdlg;
+ ndirdlg.showMaximized();
+ if (ndirdlg.exec()) {
+ QString ndir = ndirdlg.Newdir();
+ bool makesubs = ndirdlg.subpossible();
+ QString delemiter = "/";
+ IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
+ if (item) {
+ delemiter = item->Delemiter();
+ }
+ if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
+ refreshFolders(true);
+ }
+ }
+}
+
+void IMAPviewItem::contextMenuSelected(int id)
+{
+ qDebug("Id selected: %i",id);
+ switch (id) {
+ case 0:
+ refreshFolders(true);
+ break;
+ case 1:
+ createNewFolder();
+ break;
+ case 2:
+ removeChilds();
+ wrapper->logout();
+ break;
+ case 3:
+ if (account->getOffline()==false) {
+ removeChilds();
+ wrapper->logout();
+ }
+ account->setOffline(!account->getOffline());
+ account->save();
+ SETPIX(PIXMAP_IMAPFOLDER);
+ refreshFolders(false);
+ break;
+ default:
+ break;
+ }
+}
+
+RecBody IMAPviewItem::fetchBody(const RecMail&)
+{
+ return RecBody();
+}
+
+bool IMAPviewItem::offline()
+{
+ return account->getOffline();
+}
+
+IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
+ : AccountViewItem( parent , after )
+{
+ folder = folderInit;
+ imap = parent;
+ if (folder->getDisplayName().lower()!="inbox") {
+ setPixmap( 0, PIXMAP_IMAPFOLDER );
+ } else {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ }
+ setText( 0, folder->getDisplayName() );
+}
+
+IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
+ : AccountViewItem( parent,after )
+{
+ folder = folderInit;
+ imap = master;
+ if (folder->getDisplayName().lower()!="inbox") {
+ setPixmap( 0, PIXMAP_IMAPFOLDER );
+ } else {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ }
+ setText( 0, folder->getDisplayName() );
+}
+
+IMAPfolderItem::~IMAPfolderItem()
+{
+}
+
+const QString& IMAPfolderItem::Delemiter()const
+{
+ return folder->Separator();
+}
+
+void IMAPfolderItem::refresh(QList<RecMail>&target)
+{
+ if (folder->may_select()) {
+ imap->getWrapper()->listMessages( folder->getName(),target );
+ } else {
+ target.clear();
+ }
+}
+
+RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
+{
+ return imap->getWrapper()->fetchBody(aMail);
+}
+
+QPopupMenu * IMAPfolderItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ if (folder->may_select()) {
+ m->insertItem(QObject::tr("Refresh header list",contextName),0);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
+ m->insertItem(QObject::tr("Delete all mails",contextName),1);
+ }
+ if (folder->no_inferior()==false) {
+ m->insertItem(QObject::tr("Create new subfolder",contextName),2);
+ }
+ if (folder->getDisplayName().lower()!="inbox") {
+ m->insertItem(QObject::tr("Delete folder",contextName),3);
+ }
+ }
+ return m;
+}
+
+void IMAPfolderItem::createNewFolder()
+{
+ Newmdirdlg ndirdlg;
+ ndirdlg.showMaximized();
+ if (ndirdlg.exec()) {
+ QString ndir = ndirdlg.Newdir();
+ bool makesubs = ndirdlg.subpossible();
+ QString delemiter = Delemiter();
+ if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) {
+ imap->refreshFolders(true);
+ }
+ }
+}
+
+void IMAPfolderItem::deleteFolder()
+{
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
+ QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (imap->getWrapper()->deleteMbox(folder)) {
+ QListView*v=listView();
+ IMAPviewItem * box = imap;
+ /* be carefull - after that this object is destroyd so don't use
+ * any member of it after that call!!*/
+ imap->refreshFolders(true);
+ if (v) {
+ v->setSelected(box,true);
+ }
+ }
+ }
+}
+
+void IMAPfolderItem::downloadMails()
+{
+ AccountView*bl = imap->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,imap->getWrapper());
+}
+
+void IMAPfolderItem::contextMenuSelected(int id)
+{
+ qDebug("Selected id: %i",id);
+ AccountView * view = (AccountView*)listView();
+ switch(id) {
+ case 0:
+ view->refreshCurrent();
+ break;
+ case 1:
+ deleteAllMail(imap->getWrapper(),folder);
+ break;
+ case 2:
+ createNewFolder();
+ break;
+ case 3:
+ deleteFolder();
+ break;
+ case 4:
+ downloadMails();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * MH Account stuff
+ */
+/* MH is a little bit different - the top folder can contains messages other than in IMAP and
+ POP3 and MBOX */
+MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
+ : AccountViewItem( parent )
+{
+ m_Path = aPath;
+ /* be carefull - the space within settext is wanted - thats why the string twice */
+ wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
+ setPixmap( 0, PIXMAP_LOCALFOLDER );
+ setText( 0, " Local Folders" );
+ setOpen( true );
+ folder = 0;
+}
+
+MHviewItem::~MHviewItem()
+{
+ delete wrapper;
+}
+
+AbstractMail *MHviewItem::getWrapper()
+{
+ return wrapper;
+}
+
+void MHviewItem::refresh( QList<RecMail> & target)
+{
+ refresh(false);
+ getWrapper()->listMessages( "",target );
+}
+
+void MHviewItem::refresh(bool force)
+{
+ if (childCount()>0 && force==false) return;
+ removeChilds();
+ currentFolders.clear();
+ QList<Folder> *folders = wrapper->listFolders();
+ Folder *it;
+ MHfolderItem*item = 0;
+ MHfolderItem*pmaster = 0;
+ QString fname = "";
+ int pos;
+ for ( it = folders->first(); it; it = folders->next() ) {
+ fname = it->getDisplayName();
+ /* this folder itself */
+ if (fname=="/") {
+ currentFolders.append(fname);
+ folder = it;
+ continue;
+ }
+ currentFolders.append(fname);
+ pos = fname.findRev("/");
+ if (pos > 0) {
+ fname = fname.left(pos);
+ pmaster = (MHfolderItem*)findSubItem(fname);
+ } else {
+ pmaster = 0;
+ }
+ if (pmaster) {
+ item = new MHfolderItem( it, pmaster, item, this );
+ } else {
+ item = new MHfolderItem( it, this , item );
+ }
+ item->setSelectable(it->may_select());
+ }
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ folders->setAutoDelete(false);
+ delete folders;
+}
+
+RecBody MHviewItem::fetchBody( const RecMail &mail )
+{
+ qDebug( "MH fetchBody" );
+ return wrapper->fetchBody( mail );
+}
+
+QPopupMenu * MHviewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Refresh folder list",contextName),0);
+ m->insertItem(QObject::tr("Create new folder",contextName),1);
+ m->insertItem(QObject::tr("Delete all mails",contextName),2);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
+ }
+ return m;
+}
+
+void MHviewItem::createFolder()
+{
+ Newmdirdlg ndirdlg(0,0,true);
+ ndirdlg.showMaximized();
+ if (ndirdlg.exec()) {
+ QString ndir = ndirdlg.Newdir();
+ if (wrapper->createMbox(ndir)) {
+ refresh(true);
+ }
+ }
+}
+
+void MHviewItem::downloadMails()
+{
+ AccountView*bl = accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,getWrapper());
+}
+
+QStringList MHviewItem::subFolders()
+{
+ return currentFolders;
+}
+
+void MHviewItem::contextMenuSelected(int which)
+{
+ switch (which) {
+ case 0:
+ refresh(true);
+ break;
+ case 1:
+ createFolder();
+ break;
+ case 2:
+ deleteAllMail(getWrapper(),folder);
+ break;
+ case 3:
+ downloadMails();
+ break;
+ default:
+ break;
+ }
+}
+
+MHfolderItem::~MHfolderItem()
+{
+}
+
+MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
+ : AccountViewItem( parent,after )
+{
+ folder = folderInit;
+ mbox = parent;
+ initName();
+}
+
+MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
+ : AccountViewItem( parent,after )
+{
+ folder = folderInit;
+ mbox = master;
+ initName();
+}
+
+void MHfolderItem::initName()
+{
+ QString bName = folder->getDisplayName();
+ if (bName.startsWith("/")&&bName.length()>1) {
+ bName.replace(0,1,"");
+ }
+ int pos = bName.findRev("/");
+ if (pos > 0) {
+ bName.replace(0,pos+1,"");
+ }
+ if (bName.lower() == "outgoing") {
+ setPixmap( 0, PIXMAP_OUTBOXFOLDER );
+ } else if (bName.lower() == "inbox") {
+ setPixmap( 0, PIXMAP_INBOXFOLDER);
+ } else {
+ setPixmap( 0, PIXMAP_MBOXFOLDER );
+ }
+ setText( 0, bName );
+}
+
+Folder*MHfolderItem::getFolder()
+{
+ return folder;
+}
+
+void MHfolderItem::refresh(QList<RecMail>&target)
+{
+ if (folder->may_select())
+ mbox->getWrapper()->listMessages( folder->getName(),target );
+}
+
+RecBody MHfolderItem::fetchBody(const RecMail&aMail)
+{
+ return mbox->getWrapper()->fetchBody(aMail);
+}
+
+void MHfolderItem::deleteFolder()
+{
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
+ QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (mbox->getWrapper()->deleteMbox(folder)) {
+ QListView*v=listView();
+ MHviewItem * box = mbox;
+ /* be carefull - after that this object is destroyd so don't use
+ * any member of it after that call!!*/
+ mbox->refresh(true);
+ if (v) {
+ v->setSelected(box,true);
+ }
+ }
+ }
+}
+
+QPopupMenu * MHfolderItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
+ m->insertItem(QObject::tr("Delete all mails",contextName),0);
+ m->insertItem(QObject::tr("Create new subfolder",contextName),3);
+ m->insertItem(QObject::tr("Delete folder",contextName),1);
+ }
+ return m;
+}
+
+void MHfolderItem::downloadMails()
+{
+ AccountView*bl = mbox->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,mbox->getWrapper());
+}
+
+void MHfolderItem::createFolder()
+{
+ Newmdirdlg ndirdlg(0,0,true);
+ ndirdlg.showMaximized();
+ if (ndirdlg.exec()) {
+ QString ndir = ndirdlg.Newdir();
+ if (mbox->getWrapper()->createMbox(ndir,folder)) {
+ QListView*v=listView();
+ MHviewItem * box = mbox;
+ /* be carefull - after that this object is destroyd so don't use
+ * any member of it after that call!!*/
+ mbox->refresh(true);
+ if (v) {
+ v->setSelected(box,true);
+ }
+ }
+ }
+}
+
+void MHfolderItem::contextMenuSelected(int which)
+{
+ switch(which) {
+ case 0:
+ deleteAllMail(mbox->getWrapper(),folder);
+ break;
+ case 1:
+ deleteFolder();
+ break;
+ case 2:
+ downloadMails();
+ break;
+ case 3:
+ createFolder();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Generic stuff
+ */
+
+const QString AccountViewItem::contextName="AccountViewItem";
+
+AccountViewItem::AccountViewItem( AccountView *parent )
+ : QListViewItem( parent )
+{
+ init();
+ m_Backlink = parent;
+}
+
+AccountViewItem::AccountViewItem( QListViewItem *parent)
+ : QListViewItem( parent)
+{
+ init();
+}
+
+AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
+ :QListViewItem( parent,after )
+{
+ init();
+}
+
+void AccountViewItem::init()
+{
+ m_Backlink = 0;
+ folder = 0;
+}
+
+AccountViewItem::~AccountViewItem()
+{
+ if (folder) delete folder;
+}
+
+AccountView*AccountViewItem::accountView()
+{
+ return m_Backlink;
+}
+
+void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
+{
+ if (!wrapper) return;
+ QString fname="";
+ if (folder) fname = folder->getDisplayName();
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
+ QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
+ arg(fname),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (wrapper->deleteAllMail(folder)) {
+ AccountView * view = (AccountView*)listView();
+ if (view) view->refreshCurrent();
+ }
+ }
+}
+
+void AccountViewItem::removeChilds()
+{
+ QListViewItem *child = firstChild();
+ while ( child ) {
+ QListViewItem *tmp = child;
+ child = child->nextSibling();
+ delete tmp;
+ }
+}
+
+bool AccountViewItem::matchName(const QString&name)const
+{
+ if (!folder) return false;
+ return folder->getDisplayName()==name;
+}
+
+
+AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
+{
+ AccountViewItem*pitem,*sitem;
+ if (!start) pitem = (AccountViewItem*)firstChild();
+ else pitem = (AccountViewItem*)start->firstChild();
+ while (pitem) {
+ if (pitem->matchName(path)) {
+ break;
+ }
+ if (pitem->childCount()>0) {
+ sitem = findSubItem(path,pitem);
+ if (sitem) {
+ pitem = sitem;
+ break;
+ }
+ }
+ pitem=(AccountViewItem*)pitem->nextSibling();
+ }
+ return pitem;
+}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
new file mode 100644
index 0000000..99208b6
--- a/dev/null
+++ b/noncore/net/mail/accountitem.h
@@ -0,0 +1,164 @@
+#ifndef __ACCOUNT_ITEM
+#define __ACCOUNT_ITEM
+
+#include <qlistview.h>
+#include <qlist.h>
+
+class POP3wrapper;
+class RecMail;
+class RecBody;
+class QPopupMenu;
+class Selectstore;
+class AccountView;
+class POP3account;
+class IMAPaccount;
+class AbstractMail;
+class Folder;
+
+class AccountViewItem : public QListViewItem
+{
+
+public:
+ AccountViewItem( AccountView *parent );
+ AccountViewItem( QListViewItem *parent);
+ AccountViewItem( QListViewItem *parent , QListViewItem*after );
+ virtual ~AccountViewItem();
+ virtual void refresh(QList<RecMail>&)=0;
+ virtual RecBody fetchBody(const RecMail&)=0;
+ virtual QPopupMenu * getContextMenu(){return 0;};
+ virtual void contextMenuSelected(int){}
+ virtual AccountView*accountView();
+ virtual bool matchName(const QString&name)const;
+
+protected:
+ AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
+ virtual void init();
+ virtual void removeChilds();
+ virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
+ static const QString contextName;
+ AccountView*m_Backlink;
+ Folder *folder;
+};
+
+class POP3viewItem : public AccountViewItem
+{
+
+public:
+ POP3viewItem( POP3account *a, AccountView *parent );
+ virtual ~POP3viewItem();
+ virtual void refresh( QList<RecMail> &target );
+ virtual RecBody fetchBody( const RecMail &mail );
+ 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
+{
+
+public:
+ POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
+ virtual ~POP3folderItem();
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+
+protected:
+ void downloadMails();
+ POP3viewItem *pop3;
+};
+
+class IMAPviewItem : public AccountViewItem
+{
+ friend class IMAPfolderItem;
+public:
+ IMAPviewItem( IMAPaccount *a, AccountView *parent );
+ virtual ~IMAPviewItem();
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
+ AbstractMail *getWrapper();
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+ const QStringList&subFolders();
+ virtual void refreshFolders(bool force=false);
+ bool offline();
+
+protected:
+ virtual void createNewFolder();
+ IMAPaccount *account;
+ AbstractMail *wrapper;
+ QStringList currentFolders;
+};
+
+class IMAPfolderItem : public AccountViewItem
+{
+
+public:
+ IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
+ IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
+ virtual ~IMAPfolderItem();
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+ virtual const QString& Delemiter()const;
+protected:
+ virtual void createNewFolder();
+ virtual void deleteFolder();
+ virtual void downloadMails();
+ IMAPviewItem *imap;
+};
+
+class MHviewItem : public AccountViewItem
+{
+ friend class MHfolderItem;
+
+public:
+ MHviewItem( const QString&aMboxPath, AccountView *parent );
+ virtual ~MHviewItem();
+ virtual void refresh( QList<RecMail> &target );
+ virtual RecBody fetchBody( const RecMail &mail );
+ AbstractMail *getWrapper();
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+ QStringList subFolders();
+ virtual void refresh(bool force=false);
+
+protected:
+ void downloadMails();
+ virtual void createFolder();
+ QString m_Path;
+ AbstractMail *wrapper;
+ QStringList currentFolders;
+};
+
+class MHfolderItem : public AccountViewItem
+{
+
+public:
+ MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after );
+ MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
+ virtual ~MHfolderItem();
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+ virtual Folder*getFolder();
+
+protected:
+ void downloadMails();
+ virtual void createFolder();
+ virtual void deleteFolder();
+ void initName();
+ MHviewItem *mbox;
+};
+
+#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 3048e49..d9792d4 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,957 +1,149 @@
#include "accountview.h"
-#include <libmailwrapper/mailtypes.h>
-#include <libmailwrapper/abstractmail.h>
-#include "defines.h"
-#include "newmaildir.h"
+#include "accountitem.h"
#include "selectstore.h"
#include <qmessagebox.h>
#include <qpopupmenu.h>
+#include <libmailwrapper/settings.h>
+#include <libmailwrapper/mailwrapper.h>
+#include <libmailwrapper/mailtypes.h>
+#include <libmailwrapper/abstractmail.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 );
- SETPIX(PIXMAP_POP3FOLDER);
-#if 0
- if (!account->getOffline()) {
- setPixmap( 0, );
- } else {
- setPixmap( 0, PIXMAP_OFFLINE );
- }
-#endif
- setText( 0, account->getAccountName() );
- setOpen( true );
-}
-
-POP3viewItem::~POP3viewItem()
-{
- delete wrapper;
-}
-
-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();
- delete tmp;
- }
- Folder *it;
- QListViewItem*item = 0;
- for ( it = folders->first(); it; it = folders->next() ) {
- item = new POP3folderItem( it, this , item );
- item->setSelectable(it->may_select());
- }
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
- delete folders;
-}
-
-RecBody POP3viewItem::fetchBody( const RecMail &mail )
-{
- qDebug( "POP3 fetchBody" );
- return wrapper->fetchBody( mail );
-}
-
-QPopupMenu * POP3viewItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- if (!account->getOffline()) {
- m->insertItem(QObject::tr("Disconnect",contextName),0);
- m->insertItem(QObject::tr("Set offline",contextName),1);
- } else {
- m->insertItem(QObject::tr("Set online",contextName),1);
- }
- }
- return m;
-}
-
-void POP3viewItem::disconnect()
-{
- QListViewItem *child = firstChild();
- while ( child ) {
- QListViewItem *tmp = child;
- child = child->nextSibling();
- delete tmp;
- }
- wrapper->logout();
-}
-
-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:
- disconnect();
- break;
- case 1:
- setOnOffline();
- break;
- }
-}
-
-POP3folderItem::~POP3folderItem()
-{
- delete folder;
-}
-
-POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
- : AccountViewItem( parent,after )
-{
- folder = folderInit;
- pop3 = parent;
- if (folder->getDisplayName().lower()!="inbox") {
- setPixmap( 0, PIXMAP_POP3FOLDER );
- } else {
- setPixmap( 0, PIXMAP_INBOXFOLDER);
- }
- setText( 0, folder->getDisplayName() );
-}
-
-void POP3folderItem::refresh(QList<RecMail>&target)
-{
- if (folder->may_select())
- pop3->getWrapper()->listMessages( folder->getName(),target );
-}
-
-RecBody POP3folderItem::fetchBody(const RecMail&aMail)
-{
- return pop3->getWrapper()->fetchBody(aMail);
-}
-
-QPopupMenu * POP3folderItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- m->insertItem(QObject::tr("Refresh header list",contextName),0);
- m->insertItem(QObject::tr("Delete all mails",contextName),1);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
- }
- return m;
-}
-
-void POP3folderItem::downloadMails()
-{
- AccountView*bl = pop3->accountView();
- if (!bl) return;
- bl->downloadMails(folder,pop3->getWrapper());
-}
-
-void POP3folderItem::contextMenuSelected(int which)
-{
- AccountView * view = (AccountView*)listView();
- switch (which) {
- case 0:
- /* must be 'cause pop3 lists are cached */
- pop3->getWrapper()->logout();
- view->refreshCurrent();
- break;
- case 1:
- deleteAllMail(pop3->getWrapper(),folder);
- break;
- case 2:
- downloadMails();
- break;
- default:
- break;
- }
-}
-
-/**
- * IMAP Account stuff
- */
-IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
- : AccountViewItem( parent )
-{
- account = a;
- wrapper = AbstractMail::getWrapper( account );
- SETPIX(PIXMAP_IMAPFOLDER);
- setText( 0, account->getAccountName() );
- setOpen( true );
-}
-
-IMAPviewItem::~IMAPviewItem()
-{
- delete wrapper;
-}
-
-AbstractMail *IMAPviewItem::getWrapper()
-{
- return wrapper;
-}
-
-IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start)
-{
- IMAPfolderItem*pitem,*sitem;
- if (!start) pitem = (IMAPfolderItem*)firstChild();
- else pitem = (IMAPfolderItem*)start->firstChild();
- while (pitem) {
- if (pitem->matchName(path)) {
- break;
- }
- if (pitem->childCount()>0) {
- sitem = findSubItem(path,pitem);
- if (sitem) {
- pitem = sitem;
- break;
- }
- }
- pitem=(IMAPfolderItem*)pitem->nextSibling();
- }
- return pitem;
-}
-
-void IMAPviewItem::refresh(QList<RecMail>&)
-{
- refreshFolders(false);
-}
-
-void IMAPviewItem::removeChilds()
-{
- QListViewItem *child = firstChild();
- while ( child ) {
- QListViewItem *tmp = child;
- child = child->nextSibling();
- delete tmp;
- }
-}
-
-const QStringList&IMAPviewItem::subFolders()
-{
- return currentFolders;
-}
-
-void IMAPviewItem::refreshFolders(bool force)
-{
- if (childCount()>0 && force==false) return;
- if (account->getOffline()) return;
-
- removeChilds();
- currentFolders.clear();
- QList<Folder> *folders = wrapper->listFolders();
-
- Folder *it;
- QListViewItem*item = 0;
- QListViewItem*titem = 0;
- QString fname,del,search;
- int pos;
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
-
- for ( it = folders->first(); it; it = folders->next() ) {
- if (it->getDisplayName().lower()=="inbox") {
- item = new IMAPfolderItem( it, this , item );
- folders->remove(it);
- qDebug("inbox found");
- break;
- }
- }
- for ( it = folders->first(); it; it = folders->next() ) {
- fname = it->getDisplayName();
- currentFolders.append(it->getName());
- pos = fname.findRev(it->Separator());
- if (pos != -1) {
- fname = fname.left(pos);
- }
- IMAPfolderItem*pitem = findSubItem(fname);
- if (pitem) {
- titem = item;
- item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
- /* setup the short name */
- item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
- item = titem;
- } else {
- item = new IMAPfolderItem( it, this , item );
- }
- }
- delete folders;
-}
-
-QPopupMenu * IMAPviewItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- if (!account->getOffline()) {
- m->insertItem(QObject::tr("Refresh folder list",contextName),0);
- m->insertItem(QObject::tr("Create new folder",contextName),1);
- m->insertSeparator();
- m->insertItem(QObject::tr("Disconnect",contextName),2);
- m->insertItem(QObject::tr("Set offline",contextName),3);
- } else {
- m->insertItem(QObject::tr("Set online",contextName),3);
- }
- }
- return m;
-}
-
-void IMAPviewItem::createNewFolder()
-{
- Newmdirdlg ndirdlg;
- ndirdlg.showMaximized();
- if (ndirdlg.exec()) {
- QString ndir = ndirdlg.Newdir();
- bool makesubs = ndirdlg.subpossible();
- QString delemiter = "/";
- IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
- if (item) {
- delemiter = item->Delemiter();
- }
- if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
- refreshFolders(true);
- }
- }
-}
-
-void IMAPviewItem::contextMenuSelected(int id)
-{
- qDebug("Id selected: %i",id);
- switch (id) {
- case 0:
- refreshFolders(true);
- break;
- case 1:
- createNewFolder();
- break;
- case 2:
- removeChilds();
- wrapper->logout();
- break;
- case 3:
- if (account->getOffline()==false) {
- removeChilds();
- wrapper->logout();
- }
- account->setOffline(!account->getOffline());
- account->save();
- SETPIX(PIXMAP_IMAPFOLDER);
- refreshFolders(false);
- break;
- default:
- break;
- }
-}
-
-RecBody IMAPviewItem::fetchBody(const RecMail&)
-{
- return RecBody();
-}
-
-bool IMAPviewItem::offline()
-{
- return account->getOffline();
-}
-
-IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent , after )
-{
- folder = folderInit;
- imap = parent;
- if (folder->getDisplayName().lower()!="inbox") {
- setPixmap( 0, PIXMAP_IMAPFOLDER );
- } else {
- setPixmap( 0, PIXMAP_INBOXFOLDER);
- }
- setText( 0, folder->getDisplayName() );
-}
-
-IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
- : AccountViewItem( parent,after )
-{
- folder = folderInit;
- imap = master;
- if (folder->getDisplayName().lower()!="inbox") {
- setPixmap( 0, PIXMAP_IMAPFOLDER );
- } else {
- setPixmap( 0, PIXMAP_INBOXFOLDER);
- }
- setText( 0, folder->getDisplayName() );
-}
-
-IMAPfolderItem::~IMAPfolderItem()
-{
- delete folder;
-}
-
-const QString& IMAPfolderItem::Delemiter()const
-{
- return folder->Separator();
-}
-
-bool IMAPfolderItem::matchName(const QString&name)const
-{
- return folder->getDisplayName()==name;
-}
-
-void IMAPfolderItem::refresh(QList<RecMail>&target)
-{
- if (folder->may_select()) {
- imap->getWrapper()->listMessages( folder->getName(),target );
- } else {
- target.clear();
- }
-}
-
-RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
-{
- return imap->getWrapper()->fetchBody(aMail);
-}
-
-QPopupMenu * IMAPfolderItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- if (folder->may_select()) {
- m->insertItem(QObject::tr("Refresh header list",contextName),0);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
- m->insertItem(QObject::tr("Delete all mails",contextName),1);
- }
- if (folder->no_inferior()==false) {
- m->insertItem(QObject::tr("Create new subfolder",contextName),2);
- }
- if (folder->getDisplayName().lower()!="inbox") {
- m->insertItem(QObject::tr("Delete folder",contextName),3);
- }
- }
- return m;
-}
-
-void IMAPfolderItem::createNewFolder()
-{
- Newmdirdlg ndirdlg;
- ndirdlg.showMaximized();
- if (ndirdlg.exec()) {
- QString ndir = ndirdlg.Newdir();
- bool makesubs = ndirdlg.subpossible();
- QString delemiter = Delemiter();
- if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) {
- imap->refreshFolders(true);
- }
- }
-}
-
-void IMAPfolderItem::deleteFolder()
-{
- int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
- QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
- QObject::tr("Yes",contextName),
- QObject::tr("No",contextName),QString::null,1,1);
- qDebug("Auswahl: %i",yesno);
- if (yesno == 0) {
- if (imap->getWrapper()->deleteMbox(folder)) {
- QListView*v=listView();
- IMAPviewItem * box = imap;
- /* be carefull - after that this object is destroyd so don't use
- * any member of it after that call!!*/
- imap->refreshFolders(true);
- if (v) {
- v->setSelected(box,true);
- }
- }
- }
-}
-
-void IMAPfolderItem::downloadMails()
-{
- AccountView*bl = imap->accountView();
- if (!bl) return;
- bl->downloadMails(folder,imap->getWrapper());
-}
-
-void IMAPfolderItem::contextMenuSelected(int id)
-{
- qDebug("Selected id: %i",id);
- AccountView * view = (AccountView*)listView();
- switch(id) {
- case 0:
- view->refreshCurrent();
- break;
- case 1:
- deleteAllMail(imap->getWrapper(),folder);
- break;
- case 2:
- createNewFolder();
- break;
- case 3:
- deleteFolder();
- break;
- case 4:
- downloadMails();
- break;
- default:
- break;
- }
-}
-
-/**
- * Generic stuff
- */
-
-const QString AccountViewItem::contextName="AccountViewItem";
-
-AccountViewItem::AccountViewItem( AccountView *parent )
- : QListViewItem( parent )
-{
- m_Backlink = parent;
-}
-
-AccountViewItem::AccountViewItem( QListViewItem *parent)
- : QListViewItem( parent)
-{
- m_Backlink = 0;
-}
-
-AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
- :QListViewItem( parent,after )
-{
- m_Backlink = 0;
-}
-
-AccountViewItem::~AccountViewItem()
-{
-}
-
-AccountView*AccountViewItem::accountView()
-{
- return m_Backlink;
-}
-
-void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
-{
- if (!wrapper) return;
- QString fname="";
- if (folder) fname = folder->getDisplayName();
- int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
- QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
- arg(fname),
- QObject::tr("Yes",contextName),
- QObject::tr("No",contextName),QString::null,1,1);
- qDebug("Auswahl: %i",yesno);
- if (yesno == 0) {
- if (wrapper->deleteAllMail(folder)) {
- AccountView * view = (AccountView*)listView();
- if (view) view->refreshCurrent();
- }
- }
-}
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
SLOT( refresh( QListViewItem * ) ) );
connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
-
setSorting(0);
}
AccountView::~AccountView()
{
imapAccounts.clear();
mhAccounts.clear();
}
void AccountView::slotContextMenu(int id)
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return;
view->contextMenuSelected(id);
}
void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
{
if (button==1) {return;}
if (!item) return;
AccountViewItem *view = static_cast<AccountViewItem *>(item);
QPopupMenu*m = view->getContextMenu();
if (!m) return;
connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
void AccountView::populate( QList<Account> list )
{
clear();
imapAccounts.clear();
mhAccounts.clear();
mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
Account *it;
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "IMAP" ) == 0 ) {
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
qDebug( "added IMAP " + imap->getAccountName() );
imapAccounts.append(new IMAPviewItem( imap, this ));
} else if ( it->getType().compare( "POP3" ) == 0 ) {
POP3account *pop3 = static_cast<POP3account *>(it);
qDebug( "added POP3 " + pop3->getAccountName() );
/* must not be hold 'cause it isn't required */
(void) new POP3viewItem( pop3, this );
}
}
}
void AccountView::refresh(QListViewItem *item) {
qDebug("AccountView refresh...");
if ( item ) {
m_currentItem = item;
QList<RecMail> headerlist;
headerlist.setAutoDelete(true);
AccountViewItem *view = static_cast<AccountViewItem *>(item);
view->refresh(headerlist);
emit refreshMailview(&headerlist);
}
}
void AccountView::refreshCurrent()
{
m_currentItem = currentItem();
if ( !m_currentItem ) return;
QList<RecMail> headerlist;
headerlist.setAutoDelete(true);
AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
view->refresh(headerlist);
emit refreshMailview(&headerlist);
}
void AccountView::refreshAll()
{
}
RecBody AccountView::fetchBody(const RecMail&aMail)
{
QListViewItem*item = selectedItem ();
if (!item) return RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
void AccountView::setupFolderselect(Selectstore*sels)
{
sels->showMaximized();
QStringList sFolders;
unsigned int i = 0;
for (i=0; i < mhAccounts.count();++i) {
mhAccounts[i]->refresh(false);
sFolders = mhAccounts[i]->subFolders();
sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
}
for (i=0; i < imapAccounts.count();++i) {
if (imapAccounts[i]->offline())
continue;
imapAccounts[i]->refreshFolders(false);
sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
}
}
void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
{
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;
}
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();
}
-
-/**
- * MH Account stuff
- */
-/* MH is a little bit different - the top folder can contains messages other than in IMAP and
- POP3 and MBOX */
-MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
- : AccountViewItem( parent )
-{
- m_Path = aPath;
- /* be carefull - the space within settext is wanted - thats why the string twice */
- wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
- setPixmap( 0, PIXMAP_LOCALFOLDER );
- setText( 0, " Local Folders" );
- setOpen( true );
- folder = 0;
-}
-
-MHviewItem::~MHviewItem()
-{
- delete wrapper;
- if (folder) delete folder;
-}
-
-AbstractMail *MHviewItem::getWrapper()
-{
- return wrapper;
-}
-
-void MHviewItem::refresh( QList<RecMail> & target)
-{
- refresh(false);
- getWrapper()->listMessages( "",target );
-}
-
-void MHviewItem::removeChilds()
-{
- QListViewItem *child = firstChild();
- while ( child ) {
- QListViewItem *tmp = child;
- child = child->nextSibling();
- delete tmp;
- }
-}
-
-void MHviewItem::refresh(bool force)
-{
- if (childCount()>0 && force==false) return;
- removeChilds();
- QList<Folder> *folders = wrapper->listFolders();
- Folder *it;
- MHfolderItem*item = 0;
- MHfolderItem*pmaster = 0;
- QString fname = "";
- for ( it = folders->first(); it; it = folders->next() ) {
- fname = it->getDisplayName();
- /* this folder itself */
- if (fname=="/") {
- folder = it;
- continue;
- }
- if (pmaster) {
- item = new MHfolderItem( it, pmaster, item, this );
- } else {
- item = new MHfolderItem( it, this , item );
- }
- item->setSelectable(it->may_select());
- }
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
- delete folders;
-}
-
-RecBody MHviewItem::fetchBody( const RecMail &mail )
-{
- qDebug( "MH fetchBody" );
- return wrapper->fetchBody( mail );
-}
-
-QPopupMenu * MHviewItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- m->insertItem(QObject::tr("Refresh folder list",contextName),0);
- m->insertItem(QObject::tr("Create new folder",contextName),1);
- m->insertItem(QObject::tr("Delete all mails",contextName),2);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
- }
- return m;
-}
-
-void MHviewItem::createFolder()
-{
- Newmdirdlg ndirdlg(0,0,true);
- ndirdlg.showMaximized();
- if (ndirdlg.exec()) {
- QString ndir = ndirdlg.Newdir();
- if (wrapper->createMbox(ndir)) {
- refresh(true);
- }
- }
-}
-
-void MHviewItem::downloadMails()
-{
- AccountView*bl = accountView();
- if (!bl) return;
- bl->downloadMails(folder,getWrapper());
-}
-
-QStringList MHviewItem::subFolders()
-{
- QStringList result;
- QListViewItem *child = firstChild();
- result.append("/");
- while ( child ) {
- MHfolderItem *tmp = (MHfolderItem*)child;
- child = child->nextSibling();
- result.append(tmp->getFolder()->getDisplayName());
- }
- qDebug("Size of result: %i",result.count());
- return result;
-}
-
-void MHviewItem::contextMenuSelected(int which)
-{
- switch (which) {
- case 0:
- refresh(true);
- break;
- case 1:
- createFolder();
- break;
- case 2:
- deleteAllMail(getWrapper(),folder);
- break;
- case 3:
- downloadMails();
- break;
- default:
- break;
- }
-}
-
-MHfolderItem::~MHfolderItem()
-{
- delete folder;
-}
-
-MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent,after )
-{
- folder = folderInit;
- mbox = parent;
- initName();
-}
-
-MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
- : AccountViewItem( parent,after )
-{
- folder = folderInit;
- mbox = master;
- initName();
-}
-
-void MHfolderItem::initName()
-{
- QString bName = folder->getDisplayName();
- if (bName.startsWith("/")&&bName.length()>1) {
- bName.replace(0,1,"");
- }
- if (bName.lower() == "outgoing") {
- setPixmap( 0, PIXMAP_OUTBOXFOLDER );
- } else if (bName.lower() == "inbox") {
- setPixmap( 0, PIXMAP_INBOXFOLDER);
- } else {
- setPixmap( 0, PIXMAP_MBOXFOLDER );
- }
- setText( 0, bName );
-}
-
-Folder*MHfolderItem::getFolder()
-{
- return folder;
-}
-
-void MHfolderItem::refresh(QList<RecMail>&target)
-{
- if (folder->may_select())
- mbox->getWrapper()->listMessages( folder->getName(),target );
-}
-
-RecBody MHfolderItem::fetchBody(const RecMail&aMail)
-{
- return mbox->getWrapper()->fetchBody(aMail);
-}
-
-void MHfolderItem::deleteFolder()
-{
- int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
- QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
- QObject::tr("Yes",contextName),
- QObject::tr("No",contextName),QString::null,1,1);
- qDebug("Auswahl: %i",yesno);
- if (yesno == 0) {
- if (mbox->getWrapper()->deleteMbox(folder)) {
- QListView*v=listView();
- MHviewItem * box = mbox;
- /* be carefull - after that this object is destroyd so don't use
- * any member of it after that call!!*/
- mbox->refresh(true);
- if (v) {
- v->setSelected(box,true);
- }
- }
- }
-}
-
-QPopupMenu * MHfolderItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- m->insertItem(QObject::tr("Delete all mails",contextName),0);
- m->insertItem(QObject::tr("Delete folder",contextName),1);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
- m->insertItem(QObject::tr("Create new folder",contextName),3);
- }
- return m;
-}
-
-void MHfolderItem::downloadMails()
-{
- AccountView*bl = mbox->accountView();
- if (!bl) return;
- bl->downloadMails(folder,mbox->getWrapper());
-}
-
-void MHfolderItem::contextMenuSelected(int which)
-{
- switch(which) {
- case 0:
- deleteAllMail(mbox->getWrapper(),folder);
- break;
- case 1:
- deleteFolder();
- break;
- case 2:
- downloadMails();
- break;
- default:
- break;
- }
-}
-
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 60e2b4b..9f92090 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,194 +1,44 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
#include <qlistview.h>
#include <qlist.h>
-#include <libmailwrapper/settings.h>
-#include <libmailwrapper/mailwrapper.h>
-#include <libmailwrapper/abstractmail.h>
-
-class POP3wrapper;
+class Selectstore;
class RecMail;
class RecBody;
-class QPopupMenu;
-class Selectstore;
-class AccountView;
-
-class AccountViewItem : public QListViewItem
-{
-
-public:
- AccountViewItem( AccountView *parent );
- AccountViewItem( QListViewItem *parent);
- AccountViewItem( QListViewItem *parent , QListViewItem*after );
- virtual ~AccountViewItem();
- virtual void refresh(QList<RecMail>&)=0;
- virtual RecBody fetchBody(const RecMail&)=0;
- virtual QPopupMenu * getContextMenu(){return 0;};
- virtual void contextMenuSelected(int){}
- virtual AccountView*accountView();
-protected:
- virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
- static const QString contextName;
- AccountView*m_Backlink;
-};
-
-class POP3viewItem : public AccountViewItem
-{
-
-public:
- POP3viewItem( POP3account *a, AccountView *parent );
- virtual ~POP3viewItem();
- virtual void refresh( QList<RecMail> &target );
- virtual RecBody fetchBody( const RecMail &mail );
- 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
-{
-
-public:
- POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
- virtual ~POP3folderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
-
-protected:
- void downloadMails();
- Folder *folder;
- POP3viewItem *pop3;
-};
-
-class IMAPfolderItem;
-
-class IMAPviewItem : public AccountViewItem
-{
- friend class IMAPfolderItem;
-public:
- IMAPviewItem( IMAPaccount *a, AccountView *parent );
- virtual ~IMAPviewItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
- AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
- const QStringList&subFolders();
- virtual void refreshFolders(bool force=false);
- bool offline();
-
-protected:
- IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
- virtual void createNewFolder();
- virtual void removeChilds();
- IMAPaccount *account;
- AbstractMail *wrapper;
- QStringList currentFolders;
-};
-
-class IMAPfolderItem : public AccountViewItem
-{
-
-public:
- IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
- IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
- virtual ~IMAPfolderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
- bool matchName(const QString&name)const;
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
- virtual const QString& Delemiter()const;
-protected:
- virtual void createNewFolder();
- virtual void deleteFolder();
- virtual void downloadMails();
- Folder *folder;
- IMAPviewItem *imap;
-};
-
-class MHviewItem : public AccountViewItem
-{
- friend class MHfolderItem;
-
-public:
- MHviewItem( const QString&aMboxPath, AccountView *parent );
- virtual ~MHviewItem();
- virtual void refresh( QList<RecMail> &target );
- virtual RecBody fetchBody( const RecMail &mail );
- AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
- QStringList subFolders();
- virtual void refresh(bool force=false);
-
-protected:
- void downloadMails();
- void removeChilds();
- virtual void createFolder();
- QString m_Path;
- AbstractMail *wrapper;
- Folder *folder;
-};
-
-class MHfolderItem : public AccountViewItem
-{
-
-public:
- MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after );
- MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
- virtual ~MHfolderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
- virtual Folder*getFolder();
-
-protected:
- void downloadMails();
- virtual void deleteFolder();
- void initName();
- Folder *folder;
- MHviewItem *mbox;
-};
+class Folder;
+class AbstractMail;
+class Account;
+class IMAPviewItem;
+class MHviewItem;
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~AccountView();
virtual void populate( QList<Account> list );
virtual RecBody fetchBody(const RecMail&aMail);
virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper);
public slots:
virtual void refreshAll();
virtual void refresh(QListViewItem *item);
virtual void refreshCurrent();
virtual void slotHold(int, QListViewItem *,const QPoint&,int);
virtual void slotContextMenu(int id);
void setupFolderselect(Selectstore*sels);
signals:
void refreshMailview(QList<RecMail>*);
protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
QValueList<MHviewItem*> mhAccounts;
};
#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 90e1e46..552f0e5 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,57 +1,59 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
editaccounts.h \
composemail.h \
accountview.h \
+ accountitem.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
mailistviewitem.h \
settingsdialog.h \
statuswidget.h \
newmaildir.h \
selectstore.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
+ accountitem.cpp \
composemail.cpp \
addresspicker.cpp \
editaccounts.cpp \
viewmail.cpp \
viewmailbase.cpp \
mailistviewitem.cpp \
settingsdialog.cpp \
statuswidget.cpp \
newmaildir.cpp \
selectstore.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
composemailui.ui \
settingsdialogui.ui \
statuswidgetui.ui \
newmaildirui.ui \
selectstoreui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -lopie -lmailwrapper -liconv
}else{
LIBS += -lqpe -lopie -lmailwrapper
}
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 39e3a64..d3d3cdb 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,211 +1,212 @@
#include <qmessagebox.h>
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include <libmailwrapper/smtpwrapper.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qapplication.h>
#include <libmailwrapper/mailtypes.h>
+#include <libmailwrapper/abstractmail.h>
#include "mailistviewitem.h"
#include "viewmail.h"
#include "selectstore.h"
OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
: MainWindow( parent, name, WStyle_ContextHelp )
{
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
OpieMail::~OpieMail()
{
if (settings) delete settings;
}
void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
{
// copied from old mail2
if (msg == "writeMail(QString,QString)") {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
// removing the whitespaces at beginning and end is needed!
slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
} else if (msg == "newMail()") {
slotComposeMail();
}
}
void OpieMail::slotwriteMail(const QString&name,const QString&email)
{
ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
if (!email.isEmpty()) {
if (!name.isEmpty()) {
compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
} else {
compose.setTo(email);
}
}
compose.showMaximized();
compose.slotAdjustColumns();
compose.exec();
}
void OpieMail::slotComposeMail()
{
qDebug( "Compose Mail" );
slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
qDebug( "Send Queued" );
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
Account *it;
// if (list.count()==1) {
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "SMTP" ) == 0 ) {
smtp = static_cast<SMTPaccount *>(it);
break;
}
}
// }
if (smtp) {
SMTPwrapper * wrap = new SMTPwrapper(settings);
if ( wrap->flushOutbox(smtp) ) {
QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
}
}
}
void OpieMail::slotSearchMails()
{
qDebug( "Search Mails" );
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
settingsDialog.showMaximized();
settingsDialog.exec();
}
void OpieMail::slotEditAccounts()
{
qDebug( "Edit Accounts" );
EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
eaDialog.showMaximized();
eaDialog.slotAdjustColumns();
eaDialog.exec();
if ( settings ) delete settings;
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
void OpieMail::displayMail()
{
QListViewItem*item = mailView->currentItem();
if (!item) return;
RecMail mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted ) {
folderView->refreshCurrent();
} else {
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
}
}
void OpieMail::slotDeleteMail()
{
if (!mailView->currentItem()) return;
RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
mail.Wrapper()->deleteMail( mail );
folderView->refreshCurrent();
}
}
void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
{
/* just the RIGHT button - or hold on pda */
if (button!=2) {return;}
qDebug("Event right/hold");
if (!item) return;
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
}
void OpieMail::slotShowFolders( bool show )
{
qDebug( "Show Folders" );
if ( show && folderView->isHidden() ) {
qDebug( "-> showing" );
folderView->show();
} else if ( !show && !folderView->isHidden() ) {
qDebug( "-> hiding" );
folderView->hide();
}
}
void OpieMail::refreshMailView(QList<RecMail>*list)
{
MailListViewItem*item = 0;
mailView->clear();
for (unsigned int i = 0; i < list->count();++i) {
item = new MailListViewItem(mailView,item);
item->storeData(*(list->at(i)));
item->showEntry();
}
}
void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
{
/* just LEFT button - or tap with stylus on pda */
if (button!=1) return;
if (!item) return;
displayMail();
}
void OpieMail::slotMoveCopyMail()
{
if (!mailView->currentItem()) return;
RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
AbstractMail*targetMail = 0;
QString targetFolder = "";
Selectstore sels;
folderView->setupFolderselect(&sels);
if (!sels.exec()) return;
targetMail = sels.currentMail();
targetFolder = sels.currentFolder();
if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
targetFolder.isEmpty()) {
return;
}
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;
}
mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
folderView->refreshCurrent();
}