-rw-r--r-- | noncore/net/mail/accountitem.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/addresspicker.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/composemail.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/config.in | 6 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 33 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 14 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.cpp | 24 |
9 files changed, 71 insertions, 63 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index f7fdccd..f3f2182 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -1,1164 +1,1166 @@ #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 <opie2/oresource.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* 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 ); } QMap<int,QString> POP3viewItem::serverMenu() { 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 _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(); } 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); } QMap<int,QString> POP3folderItem::folderMenu() { 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()); } 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 ); } QMap<int,QString> NNTPviewItem::serverMenu() { QMap<int,QString> _entries; if (!account->getOffline()) { _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 _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(); } 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); } QMap<int,QString> NNTPfolderItem::folderMenu() { 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()); } 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; } QMap<int,QString> IMAPviewItem::serverMenu() { 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 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); } } } 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); } QMap<int,QString> IMAPfolderItem::folderMenu() { 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) { e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName); } if (folder->getDisplayName().lower()!="inbox") { e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName); } 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); } } } 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()); } 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") { 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 ); } QMap<int,QString> MHviewItem::serverMenu() { QMap<int,QString> e; e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName); return e; } 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; } 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")); + setPixmap(0, Opie::Core::OResource::loadPixmap("edit", Opie::Core::OResource::SmallIcon)); } 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); } 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; } QMap<int,QString> MHfolderItem::folderMenu() { 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); } } } } 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: 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/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp index 50c82e5..4e328d4 100644 --- a/noncore/net/mail/addresspicker.cpp +++ b/noncore/net/mail/addresspicker.cpp @@ -1,112 +1,112 @@ #include "composemail.h" /* OPIE */ #include <opie2/ocontactaccess.h> #include <opie2/opimcontact.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> #include <qpe/qpeapplication.h> /* QT */ #include <qpushbutton.h> #include <qmessagebox.h> #include <qlistbox.h> /* STD */ #include <stdlib.h> AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) : AddressPickerUI( parent, name, modal, flags ) { - okButton->setIconSet( Resource::loadPixmap( "enter" ) ); - cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); + okButton->setIconSet( Opie::Core::OResource::loadPixmap( "enter", Opie::Core::OResource::SmallIcon ) ); + cancelButton->setIconSet( Opie::Core::OResource::loadPixmap( "editdelete", Opie::Core::OResource::SmallIcon ) ); connect(okButton, SIGNAL(clicked()), SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), SLOT(close())); Opie::OPimContactAccess::List::Iterator it; QString lineEmail, lineName, contactLine; /* what name has to set here???? */ Opie::OPimContactAccess m_contactdb("opiemail"); QStringList mails; QString pre,suf; Opie::OPimContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); for ( it = m_list.begin(); it != m_list.end(); ++it ) { if ((*it).defaultEmail().length()!=0) { mails = (*it).emailList(); if ((*it).fileAs().length()>0) { pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; suf = ">"; } else { pre = ""; suf = ""; } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { contactLine=pre+(*sit)+suf; addressList->insertItem(contactLine); } } } if ( addressList->count() <= 0 ) { #if 0 // makes this realy sense?? addressList->insertItem( tr( "There are no entries in the addressbook." ) ); #endif addressList->setEnabled( false ); okButton->setEnabled( false ); } else { // addressList->sort(); } } void AddressPicker::accept() { QListBoxItem *item = addressList->firstItem(); QString names; while ( item ) { if ( item->selected() ) names += item->text() + ", "; item = item->next(); } names.replace( names.length() - 2, 2, "" ); if ( names.isEmpty() ) { QMessageBox::information(this, tr("Error"), tr("<p>You have to select" " at least one address entry.</p>"), tr("Ok")); return; } selectedNames = names; QDialog::accept(); } QString AddressPicker::getNames() { QString names = 0; AddressPicker picker(0, 0, true); int ret = QPEApplication::execDialog( &picker ); if ( QDialog::Accepted == ret ) { return picker.selectedNames; } return 0; } diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 154c1d5..9d04de3 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -1,307 +1,306 @@ #include "composemail.h" #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/storemail.h> #include <libmailwrapper/abstractmail.h> #include <libmailwrapper/mailtypes.h> /* OPIE */ #include <opie2/ofiledialog.h> #include <opie2/odebug.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/contact.h> +using namespace Opie::Core; +using namespace Opie::Ui; /* QT */ #include <qt.h> - -using namespace Opie::Core; -using namespace Opie::Ui; ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; m_replyid = ""; QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); Contact c; if (QFile::exists(vfilename)) { c = Contact::readVCard( vfilename )[0]; } QStringList mails = c.emailList(); QString defmail = c.defaultEmail(); if (defmail.length()!=0) { fromBox->insertItem(defmail); } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { if ( (*sit)==defmail) continue; fromBox->insertItem((*sit)); } senderNameEdit->setText(c.firstName()+" "+c.lastName()); Config cfg( "mail" ); cfg.setGroup( "Compose" ); checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); attList->addColumn( tr( "Name" ) ); attList->addColumn( tr( "Size" ) ); QList<Account> accounts = settings->getAccounts(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType()==MAILLIB::A_SMTP ) { SMTPaccount *smtp = static_cast<SMTPaccount *>(it); smtpAccountBox->insertItem( smtp->getAccountName() ); smtpAccounts.append( smtp ); } } if ( smtpAccounts.count() > 0 ) { fillValues( smtpAccountBox->currentItem() ); } else { QMessageBox::information( this, tr( "Problem" ), tr( "<p>Please create an SMTP account first.</p>" ), tr( "Ok" ) ); return; } connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); } void ComposeMail::pickAddress( QLineEdit *line ) { QString names = AddressPicker::getNames(); if ( line->text().isEmpty() ) { line->setText( names ); } else if ( !names.isEmpty() ) { line->setText( line->text() + ", " + names ); } } void ComposeMail::setTo( const QString & to ) { toLine->setText( to ); } void ComposeMail::setSubject( const QString & subject ) { subjectLine->setText( subject ); } void ComposeMail::setInReplyTo( const QString & messageId ) { m_replyid = messageId; } void ComposeMail::setMessage( const QString & text ) { message->setText( text ); } void ComposeMail::pickAddressTo() { pickAddress( toLine ); } void ComposeMail::pickAddressCC() { pickAddress( ccLine ); } void ComposeMail::pickAddressBCC() { pickAddress( bccLine ); } void ComposeMail::pickAddressReply() { pickAddress( replyLine ); } void ComposeMail::fillValues( int ) { #if 0 SMTPaccount *smtp = smtpAccounts.at( current ); ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); } bccLine->clear(); if ( smtp->getUseBCC() ) { bccLine->setText( smtp->getBCC() ); } replyLine->clear(); if ( smtp->getUseReply() ) { replyLine->setText( smtp->getReply() ); } sigMultiLine->setText( smtp->getSignature() ); #endif } void ComposeMail::slotAdjustColumns() { int currPage = tabWidget->currentPageIndex(); tabWidget->showPage( attachTab ); attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); attList->setColumnWidth( 1, 80 ); tabWidget->setCurrentPage( currPage ); } void ComposeMail::addAttachment() { DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); if ( !lnk.name().isEmpty() ) { Attachment *att = new Attachment( lnk ); (void) new AttachViewItem( attList, att ); } } void ComposeMail::removeAttachment() { if ( !attList->currentItem() ) { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select a File.</p>" ), tr( "Ok" ) ); } else { attList->takeItem( attList->currentItem() ); } } void ComposeMail::accept() { if ( checkBoxLater->isChecked() ) { odebug << "Send later" << oendl; } #if 0 odebug << "Sending Mail with " << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; #endif Opie::Core::OSmartPointer<Mail> mail=new Mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); mail->setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { mail->setTo( toLine->text() ); } else { QMessageBox::warning(0,tr("Sending mail"), tr("No Receiver specified" ) ); return; } mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != NULL ) { mail->addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( smtp ); wrapper.sendMail( mail,checkBoxLater->isChecked() ); QDialog::accept(); } void ComposeMail::reject() { int yesno = QMessageBox::warning(0,tr("Store message"), tr("Store message into drafts?"), tr("Yes"), tr("No"),QString::null,0,1); if (yesno == 0) { Opie::Core::OSmartPointer<Mail> mail=new Mail(); mail->setMail(fromBox->currentText()); mail->setTo( toLine->text() ); mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } odebug << txt << oendl; mail->setMessage( txt ); /* only use the default drafts folder name! */ Storemail wrapper(AbstractMail::draftFolder()); wrapper.storeMail(mail); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); /* attachments we will ignore! */ if ( it != NULL ) { QMessageBox::warning(0,tr("Store message"), tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); } } QDialog::reject(); } ComposeMail::~ComposeMail() { } void ComposeMail::reEditMail(const RecMailP¤t) { RecMailP data = current; message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); subjectLine->setText( data->getSubject()); toLine->setText(data->To().join(",")); ccLine->setText(data->CC().join(",")); bccLine->setText(data->Bcc().join(",")); replyLine->setText(data->Replyto()); } AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; odebug << att->getMimeType() << oendl; setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? - Resource::loadPixmap( "UnknownDocument-14" ) : + OResource::loadPixmap( "UnknownDocument", OResource::SmallIcon ) : attachment->getDocLnk().pixmap() ); setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); setText( 1, QString::number( att->getSize() ) ); } diff --git a/noncore/net/mail/config.in b/noncore/net/mail/config.in index f7fce91..b18feb7 100644 --- a/noncore/net/mail/config.in +++ b/noncore/net/mail/config.in @@ -1,10 +1,10 @@ source noncore/net/mail/libmailwrapper/config.in config MAIL3 boolean "opie-mail3 (a mail client)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2PIM && LIBOPIE2MM && LIBMAILWRAPPER - comment "opie-mail3 needs a libqpe, libopie2core, libopie2pim and the libmailwrapper" - depends ! ( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2PIM && LIBOPIE2MM && LIBMAILWRAPPER ) + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2MM && LIBMAILWRAPPER + comment "opie-mail3 needs a libqpe, libopie2core, libopie2ui, libopie2pim and the libmailwrapper" + depends ! ( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2MM && LIBMAILWRAPPER ) source noncore/net/mail/taskbarapplet/config.in diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h index 50d63dd..36ac5a1 100644 --- a/noncore/net/mail/defines.h +++ b/noncore/net/mail/defines.h @@ -1,72 +1,73 @@ #ifndef DEFINE_CONSTANTS_H #define DEFINE_CONSTANTS_H -#include <qpe/resource.h> +#include <opie2/oresource.h> +using namespace Opie::Core; #define USER_AGENT "OpieMail v0.3" #define PIC_COMPOSEMAIL "mail/composemail" #define PIC_SENDQUEUED "mail/sendqueued" #define PIC_SHOWFOLDERS "mail/showfolders" #define PIC_SYNC "mail/sync" #define PIC_IMAPFOLDER "mail/imapfolder" #define PIC_MBOXFOLDER "mail/mboxfolder" #define PIC_POP3FOLDER "mail/pop3folder" #define PIC_INBOXFOLDER "mail/inbox" #define PIC_OUTBOXFOLDER "mail/outbox" #define PIC_LOCALFOLDER "mail/localfolder" #define PIC_OFFLINE "mail/notconnected" #define PIC_DOCUMENT "DocsIcon" -#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) -#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) -#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) -#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) -#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) -#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) -#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) -#define ICON_READMAIL QIconSet( Resource::loadPixmap( PIC_DOCUMENT)) +#define ICON_COMPOSEMAIL QIconSet( OResource::loadPixmap( PIC_COMPOSEMAIL, OResource::SmallIcon ) ) +#define ICON_SENDQUEUED QIconSet( OResource::loadPixmap( PIC_SENDQUEUED, OResource::SmallIcon ) ) +#define ICON_SHOWFOLDERS QIconSet( OResource::loadPixmap( PIC_SHOWFOLDERS, OResource::SmallIcon ) ) +#define ICON_SEARCHMAILS QIconSet( OResource::loadPixmap( PIC_SEARCHMAILS, OResource::SmallIcon ) ) +#define ICON_EDITSETTINGS QIconSet( OResource::loadPixmap( PIC_EDITSETTINGS, OResource::SmallIcon ) ) +#define ICON_EDITACCOUNTS QIconSet( OResource::loadPixmap( PIC_EDITACCOUNTS, OResource::SmallIcon ) ) +#define ICON_SYNC QIconSet( OResource::loadPixmap( PIC_SYNC, OResource::SmallIcon ) ) +#define ICON_READMAIL QIconSet( OResource::loadPixmap( PIC_DOCUMENT, OResource::SmallIcon) ) -#define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) -#define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) -#define PIXMAP_INBOXFOLDER QPixmap( Resource::loadPixmap( PIC_INBOXFOLDER) ) -#define PIXMAP_MBOXFOLDER QPixmap( Resource::loadPixmap( PIC_MBOXFOLDER ) ) -#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) ) -#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) ) -#define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) ) +#define PIXMAP_IMAPFOLDER QPixmap( OResource::loadPixmap( PIC_IMAPFOLDER, OResource::SmallIcon ) ) +#define PIXMAP_POP3FOLDER QPixmap( OResource::loadPixmap( PIC_POP3FOLDER, OResource::SmallIcon ) ) +#define PIXMAP_INBOXFOLDER QPixmap( OResource::loadPixmap( PIC_INBOXFOLDER, OResource::SmallIcon ) ) +#define PIXMAP_MBOXFOLDER QPixmap( OResource::loadPixmap( PIC_MBOXFOLDER, OResource::SmallIcon ) ) +#define PIXMAP_OUTBOXFOLDER QPixmap( OResource::loadPixmap( PIC_OUTBOXFOLDER, OResource::SmallIcon ) ) +#define PIXMAP_LOCALFOLDER QPixmap( OResource::loadPixmap( PIC_LOCALFOLDER, OResource::SmallIcon ) ) +#define PIXMAP_OFFLINE QPixmap( OResource::loadPixmap( PIC_OFFLINE, OResource::SmallIcon ) ) #define IMAP_PORT "143" #define IMAP_SSL_PORT "993" #define SMTP_PORT "25" #define SMTP_SSL_PORT "465" #define POP3_PORT "110" #define POP3_SSL_PORT "995" #define NNTP_PORT "119" #define NNTP_SSL_PORT "563" /* used for decoding imapfoldername */ #define UNDEFINED 64 #define MAXLINE 76 #define UTF16MASK 0x03FFUL #define UTF16SHIFT 10 #define UTF16BASE 0x10000UL #define UTF16HIGHSTART 0xD800UL #define UTF16HIGHEND 0xDBFFUL #define UTF16LOSTART 0xDC00UL #define UTF16LOEND 0xDFFFUL /* used for making menuids transparent */ #define FOLDER_MENU_REFRESH_HEADER 0 #define FOLDER_MENU_DELETE_ALL_MAILS 1 #define FOLDER_MENU_NEW_SUBFOLDER 2 #define FOLDER_MENU_DELETE_FOLDER 3 #define FOLDER_MENU_MOVE_MAILS 4 #define SERVER_MENU_DISCONNECT 5 #define SERVER_MENU_OFFLINE 6 #define SERVER_MENU_REFRESH_FOLDER 7 #define SERVER_MENU_CREATE_FOLDER 8 #define SERVER_MENU_SUBSCRIBE 9 #endif diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp index d3a0723..5254616 100644 --- a/noncore/net/mail/mailistviewitem.cpp +++ b/noncore/net/mail/mailistviewitem.cpp @@ -1,86 +1,90 @@ #include "mailistviewitem.h" #include <libmailwrapper/abstractmail.h> -#include <qtextstream.h> -#include <qpe/resource.h> + +/* OPIE */ +#include <opie2/oresource.h> #include <qpe/timestring.h> +/* QT */ +#include <qtextstream.h> + MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { } void MailListViewItem::showEntry() { if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { - setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); + setPixmap( 0, Opie::Core::OResource::loadPixmap( "mail/kmmsgreplied", Opie::Core::OResource::SmallIcon ) ); } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { /* I think it looks nicer if there are not such a lot of icons but only on mails replied or new - Alwin*/ - //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); + //setPixmap( 0, Opie::Core::OResource::loadPixmap( "mail/kmmsgunseen", Opie::Core::OResource::SmallIcon ) ); } else { - setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); + setPixmap( 0, Opie::Core::OResource::loadPixmap( "mail/kmmsgnew", Opie::Core::OResource::SmallIcon ) ); } double s = mail_data->Msgsize(); int w; w=0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } QString q=""; QString fsize=""; switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: break; } { QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; } setText(1,mail_data->getSubject()); setText(2,mail_data->getFrom()); setText(3,fsize); setText(4,mail_data->getStringDate()); } QString MailListViewItem::key(int col,bool) const { QString temp; if (col == 4) { temp.sprintf( "%08d",QDateTime().secsTo(mail_data->getDate())); return temp; } if (col == 3) { temp.sprintf( "%020d",mail_data->Msgsize()); return temp; } return text(col); } void MailListViewItem::storeData(const RecMailP&data) { mail_data = data; } const RecMailP& MailListViewItem::data()const { return mail_data; } MAILLIB::ATYPE MailListViewItem::wrapperType() { if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; return mail_data->Wrapper()->getType(); } diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index b587424..bce4c0d 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -1,280 +1,281 @@ -#include <qlabel.h> -#include <qvbox.h> -#include <qheader.h> -#include <qtimer.h> -#include <qlayout.h> +#include "defines.h" +#include "mainwindow.h" +/* OPIE */ #include <opie2/odebug.h> +#include <opie2/oresource.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> - -#include "defines.h" -#include "mainwindow.h" - using namespace Opie::Core; +/* QT */ +#include <qlabel.h> +#include <qvbox.h> +#include <qheader.h> +#include <qtimer.h> +#include <qlayout.h> + 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->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 ); readMail = new QAction(tr("Read current mail"),ICON_READMAIL,0,0,this); readMail->addTo(toolBar); readMail->addTo(mailMenu); connect(readMail,SIGNAL(activated()),this,SLOT(displayMail())); 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") ), + searchMails = new QAction( tr( "Search mails" ), OResource::loadPixmap("find", OResource::SmallIcon ), 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); */ - deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); + deleteMails = new QAction(tr("Delete Mail"), OResource::loadPixmap("trash", OResource::SmallIcon ), 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") ) , + editSettings = new QAction( tr( "Edit settings" ), OResource::loadPixmap("SettingsIcon", OResource::SmallIcon ) , 0, 0, this ); editSettings->addTo( settingsMenu ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); - editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , + editAccounts = new QAction( tr( "Configure accounts" ), OResource::loadPixmap("mail/editaccounts", OResource::SmallIcon ) , 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))); connect(this,SIGNAL(settingsChanged()),folderView,SLOT(readSettings())); 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) { 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/opiemail.cpp b/noncore/net/mail/opiemail.cpp index fb8877a..e07ed6f 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -1,440 +1,439 @@ #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> #include <qpe/config.h> +using namespace Opie::Core; /* 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(); Config cfg("mail"); cfg.setGroup( "Settings" ); m_clickopens = cfg.readBoolEntry("clickOpensMail",true); 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 ); if (QPEApplication::execDialog( &settingsDialog )) { Config cfg("mail"); cfg.setGroup( "Settings" ); m_clickopens = cfg.readBoolEntry("clickOpensMail",true); emit settingsChanged(); } } void OpieMail::slotEditAccounts() { odebug << "Edit Accounts" << oendl; EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); eaDialog.slotAdjustColumns(); if (QPEApplication::execDialog( &eaDialog )==QDialog::Rejected);// return; if ( settings ) delete settings; settings = new Settings(); mailView->clear(); folderView->populate( settings->getAccounts() ); } void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP 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( "" ) ); + ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); } } 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 ) { if (!m_clickopens) return; /* 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/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 65ad0d6..9e17439 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp @@ -1,92 +1,94 @@ +#include "viewmailbase.h" + +/* OPIE */ +#include <opie2/oresource.h> +using namespace Opie::Core; + +/* QT */ #include <qtextbrowser.h> #include <qlistview.h> #include <qaction.h> #include <qlabel.h> #include <qvbox.h> - #include <qtoolbar.h> #include <qlayout.h> #include <qmenubar.h> -#include <qpe/resource.h> - -#include "viewmailbase.h" -//#include "opendiag.h" ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("E-Mail view")); setToolBarsMovable(false); toolbar = new QToolBar(this); menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); toolbar->setHorizontalStretchable(true); addToolBar(toolbar); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); - reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); + reply = new QAction(tr("Reply"), OResource::loadPixmap("mail/reply", OResource::SmallIcon), 0, 0, this); reply->addTo(toolbar); reply->addTo(mailmenu); - forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); + forward = new QAction(tr("Forward"), OResource::loadPixmap("mail/forward", OResource::SmallIcon), 0, 0, this); forward->addTo(toolbar); forward->addTo(mailmenu); - attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); + attachbutton = new QAction(tr("Attachments"), OResource::loadPixmap("mail/attach", OResource::SmallIcon), 0, 0, this, 0, true); attachbutton->addTo(toolbar); attachbutton->addTo(mailmenu); connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); - showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); + showHtml = new QAction( tr( "Show Html" ), OResource::loadPixmap( "mail/html", OResource::SmallIcon ), 0, 0, this, 0, true ); showHtml->addTo( toolbar ); showHtml->addTo( mailmenu ); - showPicsInline= new QAction(tr("Show image preview inline"), QIconSet(Resource::loadPixmap("pixmap")), 0, 0, this); + showPicsInline= new QAction(tr("Show image preview inline"), OResource::loadPixmap("pixmap", OResource::SmallIcon), 0, 0, this); showPicsInline->setToggleAction(true); showPicsInline->addTo(toolbar); showPicsInline->addTo(mailmenu); - deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); + deleteMail = new QAction(tr("Delete Mail"), OResource::loadPixmap("trash", OResource::SmallIcon), 0, 0, this); deleteMail->addTo(toolbar); deleteMail->addTo(mailmenu); QVBox * view = new QVBox(this); view->setSpacing(1); view->setMargin(0); setCentralWidget(view); attachments = new QListView(view); attachments->setMinimumHeight(90); attachments->setMaximumHeight(90); attachments->setAllColumnsShowFocus(true); attachments->addColumn("Mime Type", 60); attachments->addColumn(tr("Description"), 100); attachments->addColumn(tr("Filename"), 80); attachments->addColumn(tr("Size"), 80); attachments->setSorting(-1); browser = new QTextBrowser(view); adjustSize(); attachments->hide(); } void ViewMailBase::slotChangeAttachview(bool state) { if (state) attachments->show(); else attachments->hide(); } void ViewMailBase::keyPressEvent ( QKeyEvent * e ) { if( e->key()==Qt::Key_Escape ) { close(); e->accept(); return; } QWidget::keyPressEvent(e); } |