summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp232
-rw-r--r--noncore/net/mail/accountitem.h50
-rw-r--r--noncore/net/mail/accountview.cpp29
-rw-r--r--noncore/net/mail/accountview.h8
-rw-r--r--noncore/net/mail/mainwindow.cpp19
-rw-r--r--noncore/net/mail/mainwindow.h12
-rw-r--r--noncore/net/mail/opiemail.cpp41
-rw-r--r--noncore/net/mail/opiemail.h6
8 files changed, 242 insertions, 155 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 10db2c6..f7fdccd 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,1152 +1,1164 @@
#include "accountitem.h"
#include "accountview.h"
#include "newmaildir.h"
#include "nntpgroupsdlg.h"
#include "defines.h"
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
#include <libmailwrapper/mailwrapper.h>
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qpopupmenu.h>
#include <qmessagebox.h>
using namespace Opie::Core;
#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(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
{
refresh();
}
void POP3viewItem::refresh()
{
if (account->getOffline()) return;
QValueList<FolderP> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
QValueList<FolderP>::ConstIterator it;
QListViewItem*item = 0;
for ( it = folders->begin(); it!=folders->end(); ++it)
{
item = new POP3folderItem( (*it), this , item );
item->setSelectable( (*it)->may_select());
}
delete folders;
}
RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
{
odebug << "POP3 fetchBody" << oendl;
return wrapper->fetchBody( mail );
}
-QPopupMenu * POP3viewItem::getContextMenu()
+QMap<int,QString> POP3viewItem::serverMenu()
{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- if (!account->getOffline())
- {
- m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT);
- m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE);
- }
- else
- {
- m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE);
- }
+ QMap<int,QString> _entries;
+ if (!account->getOffline()) {
+ _entries[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName);
+ _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName);
+ } else {
+ _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName);
}
- return m;
+ return _entries;
}
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)
+bool POP3viewItem::contextMenuSelected(int which)
{
switch (which)
{
case SERVER_MENU_DISCONNECT:
disconnect();
break;
case SERVER_MENU_OFFLINE:
setOnOffline();
break;
}
+ return false;
}
POP3folderItem::~POP3folderItem()
{}
POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after )
: AccountViewItem(folderInit,parent,after )
{
pop3 = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_POP3FOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
void POP3folderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
pop3->getWrapper()->listMessages( folder->getName(),target );
}
RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
{
return pop3->getWrapper()->fetchBody(aMail);
}
-QPopupMenu * POP3folderItem::getContextMenu()
+QMap<int,QString> POP3folderItem::folderMenu()
{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
- m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS);
- }
- return m;
+ QMap<int,QString> _entries;
+ _entries[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName);
+ _entries[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName);
+ _entries[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName);
+ return _entries;
}
void POP3folderItem::downloadMails()
{
AccountView*bl = pop3->accountView();
if (!bl) return;
bl->downloadMails(folder,pop3->getWrapper());
}
-void POP3folderItem::contextMenuSelected(int which)
+bool POP3folderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which)
{
case FOLDER_MENU_REFRESH_HEADER:
/* must be 'cause pop3 lists are cached */
pop3->getWrapper()->logout();
view->refreshCurrent();
break;
case FOLDER_MENU_DELETE_ALL_MAILS:
deleteAllMail(pop3->getWrapper(),folder);
break;
case FOLDER_MENU_MOVE_MAILS:
downloadMails();
break;
default:
break;
}
+ return false;
}
/**
* NNTP Account stuff
*/
NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
//FIXME
SETPIX(PIXMAP_POP3FOLDER);
#if 0
if (!account->getOffline())
{
setPixmap( 0, );
}
else
{
setPixmap( 0, PIXMAP_OFFLINE );
}
#endif
setText( 0, account->getAccountName() );
setOpen( true );
}
NNTPviewItem::~NNTPviewItem()
{
delete wrapper;
}
AbstractMail *NNTPviewItem::getWrapper()
{
return wrapper;
}
void NNTPviewItem::refresh( QValueList<RecMailP> & )
{
refresh();
}
void NNTPviewItem::refresh()
{
if (account->getOffline()) return;
QValueList<FolderP> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
QValueList<FolderP>::ConstIterator it;
QListViewItem*item = 0;
for ( it = folders->begin(); it!=folders->end(); ++it)
{
item = new NNTPfolderItem( (*it), this , item );
item->setSelectable( (*it)->may_select());
}
delete folders;
}
RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
{
odebug << "NNTP fetchBody" << oendl;
return wrapper->fetchBody( mail );
}
-QPopupMenu * NNTPviewItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
+QMap<int,QString> NNTPviewItem::serverMenu()
{
+ QMap<int,QString> _entries;
if (!account->getOffline())
{
- m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT);
- m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE);
- m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE);
- }
- else
- {
- m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE);
- }
+ _entries[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName);
+ _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName);
+ _entries[SERVER_MENU_SUBSCRIBE]=QObject::tr("(Un-)Subscribe groups",contextName);
+ } else {
+ _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName);
}
- return m;
+ return _entries;
}
void NNTPviewItem::subscribeGroups()
{
NNTPGroupsDlg dlg(account);
if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){
refresh();
}
}
void NNTPviewItem::disconnect()
{
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
wrapper->logout();
}
void NNTPviewItem::setOnOffline()
{
if (!account->getOffline())
{
disconnect();
}
account->setOffline(!account->getOffline());
account->save();
//FIXME
SETPIX(PIXMAP_POP3FOLDER);
refresh();
}
-void NNTPviewItem::contextMenuSelected(int which)
+bool NNTPviewItem::contextMenuSelected(int which)
{
switch (which)
{
case SERVER_MENU_DISCONNECT:
disconnect();
break;
case SERVER_MENU_OFFLINE:
setOnOffline();
break;
case SERVER_MENU_SUBSCRIBE:
subscribeGroups();
break;
}
+ return false;
}
NNTPfolderItem::~NNTPfolderItem()
{}
NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after )
: AccountViewItem( folderInit, parent,after )
{
nntp = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_POP3FOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
nntp->getWrapper()->listMessages( folder->getName(),target );
}
RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
{
return nntp->getWrapper()->fetchBody(aMail);
}
-QPopupMenu * NNTPfolderItem::getContextMenu()
+QMap<int,QString> NNTPfolderItem::folderMenu()
{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
- m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS);
- }
- return m;
+ QMap<int,QString> _entries;
+ _entries[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName);
+ _entries[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Copy all postings",contextName);
+ return _entries;
}
void NNTPfolderItem::downloadMails()
{
AccountView*bl = nntp->accountView();
if (!bl) return;
bl->downloadMails(folder,nntp->getWrapper());
}
-void NNTPfolderItem::contextMenuSelected(int which)
+bool NNTPfolderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which)
{
case FOLDER_MENU_REFRESH_HEADER:
/* must be 'cause nntp lists are cached */
nntp->getWrapper()->logout();
view->refreshCurrent();
break;
case FOLDER_MENU_MOVE_MAILS:
downloadMails();
break;
default:
break;
}
+ return false;
}
/**
* 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(QValueList<RecMailP>&)
{
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();
QValueList<FolderP> * folders = wrapper->listFolders();
QValueList<FolderP>::Iterator it;
QListViewItem*item = 0;
QListViewItem*titem = 0;
QString fname,del,search;
int pos;
for ( it = folders->begin(); it!=folders->end(); ++it)
{
if ((*it)->getDisplayName().lower()=="inbox")
{
item = new IMAPfolderItem( (*it), this , item );
folders->remove(it);
odebug << "inbox found" << oendl;
break;
}
}
for ( it = folders->begin(); it!=folders->end(); ++it)
{
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()
+QMap<int,QString> IMAPviewItem::serverMenu()
{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- if (!account->getOffline())
- {
- m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT);
- m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE);
- m->insertSeparator();
- m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER);
- m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER);
- }
- else
- {
- m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE);
- }
+ QMap<int,QString> e;
+ if (!account->getOffline()) {
+ e[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName);
+ e[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName);
+ e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName);
+ e[SERVER_MENU_CREATE_FOLDER]=QObject::tr("Create new folder",contextName);
+ } else {
+ e[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName);
}
- return m;
+ return e;
}
void IMAPviewItem::createNewFolder()
{
Newmdirdlg ndirdlg;
if ( QPEApplication::execDialog( &ndirdlg ))
{
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)
+bool IMAPviewItem::contextMenuSelected(int id)
{
odebug << "Id selected: " << id << "" << oendl;
switch (id)
{
case SERVER_MENU_REFRESH_FOLDER:
refreshFolders(true);
break;
case SERVER_MENU_CREATE_FOLDER:
createNewFolder();
break;
case SERVER_MENU_DISCONNECT:
removeChilds();
wrapper->logout();
break;
case SERVER_MENU_OFFLINE:
if (account->getOffline()==false)
{
removeChilds();
wrapper->logout();
}
account->setOffline(!account->getOffline());
account->save();
SETPIX(PIXMAP_IMAPFOLDER);
refreshFolders(false);
break;
default:
break;
}
+ return false;
}
RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
{
return new RecBody();
}
bool IMAPviewItem::offline()
{
return account->getOffline();
}
IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
: AccountViewItem( folderInit, parent , after )
{
imap = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_IMAPFOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
: AccountViewItem(folderInit, parent,after )
{
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(QValueList<RecMailP>&target)
{
if (folder->may_select())
{
imap->getWrapper()->listMessages( folder->getName(),target );
}
else
{
target.clear();
}
}
RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
{
return imap->getWrapper()->fetchBody(aMail);
}
-QPopupMenu * IMAPfolderItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- if (folder->may_select())
+QMap<int,QString> IMAPfolderItem::folderMenu()
{
- m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
- m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS);
- m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
+ QMap<int,QString> e;
+ if (folder->may_select()) {
+ e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName);
+ e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copy all mails",contextName);
+ e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName);
}
- if (folder->no_inferior()==false)
- {
- m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER);
+ if (folder->no_inferior()==false) {
+ e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName);
}
- if (folder->getDisplayName().lower()!="inbox")
- {
- m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER);
+ if (folder->getDisplayName().lower()!="inbox") {
+ e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName);
}
- }
- return m;
+ return e;
}
void IMAPfolderItem::createNewFolder()
{
Newmdirdlg ndirdlg;
if ( QPEApplication::execDialog( &ndirdlg ) )
{
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()
+bool 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);
odebug << "Auswahl: " << yesno << "" << oendl;
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);
}
+ return true;
}
}
+ return false;
}
void IMAPfolderItem::downloadMails()
{
AccountView*bl = imap->accountView();
if (!bl) return;
bl->downloadMails(folder,imap->getWrapper());
}
-void IMAPfolderItem::contextMenuSelected(int id)
+bool IMAPfolderItem::contextMenuSelected(int id)
{
odebug << "Selected id: " << id << "" << oendl;
AccountView * view = (AccountView*)listView();
switch(id)
{
case FOLDER_MENU_REFRESH_HEADER:
view->refreshCurrent();
break;
case FOLDER_MENU_DELETE_ALL_MAILS:
deleteAllMail(imap->getWrapper(),folder);
break;
case FOLDER_MENU_NEW_SUBFOLDER:
if (folder->no_inferior()==false) {
createNewFolder();
}
break;
case FOLDER_MENU_DELETE_FOLDER:
if (folder->getDisplayName().lower()!="inbox") {
- deleteFolder();
+ return deleteFolder();
}
break;
case FOLDER_MENU_MOVE_MAILS:
downloadMails();
break;
default:
break;
}
+ return false;
}
/**
* 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( QValueList<RecMailP> & target)
{
refresh(false);
getWrapper()->listMessages( "",target );
}
void MHviewItem::refresh(bool force)
{
if (childCount()>0 && force==false) return;
odebug << "Refresh mh folders" << oendl;
removeChilds();
currentFolders.clear();
QValueList<FolderP> *folders = wrapper->listFolders();
QValueList<FolderP>::ConstIterator it;
MHfolderItem*item = 0;
MHfolderItem*pmaster = 0;
QString fname = "";
int pos;
for ( it = folders->begin(); it!=folders->end(); ++it)
{
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());
}
delete folders;
}
RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
{
odebug << "MH fetchBody" << oendl;
return wrapper->fetchBody( mail );
}
-QPopupMenu * MHviewItem::getContextMenu()
-{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
+QMap<int,QString> MHviewItem::serverMenu()
{
- m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER);
- m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER);
- m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS);
+ QMap<int,QString> e;
+ e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName);
+ return e;
}
- return m;
+
+QMap<int,QString> MHviewItem::folderMenu()
+{
+ QMap<int,QString> e;
+ e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName);
+ e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new folder",contextName);
+ e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName);
+ e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName);
+ return e;
}
void MHviewItem::createFolder()
{
Newmdirdlg ndirdlg(0,0,true);
if ( QPEApplication::execDialog( &ndirdlg ) )
{
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)
+bool MHviewItem::contextMenuSelected(int which)
{
AccountView*view = 0;
switch (which)
{
case SERVER_MENU_REFRESH_FOLDER:
refresh(true);
break;
case FOLDER_MENU_NEW_SUBFOLDER:
createFolder();
break;
case FOLDER_MENU_DELETE_ALL_MAILS:
deleteAllMail(getWrapper(),folder);
break;
case FOLDER_MENU_MOVE_MAILS:
downloadMails();
break;
case FOLDER_MENU_REFRESH_HEADER:
view = (AccountView*)listView();
if (view) view->refreshCurrent();
break;
default:
break;
}
+ return false;
}
MHfolderItem::~MHfolderItem()
{}
MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
: AccountViewItem(folderInit, parent,after )
{
mbox = parent;
initName();
}
MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
: AccountViewItem(folderInit, 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 if (bName.lower() == "drafts") {
setPixmap(0, Resource::loadPixmap("edit"));
} else {
setPixmap( 0, PIXMAP_MBOXFOLDER );
}
setText( 0, bName );
}
const FolderP&MHfolderItem::getFolder()const
{
return folder;
}
void MHfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
mbox->getWrapper()->listMessages( folder->getName(),target );
}
RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
-void MHfolderItem::deleteFolder()
+bool 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);
odebug << "Auswahl: " << yesno << "" << oendl;
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);
}
+ return true;
}
}
+ return false;
}
-QPopupMenu * MHfolderItem::getContextMenu()
+QMap<int,QString> MHfolderItem::folderMenu()
{
- QPopupMenu *m = new QPopupMenu(0);
- if (m)
- {
- m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER);
- m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS);
- m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
- m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER);
- }
- return m;
+ QMap<int,QString> e;
+ e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName);
+ e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName);
+ e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName);
+ e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName);
+ e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName);
+ return e;
}
void MHfolderItem::downloadMails()
{
AccountView*bl = mbox->accountView();
if (!bl) return;
bl->downloadMails(folder,mbox->getWrapper());
}
void MHfolderItem::createFolder()
{
Newmdirdlg ndirdlg(0,0,true);
if ( QPEApplication::execDialog( &ndirdlg ) )
{
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)
+bool MHfolderItem::contextMenuSelected(int which)
{
AccountView*view = 0;
switch(which)
{
case FOLDER_MENU_DELETE_ALL_MAILS:
deleteAllMail(mbox->getWrapper(),folder);
break;
case FOLDER_MENU_DELETE_FOLDER:
- deleteFolder();
+ return deleteFolder();
break;
case FOLDER_MENU_MOVE_MAILS:
downloadMails();
break;
case FOLDER_MENU_NEW_SUBFOLDER:
createFolder();
break;
case FOLDER_MENU_REFRESH_HEADER:
view = (AccountView*)listView();
if (view) view->refreshCurrent();
break;
default:
break;
}
+ return false;
}
bool MHfolderItem::isDraftfolder()
{
if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
return false;
}
/**
* Generic stuff
*/
const QString AccountViewItem::contextName="AccountViewItem";
AccountViewItem::AccountViewItem( AccountView *parent )
: QListViewItem( parent )
{
init();
m_Backlink = parent;
}
AccountViewItem::AccountViewItem( QListViewItem *parent)
: QListViewItem( parent),folder(0)
{
init();
}
AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
:QListViewItem( parent,after ),folder(0)
{
init();
}
AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
:QListViewItem( parent,after ),folder(folderInit)
{
init();
}
void AccountViewItem::init()
{
m_Backlink = 0;
}
AccountViewItem::~AccountViewItem()
{
folder = 0;
}
AccountView*AccountViewItem::accountView()
{
return m_Backlink;
}
void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&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);
odebug << "Auswahl: " << yesno << "" << oendl;
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;
}
bool AccountViewItem::isDraftfolder()
{
return false;
}
+
+QMap<int,QString> AccountViewItem::serverMenu()
+{
+ return QMap<int,QString>();
+}
+
+QMap<int,QString> AccountViewItem::folderMenu()
+{
+ return QMap<int,QString>();
+}
+
+QPopupMenu * AccountViewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m)
+ {
+ QMap<int,QString> entries;
+ entries = folderMenu();
+ QMap<int,QString>::Iterator it;
+ for (it=entries.begin();it!=entries.end();++it) {
+ m->insertItem(it.data(),it.key());
+ }
+ entries = serverMenu();
+ for (it=entries.begin();it!=entries.end();++it) {
+ m->insertItem(it.data(),it.key());
+ }
+ }
+ return m;
+}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index b2c50a1..6518899 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -1,225 +1,229 @@
#ifndef __ACCOUNT_ITEM
#define __ACCOUNT_ITEM
+#include <opie2/osmartpointer.h>
+
#include <qlistview.h>
#include <qlist.h>
-#include <opie2/osmartpointer.h>
+#include <qmap.h>
class POP3wrapper;
class RecMail;
class RecBody;
class QPopupMenu;
class Selectstore;
class AccountView;
class POP3account;
class NNTPaccount;
class IMAPaccount;
class AbstractMail;
class Folder;
#define RECBODYP Opie::Core::OSmartPointer<RecBody>
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( AccountView *parent );
AccountViewItem( QListViewItem *parent);
AccountViewItem( QListViewItem *parent , QListViewItem*after );
AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after );
virtual ~AccountViewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0;
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0;
- virtual QPopupMenu * getContextMenu(){return 0;};
- virtual void contextMenuSelected(int){}
+ virtual QPopupMenu * getContextMenu();
+ virtual bool contextMenuSelected(int){return false;}
virtual AccountView*accountView();
virtual bool matchName(const QString&name)const;
virtual bool isDraftfolder();
/* 1 - server
* 2 - folder
- * 3 - beides
+ * 3 - both
*/
virtual int isServer()const=0;
+ virtual QMap<int,QString> serverMenu();
+ virtual QMap<int,QString> folderMenu();
protected:
AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
virtual void init();
virtual void removeChilds();
virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f);
static const QString contextName;
AccountView*m_Backlink;
Opie::Core::OSmartPointer<Folder> folder;
};
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, AccountView *parent );
virtual ~POP3viewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual int isServer()const{return 1;}
+ virtual QMap<int,QString> serverMenu();
protected:
POP3account *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
};
class POP3folderItem : public AccountViewItem
{
public:
POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
virtual ~POP3folderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual int isServer()const{return 2;}
+ virtual QMap<int,QString> folderMenu();
protected:
void downloadMails();
POP3viewItem *pop3;
};
class NNTPviewItem : public AccountViewItem
{
public:
NNTPviewItem( NNTPaccount *a, AccountView *parent );
virtual ~NNTPviewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual int isServer()const{return 1;}
+ virtual QMap<int,QString> serverMenu();
protected:
NNTPaccount *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
void subscribeGroups();
};
class NNTPfolderItem : public AccountViewItem
{
public:
NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
virtual ~NNTPfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual int isServer()const{return 2;}
-
+ virtual QMap<int,QString> folderMenu();
protected:
void downloadMails();
NNTPviewItem *nntp;
};
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
IMAPviewItem( IMAPaccount *a, AccountView *parent );
virtual ~IMAPviewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
const QStringList&subFolders();
virtual void refreshFolders(bool force=false);
virtual int isServer()const{return 1;}
bool offline();
+ virtual QMap<int,QString> serverMenu();
protected:
virtual void createNewFolder();
IMAPaccount *account;
AbstractMail *wrapper;
QStringList currentFolders;
};
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
virtual ~IMAPfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual const QString& Delemiter()const;
virtual int isServer()const{return 2;}
+ virtual QMap<int,QString> folderMenu();
protected:
virtual void createNewFolder();
- virtual void deleteFolder();
+ virtual bool 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(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
QStringList subFolders();
virtual void refresh(bool force=false);
virtual int isServer()const{return 3;}
+ virtual QMap<int,QString> serverMenu();
+ virtual QMap<int,QString> folderMenu();
protected:
void downloadMails();
virtual void createFolder();
QString m_Path;
AbstractMail *wrapper;
QStringList currentFolders;
};
class MHfolderItem : public AccountViewItem
{
public:
MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
virtual ~MHfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
- virtual QPopupMenu * getContextMenu();
- virtual void contextMenuSelected(int);
+ virtual bool contextMenuSelected(int);
virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const;
virtual bool isDraftfolder();
virtual int isServer()const{return 2;}
+ virtual QMap<int,QString> folderMenu();
protected:
void downloadMails();
virtual void createFolder();
- virtual void deleteFolder();
+ virtual bool deleteFolder();
void initName();
MHviewItem *mbox;
};
#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index faa42c3..1183704 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,202 +1,221 @@
#include "accountview.h"
#include "accountitem.h"
#include "selectstore.h"
#include <libmailwrapper/settings.h>
#include <libmailwrapper/mailwrapper.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qmessagebox.h>
#include <qpopupmenu.h>
using namespace Opie::Core;
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
setSorting(0);
setSelectionMode(Single);
m_rightPressed = false;
connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
SLOT( slotSelectionChanged(QListViewItem*) ) );
connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) );
connect( this, SIGNAL(clicked(QListViewItem*) ),this,
SLOT( slotMouseClicked(QListViewItem*) ) );
m_currentItem = 0;
}
AccountView::~AccountView()
{
imapAccounts.clear();
mhAccounts.clear();
}
void AccountView::slotSelectionChanged(QListViewItem*item)
{
- odebug << "AccountView: Selection changed" << oendl;
if (!item) {
emit serverSelected(0);
return;
}
AccountViewItem *view = static_cast<AccountViewItem *>(item);
-
emit serverSelected(view->isServer());
}
+QMap<int,QString> AccountView::currentServerMenu()const
+{
+ QMap<int,QString> smap;
+ AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
+ if (!view)return smap;
+ smap = view->serverMenu();
+ return smap;
+}
+
+QMap<int,QString> AccountView::currentFolderMenu()const
+{
+ QMap<int,QString> fmap;
+ AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
+ if (!view)return fmap;
+ fmap = view->folderMenu();
+ return fmap;
+}
+
void AccountView::slotContextMenu(int id)
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return;
- view->contextMenuSelected(id);
+ bool del = view->contextMenuSelected(id);
+ if (!del && view->isServer()!=2) {
+ emit refreshMenues(view->isServer());
+ }
}
-void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int)
+void AccountView::slotRightButton(int, QListViewItem * item,const QPoint&,int)
{
m_rightPressed = true;
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::slotLeftButton(int button, QListViewItem * item,const QPoint&,int)
+void AccountView::slotLeftButton(int, QListViewItem *,const QPoint&,int)
{
m_rightPressed = false;
}
void AccountView::slotMouseClicked(QListViewItem*item)
{
if (m_rightPressed) return;
if (!item || m_currentItem == item) return;
/* ### ToDo check settings if on single tab it should open */
m_currentItem = item;
refresh(m_currentItem);
}
void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column)
{
if (button==1) {
slotLeftButton(button,item,pos,column);
} else if (button==2) {
slotRightButton(button,item,pos,column);
}
}
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() == MAILLIB::A_IMAP ) {
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
odebug << "added IMAP " + imap->getAccountName() << oendl;
imapAccounts.append(new IMAPviewItem( imap, this ));
} else if ( it->getType() == MAILLIB::A_POP3 ) {
POP3account *pop3 = static_cast<POP3account *>(it);
odebug << "added POP3 " + pop3->getAccountName() << oendl;
/* must not be hold 'cause it isn't required */
(void) new POP3viewItem( pop3, this );
} else if ( it->getType() == MAILLIB::A_NNTP ) {
NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
odebug << "added NNTP " + nntp->getAccountName() << oendl;
/* must not be hold 'cause it isn't required */
(void) new NNTPviewItem( nntp, this );
} else if ( it->getType() == MAILLIB::A_MH ) {
}
}
}
void AccountView::refresh(QListViewItem *item)
{
odebug << "AccountView refresh..." << oendl;
if ( item )
{
m_currentItem = item;
QValueList<RecMailP> headerlist;
AccountViewItem *view = static_cast<AccountViewItem *>(item);
view->refresh(headerlist);
emit refreshMailview(headerlist);
}
}
void AccountView::refreshCurrent()
{
m_currentItem = currentItem();
if ( !m_currentItem ) return;
QValueList<RecMailP> headerlist;
AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
view->refresh(headerlist);
emit refreshMailview(headerlist);
}
void AccountView::refreshAll()
{
}
RecBodyP AccountView::fetchBody(const RecMailP&aMail)
{
QListViewItem*item = selectedItem ();
if (!item) return new RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
void AccountView::setupFolderselect(Selectstore*sels)
{
QPEApplication::showDialog( sels );
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(const FolderP&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;
}
odebug << "Targetfolder: " << targetFolder.latin1() << "" << oendl;
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index ae24dce..5c4b559 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,54 +1,58 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
+#include <libmailwrapper/mailtypes.h>
+#include <opie2/osmartpointer.h>
#include <qlistview.h>
#include <qlist.h>
-#include <opie2/osmartpointer.h>
-#include <libmailwrapper/mailtypes.h>
+#include <qmap.h>
class Selectstore;
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 RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
virtual bool currentisDraft();
+ QMap<int,QString> currentServerMenu()const;
+ QMap<int,QString> currentFolderMenu()const;
public slots:
virtual void refreshAll();
virtual void refresh(QListViewItem *item);
virtual void refreshCurrent();
virtual void slotContextMenu(int id);
void setupFolderselect(Selectstore*sels);
signals:
void refreshMailview(const QValueList<RecMailP>& );
void serverSelected(int);
+ void refreshMenues(int);
protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
QValueList<MHviewItem*> mhAccounts;
bool m_rightPressed:1;
protected slots:
virtual void slotRightButton(int, QListViewItem *,const QPoint&,int);
virtual void slotLeftButton(int, QListViewItem *,const QPoint&,int);
virtual void slotMouseButton(int, QListViewItem *,const QPoint&,int);
virtual void slotMouseClicked(QListViewItem*);
virtual void slotSelectionChanged(QListViewItem*);
};
#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 81c8fee..3689352 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,270 +1,273 @@
#include <qlabel.h>
#include <qvbox.h>
#include <qheader.h>
#include <qtimer.h>
#include <qlayout.h>
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include "defines.h"
#include "mainwindow.h"
using namespace Opie::Core;
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name, flags )
{
setCaption( tr( "Mail" ) );
setToolBarsMovable( false );
toolBar = new QToolBar( this );
-
menuBar = new QMenuBar( toolBar );
mailMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Mail" ), mailMenu );
settingsMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Settings" ), settingsMenu );
+ if (QApplication::desktop()->width()<330) {
+ serverMenu = new QPopupMenu( mailMenu );
+ folderMenu = new QPopupMenu( mailMenu );
+ m_ServerMenuId = mailMenu->insertItem( tr( "Server" ), serverMenu );
+ m_FolderMenuId = mailMenu->insertItem( tr( "Folder" ), folderMenu );
+ } else {
serverMenu = new QPopupMenu( menuBar );
+ folderMenu = new QPopupMenu( menuBar );
+ m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu );
m_ServerMenuId = menuBar->insertItem( tr( "Server" ), serverMenu );
+ }
serverMenu->insertItem(tr("Disconnect"),SERVER_MENU_DISCONNECT);
serverMenu->insertItem(tr("Set on/offline"),SERVER_MENU_OFFLINE);
serverMenu->insertSeparator();
serverMenu->insertItem(tr("Refresh folder list"),SERVER_MENU_REFRESH_FOLDER);
serverMenu->insertItem(tr("Create new folder"),SERVER_MENU_CREATE_FOLDER);
serverMenu->insertSeparator();
serverMenu->insertItem(tr("(Un-)Subscribe groups"),SERVER_MENU_SUBSCRIBE);
- folderMenu = new QPopupMenu( menuBar );
- m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu );
folderMenu->insertItem(tr("Refresh headerlist"),FOLDER_MENU_REFRESH_HEADER);
folderMenu->insertItem(tr("Delete all mails"),FOLDER_MENU_DELETE_ALL_MAILS);
folderMenu->insertItem(tr("New subfolder"),FOLDER_MENU_NEW_SUBFOLDER);
folderMenu->insertItem(tr("Delete folder"),FOLDER_MENU_DELETE_FOLDER);
folderMenu->insertItem(tr("Move/Copie all mails"),FOLDER_MENU_MOVE_MAILS);
-
menuBar->setItemEnabled(m_ServerMenuId,false);
menuBar->setItemEnabled(m_FolderMenuId,false);
addToolBar( toolBar );
toolBar->setHorizontalStretchable( true );
QLabel *spacer = new QLabel( toolBar );
spacer->setBackgroundMode( QWidget::PaletteButton );
toolBar->setStretchableWidget( spacer );
composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
0, 0, this );
composeMail->addTo( toolBar );
composeMail->addTo( mailMenu );
sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
0, 0, this );
sendQueued->addTo( toolBar );
sendQueued->addTo( mailMenu );
/*
syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
0, 0, this );
syncFolders->addTo( toolBar );
syncFolders->addTo( mailMenu );
*/
showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
0, 0, this, 0, true );
showFolders->addTo( toolBar );
showFolders->addTo( mailMenu );
showFolders->setOn( true );
connect(showFolders, SIGNAL( toggled(bool) ),
SLOT( slotShowFolders(bool) ) );
/*
searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ),
0, 0, this );
searchMails->addTo( toolBar );
searchMails->addTo( mailMenu );
*/
deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this);
deleteMails->addTo( toolBar );
deleteMails->addTo( mailMenu );
connect( deleteMails, SIGNAL( activated() ),
SLOT( slotDeleteMail() ) );
editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) ,
0, 0, this );
editSettings->addTo( settingsMenu );
connect( editSettings, SIGNAL( activated() ),
SLOT( slotEditSettings() ) );
editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
0, 0, this );
editAccounts->addTo( settingsMenu );
QWidget *view = new QWidget( this );
setCentralWidget( view );
layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
folderView = new AccountView( view );
folderView->header()->hide();
folderView->setRootIsDecorated( true );
folderView->addColumn( tr( "Mailbox" ) );
connect(folderView,SIGNAL(serverSelected(int)),this,SLOT(serverSelected(int)));
connect(serverMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int)));
connect(folderMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int)));
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( "" );
mailView->addColumn( tr( "Subject" ),QListView::Manual );
mailView->addColumn( tr( "Sender" ),QListView::Manual );
mailView->addColumn( tr( "Size" ),QListView::Manual);
mailView->addColumn( tr( "Date" ));
mailView->setAllColumnsShowFocus(true);
mailView->setShowSortIndicator(true);
mailView->setSorting(4,false);
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90);
slotAdjustLayout();
QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this,
SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) );
connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
// Added by Stefan Eilers to allow starting by addressbook..
// copied from old mail2
#if !defined(QT_NO_COP)
connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
m_sysChannel = new QCopChannel( "QPE/System", this );
connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
#endif
QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) );
}
MainWindow::~MainWindow()
{
}
-void MainWindow::serverSelected(int m_isFolder)
+void MainWindow::serverSelected(int)
{
- mailView->clear();
- menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1);
- menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2);
+ odebug << "slotShowFolders not reached" << oendl;
}
void MainWindow::systemMessage( const QCString& msg, const QByteArray& data )
{
int _newrotation;
QDataStream stream( data, IO_ReadOnly );
if ( msg == "setCurrentRotation(int)" )
{
stream >> _newrotation;
if (m_Rotate != _newrotation) {
slotAdjustLayout();
m_Rotate = _newrotation;
}
}
}
void MainWindow::appMessage(const QCString &, const QByteArray &)
{
odebug << "appMessage not reached" << oendl;
}
void MainWindow::slotAdjustLayout() {
QWidget *d = QApplication::desktop();
if ( d->width() < d->height() ) {
layout->setDirection( QBoxLayout::TopToBottom );
} else {
layout->setDirection( QBoxLayout::LeftToRight );
}
}
void MainWindow::slotAdjustColumns()
{
bool hidden = folderView->isHidden();
if ( hidden ) folderView->show();
folderView->setColumnWidth( 0, folderView->visibleWidth() );
if ( hidden ) folderView->hide();
mailView->setColumnWidth( 0, 10 );
mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
mailView->setColumnWidth( 2, 80 );
mailView->setColumnWidth( 3, 50 );
mailView->setColumnWidth( 4, 50 );
}
void MainWindow::slotEditSettings()
{
}
void MainWindow::slotShowFolders( bool )
{
odebug << "slotShowFolders not reached" << oendl;
}
void MainWindow::refreshMailView(const QValueList<RecMailP>&)
{
odebug << "refreshMailView not reached" << oendl;
}
void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
{
odebug << "mailLeftClicked not reached" << oendl;
}
void MainWindow::displayMail()
{
odebug << "displayMail not reached" << oendl;
}
void MainWindow::slotDeleteMail()
{
odebug << "deleteMail not reached" << oendl;
}
void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
{
odebug << "mailHold not reached" << oendl;
}
void MainWindow::slotSendQueued()
{
}
void MainWindow::slotEditAccounts()
{
}
void MainWindow::slotComposeMail()
{
}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 409f160..b781d62 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,61 +1,61 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
+#include "accountview.h"
+#include <libmailwrapper/mailtypes.h>
+
+#include <opie2/osmartpointer.h>
+
#include <qmainwindow.h>
#include <qlistview.h>
#include <qaction.h>
-
#include <qtoolbar.h>
#include <qmenubar.h>
-
-#include "accountview.h"
-
-#include <libmailwrapper/mailtypes.h>
-#include <opie2/osmartpointer.h>
+#include <qmap.h>
class RecMail;
class QCopChannel;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~MainWindow();
public slots:
virtual void slotAdjustColumns();
virtual void appMessage(const QCString &msg, const QByteArray &data);
virtual void slotComposeMail();
virtual void systemMessage( const QCString&, const QByteArray& );
protected slots:
virtual void slotSendQueued();
virtual void slotEditAccounts();
virtual void slotShowFolders( bool show );
virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void displayMail();
virtual void slotDeleteMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotAdjustLayout();
virtual void slotEditSettings();
virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
virtual void serverSelected(int);
protected:
QToolBar *toolBar;
QMenuBar *menuBar;
QPopupMenu *mailMenu, *settingsMenu,*serverMenu,*folderMenu;
QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
QListView *mailView;
QBoxLayout *layout;
int m_Rotate;
QCopChannel* m_sysChannel;
int m_ServerMenuId,m_FolderMenuId;
};
#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 7c6d314..1bc81e4 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,238 +1,239 @@
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include "mailistviewitem.h"
#include "viewmail.h"
#include "selectstore.h"
#include "selectsmtp.h"
#include <libmailwrapper/smtpwrapper.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qmap.h>
#include <qvaluelist.h>
/* UNIX */
#include <signal.h>
using namespace Opie::Core;
typedef QMapNode<QString,QString> tkeyvalues;
typedef QValueList<tkeyvalues> tvaluelist;
class ValueExplode
{
protected:
//! what was parsed last
tvaluelist m_LastParsed;
//! the delemiter to use
QString mDelemiter;
//! the inner delemiter
QString m2Delemiter;
//! the real split routine
void splitit();
//! the content
QString m_Command;
//! constructor
ValueExplode(){}
public:
//! constructor
/*!
* \param aCommand the string to be splitted
* \param aDelemiter which sign will be the delemiter character
* \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters
*/
ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='=');
//! destructor
virtual ~ValueExplode();
//! assigen operator
/*!
* \return a list of substrings
*/
operator const tvaluelist& (){return m_LastParsed;}
};
ValueExplode::~ValueExplode()
{
}
ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter)
:m_LastParsed(),m_Command(aCommand)
{
mDelemiter = aDelemiter;
m2Delemiter = a2Delemiter;
splitit();
}
void ValueExplode::splitit()
{
QString iLine;
m_LastParsed.clear();
if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) {
m_LastParsed.append(tkeyvalues(m_Command,""));
return;
}
int pos,pos2;
unsigned startpos = 0;
iLine = m_Command;
while ( (pos = iLine.find(mDelemiter,startpos))!=-1) {
pos2 = iLine.find(m2Delemiter,startpos);
if (pos2==-1||pos2>pos) {
m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),""));
} else {
m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1)));
}
startpos = pos+1;
}
if (startpos<iLine.length()) {
pos2 = iLine.find(m2Delemiter,startpos);
if (pos2==-1) {
m_LastParsed.append(tkeyvalues(iLine.mid(startpos),""));
} else {
m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1)));
}
}
}
OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
: MainWindow( parent, name, WStyle_ContextHelp )
{
setup_signalblocking();
settings = new Settings();
folderView->populate( settings->getAccounts() );
+ connect(folderView,SIGNAL(refreshMenues(int)),this,SLOT(refreshMenu(int)));
}
OpieMail::~OpieMail()
{
if (settings) delete settings;
}
void OpieMail::setup_signalblocking()
{
/* for networking we must block SIGPIPE and Co. */
struct sigaction blocking_action,temp_action;
blocking_action.sa_handler = SIG_IGN;
sigemptyset(&(blocking_action.sa_mask));
blocking_action.sa_flags = 0;
sigaction(SIGPIPE,&blocking_action,&temp_action);
}
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();
}
}
/**
* Konqueror calls us with the mailto:name@address
*/
void OpieMail::setDocument(const QString& mail)
{
/*
* It looks like a mailto address, lets try it
*/
if( mail.startsWith(QString::fromLatin1("mailto:")) )
slotwriteMail(QString::null, mail.mid(7));
}
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.slotAdjustColumns();
QPEApplication::execDialog( &compose );
}
void OpieMail::slotComposeMail()
{
odebug << "Compose Mail" << oendl;
slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
odebug << "Send Queued" << oendl;
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
QList<SMTPaccount> smtpList;
smtpList.setAutoDelete(false);
Account *it;
for ( it = list.first(); it; it = list.next() )
{
if ( it->getType() == MAILLIB::A_SMTP )
{
smtp = static_cast<SMTPaccount *>(it);
smtpList.append(smtp);
}
}
if (smtpList.count()==0)
{
QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
return;
}
if (smtpList.count()==1)
{
smtp = smtpList.at(0);
}
else
{
smtp = 0;
selectsmtp selsmtp;
selsmtp.setSelectionlist(&smtpList);
if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
{
smtp = selsmtp.selected_smtp();
}
}
if (smtp)
{
SMTPwrapper * wrap = new SMTPwrapper(smtp);
if ( wrap->flushOutbox() )
{
QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
}
delete wrap;
}
}
void OpieMail::slotSearchMails()
{
odebug << "Search Mails" << oendl;
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
QPEApplication::execDialog( &settingsDialog );
}
@@ -261,128 +262,168 @@ void OpieMail::displayMail()
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted )
{
folderView->refreshCurrent();
}
else
{
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
}
}
void OpieMail::slotDeleteMail()
{
if (!mailView->currentItem()) return;
RecMailP 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 )
{
if (!mailView->currentItem()) return;
MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
/* just the RIGHT button - or hold on pda */
if (button!=2) {return;}
odebug << "Event right/hold" << oendl;
if (!item) return;
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (mailtype==MAILLIB::A_NNTP) {
m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
} else {
if (folderView->currentisDraft()) {
m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
}
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 )
{
odebug << "Show Folders" << oendl;
if ( show && folderView->isHidden() )
{
odebug << "-> showing" << oendl;
folderView->show();
}
else if ( !show && !folderView->isHidden() )
{
odebug << "-> hiding" << oendl;
folderView->hide();
}
}
void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
{
MailListViewItem*item = 0;
mailView->clear();
QValueList<RecMailP>::ConstIterator it;
for (it = list.begin(); it != list.end();++it)
{
item = new MailListViewItem(mailView,item);
item->storeData((*it));
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;
if (folderView->currentisDraft()) {
reEditMail();
} else {
displayMail();
}
}
void OpieMail::slotMoveCopyMail()
{
if (!mailView->currentItem()) return;
RecMailP 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();
}
void OpieMail::reEditMail()
{
if (!mailView->currentItem()) return;
ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
compose.slotAdjustColumns();
QPEApplication::execDialog( &compose );
}
+
+void OpieMail::refreshMenu(int m_isFolder)
+{
+ if (QApplication::desktop()->width()<330) {
+ mailMenu->setItemEnabled(m_ServerMenuId,m_isFolder&1);
+ mailMenu->setItemEnabled(m_FolderMenuId,m_isFolder&2);
+ } else {
+ menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1);
+ menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2);
+ }
+
+ QMap<int,QString>::ConstIterator it;
+ QMap<int,QString> server_entries=folderView->currentServerMenu();
+ QMap<int,QString> folder_entries=folderView->currentFolderMenu();
+
+ int id;
+ unsigned int i;
+ for (i=0; i<folderMenu->count();++i) {
+ id = folderMenu->idAt(i);
+ folderMenu->setItemEnabled(id,false);
+ }
+ for (it=folder_entries.begin();it!=folder_entries.end();++it) {
+ folderMenu->changeItem(it.key(),it.data());
+ folderMenu->setItemEnabled(it.key(),true);
+ }
+ for (i=0; i<serverMenu->count();++i) {
+ id = serverMenu->idAt(i);
+ serverMenu->setItemEnabled(id,false);
+ }
+ for (it=server_entries.begin();it!=server_entries.end();++it) {
+ serverMenu->changeItem(it.key(),it.data());
+ serverMenu->setItemEnabled(it.key(),true);
+ }
+}
+
+void OpieMail::serverSelected(int m_isFolder)
+{
+ mailView->clear();
+ refreshMenu(m_isFolder);
+}
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index c9d758d..75a0b2d 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,47 +1,51 @@
#ifndef OPIEMAIL_H
#define OPIEMAIL_H
#include "mainwindow.h"
#include <libmailwrapper/settings.h>
+#include <libmailwrapper/mailtypes.h>
#include <opie2/osmartpointer.h>
-#include <libmailwrapper/mailtypes.h>
+
+#include <qmap.h>
class OpieMail : public MainWindow
{
Q_OBJECT
public:
OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~OpieMail();
static QString appName() { return QString::fromLatin1("opiemail"); }
public slots:
virtual void slotwriteMail(const QString&name,const QString&email);
virtual void slotComposeMail();
virtual void appMessage(const QCString &msg, const QByteArray &data);
void setDocument(const QString&);
protected slots:
virtual void slotSendQueued();
virtual void slotSearchMails();
virtual void slotEditSettings();
virtual void slotEditAccounts();
virtual void displayMail();
virtual void slotDeleteMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotShowFolders( bool show );
virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
virtual void slotMoveCopyMail();
virtual void reEditMail();
+ virtual void serverSelected(int);
+ virtual void refreshMenu(int);
protected:
void setup_signalblocking();
private:
Settings *settings;
};
#endif