-rw-r--r-- | noncore/net/mail/accountitem.cpp | 309 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 48 | ||||
-rw-r--r-- | noncore/net/mail/addresspicker.cpp | 120 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 183 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 113 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 513 |
6 files changed, 763 insertions, 523 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 2d3cd4b..c8f6ec4 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -1,842 +1,927 @@ + #include "accountitem.h" #include "accountview.h" -#include <qpopupmenu.h> -#include <qmessagebox.h> #include "selectstore.h" #include "newmaildir.h" +#include "defines.h" + +/* OPIE */ #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> #include <libmailwrapper/mailwrapper.h> -#include "defines.h" +#include <qpe/qpeapplication.h> + +/* QT */ +#include <qpopupmenu.h> +#include <qmessagebox.h> #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} /** * POP3 Account stuff */ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) - : AccountViewItem( parent ) + : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); SETPIX(PIXMAP_POP3FOLDER); #if 0 - if (!account->getOffline()) { + if (!account->getOffline()) + { setPixmap( 0, ); - } else { + } + else + { setPixmap( 0, PIXMAP_OFFLINE ); } #endif setText( 0, account->getAccountName() ); setOpen( true ); } POP3viewItem::~POP3viewItem() { delete wrapper; } AbstractMail *POP3viewItem::getWrapper() { return wrapper; } void POP3viewItem::refresh( QList<RecMail> & ) { refresh(); } void POP3viewItem::refresh() { if (account->getOffline()) return; QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); - while ( child ) { + while ( child ) + { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } Folder *it; QListViewItem*item = 0; - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { item = new POP3folderItem( it, this , item ); item->setSelectable(it->may_select()); } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); delete folders; } RecBody POP3viewItem::fetchBody( const RecMail &mail ) { qDebug( "POP3 fetchBody" ); return wrapper->fetchBody( mail ); } QPopupMenu * POP3viewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (!account->getOffline()) { + if (m) + { + if (!account->getOffline()) + { m->insertItem(QObject::tr("Disconnect",contextName),0); m->insertItem(QObject::tr("Set offline",contextName),1); - } else { + } + else + { m->insertItem(QObject::tr("Set online",contextName),1); } } return m; } void POP3viewItem::disconnect() { QListViewItem *child = firstChild(); - while ( child ) { + while ( child ) + { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } wrapper->logout(); } void POP3viewItem::setOnOffline() { - if (!account->getOffline()) { + if (!account->getOffline()) + { disconnect(); } account->setOffline(!account->getOffline()); account->save(); SETPIX(PIXMAP_POP3FOLDER); refresh(); } void POP3viewItem::contextMenuSelected(int which) { - switch (which) { + switch (which) + { case 0: disconnect(); break; case 1: setOnOffline(); break; } } POP3folderItem::~POP3folderItem() -{ -} +{} POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) - : AccountViewItem( parent,after ) + : AccountViewItem( parent,after ) { folder = folderInit; pop3 = parent; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_POP3FOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } void POP3folderItem::refresh(QList<RecMail>&target) { if (folder->may_select()) pop3->getWrapper()->listMessages( folder->getName(),target ); } RecBody POP3folderItem::fetchBody(const RecMail&aMail) { return pop3->getWrapper()->fetchBody(aMail); } QPopupMenu * POP3folderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Delete all mails",contextName),1); m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); } return m; } void POP3folderItem::downloadMails() { AccountView*bl = pop3->accountView(); if (!bl) return; bl->downloadMails(folder,pop3->getWrapper()); } void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); - switch (which) { + switch (which) + { case 0: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; case 1: deleteAllMail(pop3->getWrapper(),folder); break; case 2: downloadMails(); break; default: break; } } /** * IMAP Account stuff */ IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) - : AccountViewItem( parent ) + : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); SETPIX(PIXMAP_IMAPFOLDER); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { delete wrapper; } AbstractMail *IMAPviewItem::getWrapper() { return wrapper; } void IMAPviewItem::refresh(QList<RecMail>&) { refreshFolders(false); } const QStringList&IMAPviewItem::subFolders() { return currentFolders; } void IMAPviewItem::refreshFolders(bool force) { if (childCount()>0 && force==false) return; - if (account->getOffline()) return; + if (account->getOffline()) return; removeChilds(); currentFolders.clear(); QList<Folder> *folders = wrapper->listFolders(); Folder *it; QListViewItem*item = 0; QListViewItem*titem = 0; QString fname,del,search; int pos; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); - for ( it = folders->first(); it; it = folders->next() ) { - if (it->getDisplayName().lower()=="inbox") { + for ( it = folders->first(); it; it = folders->next() ) + { + if (it->getDisplayName().lower()=="inbox") + { item = new IMAPfolderItem( it, this , item ); folders->remove(it); qDebug("inbox found"); break; } } - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { fname = it->getDisplayName(); currentFolders.append(it->getName()); pos = fname.findRev(it->Separator()); - if (pos != -1) { + if (pos != -1) + { fname = fname.left(pos); } IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); - if (pitem) { + 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 { + } + else + { item = new IMAPfolderItem( it, this , item ); } } delete folders; } QPopupMenu * IMAPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (!account->getOffline()) { + if (m) + { + if (!account->getOffline()) + { m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); m->insertSeparator(); m->insertItem(QObject::tr("Disconnect",contextName),2); m->insertItem(QObject::tr("Set offline",contextName),3); - } else { + } + else + { m->insertItem(QObject::tr("Set online",contextName),3); } } return m; } void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg )) + { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); - if (item) { + if (item) + { delemiter = item->Delemiter(); } - if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { + if (wrapper->createMbox(ndir,0,delemiter,makesubs)) + { refreshFolders(true); } } } void IMAPviewItem::contextMenuSelected(int id) { qDebug("Id selected: %i",id); - switch (id) { + switch (id) + { case 0: refreshFolders(true); break; case 1: createNewFolder(); break; case 2: removeChilds(); wrapper->logout(); break; case 3: - if (account->getOffline()==false) { + if (account->getOffline()==false) + { removeChilds(); wrapper->logout(); } account->setOffline(!account->getOffline()); account->save(); SETPIX(PIXMAP_IMAPFOLDER); refreshFolders(false); - break; + break; default: break; } } RecBody IMAPviewItem::fetchBody(const RecMail&) { return RecBody(); } bool IMAPviewItem::offline() { return account->getOffline(); } IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) - : AccountViewItem( parent , after ) + : AccountViewItem( parent , after ) { folder = folderInit; imap = parent; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_IMAPFOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) - : AccountViewItem( parent,after ) + : AccountViewItem( parent,after ) { folder = folderInit; imap = master; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_IMAPFOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } IMAPfolderItem::~IMAPfolderItem() -{ -} +{} const QString& IMAPfolderItem::Delemiter()const { return folder->Separator(); } void IMAPfolderItem::refresh(QList<RecMail>&target) { - if (folder->may_select()) { + if (folder->may_select()) + { imap->getWrapper()->listMessages( folder->getName(),target ); - } else { + } + else + { target.clear(); } } RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) { return imap->getWrapper()->fetchBody(aMail); } QPopupMenu * IMAPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (folder->may_select()) { + if (m) + { + if (folder->may_select()) + { m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); m->insertItem(QObject::tr("Delete all mails",contextName),1); } - if (folder->no_inferior()==false) { + if (folder->no_inferior()==false) + { m->insertItem(QObject::tr("Create new subfolder",contextName),2); } - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { m->insertItem(QObject::tr("Delete folder",contextName),3); } } return m; } void IMAPfolderItem::createNewFolder() { Newmdirdlg ndirdlg; - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = Delemiter(); - if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { + if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) + { imap->refreshFolders(true); } } } void IMAPfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), - QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), - QObject::tr("Yes",contextName), - QObject::tr("No",contextName),QString::null,1,1); + QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (imap->getWrapper()->deleteMbox(folder)) { + 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) { + if (v) + { v->setSelected(box,true); } } } } void IMAPfolderItem::downloadMails() { AccountView*bl = imap->accountView(); if (!bl) return; bl->downloadMails(folder,imap->getWrapper()); } void IMAPfolderItem::contextMenuSelected(int id) { qDebug("Selected id: %i",id); AccountView * view = (AccountView*)listView(); - switch(id) { + switch(id) + { case 0: view->refreshCurrent(); break; case 1: deleteAllMail(imap->getWrapper(),folder); break; case 2: createNewFolder(); break; case 3: deleteFolder(); break; case 4: downloadMails(); break; default: break; } } /** * MH Account stuff */ /* MH is a little bit different - the top folder can contains messages other than in IMAP and POP3 and MBOX */ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) - : AccountViewItem( parent ) + : AccountViewItem( parent ) { m_Path = aPath; /* be carefull - the space within settext is wanted - thats why the string twice */ wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); setPixmap( 0, PIXMAP_LOCALFOLDER ); setText( 0, " Local Folders" ); setOpen( true ); folder = 0; } MHviewItem::~MHviewItem() { delete wrapper; } AbstractMail *MHviewItem::getWrapper() { return wrapper; } void MHviewItem::refresh( QList<RecMail> & target) { refresh(false); getWrapper()->listMessages( "",target ); } void MHviewItem::refresh(bool force) { if (childCount()>0 && force==false) return; removeChilds(); currentFolders.clear(); QList<Folder> *folders = wrapper->listFolders(); Folder *it; MHfolderItem*item = 0; MHfolderItem*pmaster = 0; QString fname = ""; int pos; - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { fname = it->getDisplayName(); /* this folder itself */ - if (fname=="/") { + if (fname=="/") + { currentFolders.append(fname); folder = it; continue; } currentFolders.append(fname); pos = fname.findRev("/"); - if (pos > 0) { + if (pos > 0) + { fname = fname.left(pos); pmaster = (MHfolderItem*)findSubItem(fname); - } else { + } + else + { pmaster = 0; } - if (pmaster) { + if (pmaster) + { item = new MHfolderItem( it, pmaster, item, this ); - } else { + } + else + { item = new MHfolderItem( it, this , item ); } item->setSelectable(it->may_select()); } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); delete folders; } RecBody MHviewItem::fetchBody( const RecMail &mail ) { qDebug( "MH fetchBody" ); return wrapper->fetchBody( mail ); } QPopupMenu * MHviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); m->insertItem(QObject::tr("Delete all mails",contextName),2); m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); } return m; } void MHviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); - if (wrapper->createMbox(ndir)) { + if (wrapper->createMbox(ndir)) + { refresh(true); } } } void MHviewItem::downloadMails() { AccountView*bl = accountView(); if (!bl) return; bl->downloadMails(folder,getWrapper()); } QStringList MHviewItem::subFolders() { return currentFolders; } void MHviewItem::contextMenuSelected(int which) { - switch (which) { + switch (which) + { case 0: refresh(true); break; case 1: createFolder(); break; case 2: deleteAllMail(getWrapper(),folder); break; case 3: downloadMails(); break; default: break; } } MHfolderItem::~MHfolderItem() -{ -} +{} MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) - : AccountViewItem( parent,after ) + : AccountViewItem( parent,after ) { folder = folderInit; mbox = parent; initName(); } MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) - : AccountViewItem( parent,after ) + : AccountViewItem( parent,after ) { folder = folderInit; mbox = master; initName(); } void MHfolderItem::initName() { QString bName = folder->getDisplayName(); - if (bName.startsWith("/")&&bName.length()>1) { + if (bName.startsWith("/")&&bName.length()>1) + { bName.replace(0,1,""); } int pos = bName.findRev("/"); - if (pos > 0) { + if (pos > 0) + { bName.replace(0,pos+1,""); } - if (bName.lower() == "outgoing") { + if (bName.lower() == "outgoing") + { setPixmap( 0, PIXMAP_OUTBOXFOLDER ); - } else if (bName.lower() == "inbox") { + } + else if (bName.lower() == "inbox") + { setPixmap( 0, PIXMAP_INBOXFOLDER); - } else { + } + else + { setPixmap( 0, PIXMAP_MBOXFOLDER ); - } + } setText( 0, bName ); } Folder*MHfolderItem::getFolder() { return folder; } void MHfolderItem::refresh(QList<RecMail>&target) { if (folder->may_select()) mbox->getWrapper()->listMessages( folder->getName(),target ); } RecBody MHfolderItem::fetchBody(const RecMail&aMail) { return mbox->getWrapper()->fetchBody(aMail); } void MHfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), - QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), - QObject::tr("Yes",contextName), - QObject::tr("No",contextName),QString::null,1,1); + QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (mbox->getWrapper()->deleteMbox(folder)) { + 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) { + if (v) + { v->setSelected(box,true); } } } } QPopupMenu * MHfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); m->insertItem(QObject::tr("Delete all mails",contextName),0); m->insertItem(QObject::tr("Create new subfolder",contextName),3); m->insertItem(QObject::tr("Delete folder",contextName),1); } return m; } void MHfolderItem::downloadMails() { AccountView*bl = mbox->accountView(); if (!bl) return; bl->downloadMails(folder,mbox->getWrapper()); } void MHfolderItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); - if (mbox->getWrapper()->createMbox(ndir,folder)) { + 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) { + if (v) + { v->setSelected(box,true); } } } } void MHfolderItem::contextMenuSelected(int which) { - switch(which) { + switch(which) + { case 0: deleteAllMail(mbox->getWrapper(),folder); break; case 1: deleteFolder(); break; case 2: downloadMails(); break; case 3: createFolder(); break; default: break; } } /** * Generic stuff */ const QString AccountViewItem::contextName="AccountViewItem"; -AccountViewItem::AccountViewItem( AccountView *parent ) - : QListViewItem( parent ) +AccountViewItem::AccountViewItem( AccountView *parent ) + : QListViewItem( parent ) { init(); m_Backlink = parent; } AccountViewItem::AccountViewItem( QListViewItem *parent) - : QListViewItem( parent) + : QListViewItem( parent) { init(); } AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) - :QListViewItem( parent,after ) + :QListViewItem( parent,after ) { init(); } void AccountViewItem::init() { m_Backlink = 0; folder = 0; } AccountViewItem::~AccountViewItem() { if (folder) delete folder; } AccountView*AccountViewItem::accountView() { return m_Backlink; } void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) { if (!wrapper) return; QString fname=""; if (folder) fname = folder->getDisplayName(); int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), - QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). - arg(fname), - QObject::tr("Yes",contextName), - QObject::tr("No",contextName),QString::null,1,1); + QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). + arg(fname), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (wrapper->deleteAllMail(folder)) { + if (yesno == 0) + { + if (wrapper->deleteAllMail(folder)) + { AccountView * view = (AccountView*)listView(); if (view) view->refreshCurrent(); } } } void AccountViewItem::removeChilds() { QListViewItem *child = firstChild(); - while ( child ) { + 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)) { + while (pitem) + { + if (pitem->matchName(path)) + { break; } - if (pitem->childCount()>0) { + if (pitem->childCount()>0) + { sitem = findSubItem(path,pitem); - if (sitem) { + if (sitem) + { pitem = sitem; break; } } pitem=(AccountViewItem*)pitem->nextSibling(); } return pitem; } diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index d9792d4..2ddf834 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -1,149 +1,163 @@ + #include "accountview.h" #include "accountitem.h" #include "selectstore.h" -#include <qmessagebox.h> -#include <qpopupmenu.h> + +/* OPIE */ #include <libmailwrapper/settings.h> #include <libmailwrapper/mailwrapper.h> #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> +#include <qpe/qpeapplication.h> +/* QT */ +#include <qmessagebox.h> +#include <qpopupmenu.h> AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) - : QListView( parent, name, flags ) + : QListView( parent, name, flags ) { connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), - SLOT( refresh( QListViewItem * ) ) ); + SLOT( refresh( QListViewItem * ) ) ); connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, - SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); + SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); setSorting(0); } AccountView::~AccountView() { imapAccounts.clear(); mhAccounts.clear(); } void AccountView::slotContextMenu(int id) { AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); if (!view) return; view->contextMenuSelected(id); } void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) { if (button==1) {return;} if (!item) return; AccountViewItem *view = static_cast<AccountViewItem *>(item); QPopupMenu*m = view->getContextMenu(); if (!m) return; connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } void AccountView::populate( QList<Account> list ) { clear(); imapAccounts.clear(); mhAccounts.clear(); mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "IMAP" ) == 0 ) { + for ( it = list.first(); it; it = list.next() ) + { + if ( it->getType().compare( "IMAP" ) == 0 ) + { IMAPaccount *imap = static_cast<IMAPaccount *>(it); qDebug( "added IMAP " + imap->getAccountName() ); imapAccounts.append(new IMAPviewItem( imap, this )); - } else if ( it->getType().compare( "POP3" ) == 0 ) { + } + else if ( it->getType().compare( "POP3" ) == 0 ) + { POP3account *pop3 = static_cast<POP3account *>(it); qDebug( "added POP3 " + pop3->getAccountName() ); /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); } } } -void AccountView::refresh(QListViewItem *item) { +void AccountView::refresh(QListViewItem *item) +{ qDebug("AccountView refresh..."); - if ( item ) { + if ( item ) + { m_currentItem = item; QList<RecMail> headerlist; headerlist.setAutoDelete(true); AccountViewItem *view = static_cast<AccountViewItem *>(item); view->refresh(headerlist); emit refreshMailview(&headerlist); } } void AccountView::refreshCurrent() { m_currentItem = currentItem(); if ( !m_currentItem ) return; QList<RecMail> headerlist; headerlist.setAutoDelete(true); AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); view->refresh(headerlist); emit refreshMailview(&headerlist); } void AccountView::refreshAll() { - } RecBody AccountView::fetchBody(const RecMail&aMail) { QListViewItem*item = selectedItem (); if (!item) return RecBody(); AccountViewItem *view = static_cast<AccountViewItem *>(item); return view->fetchBody(aMail); } void AccountView::setupFolderselect(Selectstore*sels) { - sels->showMaximized(); + QPEApplication::showDialog( sels ); QStringList sFolders; unsigned int i = 0; - for (i=0; i < mhAccounts.count();++i) { + 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) { + for (i=0; i < imapAccounts.count();++i) + { if (imapAccounts[i]->offline()) continue; imapAccounts[i]->refreshFolders(false); sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); } } void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) { AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || - targetFolder.isEmpty()) { + targetFolder.isEmpty()) + { return; } - if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { + if (sels.newFolder() && !targetMail->createMbox(targetFolder)) + { QMessageBox::critical(0,tr("Error creating new Folder"), - tr("<center>Error while creating<br>new folder - breaking.</center>")); + tr("<center>Error while creating<br>new folder - breaking.</center>")); return; } qDebug("Targetfolder: %s",targetFolder.latin1()); qDebug("Fromfolder: %s",fromFolder->getName().latin1()); fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); refreshCurrent(); } diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp index f4f4cea..8cdabde 100644 --- a/noncore/net/mail/addresspicker.cpp +++ b/noncore/net/mail/addresspicker.cpp @@ -1,100 +1,114 @@ + +#include "composemail.h" + +/* OPIE */ +#include <opie2/ocontactaccess.h> +#include <opie2/ocontact.h> +#include <qpe/resource.h> +#include <qpe/qpeapplication.h> + +/* QT */ #include <qpushbutton.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qlistbox.h> #include <qfile.h> -#include <qpe/resource.h> -#include <opie2/ocontactaccess.h> -#include <opie2/ocontact.h> - - +/* STD */ #include <stdlib.h> -#include "composemail.h" - -AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) - : AddressPickerUI( parent, name, modal, flags ) +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" ) ); connect(okButton, SIGNAL(clicked()), SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), SLOT(close())); Opie::OContactAccess::List::Iterator it; QString lineEmail, lineName, contactLine; /* what name has to set here???? */ Opie::OContactAccess m_contactdb("opiemail"); - + QStringList mails; QString pre,suf; Opie::OContactAccess::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) { + for ( it = m_list.begin(); it != m_list.end(); ++it ) + { + if ((*it).defaultEmail().length()!=0) + { mails = (*it).emailList(); - if ((*it).fileAs().length()>0) { + if ((*it).fileAs().length()>0) + { pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; suf = ">"; - } else { + } + else + { pre = ""; suf = ""; } QStringList::ConstIterator sit = mails.begin(); - for (;sit!=mails.end();++sit) { + for (;sit!=mails.end();++sit) + { contactLine=pre+(*sit)+suf; addressList->insertItem(contactLine); - } + } } } - if ( addressList->count() <= 0 ) { + if ( addressList->count() <= 0 ) + { #if 0 - // makes this realy sense?? - addressList->insertItem( + // makes this realy sense?? + addressList->insertItem( tr( "There are no entries in the addressbook." ) ); #endif - addressList->setEnabled( false ); - okButton->setEnabled( false ); - } else { -// addressList->sort(); + 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(); + 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); - picker.showMaximized(); - picker.show(); - - int ret = picker.exec(); - if ( QDialog::Accepted == ret ) { - return picker.selectedNames; - } - - return 0; + 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/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 1cb202e..60bffa5 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -1,473 +1,528 @@ -#include <qt.h> #include "defines.h" #include "editaccounts.h" +/* OPIE */ +#include <qpe/qpeapplication.h> + +/* QT */ +#include <qt.h> + AccountListItem::AccountListItem( QListView *parent, Account *a) - : QListViewItem( parent ) + : QListViewItem( parent ) { account = a; setText( 0, account->getAccountName() ); setText( 1, account->getType() ); } EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) - : EditAccountsUI( parent, name, modal, flags ) + : EditAccountsUI( parent, name, modal, flags ) { qDebug( "New Account Configuration Widget" ); settings = s; mailList->addColumn( tr( "Account" ) ); mailList->addColumn( tr( "Type" ) ); newsList->addColumn( tr( "Account" ) ); connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); slotFillLists(); } void EditAccounts::slotFillLists() { mailList->clear(); newsList->clear(); QList<Account> accounts = settings->getAccounts(); Account *it; - for ( it = accounts.first(); it; it = accounts.next() ) { - if ( it->getType().compare( "NNTP" ) == 0 ) { + for ( it = accounts.first(); it; it = accounts.next() ) + { + if ( it->getType().compare( "NNTP" ) == 0 ) + { (void) new AccountListItem( newsList, it ); - } else { + } + else + { (void) new AccountListItem( mailList, it ); } } } void EditAccounts::slotNewMail() { qDebug( "New Mail Account" ); QString *selection = new QString(); SelectMailType selType( selection, this, 0, true ); selType.show(); - if ( QDialog::Accepted == selType.exec() ) { + if ( QDialog::Accepted == selType.exec() ) + { slotNewAccount( *selection ); } } void EditAccounts::slotNewAccount( const QString &type ) { - if ( type.compare( "IMAP" ) == 0 ) { + if ( type.compare( "IMAP" ) == 0 ) + { qDebug( "-> config IMAP" ); IMAPaccount *account = new IMAPaccount(); IMAPconfig imap( account, this, 0, true ); - imap.showMaximized(); - if ( QDialog::Accepted == imap.exec() ) { + if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) + { settings->addAccount( account ); account->save(); slotFillLists(); - } else { + } + else + { account->remove(); } - } else if ( type.compare( "POP3" ) == 0 ) { + } + else if ( type.compare( "POP3" ) == 0 ) + { qDebug( "-> config POP3" ); POP3account *account = new POP3account(); POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); - pop3.showMaximized(); - if ( QDialog::Accepted == pop3.exec() ) { + if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) + { settings->addAccount( account ); account->save(); slotFillLists(); - } else { + } + else + { account->remove(); } - } else if ( type.compare( "SMTP" ) == 0 ) { + } + else if ( type.compare( "SMTP" ) == 0 ) + { qDebug( "-> config SMTP" ); SMTPaccount *account = new SMTPaccount(); SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); - smtp.showMaximized(); - if ( QDialog::Accepted == smtp.exec() ) { + if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) + { settings->addAccount( account ); account->save(); slotFillLists(); - } else { + } + else + { account->remove(); } - } else if ( type.compare( "NNTP" ) == 0 ) { + } + else if ( type.compare( "NNTP" ) == 0 ) + { qDebug( "-> config NNTP" ); NNTPaccount *account = new NNTPaccount(); NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); - nntp.showMaximized(); - if ( QDialog::Accepted == nntp.exec() ) { + if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) + { settings->addAccount( account ); account->save(); slotFillLists(); - } else { + } + else + { account->remove(); } } } void EditAccounts::slotEditAccount( Account *account ) { - if ( account->getType().compare( "IMAP" ) == 0 ) { + if ( account->getType().compare( "IMAP" ) == 0 ) + { IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); - imap.showMaximized(); - if ( QDialog::Accepted == imap.exec() ) { - slotFillLists(); + if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) + { + slotFillLists(); } - } else if ( account->getType().compare( "POP3" ) == 0 ) { + } + else if ( account->getType().compare( "POP3" ) == 0 ) + { POP3account *pop3Acc = static_cast<POP3account *>(account); POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); - pop3.showMaximized(); - if ( QDialog::Accepted == pop3.exec() ) { - slotFillLists(); + if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) + { + slotFillLists(); } - } else if ( account->getType().compare( "SMTP" ) == 0 ) { + } + else if ( account->getType().compare( "SMTP" ) == 0 ) + { SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); - smtp.showMaximized(); - if ( QDialog::Accepted == smtp.exec() ) { - slotFillLists(); + if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) + { + slotFillLists(); } - } else if ( account->getType().compare( "NNTP" ) == 0 ) { + } + else if ( account->getType().compare( "NNTP" ) == 0 ) + { NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); - nntp.showMaximized(); - if ( QDialog::Accepted == nntp.exec() ) { - slotFillLists(); + if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) + { + slotFillLists(); } } } void EditAccounts::slotDeleteAccount( Account *account ) { if ( QMessageBox::information( this, tr( "Question" ), - tr( "<p>Do you really want to delete the selected Account?</p>" ), - tr( "Yes" ), tr( "No" ) ) == 0 ) { + tr( "<p>Do you really want to delete the selected Account?</p>" ), + tr( "Yes" ), tr( "No" ) ) == 0 ) + { settings->delAccount( account ); slotFillLists(); } } void EditAccounts::slotEditMail() { qDebug( "Edit Mail Account" ); - if ( !mailList->currentItem() ) { + if ( !mailList->currentItem() ) + { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); slotEditAccount( a ); } void EditAccounts::slotDeleteMail() { - if ( !mailList->currentItem() ) { + if ( !mailList->currentItem() ) + { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); slotDeleteAccount( a ); } void EditAccounts::slotNewNews() { qDebug( "New News Account" ); slotNewAccount( "NNTP" ); } void EditAccounts::slotEditNews() { qDebug( "Edit News Account" ); - if ( !newsList->currentItem() ) { + if ( !newsList->currentItem() ) + { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); slotEditAccount( a ); } void EditAccounts::slotDeleteNews() { qDebug( "Delete News Account" ); - if ( !newsList->currentItem() ) { + if ( !newsList->currentItem() ) + { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); slotDeleteAccount( a ); } void EditAccounts::slotAdjustColumns() { int currPage = configTab->currentPageIndex(); configTab->showPage( mailTab ); mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); mailList->setColumnWidth( 1, 50 ); configTab->showPage( newsTab ); newsList->setColumnWidth( 0, newsList->visibleWidth() ); configTab->setCurrentPage( currPage ); } void EditAccounts::accept() { settings->saveAccounts(); QDialog::accept(); } /** * SelectMailType */ SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) - : SelectMailTypeUI( parent, name, modal, flags ) + : SelectMailTypeUI( parent, name, modal, flags ) { selected = selection; selected->replace( 0, selected->length(), typeBox->currentText() ); connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); } void SelectMailType::slotSelection( const QString &sel ) { selected->replace( 0, selected->length(), sel ); } /** * IMAPconfig */ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) - : IMAPconfigUI( parent, name, modal, flags ) + : IMAPconfigUI( parent, name, modal, flags ) { data = account; fillValues(); connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); ComboBox1->insertItem( "Only if available", 0 ); ComboBox1->insertItem( "Always, Negotiated", 1 ); ComboBox1->insertItem( "Connect on secure port", 2 ); ComboBox1->insertItem( "Run command instead", 3 ); CommandEdit->hide(); ComboBox1->setCurrentItem( data->ConnectionType() ); } void IMAPconfig::slotConnectionToggle( int index ) { - if ( index == 2 ) { - portLine->setText( IMAP_SSL_PORT ); - } else if ( index == 3 ) { + if ( index == 2 ) + { + portLine->setText( IMAP_SSL_PORT ); + } + else if ( index == 3 ) + { portLine->setText( IMAP_PORT ); CommandEdit->show(); - } else { + } + else + { portLine->setText( IMAP_PORT ); } } void IMAPconfig::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); prefixLine->setText(data->getPrefix()); } void IMAPconfig::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); data->setPrefix(prefixLine->text()); QDialog::accept(); } /** * POP3config */ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) - : POP3configUI( parent, name, modal, flags ) + : POP3configUI( parent, name, modal, flags ) { data = account; fillValues(); connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); ComboBox1->insertItem( "Only if available", 0 ); ComboBox1->insertItem( "Always, Negotiated", 1 ); ComboBox1->insertItem( "Connect on secure port", 2 ); ComboBox1->insertItem( "Run command instead", 3 ); CommandEdit->hide(); ComboBox1->setCurrentItem( data->ConnectionType() ); } void POP3config::slotConnectionToggle( int index ) { // 2 is ssl connection - if ( index == 2 ) { - portLine->setText( POP3_SSL_PORT ); - } else if ( index == 3 ) { + if ( index == 2 ) + { + portLine->setText( POP3_SSL_PORT ); + } + else if ( index == 3 ) + { portLine->setText( POP3_PORT ); CommandEdit->show(); - } else { + } + else + { portLine->setText( POP3_PORT ); } } void POP3config::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); ComboBox1->setCurrentItem( data->ConnectionType() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); } void POP3config::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setConnectionType( ComboBox1->currentItem() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QDialog::accept(); } /** * SMTPconfig */ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) - : SMTPconfigUI( parent, name, modal, flags ) + : SMTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); fillValues(); connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); ComboBox1->insertItem( "Only if available", 0 ); ComboBox1->insertItem( "Always, Negotiated", 1 ); ComboBox1->insertItem( "Connect on secure port", 2 ); ComboBox1->insertItem( "Run command instead", 3 ); CommandEdit->hide(); ComboBox1->setCurrentItem( data->ConnectionType() ); } void SMTPconfig::slotConnectionToggle( int index ) { // 2 is ssl connection - if ( index == 2 ) { - portLine->setText( SMTP_SSL_PORT ); - } else if ( index == 3 ) { + if ( index == 2 ) + { + portLine->setText( SMTP_SSL_PORT ); + } + else if ( index == 3 ) + { portLine->setText( SMTP_PORT ); CommandEdit->show(); - } else { + } + else + { portLine->setText( SMTP_PORT ); } } void SMTPconfig::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); ComboBox1->setCurrentItem( data->ConnectionType() ); loginBox->setChecked( data->getLogin() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); } void SMTPconfig::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setConnectionType( ComboBox1->currentItem() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QDialog::accept(); } /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) - : NNTPconfigUI( parent, name, modal, flags ) + : NNTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); fillValues(); connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); } void NNTPconfig::slotSSL( bool enabled ) { - if ( enabled ) { + if ( enabled ) + { portLine->setText( NNTP_SSL_PORT ); - } else { + } + else + { portLine->setText( NNTP_PORT ); } } void NNTPconfig::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); sslBox->setChecked( data->getSSL() ); loginBox->setChecked( data->getLogin() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); } void NNTPconfig::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 0795436..abf93dc 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -1,229 +1,258 @@ -#include <qmessagebox.h> + #include "settingsdialog.h" #include "opiemail.h" #include "editaccounts.h" #include "composemail.h" +#include "mailistviewitem.h" +#include "viewmail.h" +#include "selectstore.h" +#include "selectsmtp.h" + +/* OPIE */ #include <libmailwrapper/smtpwrapper.h> +#include <libmailwrapper/mailtypes.h> +#include <libmailwrapper/abstractmail.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> +#include <qpe/qpeapplication.h> + +/* QT */ +#include <qmessagebox.h> #include <qaction.h> #include <qapplication.h> -#include <libmailwrapper/mailtypes.h> -#include <libmailwrapper/abstractmail.h> -#include "mailistviewitem.h" -#include "viewmail.h" -#include "selectstore.h" -#include "selectsmtp.h" OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) - : MainWindow( parent, name, WStyle_ContextHelp ) + : MainWindow( parent, name, WStyle_ContextHelp ) { settings = new Settings(); folderView->populate( settings->getAccounts() ); } OpieMail::~OpieMail() { if (settings) delete settings; } void OpieMail::appMessage(const QCString &msg, const QByteArray &data) { // copied from old mail2 - if (msg == "writeMail(QString,QString)") { + 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()") { + } + else if (msg == "newMail()") + { slotComposeMail(); } } void OpieMail::slotwriteMail(const QString&name,const QString&email) { ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); - if (!email.isEmpty()) { - if (!name.isEmpty()) { + if (!email.isEmpty()) + { + if (!name.isEmpty()) + { compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); - } else { + } + else + { compose.setTo(email); } } - compose.showMaximized(); compose.slotAdjustColumns(); - compose.exec(); + QPEApplication::execDialog( &compose ); } void OpieMail::slotComposeMail() { qDebug( "Compose Mail" ); slotwriteMail(0l,0l); } void OpieMail::slotSendQueued() { qDebug( "Send Queued" ); 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().compare( "SMTP" ) == 0 ) { + for ( it = list.first(); it; it = list.next() ) + { + if ( it->getType().compare( "SMTP" ) == 0 ) + { smtp = static_cast<SMTPaccount *>(it); smtpList.append(smtp); } } - if (smtpList.count()==0) { + if (smtpList.count()==0) + { QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); return; } - if (smtpList.count()==1) { + if (smtpList.count()==1) + { smtp = smtpList.at(0); - } else { + } + else + { smtp = 0; selectsmtp selsmtp; selsmtp.setSelectionlist(&smtpList); - selsmtp.showMaximized(); - if (selsmtp.exec()==QDialog::Accepted) { + if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) + { smtp = selsmtp.selected_smtp(); } } - if (smtp) { + if (smtp) + { SMTPwrapper * wrap = new SMTPwrapper(smtp); - if ( wrap->flushOutbox() ) { + if ( wrap->flushOutbox() ) + { QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); } delete wrap; } } void OpieMail::slotSearchMails() { qDebug( "Search Mails" ); } void OpieMail::slotEditSettings() { SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); - settingsDialog.showMaximized(); - settingsDialog.exec(); + QPEApplication::execDialog( &settingsDialog ); } void OpieMail::slotEditAccounts() { qDebug( "Edit Accounts" ); EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); - eaDialog.showMaximized(); eaDialog.slotAdjustColumns(); - eaDialog.exec(); + QPEApplication::execDialog( &eaDialog ); if ( settings ) delete settings; settings = new Settings(); folderView->populate( settings->getAccounts() ); } void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMail mail = ((MailListViewItem*)item)->data(); RecBody body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); - if ( readMail.deleted ) { - folderView->refreshCurrent(); - } else { + if ( readMail.deleted ) + { + folderView->refreshCurrent(); + } + else + { ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); } } void OpieMail::slotDeleteMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); - if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { - mail.Wrapper()->deleteMail( mail ); - folderView->refreshCurrent(); + if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) + { + mail.Wrapper()->deleteMail( mail ); + folderView->refreshCurrent(); } } void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) { /* just the RIGHT button - or hold on pda */ if (button!=2) {return;} qDebug("Event right/hold"); if (!item) return; QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } } void OpieMail::slotShowFolders( bool show ) { - qDebug( "Show Folders" ); - if ( show && folderView->isHidden() ) { + qDebug( "Show Folders" ); + if ( show && folderView->isHidden() ) + { qDebug( "-> showing" ); folderView->show(); - } else if ( !show && !folderView->isHidden() ) { + } + else if ( !show && !folderView->isHidden() ) + { qDebug( "-> hiding" ); folderView->hide(); } } void OpieMail::refreshMailView(QList<RecMail>*list) { MailListViewItem*item = 0; mailView->clear(); - for (unsigned int i = 0; i < list->count();++i) { + for (unsigned int i = 0; i < list->count();++i) + { item = new MailListViewItem(mailView,item); item->storeData(*(list->at(i))); item->showEntry(); } } void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) { /* just LEFT button - or tap with stylus on pda */ if (button!=1) return; if (!item) return; displayMail(); } void OpieMail::slotMoveCopyMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; folderView->setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || - targetFolder.isEmpty()) { + targetFolder.isEmpty()) + { return; } - if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { + if (sels.newFolder() && !targetMail->createMbox(targetFolder)) + { QMessageBox::critical(0,tr("Error creating new Folder"), - tr("<center>Error while creating<br>new folder - breaking.</center>")); + tr("<center>Error while creating<br>new folder - breaking.</center>")); return; } mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); folderView->refreshCurrent(); } diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 99965d4..f015228 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -1,429 +1,472 @@ +#include "composemail.h" +#include "viewmail.h" +#include "accountview.h" + +/* OPIE */ +#include <libmailwrapper/settings.h> +#include <libmailwrapper/abstractmail.h> +#include <libmailwrapper/mailtypes.h> + +#include <opie2/ofiledialog.h> +#include <qpe/config.h> +#include <qpe/qpeapplication.h> + +/* QT */ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qaction.h> #include <qpopupmenu.h> #include <qfile.h> #include <qapplication.h> #include <qvaluelist.h> -#include <qpe/config.h> - -#include <opie2/ofiledialog.h> - -#include <libmailwrapper/settings.h> -#include "composemail.h" -#include "viewmail.h" -#include <libmailwrapper/abstractmail.h> -#include "accountview.h" -#include <libmailwrapper/mailtypes.h> - AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, - const QString&fsize,int num,const QValueList<int>&path) - : QListViewItem(parent,after),_partNum(num) + const QString&fsize,int num,const QValueList<int>&path) + : QListViewItem(parent,after),_partNum(num) { _path=path; - setText(0, mime); - setText(1, desc); - setText(2, file); + setText(0, mime); + setText(1, desc); + setText(2, file); setText(3, fsize); } AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, - const QString&fsize,int num,const QValueList<int>&path) - : QListViewItem(parent,after),_partNum(num) + const QString&fsize,int num,const QValueList<int>&path) + : QListViewItem(parent,after),_partNum(num) { _path=path; - setText(0, mime); - setText(1, desc); - setText(2, file); + setText(0, mime); + setText(1, desc); + setText(2, file); setText(3, fsize); } bool AttachItem::isParentof(const QValueList<int>&path) { /* if not set, then no parent */ if (path.count()==0||_path.count()==0) return false; /* the parent must have one digit less then a child */ if (path.count()!=_path.count()+1) return false; - for (unsigned int i=0; i < _path.count();++i) { + for (unsigned int i=0; i < _path.count();++i) + { if (_path[i]!=path[i]) return false; } return true; } AttachItem* ViewMail::searchParent(const QValueList<int>&path) { QListViewItemIterator it( attachments ); - for ( ; it.current(); ++it ) { + for ( ; it.current(); ++it ) + { AttachItem*ati = (AttachItem*)it.current(); if (ati->isParentof(path)) return ati; } return 0; } AttachItem* ViewMail::lastChild(AttachItem*parent) { if (!parent) return 0; AttachItem* item = (AttachItem*)parent->firstChild(); if (!item) return item; AttachItem*temp=0; - while( (temp=(AttachItem*)item->nextSibling())) { + while( (temp=(AttachItem*)item->nextSibling())) + { item = temp; } return item; } -void ViewMail::setBody( RecBody body ) { - -m_body = body; -m_mail[2] = body.Bodytext(); -attachbutton->setEnabled(body.Parts().count()>0); -attachments->setEnabled(body.Parts().count()>0); -if (body.Parts().count()==0) { - return; -} -AttachItem * curItem=0; -AttachItem * parentItem = 0; -QString type=body.Description().Type()+"/"+body.Description().Subtype(); -QString desc,fsize; -double s = body.Description().Size(); -int w; -w=0; - -while (s>1024) { - s/=1024; - ++w; - if (w>=2) break; -} - -QString q=""; -switch(w) { -case 1: - q="k"; - break; -case 2: - q="M"; - break; -default: - break; -} - +void ViewMail::setBody( RecBody body ) { - /* I did not found a method to make a CONTENT reset on a QTextStream - so I use this construct that the stream will re-constructed in each - loop. To let it work, the textstream is packed into a own area of - code is it will be destructed after finishing its small job. - */ - QTextOStream o(&fsize); - if (w>0) o.precision(2); else o.precision(0); - o.setf(QTextStream::fixed); - o << s << " " << q << "Byte"; -} - -curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); -QString filename = ""; -for (unsigned int i = 0; i < body.Parts().count();++i) { - type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); - part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); - for (;it!=body.Parts()[i].Parameters().end();++it) { - qDebug(it.key()); - if (it.key().lower()=="name") { - filename=it.data(); - } + m_body = body; + m_mail[2] = body.Bodytext(); + attachbutton->setEnabled(body.Parts().count()>0); + attachments->setEnabled(body.Parts().count()>0); + if (body.Parts().count()==0) + { + return; } - s = body.Parts()[i].Size(); - w = 0; - while (s>1024) { + AttachItem * curItem=0; + AttachItem * parentItem = 0; + QString type=body.Description().Type()+"/"+body.Description().Subtype(); + QString desc,fsize; + double s = body.Description().Size(); + int w; + w=0; + + while (s>1024) + { s/=1024; ++w; if (w>=2) break; } - switch(w) { + + QString q=""; + switch(w) + { case 1: q="k"; break; case 2: q="M"; break; default: - q=""; break; } - QTextOStream o(&fsize); - if (w>0) o.precision(2); else o.precision(0); - o.setf(QTextStream::fixed); - o << s << " " << q << "Byte"; - desc = body.Parts()[i].Description(); - parentItem = searchParent(body.Parts()[i].Positionlist()); - if (parentItem) { - AttachItem*temp = lastChild(parentItem); - if (temp) curItem = temp; - curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); - attachments->setRootIsDecorated(true); - curItem = parentItem; - } else { - curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); + + { + /* I did not found a method to make a CONTENT reset on a QTextStream + so I use this construct that the stream will re-constructed in each + loop. To let it work, the textstream is packed into a own area of + code is it will be destructed after finishing its small job. + */ + QTextOStream o(&fsize); + if (w>0) o.precision(2); else o.precision(0); + o.setf(QTextStream::fixed); + o << s << " " << q << "Byte"; + } + + curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); + QString filename = ""; + + for (unsigned int i = 0; i < body.Parts().count();++i) + { + type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); + part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); + for (;it!=body.Parts()[i].Parameters().end();++it) + { + qDebug(it.key()); + if (it.key().lower()=="name") + { + filename=it.data(); + } + } + s = body.Parts()[i].Size(); + w = 0; + while (s>1024) + { + s/=1024; + ++w; + if (w>=2) break; + } + switch(w) + { + case 1: + q="k"; + break; + case 2: + q="M"; + break; + default: + q=""; + break; + } + QTextOStream o(&fsize); + if (w>0) o.precision(2); else o.precision(0); + o.setf(QTextStream::fixed); + o << s << " " << q << "Byte"; + desc = body.Parts()[i].Description(); + parentItem = searchParent(body.Parts()[i].Positionlist()); + if (parentItem) + { + AttachItem*temp = lastChild(parentItem); + if (temp) curItem = temp; + curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); + attachments->setRootIsDecorated(true); + curItem = parentItem; + } + else + { + curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); + } } -} } -void ViewMail::slotShowHtml( bool state ) { +void ViewMail::slotShowHtml( bool state ) +{ m_showHtml = state; setText(); } -void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { +void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) +{ if (!item ) return; - if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { + if ( ( ( AttachItem* )item )->Partnumber() == -1 ) + { setText(); return; } QPopupMenu *menu = new QPopupMenu(); - int ret=0; - - if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { - menu->insertItem( tr( "Show Text" ), 1 ); - } - menu->insertItem( tr( "Save Attachment" ), 0 ); - menu->insertSeparator(1); - - ret = menu->exec( point, 0 ); - - switch(ret) { - case 0: - { MimeTypes types; - types.insert( "all", "*" ); - QString str = Opie::OFileDialog::getSaveFileName( 1, - "/", item->text( 2 ) , types, 0 ); - - if( !str.isEmpty() ) { - encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); - if (content) { - QFile output(str); - output.open(IO_WriteOnly); - output.writeBlock(content->Content(),content->Length()); - output.close(); - delete content; - } - } - } + int ret=0; + + if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) + { + menu->insertItem( tr( "Show Text" ), 1 ); + } + menu->insertItem( tr( "Save Attachment" ), 0 ); + menu->insertSeparator(1); + + ret = menu->exec( point, 0 ); + + switch(ret) + { + case 0: + { + MimeTypes types; + types.insert( "all", "*" ); + QString str = Opie::OFileDialog::getSaveFileName( 1, + "/", item->text( 2 ) , types, 0 ); + + if( !str.isEmpty() ) + { + encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); + if (content) + { + QFile output(str); + output.open(IO_WriteOnly); + output.writeBlock(content->Content(),content->Length()); + output.close(); + delete content; + } + } + } break ; - case 1: - if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { - setText(); - } else { - if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions + case 1: + if ( ( ( AttachItem* )item )->Partnumber() == -1 ) + { + setText(); + } + else + { + if ( m_recMail.Wrapper() != 0l ) + { // make sure that there is a wrapper , even after delete or simular actions browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); - } - } + } + } break; - } - delete menu; + } + delete menu; } -void ViewMail::setMail( RecMail mail ) { +void ViewMail::setMail( RecMail mail ) +{ m_recMail = mail; m_mail[0] = mail.getFrom(); m_mail[1] = mail.getSubject(); m_mail[3] = mail.getDate(); m_mail[4] = mail.Msgid(); m_mail2[0] = mail.To(); m_mail2[1] = mail.CC(); m_mail2[2] = mail.Bcc(); setText(); } ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) - : ViewMailBase(parent, name, fl), _inLoop(false) + : ViewMailBase(parent, name, fl), _inLoop(false) { - m_gotBody = false; - deleted = false; + m_gotBody = false; + deleted = false; - connect( reply, SIGNAL(activated()), SLOT(slotReply())); - connect( forward, SIGNAL(activated()), SLOT(slotForward())); - connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); - connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); + connect( reply, SIGNAL(activated()), SLOT(slotReply())); + connect( forward, SIGNAL(activated()), SLOT(slotForward())); + connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); + connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); - attachments->setEnabled(m_gotBody); - connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); + attachments->setEnabled(m_gotBody); + connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); - readConfig(); + readConfig(); attachments->setSorting(-1); } -void ViewMail::readConfig() { +void ViewMail::readConfig() +{ Config cfg( "mail" ); cfg.setGroup( "Settings" ); m_showHtml = cfg.readBoolEntry( "showHtml", false ); showHtml->setOn( m_showHtml ); } void ViewMail::setText() { QString toString; QString ccString; QString bccString; - for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { + for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) + { toString += (*it); } - for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { + for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) + { ccString += (*it); } - for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { + for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) + { bccString += (*it); } setCaption( caption().arg( m_mail[0] ) ); m_mailHtml = "<html><body>" "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + "</td></tr></table><font face=fixed>"; - if ( !m_showHtml ) { - browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); - } else { - browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); + if ( !m_showHtml ) + { + browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); + } + else + { + browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); } // remove later in favor of a real handling m_gotBody = true; } ViewMail::~ViewMail() { m_recMail.Wrapper()->cleanMimeCache(); - hide(); + hide(); } void ViewMail::hide() { - QWidget::hide(); + QWidget::hide(); - if (_inLoop) { - _inLoop = false; - qApp->exit_loop(); + if (_inLoop) + { + _inLoop = false; + qApp->exit_loop(); - } + } } void ViewMail::exec() { - show(); + show(); - if (!_inLoop) { - _inLoop = true; - qApp->enter_loop(); - } + if (!_inLoop) + { + _inLoop = true; + qApp->enter_loop(); + } } QString ViewMail::deHtml(const QString &string) { - QString string_ = string; - string_.replace(QRegExp("&"), "&"); - string_.replace(QRegExp("<"), "<"); - string_.replace(QRegExp(">"), ">"); - string_.replace(QRegExp("\\n"), "<br>"); - return string_; + QString string_ = string; + string_.replace(QRegExp("&"), "&"); + string_.replace(QRegExp("<"), "<"); + string_.replace(QRegExp(">"), ">"); + string_.replace(QRegExp("\\n"), "<br>"); + return string_; } void ViewMail::slotReply() { - if (!m_gotBody) { - QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); - return; - } - - QString rtext; - rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose - .arg( m_mail[0] ) - .arg( m_mail[3] ); - - QString text = m_mail[2]; - QStringList lines = QStringList::split(QRegExp("\\n"), text); - QStringList::Iterator it; - for (it = lines.begin(); it != lines.end(); it++) { - rtext += "> " + *it + "\n"; - } - rtext += "\n"; - - QString prefix; - if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; - else prefix = "Re: "; // no i18n on purpose - - Settings *settings = new Settings(); - ComposeMail composer( settings ,this, 0, true); - composer.setTo( m_mail[0] ); - composer.setSubject( "Re: " + m_mail[1] ); - composer.setMessage( rtext ); - composer.showMaximized(); - if ( QDialog::Accepted==composer.exec()) { + if (!m_gotBody) + { + QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); + return; + } + + QString rtext; + rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose + .arg( m_mail[0] ) + .arg( m_mail[3] ); + + QString text = m_mail[2]; + QStringList lines = QStringList::split(QRegExp("\\n"), text); + QStringList::Iterator it; + for (it = lines.begin(); it != lines.end(); it++) + { + rtext += "> " + *it + "\n"; + } + rtext += "\n"; + + QString prefix; + if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; + else prefix = "Re: "; // no i18n on purpose + + Settings *settings = new Settings(); + ComposeMail composer( settings ,this, 0, true); + composer.setTo( m_mail[0] ); + composer.setSubject( "Re: " + m_mail[1] ); + composer.setMessage( rtext ); + if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) + { m_recMail.Wrapper()->answeredMail(m_recMail); } } void ViewMail::slotForward() { - if (!m_gotBody) { - QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); - return; - } - - QString ftext; - ftext += QString("\n----- Forwarded message from %1 -----\n\n") - .arg( m_mail[0] ); - if (!m_mail[3].isNull()) - ftext += QString("Date: %1\n") - .arg( m_mail[3] ); - if (!m_mail[0].isNull()) - ftext += QString("From: %1\n") - .arg( m_mail[0] ); - if (!m_mail[1].isNull()) - ftext += QString("Subject: %1\n") - .arg( m_mail[1] ); - - ftext += QString("\n%1\n") - .arg( m_mail[2]); - - ftext += QString("----- End forwarded message -----\n"); - - Settings *settings = new Settings(); - ComposeMail composer( settings ,this, 0, true); - composer.setSubject( "Fwd: " + m_mail[1] ); - composer.setMessage( ftext ); - composer.showMaximized(); - if ( QDialog::Accepted==composer.exec()) { + if (!m_gotBody) + { + QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); + return; + } + QString ftext; + ftext += QString("\n----- Forwarded message from %1 -----\n\n") + .arg( m_mail[0] ); + if (!m_mail[3].isNull()) + ftext += QString("Date: %1\n") + .arg( m_mail[3] ); + if (!m_mail[0].isNull()) + ftext += QString("From: %1\n") + .arg( m_mail[0] ); + if (!m_mail[1].isNull()) + ftext += QString("Subject: %1\n") + .arg( m_mail[1] ); + + ftext += QString("\n%1\n") + .arg( m_mail[2]); + + ftext += QString("----- End forwarded message -----\n"); + + Settings *settings = new Settings(); + ComposeMail composer( settings ,this, 0, true); + composer.setSubject( "Fwd: " + m_mail[1] ); + composer.setMessage( ftext ); + if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) + { } } void ViewMail::slotDeleteMail( ) { - if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { + if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) + { m_recMail.Wrapper()->deleteMail( m_recMail ); hide(); deleted = true; } } |