summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp34
-rw-r--r--noncore/net/mail/accountitem.h58
-rw-r--r--noncore/net/mail/accountview.cpp12
-rw-r--r--noncore/net/mail/accountview.h11
-rw-r--r--noncore/net/mail/composemail.cpp24
-rw-r--r--noncore/net/mail/composemail.h4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp16
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h36
-rw-r--r--noncore/net/mail/libmailwrapper/generatemail.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/generatemail.h6
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp10
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h10
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp49
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h34
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h15
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h8
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp43
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h24
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp50
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h26
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp26
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h14
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp32
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h14
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp18
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.h2
-rw-r--r--noncore/net/mail/mailistviewitem.cpp20
-rw-r--r--noncore/net/mail/mailistviewitem.h6
-rw-r--r--noncore/net/mail/mainwindow.cpp7
-rw-r--r--noncore/net/mail/mainwindow.h11
-rw-r--r--noncore/net/mail/opiemail.cpp24
-rw-r--r--noncore/net/mail/opiemail.h4
-rw-r--r--noncore/net/mail/viewmail.cpp36
-rw-r--r--noncore/net/mail/viewmail.h34
38 files changed, 369 insertions, 367 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 3e12563..9a09c18 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,1133 +1,1133 @@
#include "accountitem.h"
#include "accountview.h"
#include "newmaildir.h"
#include "nntpgroupsdlg.h"
#include "defines.h"
/* OPIE */
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
#include <libmailwrapper/mailwrapper.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 )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
SETPIX(PIXMAP_POP3FOLDER);
#if 0
if (!account->getOffline())
{
setPixmap( 0, );
}
else
{
setPixmap( 0, PIXMAP_OFFLINE );
}
#endif
setText( 0, account->getAccountName() );
setOpen( true );
}
POP3viewItem::~POP3viewItem()
{
delete wrapper;
}
AbstractMail *POP3viewItem::getWrapper()
{
return wrapper;
}
-void POP3viewItem::refresh( QList<RecMail> & )
+void POP3viewItem::refresh(QValueList<Opie::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;
}
-RecBody POP3viewItem::fetchBody( const RecMail &mail )
+RecBody POP3viewItem::fetchBody( const RecMailP &mail )
{
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * POP3viewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (!account->getOffline())
{
m->insertItem(QObject::tr("Disconnect",contextName),0);
m->insertItem(QObject::tr("Set offline",contextName),1);
}
else
{
m->insertItem(QObject::tr("Set online",contextName),1);
}
}
return m;
}
void POP3viewItem::disconnect()
{
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
wrapper->logout();
}
void POP3viewItem::setOnOffline()
{
if (!account->getOffline())
{
disconnect();
}
account->setOffline(!account->getOffline());
account->save();
SETPIX(PIXMAP_POP3FOLDER);
refresh();
}
void POP3viewItem::contextMenuSelected(int which)
{
switch (which)
{
case 0:
disconnect();
break;
case 1:
setOnOffline();
break;
}
}
POP3folderItem::~POP3folderItem()
{}
POP3folderItem::POP3folderItem( 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(QList<RecMail>&target)
+void POP3folderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
pop3->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody POP3folderItem::fetchBody(const RecMail&aMail)
+RecBody POP3folderItem::fetchBody(const RecMailP&aMail)
{
return pop3->getWrapper()->fetchBody(aMail);
}
QPopupMenu * POP3folderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Refresh header list",contextName),0);
m->insertItem(QObject::tr("Delete all mails",contextName),1);
m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
}
return m;
}
void POP3folderItem::downloadMails()
{
AccountView*bl = pop3->accountView();
if (!bl) return;
bl->downloadMails(folder,pop3->getWrapper());
}
void POP3folderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which)
{
case 0:
/* must be 'cause pop3 lists are cached */
pop3->getWrapper()->logout();
view->refreshCurrent();
break;
case 1:
deleteAllMail(pop3->getWrapper(),folder);
break;
case 2:
downloadMails();
break;
default:
break;
}
}
/**
* 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( QList<RecMail> & )
+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;
}
-RecBody NNTPviewItem::fetchBody( const RecMail &mail )
+RecBody NNTPviewItem::fetchBody( const RecMailP &mail )
{
qDebug( "NNTP fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * NNTPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (!account->getOffline())
{
m->insertItem(QObject::tr("Disconnect",contextName),0);
m->insertItem(QObject::tr("Set offline",contextName),1);
m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2);
}
else
{
m->insertItem(QObject::tr("Set online",contextName),1);
}
}
return m;
}
void NNTPviewItem::subscribeGroups()
{
NNTPGroupsDlg dlg(account);
if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){
refresh();
}
}
void NNTPviewItem::disconnect()
{
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
wrapper->logout();
}
void NNTPviewItem::setOnOffline()
{
if (!account->getOffline())
{
disconnect();
}
account->setOffline(!account->getOffline());
account->save();
//FIXME
SETPIX(PIXMAP_POP3FOLDER);
refresh();
}
void NNTPviewItem::contextMenuSelected(int which)
{
switch (which)
{
case 0:
disconnect();
break;
case 1:
setOnOffline();
break;
case 2:
subscribeGroups();
break;
}
}
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(QList<RecMail>&target)
+void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
nntp->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody NNTPfolderItem::fetchBody(const RecMail&aMail)
+RecBody NNTPfolderItem::fetchBody(const RecMailP&aMail)
{
return nntp->getWrapper()->fetchBody(aMail);
}
QPopupMenu * NNTPfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Refresh header list",contextName),0);
m->insertItem(QObject::tr("Copy all postings",contextName),1);
}
return m;
}
void NNTPfolderItem::downloadMails()
{
AccountView*bl = nntp->accountView();
if (!bl) return;
bl->downloadMails(folder,nntp->getWrapper());
}
void NNTPfolderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which)
{
case 0:
/* must be 'cause pop3 lists are cached */
nntp->getWrapper()->logout();
view->refreshCurrent();
break;
case 1:
downloadMails();
break;
default:
break;
}
}
/**
* IMAP Account stuff
*/
IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
SETPIX(PIXMAP_IMAPFOLDER);
setText( 0, account->getAccountName() );
setOpen( true );
}
IMAPviewItem::~IMAPviewItem()
{
delete wrapper;
}
AbstractMail *IMAPviewItem::getWrapper()
{
return wrapper;
}
-void IMAPviewItem::refresh(QList<RecMail>&)
+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);
qDebug("inbox found");
break;
}
}
for ( it = folders->begin(); it!=folders->end(); ++it)
{
fname = (*it)->getDisplayName();
currentFolders.append((*it)->getName());
pos = fname.findRev((*it)->Separator());
if (pos != -1)
{
fname = fname.left(pos);
}
IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
if (pitem)
{
titem = item;
item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
/* setup the short name */
item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1));
item = titem;
}
else
{
item = new IMAPfolderItem( (*it), this , item );
}
}
delete folders;
}
QPopupMenu * IMAPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (!account->getOffline())
{
m->insertItem(QObject::tr("Refresh folder list",contextName),0);
m->insertItem(QObject::tr("Create new folder",contextName),1);
m->insertSeparator();
m->insertItem(QObject::tr("Disconnect",contextName),2);
m->insertItem(QObject::tr("Set offline",contextName),3);
}
else
{
m->insertItem(QObject::tr("Set online",contextName),3);
}
}
return m;
}
void IMAPviewItem::createNewFolder()
{
Newmdirdlg ndirdlg;
if ( QPEApplication::execDialog( &ndirdlg ))
{
QString ndir = ndirdlg.Newdir();
bool makesubs = ndirdlg.subpossible();
QString delemiter = "/";
IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
if (item)
{
delemiter = item->Delemiter();
}
if (wrapper->createMbox(ndir,0,delemiter,makesubs))
{
refreshFolders(true);
}
}
}
void IMAPviewItem::contextMenuSelected(int id)
{
qDebug("Id selected: %i",id);
switch (id)
{
case 0:
refreshFolders(true);
break;
case 1:
createNewFolder();
break;
case 2:
removeChilds();
wrapper->logout();
break;
case 3:
if (account->getOffline()==false)
{
removeChilds();
wrapper->logout();
}
account->setOffline(!account->getOffline());
account->save();
SETPIX(PIXMAP_IMAPFOLDER);
refreshFolders(false);
break;
default:
break;
}
}
-RecBody IMAPviewItem::fetchBody(const RecMail&)
+RecBody IMAPviewItem::fetchBody(const RecMailP&)
{
return 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(QList<RecMail>&target)
+void IMAPfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
{
imap->getWrapper()->listMessages( folder->getName(),target );
}
else
{
target.clear();
}
}
-RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
+RecBody IMAPfolderItem::fetchBody(const RecMailP&aMail)
{
return imap->getWrapper()->fetchBody(aMail);
}
QPopupMenu * IMAPfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (folder->may_select())
{
m->insertItem(QObject::tr("Refresh header list",contextName),0);
m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
m->insertItem(QObject::tr("Delete all mails",contextName),1);
}
if (folder->no_inferior()==false)
{
m->insertItem(QObject::tr("Create new subfolder",contextName),2);
}
if (folder->getDisplayName().lower()!="inbox")
{
m->insertItem(QObject::tr("Delete folder",contextName),3);
}
}
return m;
}
void IMAPfolderItem::createNewFolder()
{
Newmdirdlg ndirdlg;
if ( QPEApplication::execDialog( &ndirdlg ) )
{
QString ndir = ndirdlg.Newdir();
bool makesubs = ndirdlg.subpossible();
QString delemiter = Delemiter();
if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
{
imap->refreshFolders(true);
}
}
}
void IMAPfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
QObject::tr("Yes",contextName),
QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
if (yesno == 0)
{
if (imap->getWrapper()->deleteMbox(folder))
{
QListView*v=listView();
IMAPviewItem * box = imap;
/* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
imap->refreshFolders(true);
if (v)
{
v->setSelected(box,true);
}
}
}
}
void IMAPfolderItem::downloadMails()
{
AccountView*bl = imap->accountView();
if (!bl) return;
bl->downloadMails(folder,imap->getWrapper());
}
void IMAPfolderItem::contextMenuSelected(int id)
{
qDebug("Selected id: %i",id);
AccountView * view = (AccountView*)listView();
switch(id)
{
case 0:
view->refreshCurrent();
break;
case 1:
deleteAllMail(imap->getWrapper(),folder);
break;
case 2:
createNewFolder();
break;
case 3:
deleteFolder();
break;
case 4:
downloadMails();
break;
default:
break;
}
}
/**
* MH Account stuff
*/
/* MH is a little bit different - the top folder can contains messages other than in IMAP and
POP3 and MBOX */
MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
: AccountViewItem( parent )
{
m_Path = aPath;
/* be carefull - the space within settext is wanted - thats why the string twice */
wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
setPixmap( 0, PIXMAP_LOCALFOLDER );
setText( 0, " Local Folders" );
setOpen( true );
folder = 0;
}
MHviewItem::~MHviewItem()
{
delete wrapper;
}
AbstractMail *MHviewItem::getWrapper()
{
return wrapper;
}
-void MHviewItem::refresh( QList<RecMail> & target)
+void MHviewItem::refresh( QValueList<RecMailP> & target)
{
refresh(false);
getWrapper()->listMessages( "",target );
}
void MHviewItem::refresh(bool force)
{
if (childCount()>0 && force==false) return;
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;
}
-RecBody MHviewItem::fetchBody( const RecMail &mail )
+RecBody MHviewItem::fetchBody( const RecMailP &mail )
{
qDebug( "MH fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * MHviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Refresh folder list",contextName),0);
m->insertItem(QObject::tr("Create new folder",contextName),1);
m->insertItem(QObject::tr("Delete all mails",contextName),2);
m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
}
return m;
}
void MHviewItem::createFolder()
{
Newmdirdlg ndirdlg(0,0,true);
if ( QPEApplication::execDialog( &ndirdlg ) )
{
QString ndir = ndirdlg.Newdir();
if (wrapper->createMbox(ndir))
{
refresh(true);
}
}
}
void MHviewItem::downloadMails()
{
AccountView*bl = accountView();
if (!bl) return;
bl->downloadMails(folder,getWrapper());
}
QStringList MHviewItem::subFolders()
{
return currentFolders;
}
void MHviewItem::contextMenuSelected(int which)
{
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( 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("inline/edit"));
} else {
setPixmap( 0, PIXMAP_MBOXFOLDER );
}
setText( 0, bName );
}
const FolderP&MHfolderItem::getFolder()const
{
return folder;
}
-void MHfolderItem::refresh(QList<RecMail>&target)
+void MHfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
mbox->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody MHfolderItem::fetchBody(const RecMail&aMail)
+RecBody MHfolderItem::fetchBody(const RecMailP&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
void MHfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
QObject::tr("Yes",contextName),
QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
if (yesno == 0)
{
if (mbox->getWrapper()->deleteMbox(folder))
{
QListView*v=listView();
MHviewItem * box = mbox;
/* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
mbox->refresh(true);
if (v)
{
v->setSelected(box,true);
}
}
}
}
QPopupMenu * MHfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
m->insertItem(QObject::tr("Delete all mails",contextName),0);
m->insertItem(QObject::tr("Create new subfolder",contextName),3);
m->insertItem(QObject::tr("Delete folder",contextName),1);
}
return m;
}
void MHfolderItem::downloadMails()
{
AccountView*bl = mbox->accountView();
if (!bl) return;
bl->downloadMails(folder,mbox->getWrapper());
}
void MHfolderItem::createFolder()
{
Newmdirdlg ndirdlg(0,0,true);
if ( QPEApplication::execDialog( &ndirdlg ) )
{
QString ndir = ndirdlg.Newdir();
if (mbox->getWrapper()->createMbox(ndir,folder))
{
QListView*v=listView();
MHviewItem * box = mbox;
/* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
mbox->refresh(true);
if (v)
{
v->setSelected(box,true);
}
}
}
}
void MHfolderItem::contextMenuSelected(int which)
{
switch(which)
{
case 0:
deleteAllMail(mbox->getWrapper(),folder);
break;
case 1:
deleteFolder();
break;
case 2:
downloadMails();
break;
case 3:
createFolder();
break;
default:
break;
}
}
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::osmart_pointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
+AccountViewItem::AccountViewItem( const Opie::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);
qDebug("Auswahl: %i",yesno);
if (yesno == 0)
{
if (wrapper->deleteAllMail(folder))
{
AccountView * view = (AccountView*)listView();
if (view) view->refreshCurrent();
}
}
}
void AccountViewItem::removeChilds()
{
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
}
bool AccountViewItem::matchName(const QString&name)const
{
if (!folder) return false;
return folder->getDisplayName()==name;
}
AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
{
AccountViewItem*pitem,*sitem;
if (!start) pitem = (AccountViewItem*)firstChild();
else pitem = (AccountViewItem*)start->firstChild();
while (pitem)
{
if (pitem->matchName(path))
{
break;
}
if (pitem->childCount()>0)
{
sitem = findSubItem(path,pitem);
if (sitem)
{
pitem = sitem;
break;
}
}
pitem=(AccountViewItem*)pitem->nextSibling();
}
return pitem;
}
bool AccountViewItem::isDraftfolder()
{
return false;
}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index 8f712f5..276eae0 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -1,210 +1,210 @@
#ifndef __ACCOUNT_ITEM
#define __ACCOUNT_ITEM
#include <qlistview.h>
#include <qlist.h>
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
class POP3wrapper;
class RecMail;
class RecBody;
class QPopupMenu;
class Selectstore;
class AccountView;
class POP3account;
class NNTPaccount;
class IMAPaccount;
class AbstractMail;
class Folder;
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( AccountView *parent );
AccountViewItem( QListViewItem *parent);
AccountViewItem( QListViewItem *parent , QListViewItem*after );
- AccountViewItem( const Opie::osmart_pointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after );
+ AccountViewItem( const Opie::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after );
virtual ~AccountViewItem();
- virtual void refresh(QList<RecMail>&)=0;
- virtual RecBody fetchBody(const RecMail&)=0;
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&)=0;
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&)=0;
virtual QPopupMenu * getContextMenu(){return 0;};
virtual void contextMenuSelected(int){}
virtual AccountView*accountView();
virtual bool matchName(const QString&name)const;
virtual bool isDraftfolder();
protected:
AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
virtual void init();
virtual void removeChilds();
- virtual void deleteAllMail(AbstractMail*wrapper,const Opie::osmart_pointer<Folder>&f);
+ virtual void deleteAllMail(AbstractMail*wrapper,const Opie::OSmartPointer<Folder>&f);
static const QString contextName;
AccountView*m_Backlink;
- Opie::osmart_pointer<Folder> folder;
+ Opie::OSmartPointer<Folder> folder;
};
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, AccountView *parent );
virtual ~POP3viewItem();
- virtual void refresh( QList<RecMail> &target );
- virtual RecBody fetchBody( const RecMail &mail );
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target );
+ virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
POP3account *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
};
class POP3folderItem : public AccountViewItem
{
public:
- POP3folderItem( const Opie::osmart_pointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
+ POP3folderItem( const Opie::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
virtual ~POP3folderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
POP3viewItem *pop3;
};
class NNTPviewItem : public AccountViewItem
{
public:
NNTPviewItem( NNTPaccount *a, AccountView *parent );
virtual ~NNTPviewItem();
- virtual void refresh( QList<RecMail> &target );
- virtual RecBody fetchBody( const RecMail &mail );
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target );
+ virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
NNTPaccount *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
void subscribeGroups();
};
class NNTPfolderItem : public AccountViewItem
{
public:
- NNTPfolderItem(const Opie::osmart_pointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
+ NNTPfolderItem(const Opie::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
virtual ~NNTPfolderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
NNTPviewItem *nntp;
};
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
IMAPviewItem( IMAPaccount *a, AccountView *parent );
virtual ~IMAPviewItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&);
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
const QStringList&subFolders();
virtual void refreshFolders(bool force=false);
bool offline();
protected:
virtual void createNewFolder();
IMAPaccount *account;
AbstractMail *wrapper;
QStringList currentFolders;
};
class IMAPfolderItem : public AccountViewItem
{
public:
- IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
- IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
+ IMAPfolderItem( const Opie::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
+ IMAPfolderItem( const Opie::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
virtual ~IMAPfolderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
virtual void downloadMails();
IMAPviewItem *imap;
};
class MHviewItem : public AccountViewItem
{
friend class MHfolderItem;
public:
MHviewItem( const QString&aMboxPath, AccountView *parent );
virtual ~MHviewItem();
- virtual void refresh( QList<RecMail> &target );
- virtual RecBody fetchBody( const RecMail &mail );
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target );
+ virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
QStringList subFolders();
virtual void refresh(bool force=false);
protected:
void downloadMails();
virtual void createFolder();
QString m_Path;
AbstractMail *wrapper;
QStringList currentFolders;
};
class MHfolderItem : public AccountViewItem
{
public:
- MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
- MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
+ MHfolderItem( const Opie::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
+ MHfolderItem( const Opie::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
virtual ~MHfolderItem();
- virtual void refresh(QList<RecMail>&);
- virtual RecBody fetchBody(const RecMail&);
+ virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
- virtual const Opie::osmart_pointer<Folder>&getFolder()const;
+ virtual const Opie::OSmartPointer<Folder>&getFolder()const;
virtual bool isDraftfolder();
protected:
void downloadMails();
virtual void createFolder();
virtual void deleteFolder();
void initName();
MHviewItem *mbox;
};
#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 297f553..26107ff 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,177 +1,175 @@
#include "accountview.h"
#include "accountitem.h"
#include "selectstore.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 )
{
connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
SLOT( refresh(QListViewItem*) ) );
connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
setSorting(0);
}
AccountView::~AccountView()
{
imapAccounts.clear();
mhAccounts.clear();
}
void AccountView::slotContextMenu(int id)
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return;
view->contextMenuSelected(id);
}
void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
{
if (button==1) {return;}
if (!item) return;
AccountViewItem *view = static_cast<AccountViewItem *>(item);
QPopupMenu*m = view->getContextMenu();
if (!m) return;
connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
void AccountView::populate( QList<Account> list )
{
clear();
imapAccounts.clear();
mhAccounts.clear();
mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
Account *it;
for ( it = list.first(); it; it = list.next() )
{
if ( it->getType() == MAILLIB::A_IMAP )
{
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
qDebug( "added IMAP " + imap->getAccountName() );
imapAccounts.append(new IMAPviewItem( imap, this ));
}
else if ( it->getType() == MAILLIB::A_POP3 )
{
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 );
}
else if ( it->getType() == MAILLIB::A_NNTP )
{
NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
qDebug( "added NNTP " + nntp->getAccountName() );
/* must not be hold 'cause it isn't required */
(void) new NNTPviewItem( nntp, this );
}
}
}
void AccountView::refresh(QListViewItem *item)
{
qDebug("AccountView refresh...");
if ( item )
{
m_currentItem = item;
- QList<RecMail> headerlist;
- headerlist.setAutoDelete(true);
+ QValueList<RecMailP> headerlist;
AccountViewItem *view = static_cast<AccountViewItem *>(item);
view->refresh(headerlist);
- emit refreshMailview(&headerlist);
+ emit refreshMailview(headerlist);
}
}
void AccountView::refreshCurrent()
{
m_currentItem = currentItem();
if ( !m_currentItem ) return;
- QList<RecMail> headerlist;
- headerlist.setAutoDelete(true);
+ QValueList<RecMailP> headerlist;
AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
view->refresh(headerlist);
- emit refreshMailview(&headerlist);
+ emit refreshMailview(headerlist);
}
void AccountView::refreshAll()
{
}
-RecBody AccountView::fetchBody(const RecMail&aMail)
+RecBody AccountView::fetchBody(const RecMailP&aMail)
{
QListViewItem*item = selectedItem ();
if (!item) return RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
void AccountView::setupFolderselect(Selectstore*sels)
{
QPEApplication::showDialog( sels );
QStringList sFolders;
unsigned int i = 0;
for (i=0; i < mhAccounts.count();++i)
{
mhAccounts[i]->refresh(false);
sFolders = mhAccounts[i]->subFolders();
sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
}
for (i=0; i < imapAccounts.count();++i)
{
if (imapAccounts[i]->offline())
continue;
imapAccounts[i]->refreshFolders(false);
sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
}
}
void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
{
AbstractMail*targetMail = 0;
QString targetFolder = "";
Selectstore sels;
setupFolderselect(&sels);
if (!sels.exec()) return;
targetMail = sels.currentMail();
targetFolder = sels.currentFolder();
if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
targetFolder.isEmpty())
{
return;
}
if (sels.newFolder() && !targetMail->createMbox(targetFolder))
{
QMessageBox::critical(0,tr("Error creating new Folder"),
tr("<center>Error while creating<br>new folder - breaking.</center>"));
return;
}
qDebug("Targetfolder: %s",targetFolder.latin1());
qDebug("Fromfolder: %s",fromFolder->getName().latin1());
fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
refreshCurrent();
}
bool AccountView::currentisDraft()
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return false;
return view->isDraftfolder();
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 3478c0b..d236058 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,46 +1,45 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
#include <qlistview.h>
#include <qlist.h>
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
+#include <libmailwrapper/mailtypes.h>
class Selectstore;
-class RecMail;
-class RecBody;
class Folder;
class AbstractMail;
class Account;
class IMAPviewItem;
class MHviewItem;
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~AccountView();
virtual void populate( QList<Account> list );
- virtual RecBody fetchBody(const RecMail&aMail);
- virtual void downloadMails(const Opie::osmart_pointer<Folder>&fromFolder,AbstractMail*fromWrapper);
+ virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&aMail);
+ virtual void downloadMails(const Opie::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
virtual bool currentisDraft();
public slots:
virtual void refreshAll();
virtual void refresh(QListViewItem *item);
virtual void refreshCurrent();
virtual void slotHold(int, QListViewItem *,const QPoint&,int);
virtual void slotContextMenu(int id);
void setupFolderselect(Selectstore*sels);
signals:
- void refreshMailview(QList<RecMail>*);
+ void refreshMailview(const QValueList<RecMailP>& );
protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
QValueList<MHviewItem*> mhAccounts;
};
#endif
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 445cc5e..74ccc7b 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -95,206 +95,206 @@ 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 = Opie::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() ) {
qDebug( "Send later" );
}
#if 0
qDebug( "Sending Mail with " +
smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
#endif
- Opie::osmart_pointer<Mail> mail=new Mail;
+ Opie::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 spezified" ) );
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::osmart_pointer<Mail> mail=new Mail();
+ Opie::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() );
}
qDebug(txt);
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 RecMail&current)
+void ComposeMail::reEditMail(const RecMailP&current)
{
- RecMail 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());
+ 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;
qDebug( att->getMimeType() );
setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
Resource::loadPixmap( "UnknownDocument-14" ) :
attachment->getDocLnk().pixmap() );
setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
setText( 1, QString::number( att->getSize() ) );
}
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h
index 1b9fc79..c12eb30 100644
--- a/noncore/net/mail/composemail.h
+++ b/noncore/net/mail/composemail.h
@@ -1,79 +1,81 @@
#ifndef COMPOSEMAIL_H
#define COMPOSEMAIL_H
#include <qlineedit.h>
#include <qlistview.h>
#include "composemailui.h"
#include "addresspickerui.h"
#include <libmailwrapper/settings.h>
#include <libmailwrapper/mailwrapper.h>
+class RecMail;
+#include <opie2/osmartpointer.h>
class AddressPicker : public AddressPickerUI
{
Q_OBJECT
public:
AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
static QString getNames();
protected:
QString selectedNames;
void accept();
};
class RecMail;
class ComposeMail : public ComposeMailUI
{
Q_OBJECT
public:
ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
virtual ~ComposeMail();
- void reEditMail(const RecMail&current);
+ void reEditMail(const Opie::OSmartPointer<RecMail>&current);
public slots:
void slotAdjustColumns();
void setTo( const QString & to );
void setSubject( const QString & subject );
void setInReplyTo( const QString & messageId );
void setMessage( const QString & text );
protected slots:
void accept();
void reject();
private slots:
void fillValues( int current );
void pickAddress( QLineEdit *line );
void pickAddressTo();
void pickAddressCC();
void pickAddressBCC();
void pickAddressReply();
void addAttachment();
void removeAttachment();
protected:
Settings *settings;
QList<SMTPaccount> smtpAccounts;
QString m_replyid;
};
class AttachViewItem : public QListViewItem
{
public:
AttachViewItem( QListView *parent, Attachment *att );
Attachment *getAttachment() { return attachment; }
private:
Attachment *attachment;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 7e6d383..68a7a4d 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -1,167 +1,167 @@
#include "abstractmail.h"
#include "imapwrapper.h"
#include "pop3wrapper.h"
#include "nntpwrapper.h"
#include "mhwrapper.h"
#include "mailtypes.h"
#include <qfile.h>
#include <qtextstream.h>
#include <stdlib.h>
#include <libetpan/mailmime_content.h>
#include <libetpan/mailmime.h>
AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
{
return new IMAPwrapper(a);
}
AbstractMail* AbstractMail::getWrapper(POP3account *a)
{
return new POP3wrapper(a);
}
AbstractMail* AbstractMail::getWrapper(NNTPaccount *a)
{
return new NNTPwrapper(a);
}
AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
{
return new MHwrapper(a,name);
}
AbstractMail* AbstractMail::getWrapper(Account*a)
{
if (!a) return 0;
switch (a->getType()) {
case MAILLIB::A_IMAP:
return new IMAPwrapper((IMAPaccount*)a);
break;
case MAILLIB::A_POP3:
return new POP3wrapper((POP3account*)a);
break;
case MAILLIB::A_NNTP:
return new NNTPwrapper((NNTPaccount*)a);
break;
default:
return 0;
}
}
encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
{
qDebug("Decode string start");
char*result_text;
size_t index = 0;
/* reset for recursive use! */
size_t target_length = 0;
result_text = 0;
int mimetype = MAILMIME_MECHANISM_7BIT;
if (enc.lower()=="quoted-printable") {
mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
} else if (enc.lower()=="base64") {
mimetype = MAILMIME_MECHANISM_BASE64;
} else if (enc.lower()=="8bit") {
mimetype = MAILMIME_MECHANISM_8BIT;
} else if (enc.lower()=="binary") {
mimetype = MAILMIME_MECHANISM_BINARY;
}
int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
&result_text,&target_length);
encodedString* result = new encodedString();
if (err == MAILIMF_NO_ERROR) {
result->setContent(result_text,target_length);
}
qDebug("Decode string finished");
return result;
}
QString AbstractMail::convert_String(const char*text)
{
- size_t index = 0;
+ //size_t index = 0;
char*res = 0;
int err = MAILIMF_NO_ERROR;
QString result(text);
/* due a bug in libetpan it isn't usable this moment */
/* int err = mailmime_encoded_phrase_parse("iso-8859-1",
text, strlen(text),&index, "iso-8859-1",&res);*/
//qDebug("Input: %s",text);
if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
// result = QString(res);
// qDebug("Res: %s, length: %i",res,strlen(res));
}
if (res) free(res);
return result;
}
/* cp & paste from launcher */
QString AbstractMail::gen_attachment_id()
{
QFile file( "/proc/sys/kernel/random/uuid" );
if (!file.open(IO_ReadOnly ) )
return QString::null;
QTextStream stream(&file);
return "{" + stream.read().stripWhiteSpace() + "}";
}
-int AbstractMail::createMbox(const QString&,const FolderP&,const QString& delemiter,bool)
+int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
{
return 0;
}
QString AbstractMail::defaultLocalfolder()
{
QString f = getenv( "HOME" );
f += "/Applications/opiemail/localmail";
return f;
}
QString AbstractMail::draftFolder()
{
return QString("Drafts");
}
/* temporary - will be removed when implemented in all classes */
-void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
+void AbstractMail::deleteMails(const QString &,const QValueList<Opie::OSmartPointer<RecMail> > &)
{
}
void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
- QList<RecMail> t;
+ QValueList<RecMailP> t;
listMessages(fromFolder->getName(),t);
encodedString*st = 0;
while (t.count()>0) {
- RecMail*r = t.at(0);
- st = fetchRawBody(*r);
+ RecMailP r = (*t.begin());
+ st = fetchRawBody(r);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
- t.removeFirst();
+ t.remove(t.begin());
}
if (moveit) {
deleteAllMail(fromFolder);
}
}
-void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
encodedString*st = 0;
st = fetchRawBody(mail);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
if (moveit) {
deleteMail(mail);
}
}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index d911468..b03d757 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,74 +1,72 @@
#ifndef __abstract_mail_
#define __abstract_mail_
#include "maildefines.h"
#include "settings.h"
#include <qobject.h>
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
+#include "mailtypes.h"
-class RecMail;
-class RecBody;
-class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
struct folderStat;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders()=0;
- virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders()=0;
+ virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0;
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
- virtual RecBody fetchBody(const RecMail&mail)=0;
- virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
- virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
- virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
- virtual encodedString* fetchRawBody(const RecMail&mail)=0;
+ virtual RecBody fetchBody(const RecMailP&mail)=0;
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0;
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0;
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0;
+ virtual encodedString* fetchRawBody(const RecMailP&mail)=0;
- virtual void deleteMail(const RecMail&mail)=0;
- virtual void answeredMail(const RecMail&mail)=0;
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&)=0;
- virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
- virtual int deleteMbox(const Opie::osmart_pointer<Folder>&)=0;
+ virtual void deleteMail(const RecMailP&mail)=0;
+ virtual void answeredMail(const RecMailP&mail)=0;
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&)=0;
+ virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> >&target);
+ virtual int deleteMbox(const Opie::OSmartPointer<Folder>&)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
- virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
* if the implementing subclass has prefixes,
* them has to be appended automatic.
*/
- virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0,
+ virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0,
const QString& delemiter="/",bool getsubfolder=false);
virtual void logout()=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
static AbstractMail* getWrapper(NNTPaccount *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
static AbstractMail* getWrapper(Account*a);
static QString defaultLocalfolder();
static QString draftFolder();
virtual MAILLIB::ATYPE getType()const=0;
virtual const QString&getName()const=0;
protected:
static encodedString*decode_String(const encodedString*text,const QString&enc);
static QString convert_String(const char*text);
static QString gen_attachment_id();
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp
index 4f7ec0c..cb7ccc0 100644
--- a/noncore/net/mail/libmailwrapper/generatemail.cpp
+++ b/noncore/net/mail/libmailwrapper/generatemail.cpp
@@ -186,282 +186,282 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet
}
if (content) {
mailmime_content_free( content );
}
if (fields) {
mailmime_fields_free( fields );
} else {
if (name) {
free( name );
}
if (file) {
free( file );
}
}
}
return filePart; // Success :)
}
void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) {
const Attachment *it;
unsigned int count = files.count();
qDebug("List contains %i values",count);
for ( unsigned int i = 0; i < count; ++i ) {
qDebug( "Adding file" );
mailmime *filePart;
int err;
it = ((QList<Attachment>)files).at(i);
filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
if ( filePart == NULL ) {
qDebug( "addFileParts: error adding file:" );
qDebug( it->getFileName() );
continue;
}
err = mailmime_smart_add_part( message, filePart );
if ( err != MAILIMF_NO_ERROR ) {
mailmime_free( filePart );
qDebug("error smart add");
}
}
}
mailmime *Generatemail::buildTxtPart(const QString&str ) {
mailmime *txtPart;
mailmime_fields *fields;
mailmime_content *content;
mailmime_parameter *param;
int err;
param = mailmime_parameter_new( strdup( "charset" ),
strdup( "iso-8859-1" ) );
if ( param == NULL )
goto err_free;
content = mailmime_content_new_with_str( "text/plain" );
if ( content == NULL )
goto err_free_param;
err = clist_append( content->ct_parameters, param );
if ( err != MAILIMF_NO_ERROR )
goto err_free_content;
fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
if ( fields == NULL )
goto err_free_content;
txtPart = mailmime_new_empty( content, fields );
if ( txtPart == NULL )
goto err_free_fields;
err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() );
if ( err != MAILIMF_NO_ERROR )
goto err_free_txtPart;
return txtPart; // Success :)
err_free_txtPart:
mailmime_free( txtPart );
err_free_fields:
mailmime_fields_free( fields );
err_free_content:
mailmime_content_free( content );
err_free_param:
mailmime_parameter_free( param );
err_free:
qDebug( "buildTxtPart - error" );
return NULL; // Error :(
}
mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) {
return mailimf_mailbox_new( strdup( name.latin1() ),
strdup( mail.latin1() ) );
}
-mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&mail )
+mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&mail )
{
mailimf_fields *fields = NULL;
mailimf_field *xmailer = NULL;
mailimf_mailbox *sender=0,*fromBox=0;
mailimf_mailbox_list *from=0;
mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
clist*in_reply_to = 0;
char *subject = strdup( mail->getSubject().latin1() );
int err;
int res = 1;
sender = newMailbox( mail->getName(), mail->getMail() );
if ( sender == NULL ) {
res = 0;
}
if (res) {
fromBox = newMailbox( mail->getName(), mail->getMail() );
}
if ( fromBox == NULL ) {
res = 0;
}
if (res) {
from = mailimf_mailbox_list_new_empty();
}
if ( from == NULL ) {
res = 0;
}
if (res && from) {
err = mailimf_mailbox_list_add( from, fromBox );
if ( err != MAILIMF_NO_ERROR ) {
res = 0;
}
}
if (res) to = parseAddresses( mail->getTo() );
if (res) cc = parseAddresses( mail->getCC() );
if (res) bcc = parseAddresses( mail->getBCC() );
if (res) reply = parseAddresses( mail->getReply() );
if (res && mail->Inreply().count()>0) {
in_reply_to = clist_new();
char*c_reply;
unsigned int nsize = 0;
for (QStringList::ConstIterator it=mail->Inreply().begin();
it != mail->Inreply().end();++it) {
if ((*it).isEmpty())
continue;
QString h((*it));
while (h.length()>0 && h[0]=='<') {
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.isEmpty()) continue;
nsize = strlen(h.latin1());
/* yes! must be malloc! */
c_reply = (char*)malloc( (nsize+1)*sizeof(char));
memset(c_reply,0,nsize+1);
memcpy(c_reply,h.latin1(),nsize);
clist_append(in_reply_to,c_reply);
qDebug("In reply to: %s",c_reply);
}
}
if (res) {
fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
in_reply_to, NULL, subject );
if ( fields == NULL ) {
qDebug("Error creating mailimf fields");
res = 0;
}
}
if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
strdup( USER_AGENT ) );
if ( xmailer == NULL ) {
res = 0;
} else {
err = mailimf_fields_add( fields, xmailer );
if ( err != MAILIMF_NO_ERROR ) {
res = 0;
}
}
if (!res ) {
if (xmailer) {
mailimf_field_free( xmailer );
xmailer = NULL;
}
if (fields) {
mailimf_fields_free( fields );
fields = NULL;
} else {
if (reply)
mailimf_address_list_free( reply );
if (bcc)
mailimf_address_list_free( bcc );
if (cc)
mailimf_address_list_free( cc );
if (to)
mailimf_address_list_free( to );
if (fromBox) {
mailimf_mailbox_free( fromBox );
} else if (from) {
mailimf_mailbox_list_free( from );
}
if (sender) {
mailimf_mailbox_free( sender );
}
if (subject) {
free( subject );
}
}
}
return fields;
}
-mailmime *Generatemail::createMimeMail(const Opie::osmart_pointer<Mail> &mail ) {
+mailmime *Generatemail::createMimeMail(const Opie::OSmartPointer<Mail> &mail ) {
mailmime *message, *txtPart;
mailimf_fields *fields;
int err;
fields = createImfFields( mail );
if ( fields == NULL )
goto err_free;
message = mailmime_new_message_data( NULL );
if ( message == NULL )
goto err_free_fields;
mailmime_set_imf_fields( message, fields );
txtPart = buildTxtPart( mail->getMessage() );
if ( txtPart == NULL )
goto err_free_message;
err = mailmime_smart_add_part( message, txtPart );
if ( err != MAILIMF_NO_ERROR )
goto err_free_txtPart;
addFileParts( message, mail->getAttachments() );
return message; // Success :)
err_free_txtPart:
mailmime_free( txtPart );
err_free_message:
mailmime_free( message );
err_free_fields:
mailimf_fields_free( fields );
err_free:
qDebug( "createMimeMail: error" );
return NULL; // Error :(
}
clist *Generatemail::createRcptList( mailimf_fields *fields ) {
clist *rcptList;
mailimf_field *field;
rcptList = esmtp_address_list_new();
field = getField( fields, MAILIMF_FIELD_TO );
if ( field && (field->fld_type == MAILIMF_FIELD_TO)
&& field->fld_data.fld_to->to_addr_list ) {
addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
}
field = getField( fields, MAILIMF_FIELD_CC );
if ( field && (field->fld_type == MAILIMF_FIELD_CC)
&& field->fld_data.fld_cc->cc_addr_list ) {
addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
}
field = getField( fields, MAILIMF_FIELD_BCC );
if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
&& field->fld_data.fld_bcc->bcc_addr_list ) {
addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
}
return rcptList;
}
diff --git a/noncore/net/mail/libmailwrapper/generatemail.h b/noncore/net/mail/libmailwrapper/generatemail.h
index 409a55e..c246a2a 100644
--- a/noncore/net/mail/libmailwrapper/generatemail.h
+++ b/noncore/net/mail/libmailwrapper/generatemail.h
@@ -1,46 +1,46 @@
#ifndef __GENERATE_MAIL_H
#define __GENERATE_MAIL_H
#include <qpe/applnk.h>
#include <qobject.h>
#include <libetpan/clist.h>
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
class Mail;
class RecMail;
class Attachment;
struct mailimf_fields;
struct mailimf_field;
struct mailimf_mailbox;
struct mailmime;
struct mailimf_address_list;
class progressMailSend;
struct mailsmtp;
class Generatemail : public QObject
{
Q_OBJECT
public:
Generatemail();
virtual ~Generatemail();
protected:
static void addRcpts( clist *list, mailimf_address_list *addr_list );
static char *getFrom( mailmime *mail );
static char *getFrom( mailimf_field *ffrom);
static mailimf_field *getField( mailimf_fields *fields, int type );
mailimf_address_list *parseAddresses(const QString&addr );
void addFileParts( mailmime *message,const QList<Attachment>&files );
mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
mailmime *buildTxtPart(const QString&str );
mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
- mailimf_fields *createImfFields(const Opie::osmart_pointer<Mail> &mail );
- mailmime *createMimeMail(const Opie::osmart_pointer<Mail>&mail );
+ mailimf_fields *createImfFields(const Opie::OSmartPointer<Mail> &mail );
+ mailmime *createMimeMail(const Opie::OSmartPointer<Mail>&mail );
clist *createRcptList( mailimf_fields *fields );
static const char* USER_AGENT;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 6c8a5a1..ee2c8cd 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -238,238 +238,238 @@ RecBody Genericwrapper::parseMail( mailmessage * msg )
return body;
}
QString Genericwrapper::parseDateTime( mailimf_date_time *date )
{
char tmp[23];
snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
return QString( tmp );
}
QString Genericwrapper::parseAddressList( mailimf_address_list *list )
{
QString result( "" );
bool first = true;
if (list == 0) return result;
for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
mailimf_address *addr = (mailimf_address *) current->data;
if ( !first ) {
result.append( "," );
} else {
first = false;
}
switch ( addr->ad_type ) {
case MAILIMF_ADDRESS_MAILBOX:
result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
break;
case MAILIMF_ADDRESS_GROUP:
result.append( parseGroup( addr->ad_data.ad_group ) );
break;
default:
qDebug( "Generic: unkown mailimf address type" );
break;
}
}
return result;
}
QString Genericwrapper::parseGroup( mailimf_group *group )
{
QString result( "" );
result.append( group->grp_display_name );
result.append( ": " );
if ( group->grp_mb_list != NULL ) {
result.append( parseMailboxList( group->grp_mb_list ) );
}
result.append( ";" );
return result;
}
QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
{
QString result( "" );
if ( box->mb_display_name == NULL ) {
result.append( box->mb_addr_spec );
} else {
result.append( convert_String(box->mb_display_name).latin1() );
result.append( " <" );
result.append( box->mb_addr_spec );
result.append( ">" );
}
return result;
}
QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
{
QString result( "" );
bool first = true;
for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
mailimf_mailbox *box = (mailimf_mailbox *) current->data;
if ( !first ) {
result.append( "," );
} else {
first = false;
}
result.append( parseMailbox( box ) );
}
return result;
}
-encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part)
+encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part)
{
QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
if (it==bodyCache.end()) return new encodedString();
encodedString*t = decode_String(it.data(),part.Encoding());
return t;
}
-encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
+encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part)
{
QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
if (it==bodyCache.end()) return new encodedString();
encodedString*t = it.data();
return t;
}
-QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
+QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part)
{
encodedString*t = fetchDecodedPart(mail,part);
QString text=t->Content();
delete t;
return text;
}
void Genericwrapper::cleanMimeCache()
{
QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
for (;it!=bodyCache.end();++it) {
encodedString*t = it.data();
//it.setValue(0);
if (t) delete t;
}
bodyCache.clear();
qDebug("Genericwrapper: cache cleaned");
}
QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
{
QStringList res;
if (!in_replies || !in_replies->mid_list) return res;
clistiter * current = 0;
for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
QString h((char*)current->data);
while (h.length()>0 && h[0]=='<') {
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
res.append(h);
}
}
return res;
}
-void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
+void Genericwrapper::parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
{
int r;
mailmessage_list * env_list = 0;
r = mailsession_get_messages_list(session,&env_list);
if (r != MAIL_NO_ERROR) {
qDebug("Error message list");
return;
}
r = mailsession_get_envelopes_list(session, env_list);
if (r != MAIL_NO_ERROR) {
qDebug("Error filling message list");
if (env_list) {
mailmessage_list_free(env_list);
}
return;
}
mailimf_references * refs = 0;
mailimf_in_reply_to * in_replies = 0;
uint32_t i = 0;
for(; i < carray_count(env_list->msg_tab) ; ++i) {
mailmessage * msg;
QBitArray mFlags(7);
msg = (mailmessage*)carray_get(env_list->msg_tab, i);
if (msg->msg_fields == NULL) {
//qDebug("could not fetch envelope of message %i", i);
continue;
}
- RecMail * mail = new RecMail();
+ RecMailP mail = new RecMail();
mail->setWrapper(this);
mail_flags * flag_result = 0;
r = mailmessage_get_flags(msg,&flag_result);
if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
mFlags.setBit(FLAG_SEEN);
}
mailimf_single_fields single_fields;
mailimf_single_fields_init(&single_fields, msg->msg_fields);
mail->setMsgsize(msg->msg_size);
mail->setFlags(mFlags);
mail->setMbox(mailbox);
mail->setNumber(msg->msg_index);
if (single_fields.fld_subject)
mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
if (single_fields.fld_from)
mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
if (!mbox_as_to) {
if (single_fields.fld_to)
mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
} else {
mail->setTo(mailbox);
}
if (single_fields.fld_cc)
mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
if (single_fields.fld_bcc)
mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
if (single_fields.fld_orig_date)
mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
// crashes when accessing pop3 account?
if (single_fields.fld_message_id->mid_value) {
mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
qDebug("Msgid == %s",mail->Msgid().latin1());
}
if (single_fields.fld_reply_to) {
QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
if (t.count()>0) {
mail->setReplyto(t[0]);
}
}
#if 0
refs = single_fields.fld_references;
if (refs && refs->mid_list && clist_count(refs->mid_list)) {
char * text = (char*)refs->mid_list->first->data;
mail->setReplyto(QString(text));
}
#endif
if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
clist_count(single_fields.fld_in_reply_to->mid_list)) {
mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
}
target.append(mail);
}
if (env_list) {
mailmessage_list_free(env_list);
}
}
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index d0db45a..f9968d1 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -1,67 +1,67 @@
#ifndef __GENERIC_WRAPPER_H
#define __GENERIC_WRAPPER_H
#include "abstractmail.h"
#include <qmap.h>
#include <qstring.h>
#include <libetpan/clist.h>
class RecMail;
class RecBody;
class encodedString;
struct mailpop3;
struct mailmessage;
struct mailmime;
struct mailmime_mechanism;
struct mailimf_mailbox_list;
struct mailimf_mailbox;
struct mailimf_date_time;
struct mailimf_group;
struct mailimf_address_list;
struct mailsession;
struct mailstorage;
struct mailfolder;
struct mailimf_in_reply_to;
/* this class hold just the funs shared between
* mbox and pop3 (later mh, too) mail access.
* it is not desigend to make a instance of it!
*/
class Genericwrapper : public AbstractMail
{
Q_OBJECT
public:
Genericwrapper();
virtual ~Genericwrapper();
- virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
- virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
- virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
virtual void cleanMimeCache();
- virtual int deleteMbox(const Opie::osmart_pointer<Folder>&){return 1;}
+ virtual int deleteMbox(const Opie::OSmartPointer<Folder>&){return 1;}
virtual void logout(){};
virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
protected:
RecBody parseMail( mailmessage * msg );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
static void fillParameters(RecPart&target,clist*parameters);
static QString getencoding(mailmime_mechanism*aEnc);
- virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
+ virtual void parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
QStringList parseInreplies(mailimf_in_reply_to * in_replies);
QString msgTempName;
unsigned int last_msg_id;
QMap<QString,encodedString*> bodyCache;
mailstorage * m_storage;
mailfolder*m_folder;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 3b3be0f..071e734 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -112,254 +112,254 @@ void IMAPwrapper::login()
}
}
server = account->getServer().latin1();
port = account->getPort().toUInt();
if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
} else {
// cancel
qDebug( "IMAP: Login canceled" );
return;
}
} else {
user = account->getUser().latin1();
pass = account->getPassword().latin1();
}
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
bool ssl = false;
bool try_tls = false;
bool force_tls = false;
if ( account->ConnectionType() == 2 ) {
ssl = true;
}
if (account->ConnectionType()==1) {
force_tls = true;
}
if ( ssl ) {
qDebug( "using ssl" );
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
err = mailimap_socket_connect( m_imap, (char*)server, port );
}
if ( err != MAILIMAP_NO_ERROR &&
err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
QString failure = "";
if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
failure="Connection refused";
} else {
failure="Unknown failure";
}
Global::statusMessage(tr("error connecting imap server: %1").arg(failure));
mailimap_free( m_imap );
m_imap = 0;
return;
}
if (!ssl) {
try_tls = start_tls(force_tls);
}
bool ok = true;
if (force_tls && !try_tls) {
Global::statusMessage(tr("Server has no TLS support!"));
qDebug("Server has no TLS support!");
ok = false;
}
/* login */
if (ok) {
err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
if ( err != MAILIMAP_NO_ERROR ) {
Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
ok = false;
}
}
if (!ok) {
err = mailimap_close( m_imap );
mailimap_free( m_imap );
m_imap = 0;
}
}
void IMAPwrapper::logout()
{
int err = MAILIMAP_NO_ERROR;
if (!m_imap) return;
err = mailimap_logout( m_imap );
err = mailimap_close( m_imap );
mailimap_free( m_imap );
m_imap = 0;
m_Lastmbox = "";
}
-void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
+void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target )
{
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = selectMbox(mailbox);
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
int last = m_imap->imap_selection_info->sel_exists;
if (last == 0) {
Global::statusMessage(tr("Mailbox has no mails"));
return;
} else {
}
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
m->setNumber(i);
m->setMbox(mailbox);
m->setWrapper(this);
target.append(m);
}
}
Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
} else {
Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
}
if (result) mailimap_fetch_list_free(result);
}
-QValueList<Opie::osmart_pointer<Folder> >* IMAPwrapper::listFolders()
+QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current = 0;
clistcell*cur_flag = 0;
mailimap_mbx_list_flags*bflags = 0;
QValueList<FolderP>* folders = new QValueList<FolderP>();
login();
if (!m_imap) {
return folders;
}
/*
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
* We must not forget to filter them out in next loop!
* it seems like ugly code. and yes - it is ugly code. but the best way.
*/
QString temp;
mask = "INBOX" ;
mailimap_mailbox_list *list;
err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
QString del;
bool selectable = true;
bool no_inferiors = false;
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( int i = result->count; i > 0; i-- ) {
list = (mailimap_mailbox_list *) current->data;
// it is better use the deep copy mechanism of qt itself
// instead of using strdup!
temp = list->mb_name;
del = list->mb_delimiter;
current = current->next;
if ( (bflags = list->mb_flag) ) {
selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
no_inferiors = true;
}
}
}
folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
qDebug("error fetching folders: %s",m_imap->imap_response);
}
mailimap_list_result_free( result );
/*
* second stage - get the other then inbox folders
*/
mask = "*" ;
path = account->getPrefix().latin1();
if (!path) path = "";
qDebug(path);
err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
no_inferiors = false;
list = (mailimap_mailbox_list *) current->data;
// it is better use the deep copy mechanism of qt itself
// instead of using strdup!
temp = list->mb_name;
if (temp.lower()=="inbox")
continue;
if (temp.lower()==account->getPrefix().lower())
continue;
if ( (bflags = list->mb_flag) ) {
selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
no_inferiors = true;
}
}
}
del = list->mb_delimiter;
folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
qDebug("error fetching folders %s",m_imap->imap_response);
}
if (result) mailimap_list_result_free( result );
return folders;
}
RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
mailimap_msg_att_item *item=0;
clistcell *current,*c,*cf;
mailimap_msg_att_dynamic*flist;
@@ -389,352 +389,352 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
mFlags.setBit(FLAG_ANSWERED);
break;
case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
mFlags.setBit(FLAG_FLAGGED);
break;
case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
mFlags.setBit(FLAG_DELETED);
break;
case MAILIMAP_FLAG_SEEN: /* \Seen flag */
mFlags.setBit(FLAG_SEEN);
break;
case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
mFlags.setBit(FLAG_DRAFT);
break;
case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
break;
case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
break;
default:
break;
}
} else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
mFlags.setBit(FLAG_RECENT);
}
}
continue;
}
if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
m->setDate(head->env_date);
m->setSubject(convert_String((const char*)head->env_subject));
//m->setSubject(head->env_subject);
if (head->env_from!=NULL) {
addresslist = address_list_to_stringlist(head->env_from->frm_list);
if (addresslist.count()) {
m->setFrom(addresslist.first());
}
}
if (head->env_to!=NULL) {
addresslist = address_list_to_stringlist(head->env_to->to_list);
m->setTo(addresslist);
}
if (head->env_cc!=NULL) {
addresslist = address_list_to_stringlist(head->env_cc->cc_list);
m->setCC(addresslist);
}
if (head->env_bcc!=NULL) {
addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
m->setBcc(addresslist);
}
/* reply to address, eg. email. */
if (head->env_reply_to!=NULL) {
addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
if (addresslist.count()) {
m->setReplyto(addresslist.first());
}
}
if (head->env_in_reply_to!=NULL) {
QString h(head->env_in_reply_to);
while (h.length()>0 && h[0]=='<') {
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
m->setInreply(QStringList(h));
}
}
if (head->env_message_id) {
m->setMsgid(QString(head->env_message_id));
}
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
#if 0
mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
qDebug(da.toString());
#endif
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
size = item->att_data.att_static->att_data.att_rfc822_size;
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
delete m;
m = 0;
}
if (m) {
m->setFlags(mFlags);
m->setMsgsize(size);
}
return m;
}
-RecBody IMAPwrapper::fetchBody(const RecMail&mail)
+RecBody IMAPwrapper::fetchBody(const RecMailP&mail)
{
RecBody body;
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current;
mailimap_fetch_att *fetchAtt = 0;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
mailimap_body*body_desc = 0;
- mb = mail.getMbox().latin1();
+ mb = mail->getMbox().latin1();
login();
if (!m_imap) {
return body;
}
- err = selectMbox(mail.getMbox());
+ err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return body;
}
/* the range has to start at 1!!! not with 0!!!! */
- set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
+ set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
fetchAtt = mailimap_fetch_att_new_bodystructure();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
mailimap_msg_att * msg_att;
msg_att = (mailimap_msg_att*)current->data;
mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
QValueList<int> path;
body_desc = item->att_data.att_static->att_data.att_body;
traverseBody(mail,body_desc,body,0,path);
} else {
qDebug("error fetching body: %s",m_imap->imap_response);
}
if (result) mailimap_fetch_list_free(result);
return body;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
{
QStringList l;
QString from;
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;
if (!list) {
return l;
}
unsigned int count = 0;
for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
from = "";
named_from = false;
current_address=(mailimap_address*)current->data;
if (current_address->ad_personal_name){
from+=convert_String((const char*)current_address->ad_personal_name);
from+=" ";
named_from = true;
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+="<";
}
if (current_address->ad_mailbox_name) {
from+=QString(current_address->ad_mailbox_name);
from+="@";
}
if (current_address->ad_host_name) {
from+=QString(current_address->ad_host_name);
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+=">";
}
l.append(QString(from));
if (++count > 99) {
break;
}
}
return l;
}
-encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
+encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
{
encodedString*res=new encodedString;
int err;
mailimap_fetch_type *fetchType;
mailimap_set *set;
clistcell*current,*cur;
mailimap_section_part * section_part = 0;
mailimap_section_spec * section_spec = 0;
mailimap_section * section = 0;
mailimap_fetch_att * fetch_att = 0;
login();
if (!m_imap) {
return res;
}
if (!internal_call) {
- err = selectMbox(mail.getMbox());
+ err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return res;
}
}
- set = mailimap_set_new_single(mail.getNumber());
+ set = mailimap_set_new_single(mail->getNumber());
clist*id_list = 0;
/* if path == empty then its a request for the whole rfc822 mail and generates
a "fetch <id> (body[])" statement on imap server */
if (path.count()>0 ) {
id_list = clist_new();
for (unsigned j=0; j < path.count();++j) {
uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
*p_id = path[j];
clist_append(id_list,p_id);
}
section_part = mailimap_section_part_new(id_list);
section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
}
section = mailimap_section_new(section_spec);
fetch_att = mailimap_fetch_att_new_body_section(section);
fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
clist*result = 0;
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
mailimap_msg_att * msg_att;
msg_att = (mailimap_msg_att*)current->data;
mailimap_msg_att_item*msg_att_item;
for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
/* detach - we take over the content */
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
}
}
}
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
if (result) mailimap_fetch_list_free(result);
return res;
}
/* current_recursion is for recursive calls.
current_count means the position inside the internal loop! */
-void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,
+void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,
int current_recursion,QValueList<int>recList,int current_count)
{
if (!body || current_recursion>=10) {
return;
}
switch (body->bd_type) {
case MAILIMAP_BODY_1PART:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
RecPart currentPart;
mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
QString id("");
currentPart.setPositionlist(countlist);
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
qDebug("ID = %s",id.latin1());
currentPart.setIdentifier(id);
fillSinglePart(currentPart,part1);
/* important: Check for is NULL 'cause a body can be empty!
And we put it only into the mail if it is the FIRST part */
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) {
QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding());
target_body.setDescription(currentPart);
target_body.setBodytext(body_text);
if (countlist.count()>1) {
target_body.addPart(currentPart);
}
} else {
target_body.addPart(currentPart);
}
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
}
}
break;
case MAILIMAP_BODY_MPART:
{
QValueList<int>countlist = recList;
clistcell*current=0;
mailimap_body*current_body=0;
unsigned int ccount = 1;
mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
current_body = (mailimap_body*)current->data;
if (current_body->bd_type==MAILIMAP_BODY_MPART) {
RecPart targetPart;
targetPart.setType("multipart");
fillMultiPart(targetPart,mailDescription);
countlist.append(current_count);
targetPart.setPositionlist(countlist);
target_body.addPart(targetPart);
QString id("");
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
qDebug("ID(mpart) = %s",id.latin1());
}
traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
if (current_body->bd_type==MAILIMAP_BODY_MPART) {
countlist = recList;
}
++ccount;
}
}
break;
default:
break;
}
}
void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
{
if (!Description) {
return;
}
switch (Description->bd_type) {
case MAILIMAP_BODY_TYPE_1PART_TEXT:
target_part.setType("text");
fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
break;
case MAILIMAP_BODY_TYPE_1PART_BASIC:
fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
break;
case MAILIMAP_BODY_TYPE_1PART_MSG:
target_part.setType("message");
fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
break;
default:
break;
}
}
@@ -776,410 +776,409 @@ void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*whi
if (param) {
target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
}
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
{
if (!which) {
return;
}
QString type,sub;
switch (which->bd_media_basic->med_type) {
case MAILIMAP_MEDIA_BASIC_APPLICATION:
type = "application";
break;
case MAILIMAP_MEDIA_BASIC_AUDIO:
type = "audio";
break;
case MAILIMAP_MEDIA_BASIC_IMAGE:
type = "image";
break;
case MAILIMAP_MEDIA_BASIC_MESSAGE:
type = "message";
break;
case MAILIMAP_MEDIA_BASIC_VIDEO:
type = "video";
break;
case MAILIMAP_MEDIA_BASIC_OTHER:
default:
if (which->bd_media_basic->med_basic_type) {
type = which->bd_media_basic->med_basic_type;
} else {
type = "";
}
break;
}
if (which->bd_media_basic->med_subtype) {
sub = which->bd_media_basic->med_subtype;
} else {
sub = "";
}
qDebug("Type = %s/%s",type.latin1(),sub.latin1());
target_part.setType(type.lower());
target_part.setSubtype(sub.lower());
fillBodyFields(target_part,which->bd_fields);
}
void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
{
if (!which) return;
if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
clistcell*cur;
mailimap_single_body_fld_param*param=0;
for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
param = (mailimap_single_body_fld_param*)cur->data;
if (param) {
target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
mailimap_body_fld_enc*enc = which->bd_encoding;
QString encoding("");
switch (enc->enc_type) {
case MAILIMAP_BODY_FLD_ENC_7BIT:
encoding = "7bit";
break;
case MAILIMAP_BODY_FLD_ENC_8BIT:
encoding = "8bit";
break;
case MAILIMAP_BODY_FLD_ENC_BINARY:
encoding="binary";
break;
case MAILIMAP_BODY_FLD_ENC_BASE64:
encoding="base64";
break;
case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
encoding="quoted-printable";
break;
case MAILIMAP_BODY_FLD_ENC_OTHER:
default:
if (enc->enc_value) {
char*t=enc->enc_value;
encoding=QString(enc->enc_value);
enc->enc_value=0L;
free(t);
}
}
if (which->bd_description) {
target_part.setDescription(QString(which->bd_description));
}
target_part.setEncoding(encoding);
target_part.setSize(which->bd_size);
}
-void IMAPwrapper::deleteMail(const RecMail&mail)
+void IMAPwrapper::deleteMail(const RecMailP&mail)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
login();
if (!m_imap) {
return;
}
- err = selectMbox(mail.getMbox());
+ err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
flist = mailimap_flag_list_new_empty();
mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
store_flags = mailimap_store_att_flags_new_set_flags(flist);
- set = mailimap_set_new_single(mail.getNumber());
+ set = mailimap_set_new_single(mail->getNumber());
err = mailimap_store(m_imap,set,store_flags);
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
qDebug("error deleting mail: %s",m_imap->imap_response);
return;
}
qDebug("deleting mail: %s",m_imap->imap_response);
/* should we realy do that at this moment? */
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
qDebug("error deleting mail: %s",m_imap->imap_response);
}
qDebug("Delete successfull %s",m_imap->imap_response);
}
-void IMAPwrapper::answeredMail(const RecMail&mail)
+void IMAPwrapper::answeredMail(const RecMailP&mail)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
login();
if (!m_imap) {
return;
}
- err = selectMbox(mail.getMbox());
+ err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
flist = mailimap_flag_list_new_empty();
mailimap_flag_list_add(flist,mailimap_flag_new_answered());
store_flags = mailimap_store_att_flags_new_add_flags(flist);
- set = mailimap_set_new_single(mail.getNumber());
+ set = mailimap_set_new_single(mail->getNumber());
err = mailimap_store(m_imap,set,store_flags);
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
qDebug("error marking mail: %s",m_imap->imap_response);
return;
}
}
-QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
+QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
{
QString body("");
encodedString*res = fetchRawPart(mail,path,internal_call);
encodedString*r = decode_String(res,enc);
delete res;
if (r) {
if (r->Length()>0) {
body = r->Content();
}
delete r;
}
return body;
}
-QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
+QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part)
{
return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
}
-encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part)
+encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part)
{
encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
encodedString*r = decode_String(res,part.Encoding());
delete res;
return r;
}
-encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
+encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part)
{
return fetchRawPart(mail,part.Positionlist(),false);
}
int IMAPwrapper::deleteAllMail(const FolderP&folder)
{
login();
if (!m_imap) {
return 0;
}
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err = selectMbox(folder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
return 0;
}
int last = m_imap->imap_selection_info->sel_exists;
if (last == 0) {
Global::statusMessage(tr("Mailbox has no mails!"));
return 0;
}
flist = mailimap_flag_list_new_empty();
mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
store_flags = mailimap_store_att_flags_new_set_flags(flist);
set = mailimap_set_new_interval( 1, last );
err = mailimap_store(m_imap,set,store_flags);
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
return 0;
}
qDebug("deleting mail: %s",m_imap->imap_response);
/* should we realy do that at this moment? */
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
return 0;
}
qDebug("Delete successfull %s",m_imap->imap_response);
return 1;
}
int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
{
if (folder.length()==0) return 0;
login();
if (!m_imap) {return 0;}
QString pre = account->getPrefix();
if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
pre+=delemiter;
}
if (parentfolder) {
pre += parentfolder->getDisplayName()+delemiter;
}
pre+=folder;
if (getsubfolder) {
if (delemiter.length()>0) {
pre+=delemiter;
} else {
Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
return 0;
}
}
qDebug("Creating %s",pre.latin1());
int res = mailimap_create(m_imap,pre.latin1());
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
int IMAPwrapper::deleteMbox(const FolderP&folder)
{
if (!folder) return 0;
login();
if (!m_imap) {return 0;}
int res = mailimap_delete(m_imap,folder->getName());
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
{
mailimap_status_att_list * att_list =0;
mailimap_mailbox_data_status * status=0;
clistiter * cur = 0;
int r = 0;
- int res = 0;
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
login();
if (!m_imap) {
return;
}
att_list = mailimap_status_att_list_new_empty();
if (!att_list) return;
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
for (cur = clist_begin(status->st_info_list);
cur != NULL ; cur = clist_next(cur)) {
mailimap_status_info * status_info;
status_info = (mailimap_status_info *)clist_content(cur);
switch (status_info->st_att) {
case MAILIMAP_STATUS_ATT_MESSAGES:
target_stat.message_count = status_info->st_value;
break;
case MAILIMAP_STATUS_ATT_RECENT:
target_stat.message_recent = status_info->st_value;
break;
case MAILIMAP_STATUS_ATT_UNSEEN:
target_stat.message_unseen = status_info->st_value;
break;
}
}
} else {
qDebug("Error retrieving status");
}
if (status) mailimap_mailbox_data_status_free(status);
if (att_list) mailimap_status_att_list_free(att_list);
}
void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
{
login();
if (!m_imap) return;
if (!msg) return;
int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
if (r != MAILIMAP_NO_ERROR) {
Global::statusMessage("Error storing mail!");
}
}
MAILLIB::ATYPE IMAPwrapper::getType()const
{
return account->getType();
}
const QString&IMAPwrapper::getName()const
{
qDebug("Get name: %s",account->getAccountName().latin1());
return account->getAccountName();
}
-encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
+encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
{
// dummy
QValueList<int> path;
return fetchRawPart(mail,path,false);
}
void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
if (targetWrapper != this) {
AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
qDebug("Using generic");
return;
}
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
int err = selectMbox(fromFolder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
int last = m_imap->imap_selection_info->sel_exists;
set = mailimap_set_new_interval( 1, last );
err = mailimap_copy(m_imap,set,targetFolder.latin1());
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
qDebug(error_msg);
return;
}
if (moveit) {
deleteAllMail(fromFolder);
}
}
-void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
if (targetWrapper != this) {
qDebug("Using generic");
AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
return;
}
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
- int err = selectMbox(mail.getMbox());
+ int err = selectMbox(mail->getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
- set = mailimap_set_new_single(mail.getNumber());
+ set = mailimap_set_new_single(mail->getNumber());
err = mailimap_copy(m_imap,set,targetFolder.latin1());
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
qDebug(error_msg);
return;
}
if (moveit) {
deleteMail(mail);
}
}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 15f049f..3bd5967 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,80 +1,80 @@
#ifndef __IMAPWRAPPER
#define __IMAPWRAPPER
#include <qlist.h>
#include "mailwrapper.h"
#include "abstractmail.h"
#include <libetpan/clist.h>
struct mailimap;
struct mailimap_body;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class encodedString;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
- virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders();
+ virtual void listMessages(const QString & mailbox,QValueList<Opie::OSmartPointer<RecMail> >&target );
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
- virtual void deleteMail(const RecMail&mail);
- virtual void answeredMail(const RecMail&mail);
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&folder);
+ virtual void deleteMail(const RecMailP&mail);
+ virtual void answeredMail(const RecMailP&mail);
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual RecBody fetchBody(const RecMail&mail);
- virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
- virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
- virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
- virtual encodedString* fetchRawBody(const RecMail&mail);
+ virtual RecBody fetchBody(const RecMailP&mail);
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
+ virtual encodedString* fetchRawBody(const RecMailP&mail);
- virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0,
+ virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0,
const QString& delemiter="/",bool getsubfolder=false);
- virtual int deleteMbox(const Opie::osmart_pointer<Folder>&folder);
+ virtual int deleteMbox(const Opie::OSmartPointer<Folder>&folder);
static void imap_progress( size_t current, size_t maximum );
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
bool start_tls(bool force=true);
- virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
- virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
+ virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
+ virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call);
int selectMbox(const QString&mbox);
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
- void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
+ void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
IMAPaccount *account;
mailimap *m_imap;
QString m_Lastmbox;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index 49b3caa..7dd7e58 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,107 +1,107 @@
#include "mailtypes.h"
#include <stdlib.h>
RecMail::RecMail()
- :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
+ :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
- :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
+ :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
{
init();
copy_old(old);
qDebug("Copy constructor RecMail");
}
RecMail::~RecMail()
{
wrapper = 0;
}
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
wrapper = old.wrapper;
in_reply_to = old.in_reply_to;
references = old.references;
replyto = old.replyto;
}
void RecMail::init()
{
to.clear();
cc.clear();
bcc.clear();
in_reply_to.clear();
references.clear();
wrapper = 0;
}
void RecMail::setWrapper(AbstractMail*awrapper)
{
wrapper = awrapper;
}
AbstractMail* RecMail::Wrapper()
{
return wrapper;
}
void RecMail::setTo(const QStringList&list)
{
to = list;
}
const QStringList&RecMail::To()const
{
return to;
}
void RecMail::setCC(const QStringList&list)
{
cc = list;
}
const QStringList&RecMail::CC()const
{
return cc;
}
void RecMail::setBcc(const QStringList&list)
{
bcc = list;
}
const QStringList& RecMail::Bcc()const
{
return bcc;
}
void RecMail::setInreply(const QStringList&list)
{
in_reply_to = list;
}
const QStringList& RecMail::Inreply()const
{
return in_reply_to;
}
void RecMail::setReferences(const QStringList&list)
{
references = list;
}
const QStringList& RecMail::References()const
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 10d367f..dc10de6 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -1,177 +1,180 @@
#ifndef __MAIL_TYPES_H
#define __MAIL_TYPES_H
#define FLAG_ANSWERED 0
#define FLAG_FLAGGED 1
#define FLAG_DELETED 2
#define FLAG_SEEN 3
#define FLAG_DRAFT 4
#define FLAG_RECENT 5
+#include <opie2/osmartpointer.h>
+
#include <qbitarray.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qmap.h>
#include <qvaluelist.h>
class AbstractMail;
/* a class to describe mails in a mailbox */
/* Attention!
From programmers point of view it would make sense to
store the mail body into this class, too.
But: not from the point of view of the device.
Mailbodies can be real large. So we request them when
needed from the mail-wrapper class direct from the server itself
(imap) or from a file-based cache (pop3?)
So there is no interface "const QString&body()" but you should
make a request to the mailwrapper with this class as parameter to
get the body. Same words for the attachments.
*/
-class RecMail
+class RecMail:public Opie::ORefCount
{
public:
RecMail();
RecMail(const RecMail&old);
virtual ~RecMail();
- const int getNumber()const{return msg_number;}
- void setNumber(int number){msg_number=number;}
+ const unsigned int getNumber()const{return msg_number;}
+ void setNumber(unsigned int number){msg_number=number;}
const QString&getDate()const{ return date; }
void setDate( const QString&a ) { date = a; }
const QString&getFrom()const{ return from; }
void setFrom( const QString&a ) { from = a; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getMbox()const{return mbox;}
void setMbox(const QString&box){mbox = box;}
void setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
- void setMsgsize(int size){msg_size = size;}
- const int Msgsize()const{return msg_size;}
+ void setMsgsize(unsigned int size){msg_size = size;}
+ const unsigned int Msgsize()const{return msg_size;}
void setTo(const QStringList&list);
const QStringList&To()const;
void setCC(const QStringList&list);
const QStringList&CC()const;
void setBcc(const QStringList&list);
const QStringList&Bcc()const;
void setInreply(const QStringList&list);
const QStringList&Inreply()const;
void setReferences(const QStringList&list);
const QStringList&References()const;
const QBitArray&getFlags()const{return msg_flags;}
void setFlags(const QBitArray&flags){msg_flags = flags;}
void setWrapper(AbstractMail*wrapper);
AbstractMail* Wrapper();
protected:
QString subject,date,from,mbox,msg_id,replyto;
- int msg_number,msg_size;
+ unsigned int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc,in_reply_to,references;
AbstractMail*wrapper;
void init();
void copy_old(const RecMail&old);
};
+typedef Opie::OSmartPointer<RecMail> RecMailP;
typedef QMap<QString,QString> part_plist_t;
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding,m_description;
unsigned int m_lines,m_size;
part_plist_t m_Parameters;
/* describes the position in the mail */
QValueList<int> m_poslist;
public:
RecPart();
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
void setIdentifier(const QString&identifier);
const QString&Encoding()const;
void setEncoding(const QString&encoding);
const QString&Description()const;
void setDescription(const QString&desc);
void setLines(unsigned int lines);
const unsigned int Lines()const;
void setSize(unsigned int size);
const unsigned int Size()const;
void setParameters(const part_plist_t&list);
const part_plist_t&Parameters()const;
void addParameter(const QString&key,const QString&value);
const QString searchParamter(const QString&key)const;
void setPositionlist(const QValueList<int>&poslist);
const QValueList<int>& Positionlist()const;
};
class RecBody
{
protected:
QString m_BodyText;
QValueList<RecPart> m_PartsList;
RecPart m_description;
public:
RecBody();
virtual ~RecBody();
void setBodytext(const QString&);
const QString& Bodytext()const;
void setDescription(const RecPart&des);
const RecPart& Description()const;
void setParts(const QValueList<RecPart>&parts);
const QValueList<RecPart>& Parts()const;
void addPart(const RecPart&part);
};
class encodedString
{
public:
encodedString();
/*
creates an new content string.
it makes a deep copy of it!
*/
encodedString(const char*nContent,unsigned int length);
/*
Take over the nContent. Means: it will just copy the pointer, not the content.
so make sure: No one else frees the string, the string has allocated with
malloc for compatibility with c-based libs
*/
encodedString(char*nContent,unsigned int nSize);
/* copy construkor - makes ALWAYS a deep copy!!!! */
encodedString(const encodedString&old);
/* assign operator - makes ALWAYS a deep copy!!!! */
encodedString& operator=(const encodedString&old);
/* destructor - cleans the content */
virtual ~encodedString();
/* returns a pointer to the content - do not delete yoursel! */
const char*Content()const;
/* returns the lengths of the content 'cause it must not be a null-terminated string! */
const int Length()const;
/*
makes a deep copy of nContent!
*/
void setContent(const char*nContent,int nSize);
/*
Take over the nContent. Means: it will just copy the pointer, not the content.
so make sure: No one else frees the string, the string has allocated with
malloc for compatibility with c-based libs
*/
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index c71d69f..9bf2fd3 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -62,117 +62,117 @@ IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no
}
IMAPFolder::~IMAPFolder()
{
}
static unsigned char base64chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
/**
* Decodes base64 encoded parts of the imapfolder name
* Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc
*/
QString IMAPFolder::decodeFolderName( const QString &name )
{
unsigned char c, i, bitcount;
unsigned long ucs4, utf16, bitbuf;
unsigned char base64[256], utf8[6];
unsigned long srcPtr = 0;
QCString dst = "";
QCString src = name.ascii();
/* initialize modified base64 decoding table */
memset(base64, UNDEFINED, sizeof(base64));
for (i = 0; i < sizeof(base64chars); ++i) {
base64[(int)base64chars[i]] = i;
}
/* loop until end of string */
while (srcPtr < src.length ()) {
c = src[srcPtr++];
/* deal with literal characters and &- */
if (c != '&' || src[srcPtr] == '-') {
/* encode literally */
dst += c;
/* skip over the '-' if this is an &- sequence */
if (c == '&')
srcPtr++;
} else {
/* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */
bitbuf = 0;
bitcount = 0;
ucs4 = 0;
while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) {
++srcPtr;
bitbuf = (bitbuf << 6) | c;
bitcount += 6;
/* enough bits for a UTF-16 character? */
if (bitcount >= 16) {
bitcount -= 16;
utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff;
/* convert UTF16 to UCS4 */
if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) {
ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT;
continue;
} else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) {
ucs4 += utf16 - UTF16LOSTART + UTF16BASE;
} else {
ucs4 = utf16;
}
/* convert UTF-16 range of UCS4 to UTF-8 */
if (ucs4 <= 0x7fUL) {
utf8[0] = ucs4;
i = 1;
} else if (ucs4 <= 0x7ffUL) {
utf8[0] = 0xc0 | (ucs4 >> 6);
utf8[1] = 0x80 | (ucs4 & 0x3f);
i = 2;
} else if (ucs4 <= 0xffffUL) {
utf8[0] = 0xe0 | (ucs4 >> 12);
utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[2] = 0x80 | (ucs4 & 0x3f);
i = 3;
} else {
utf8[0] = 0xf0 | (ucs4 >> 18);
utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f);
utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f);
utf8[3] = 0x80 | (ucs4 & 0x3f);
i = 4;
}
/* copy it */
for (c = 0; c < i; ++c) {
dst += utf8[c];
}
}
}
/* skip over trailing '-' in modified UTF-7 encoding */
if (src[srcPtr] == '-')
++srcPtr;
}
}
return QString::fromUtf8( dst.data() );
}
Mail::Mail()
- :Opie::oref_count(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
+ :Opie::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
{
}
MHFolder::MHFolder(const QString&disp_name,const QString&mbox)
: Folder( disp_name,"/" )
{
separator = "/";
name = mbox;
if (!disp_name.startsWith("/") && disp_name.length()>0)
name+="/";
name+=disp_name;
if (disp_name.length()==0) {
nameDisplay = separator;
}
prefix = mbox;
}
MHFolder::~MHFolder()
{
}
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h
index 3b3bb32..6bf0078 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -1,106 +1,106 @@
#ifndef MAILWRAPPER_H
#define MAILWRAPPER_H
#include <qpe/applnk.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include "settings.h"
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
class Attachment
{
public:
Attachment( DocLnk lnk );
virtual ~Attachment(){}
const QString getFileName()const{ return doc.file(); }
const QString getName()const{ return doc.name(); }
const QString getMimeType()const{ return doc.type(); }
const QPixmap getPixmap()const{ return doc.pixmap(); }
const int getSize()const { return size; }
DocLnk getDocLnk() { return doc; }
protected:
DocLnk doc;
int size;
};
-class Mail:public Opie::oref_count
+class Mail:public Opie::ORefCount
{
public:
Mail();
/* Possible that this destructor must not be declared virtual
* 'cause it seems that it will never have some child classes.
* in this case this object will not get a virtual table -> memory and
* speed will be a little bit better?
*/
virtual ~Mail(){}
void addAttachment( Attachment *att ) { attList.append( att ); }
const QList<Attachment>& getAttachments()const { return attList; }
void removeAttachment( Attachment *att ) { attList.remove( att ); }
const QString&getName()const { return name; }
void setName( QString s ) { name = s; }
const QString&getMail()const{ return mail; }
void setMail( const QString&s ) { mail = s; }
const QString&getTo()const{ return to; }
void setTo( const QString&s ) { to = s; }
const QString&getCC()const{ return cc; }
void setCC( const QString&s ) { cc = s; }
const QString&getBCC()const { return bcc; }
void setBCC( const QString&s ) { bcc = s; }
const QString&getMessage()const { return message; }
void setMessage( const QString&s ) { message = s; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getReply()const{ return reply; }
void setReply( const QString&a ) { reply = a; }
void setInreply(const QStringList&list){m_in_reply_to = list;}
const QStringList&Inreply()const{return m_in_reply_to;}
private:
QList<Attachment> attList;
QString name, mail, to, cc, bcc, reply, subject, message;
QStringList m_in_reply_to;
};
-class Folder:public Opie::oref_count
+class Folder:public Opie::ORefCount
{
public:
Folder( const QString&init_name,const QString&sep );
virtual ~Folder();
const QString&getDisplayName()const { return nameDisplay; }
const QString&getName()const { return name; }
const QString&getPrefix()const{return prefix; }
virtual bool may_select()const{return true;}
virtual bool no_inferior()const{return true;}
const QString&Separator()const;
protected:
QString nameDisplay, name, separator,prefix;
};
-typedef Opie::osmart_pointer<Folder> FolderP;
+typedef Opie::OSmartPointer<Folder> FolderP;
class MHFolder : public Folder
{
public:
MHFolder(const QString&disp_name,const QString&mbox);
virtual ~MHFolder();
};
class IMAPFolder : public Folder
{
public:
IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
virtual ~IMAPFolder();
virtual bool may_select()const{return m_MaySelect;}
virtual bool no_inferior()const{return m_NoInferior;}
private:
static QString decodeFolderName( const QString &name );
bool m_MaySelect,m_NoInferior;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 9ff3de2..5e6b714 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -1,330 +1,331 @@
#include "mboxwrapper.h"
#include "mailtypes.h"
#include "mailwrapper.h"
#include <libetpan/libetpan.h>
#include <qdir.h>
#include <stdlib.h>
#include <qpe/global.h>
MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name)
: Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name)
{
QDir dir(MBOXPath);
if (!dir.exists()) {
dir.mkdir(MBOXPath);
}
}
MBOXwrapper::~MBOXwrapper()
{
}
-void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
+void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target )
{
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
p+=mailbox;
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
qDebug("Error initializing mbox");
mailfolder_free(folder);
mailstorage_free(storage);
return;
}
parseList(target,folder->fld_session,mailbox);
mailfolder_disconnect(folder);
mailfolder_free(folder);
mailstorage_free(storage);
Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
}
-QValueList<Opie::osmart_pointer<Folder> >* MBOXwrapper::listFolders()
+QValueList<Opie::OSmartPointer<Folder> >* MBOXwrapper::listFolders()
{
- QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >();
+ QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >();
QDir dir(MBOXPath);
if (!dir.exists()) return folders;
dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable);
QStringList entries = dir.entryList();
QStringList::ConstIterator it = entries.begin();
for (;it!=entries.end();++it) {
FolderP inb=new Folder(*it,"/");
folders->append(inb);
}
return folders;
}
-void MBOXwrapper::deleteMail(const RecMail&mail)
+void MBOXwrapper::deleteMail(const RecMailP & mail)
{
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
- p+=mail.getMbox();
+ p+=mail->getMbox();
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
qDebug("Error initializing mbox");
mailfolder_free(folder);
mailstorage_free(storage);
return;
}
- r = mailsession_remove_message(folder->fld_session,mail.getNumber());
+ r = mailsession_remove_message(folder->fld_session,mail->getNumber());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail");
}
mailfolder_free(folder);
mailstorage_free(storage);
}
-void MBOXwrapper::answeredMail(const RecMail&)
+void MBOXwrapper::answeredMail(const RecMailP&)
{
}
-RecBody MBOXwrapper::fetchBody( const RecMail &mail )
+RecBody MBOXwrapper::fetchBody( const RecMailP &mail )
{
RecBody body;
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
- p+=mail.getMbox();
+ p+=mail->getMbox();
mailmessage * msg;
char*data=0;
size_t size;
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
qDebug("Error initializing mbox");
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
- r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
+ r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ qDebug("Error fetching mail %i",mail->getNumber());
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
r = mailmessage_fetch(msg,&data,&size);
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ qDebug("Error fetching mail %i",mail->getNumber());
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return body;
}
body = parseMail(msg);
mailmessage_fetch_result_free(msg,data);
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
{
qDebug("MBOX %i von %i",current,maximum);
}
int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool )
{
QString p = MBOXPath+"/";
p+=folder;
QFileInfo fi(p);
if (fi.exists()) {
Global::statusMessage(tr("Mailbox exists."));
return 0;
}
mailmbox_folder*f = 0;
if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error init folder"));
return 0;
}
if (f) mailmbox_done(f);
return 1;
}
void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
{
QString p = MBOXPath+"/";
p+=folder;
mailmbox_folder*f = 0;
int r = mailmbox_init(p.latin1(),0,1,0,&f);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error init folder"));
return;
}
r = mailmbox_append_message(f,msg,length);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error writing to message folder"));
}
mailmbox_done(f);
}
-encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail)
+encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail)
{
RecBody body;
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
- p+=mail.getMbox();
+ p+=mail->getMbox();
mailmessage * msg;
char*data=0;
size_t size;
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error initializing mbox"));
mailfolder_free(folder);
mailstorage_free(storage);
return 0;
}
- r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
+ r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
- Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
mailfolder_free(folder);
mailstorage_free(storage);
return 0;
}
r = mailmessage_fetch(msg,&data,&size);
if (r != MAIL_NO_ERROR) {
- Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return 0;
}
encodedString*result = new encodedString(data,size);
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return result;
}
-void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
+void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
{
QString p = MBOXPath+"/";
p+=mailbox;
mailmbox_folder*f = 0;
int r = mailmbox_init(p.latin1(),0,1,0,&f);
if (r != MAIL_NO_ERROR) {
qDebug("Error init folder");
return;
}
deleteMails(f,target);
mailmbox_done(f);
}
-void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
+void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target)
{
if (!f) return;
int r;
- for (unsigned int i=0; i < target.count();++i) {
- r = mailmbox_delete_msg(f,target.at(i)->getNumber());
+ QValueList<RecMailP>::ConstIterator it;
+ for (it=target.begin(); it != target.end();++it) {
+ r = mailmbox_delete_msg(f,(*it)->getNumber());
if (r!=MAILMBOX_NO_ERROR) {
qDebug("error delete mail");
}
}
r = mailmbox_expunge(f);
if (r != MAILMBOX_NO_ERROR) {
qDebug("error expunge mailbox");
}
}
int MBOXwrapper::deleteAllMail(const FolderP&tfolder)
{
if (!tfolder) return 0;
QString p = MBOXPath+"/"+tfolder->getDisplayName();
int res = 1;
mailfolder*folder = 0;
mailmessage_list*l=0;
mailstorage*storage = mailstorage_new(NULL);
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error initializing mbox"));
res = 0;
}
if (res) {
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error initializing mbox"));
res = 0;
}
}
if (res) {
r = mailsession_get_messages_list(folder->fld_session,&l);
if (r != MAIL_NO_ERROR) {
qDebug("Error message list");
res=0;
}
}
for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
r = mailsession_remove_message(folder->fld_session,i+1);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
res = 0;
break;
}
}
if (l) mailmessage_list_free(l);
if (folder) mailfolder_free(folder);
if (storage) mailstorage_free(storage);
return res;
}
int MBOXwrapper::deleteMbox(const FolderP&tfolder)
{
if (!tfolder) return 0;
QString p = MBOXPath+"/"+tfolder->getDisplayName();
QFile fi(p);
if (!fi.exists()) {
Global::statusMessage(tr("Mailbox doesn't exist."));
return 0;
}
if (!fi.remove()) {
Global::statusMessage(tr("Error deleting Mailbox."));
return 0;
}
return 1;
}
void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
{
mailfolder*folder = 0;
mailstorage*storage = mailstorage_new(NULL);
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
QString p = MBOXPath+"/"+mailbox;
QFile fi(p);
if (!fi.exists()) {
Global::statusMessage(tr("Mailbox doesn't exist."));
return;
}
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
if (folder) mailfolder_free(folder);
if (storage) mailstorage_free(storage);
}
MAILLIB::ATYPE MBOXwrapper::getType()const
{
return MAILLIB::A_MBOX;
}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index c3d9b50..33eeb1e 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -1,48 +1,46 @@
#ifndef __MBOX_WRAPPER_H
#define __MBOX_WRAPPER_H
#include "genericwrapper.h"
#include <qstring.h>
-class RecMail;
-class RecBody;
class encodedString;
struct mailmbox_folder;
class MBOXwrapper : public Genericwrapper
{
Q_OBJECT
public:
MBOXwrapper(const QString & dir,const QString&name);
virtual ~MBOXwrapper();
- virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
+ virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target );
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders();
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
- virtual void deleteMail(const RecMail&mail);
- virtual void answeredMail(const RecMail&mail);
+ virtual void deleteMail(const RecMailP&mail);
+ virtual void answeredMail(const RecMailP&mail);
- virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0,
+ virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0,
const QString&d="",bool s=false);
- virtual int deleteMbox(const Opie::osmart_pointer<Folder>&);
+ virtual int deleteMbox(const Opie::OSmartPointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual RecBody fetchBody( const RecMail &mail );
+ virtual RecBody fetchBody( const RecMailP &mail );
static void mbox_progress( size_t current, size_t maximum );
- virtual encodedString* fetchRawBody(const RecMail&mail);
- virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
+ virtual encodedString* fetchRawBody(const RecMailP&mail);
+ virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target);
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
protected:
- static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
+ static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target);
QString MBOXPath;
QString MBOXName;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index aaaa20a..0b00a2e 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -1,443 +1,441 @@
#include "mhwrapper.h"
#include "mailtypes.h"
#include "mailwrapper.h"
#include <libetpan/libetpan.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <stdlib.h>
#include <qpe/global.h>
#include <opie2/oprocess.h>
MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
: Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
{
if (MHPath.length()>0) {
if (MHPath[MHPath.length()-1]=='/') {
MHPath=MHPath.left(MHPath.length()-1);
}
qDebug(MHPath);
QDir dir(MHPath);
if (!dir.exists()) {
dir.mkdir(MHPath);
}
init_storage();
}
}
void MHwrapper::init_storage()
{
int r;
QString pre = MHPath;
if (!m_storage) {
m_storage = mailstorage_new(NULL);
r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0);
if (r != MAIL_NO_ERROR) {
qDebug("error initializing storage");
mailstorage_free(m_storage);
m_storage = 0;
return;
}
}
r = mailstorage_connect(m_storage);
if (r!=MAIL_NO_ERROR) {
qDebug("error connecting storage");
mailstorage_free(m_storage);
m_storage = 0;
}
}
void MHwrapper::clean_storage()
{
if (m_storage) {
mailstorage_disconnect(m_storage);
mailstorage_free(m_storage);
m_storage = 0;
}
}
MHwrapper::~MHwrapper()
{
clean_storage();
}
-void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
+void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target )
{
init_storage();
if (!m_storage) {
return;
}
QString f = buildPath(mailbox);
int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("listMessages: error selecting folder!");
return;
}
parseList(target,m_storage->sto_session,f);
Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
}
-QValueList<Opie::osmart_pointer<Folder> >* MHwrapper::listFolders()
+QValueList<Opie::OSmartPointer<Folder> >* MHwrapper::listFolders()
{
- QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >();
+ QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >();
/* this is needed! */
if (m_storage) mailstorage_disconnect(m_storage);
init_storage();
if (!m_storage) {
return folders;
}
mail_list*flist = 0;
clistcell*current=0;
int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
if (r != MAIL_NO_ERROR || !flist) {
qDebug("error getting folder list");
return folders;
}
for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
QString t = (char*)current->data;
t.replace(0,MHPath.length(),"");
folders->append(new MHFolder(t,MHPath));
}
mail_list_free(flist);
return folders;
}
-void MHwrapper::deleteMail(const RecMail&mail)
+void MHwrapper::deleteMail(const RecMailP&mail)
{
init_storage();
if (!m_storage) {
return;
}
- int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1());
+ int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("error selecting folder!");
return;
}
- r = mailsession_remove_message(m_storage->sto_session,mail.getNumber());
+ r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail");
}
}
-void MHwrapper::answeredMail(const RecMail&)
+void MHwrapper::answeredMail(const RecMailP&)
{
}
-RecBody MHwrapper::fetchBody( const RecMail &mail )
+RecBody MHwrapper::fetchBody( const RecMailP &mail )
{
RecBody body;
init_storage();
if (!m_storage) {
return body;
}
mailmessage * msg;
char*data=0;
- size_t size;
/* mail should hold the complete path! */
- int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1());
+ int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
if (r != MAIL_NO_ERROR) {
return body;
}
- r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg);
+ r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ qDebug("Error fetching mail %i",mail->getNumber());
return body;
}
body = parseMail(msg);
mailmessage_fetch_result_free(msg,data);
return body;
}
void MHwrapper::mbox_progress( size_t current, size_t maximum )
{
qDebug("MH %i von %i",current,maximum);
}
QString MHwrapper::buildPath(const QString&p)
{
QString f="";
if (p.length()==0||p=="/")
return MHPath;
if (!p.startsWith(MHPath)) {
f+=MHPath;
}
if (!p.startsWith("/")) {
f+="/";
}
f+=p;
return f;
}
int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool )
{
init_storage();
if (!m_storage) {
return 0;
}
QString f;
if (!pfolder) {
// toplevel folder
f = buildPath(folder);
} else {
f = pfolder->getName();
f+="/";
f+=folder;
}
qDebug(f);
int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
if (r != MAIL_NO_ERROR) {
qDebug("error creating folder %i",r);
return 0;
}
qDebug("Folder created");
return 1;
}
void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
{
init_storage();
if (!m_storage) {
return;
}
QString f = buildPath(Folder);
int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("error selecting folder!");
return;
}
r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
if (r!=MAIL_NO_ERROR) {
qDebug("error storing mail");
}
return;
}
-encodedString* MHwrapper::fetchRawBody(const RecMail&mail)
+encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
{
encodedString*result = 0;
init_storage();
if (!m_storage) {
return result;
}
mailmessage * msg = 0;
char*data=0;
size_t size;
- int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1());
+ int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("error selecting folder!");
return result;
}
- r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg);
+ r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
- Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
return 0;
}
r = mailmessage_fetch(msg,&data,&size);
if (r != MAIL_NO_ERROR) {
- Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
if (msg) mailmessage_free(msg);
return 0;
}
result = new encodedString(data,size);
if (msg) mailmessage_free(msg);
return result;
}
-void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
+void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
{
QString f = buildPath(mailbox);
int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("deleteMails: error selecting folder!");
return;
}
- RecMail*c = 0;
- for (unsigned int i=0; i < target.count();++i) {
- c = target.at(i);
- r = mailsession_remove_message(m_storage->sto_session,c->getNumber());
+ QValueList<RecMailP>::ConstIterator it;
+ for (it=target.begin(); it!=target.end();++it) {
+ r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail");
break;
}
}
}
int MHwrapper::deleteAllMail(const FolderP&tfolder)
{
init_storage();
if (!m_storage) {
return 0;
}
int res = 1;
if (!tfolder) return 0;
int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("error selecting folder!");
return 0;
}
mailmessage_list*l=0;
r = mailsession_get_messages_list(m_storage->sto_session,&l);
if (r != MAIL_NO_ERROR) {
qDebug("Error message list");
res = 0;
}
unsigned j = 0;
for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
mailmessage * msg;
msg = (mailmessage*)carray_get(l->msg_tab, i);
j = msg->msg_index;
r = mailsession_remove_message(m_storage->sto_session,j);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
res = 0;
break;
}
}
if (l) mailmessage_list_free(l);
return res;
}
int MHwrapper::deleteMbox(const FolderP&tfolder)
{
init_storage();
if (!m_storage) {
return 0;
}
if (!tfolder) return 0;
if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0;
int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail box");
return 0;
}
QString cmd = "rm -rf "+tfolder->getName();
QStringList command;
command << "/bin/sh";
command << "-c";
command << cmd.latin1();
OProcess *process = new OProcess();
connect(process, SIGNAL(processExited(OProcess*)),
this, SLOT( processEnded(OProcess*)));
connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)),
this, SLOT( oprocessStderr(OProcess*,char*,int)));
*process << command;
removeMboxfailed = false;
if(!process->start(OProcess::Block, OProcess::All) ) {
qDebug("could not start process");
return 0;
}
qDebug("mail box deleted");
return 1;
}
void MHwrapper::processEnded(OProcess *p)
{
if (p) delete p;
}
void MHwrapper::oprocessStderr(OProcess*, char *buffer, int )
{
QString lineStr = buffer;
QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") );
removeMboxfailed = true;
}
void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
{
init_storage();
if (!m_storage) {
return;
}
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
QString f = buildPath(mailbox);
int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error retrieving status"));
}
}
MAILLIB::ATYPE MHwrapper::getType()const
{
return MAILLIB::A_MH;
}
const QString&MHwrapper::getName()const
{
return MHName;
}
-void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
init_storage();
if (!m_storage) {
return;
}
if (targetWrapper != this) {
qDebug("Using generic");
Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit);
return;
}
qDebug("Using internal routines for move/copy");
QString tf = buildPath(targetFolder);
- int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1());
+ int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
if (r != MAIL_NO_ERROR) {
qDebug("Error selecting source mailbox");
return;
}
if (moveit) {
- r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1());
+ r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
} else {
- r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1());
+ r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
}
if (r != MAIL_NO_ERROR) {
qDebug("Error copy/moving mail internal (%i)",r);
}
}
void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
init_storage();
if (!m_storage) {
return;
}
if (targetWrapper != this) {
qDebug("Using generic");
Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
return;
}
if (!fromFolder) return;
int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1());
if (r!=MAIL_NO_ERROR) {
qDebug("error selecting source folder!");
return;
}
QString tf = buildPath(targetFolder);
mailmessage_list*l=0;
r = mailsession_get_messages_list(m_storage->sto_session,&l);
if (r != MAIL_NO_ERROR) {
qDebug("Error message list");
}
unsigned j = 0;
for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) {
mailmessage * msg;
msg = (mailmessage*)carray_get(l->msg_tab, i);
j = msg->msg_index;
if (moveit) {
r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1());
} else {
r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1());
}
if (r != MAIL_NO_ERROR) {
qDebug("Error copy/moving mail internal (%i)",r);
break;
}
}
if (l) mailmessage_list_free(l);
}
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
index c7c8183..208cf2f 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -1,62 +1,60 @@
#ifndef __MH_WRAPPER_H
#define __MH_WRAPPER_H
#include "maildefines.h"
#include "genericwrapper.h"
#include <qstring.h>
-class RecMail;
-class RecBody;
class encodedString;
struct mailmbox_folder;
class OProcess;
class MHwrapper : public Genericwrapper
{
Q_OBJECT
public:
MHwrapper(const QString & dir,const QString&name);
virtual ~MHwrapper();
- virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target );
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders();
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
- virtual void deleteMail(const RecMail&mail);
- virtual void answeredMail(const RecMail&mail);
- virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ virtual void deleteMail(const RecMailP&mail);
+ virtual void answeredMail(const RecMailP&mail);
+ virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0,
+ virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0,
const QString&d="",bool s=false);
- virtual int deleteMbox(const Opie::osmart_pointer<Folder>&);
+ virtual int deleteMbox(const Opie::OSmartPointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual RecBody fetchBody( const RecMail &mail );
+ virtual RecBody fetchBody( const RecMailP &mail );
static void mbox_progress( size_t current, size_t maximum );
- virtual encodedString* fetchRawBody(const RecMail&mail);
- virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
+ virtual encodedString* fetchRawBody(const RecMailP&mail);
+ virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> > &target);
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
public slots:
/* for deleting maildirs we are using a system call */
virtual void oprocessStderr(OProcess*, char *buffer, int );
virtual void processEnded(OProcess *);
protected:
QString buildPath(const QString&p);
QString MHPath;
QString MHName;
void init_storage();
void clean_storage();
bool removeMboxfailed;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 2ec052c..c0b3eec 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -1,283 +1,283 @@
#include "nntpwrapper.h"
#include "logindialog.h"
#include "mailtypes.h"
#include <qfile.h>
#include <stdlib.h>
#include <libetpan/libetpan.h>
#define HARD_MSG_SIZE_LIMIT 5242880
NNTPwrapper::NNTPwrapper( NNTPaccount *a )
: Genericwrapper() {
account = a;
m_nntp = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
NNTPwrapper::~NNTPwrapper() {
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) {
qDebug( "NNTP: %i of %i", current, maximum );
}
-RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
+RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) {
int err = NEWSNNTP_NO_ERROR;
char *message = 0;
size_t length = 0;
login();
if ( !m_nntp ) {
return RecBody();
}
RecBody body;
mailmessage * mailmsg;
- if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
- qDebug("Message to large: %i",mail.Msgsize());
+ if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
+ qDebug("Message to large: %i",mail->Msgsize());
return body;
}
QFile msg_cache(msgTempName);
cleanMimeCache();
- if (mail.getNumber()!=last_msg_id) {
+ if (mail->getNumber()!=last_msg_id) {
if (msg_cache.exists()) {
msg_cache.remove();
}
msg_cache.open(IO_ReadWrite|IO_Truncate);
- last_msg_id = mail.getNumber();
- err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
+ last_msg_id = mail->getNumber();
+ err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg);
err = mailmessage_fetch(mailmsg,&message,&length);
msg_cache.writeBlock(message,length);
} else {
QString msg="";
msg_cache.open(IO_ReadOnly);
message = new char[4096];
memset(message,0,4096);
while (msg_cache.readBlock(message,4095)>0) {
msg+=message;
memset(message,0,4096);
}
delete message;
message = (char*)malloc(msg.length()+1*sizeof(char));
memset(message,0,msg.length()+1);
memcpy(message,msg.latin1(),msg.length());
/* transform to libetpan stuff */
mailmsg = mailmessage_new();
mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
generic_message_t * msg_data;
msg_data = (generic_message_t *)mailmsg->msg_data;
msg_data->msg_fetched = 1;
msg_data->msg_message = message;
msg_data->msg_length = strlen(message);
}
body = parseMail(mailmsg);
/* clean up */
if (mailmsg)
mailmessage_free(mailmsg);
if (message)
free(message);
return body;
}
-void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target )
+void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::OSmartPointer<RecMail> > &target )
{
login();
if (!m_nntp)
return;
uint32_t res_messages,res_recent,res_unseen;
mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
parseList(target,m_nntp->sto_session,which,true);
}
void NNTPwrapper::login()
{
if (account->getOffline())
return;
/* we'll hold the line */
if ( m_nntp != NULL )
return;
const char *server, *user, *pass;
QString User,Pass;
uint16_t port;
int err = NEWSNNTP_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = pass = 0;
if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
User = login.getUser().latin1();
Pass = login.getPassword().latin1();
} else {
// cancel
qDebug( "NNTP: Login canceled" );
return;
}
} else {
User = account->getUser().latin1();
Pass = account->getPassword().latin1();
}
if (User.isEmpty()) {
user=0;
pass = 0;
} else {
user=User.latin1();
pass=Pass.latin1();
}
// bool ssl = account->getSSL();
m_nntp=mailstorage_new(NULL);
int conntypeset = account->ConnectionType();
int conntype = 0;
if ( conntypeset == 3 ) {
conntype = CONNECTION_TYPE_COMMAND;
} else if ( conntypeset == 2 ) {
conntype = CONNECTION_TYPE_TLS;
} else if ( conntypeset == 1 ) {
conntype = CONNECTION_TYPE_STARTTLS;
} else if ( conntypeset == 0 ) {
conntype = CONNECTION_TYPE_TRY_STARTTLS;
}
nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
(char*)user,(char*)pass,0,0,0);
err = mailstorage_connect( m_nntp );
if (err != NEWSNNTP_NO_ERROR) {
qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
// Global::statusMessage(tr("Error initializing folder"));
mailstorage_free(m_nntp);
m_nntp = 0;
}
}
void NNTPwrapper::logout()
{
int err = NEWSNNTP_NO_ERROR;
if ( m_nntp == NULL )
return;
mailstorage_free(m_nntp);
m_nntp = 0;
}
-QValueList<Opie::osmart_pointer<Folder> >* NNTPwrapper::listFolders() {
+QValueList<Opie::OSmartPointer<Folder> >* NNTPwrapper::listFolders() {
- QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >();
+ QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >();
QStringList groups;
if (account) {
groups = account->getGroups();
}
for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) {
folders->append(new Folder((*it),"."));
}
return folders;
}
/* we made this method in raw nntp access of etpan and not via generic interface
* 'cause in that case there will be doubled copy operations. eg. the etpan would
* copy that stuff into its own structures and we must copy it into useable c++
* structures for our frontend. this would not make sense, so it is better to reimplement
* the stuff from generic interface of etpan but copy it direct to qt classes.
*/
QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) {
login();
QStringList res;
clist *result = 0;
clistcell *current = 0;
newsnntp_group_description *group;
if ( m_nntp ) {
mailsession * session = m_nntp->sto_session;
newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session;
int err = NEWSNNTP_NO_ERROR;
if (mask.isEmpty()) {
err = newsnntp_list(news, &result);
} else {
/* taken from generic wrapper of etpan */
QString nmask = mask+".*";
err = newsnntp_list_active(news, nmask.latin1(), &result);
}
if ( err == NEWSNNTP_NO_ERROR && result) {
for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) {
group = ( newsnntp_group_description* ) current->data;
if (!group||!group->grp_name||strlen(group->grp_name)==0) continue;
res.append(group->grp_name);
}
}
}
if (result) {
newsnntp_list_free(result);
}
return res;
}
-void NNTPwrapper::answeredMail(const RecMail&) {}
+void NNTPwrapper::answeredMail(const RecMailP&) {}
void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) {
login();
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
if (!m_nntp)
return;
int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
}
-encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) {
+encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) {
char*target=0;
size_t length=0;
encodedString*res = 0;
mailmessage * mailmsg = 0;
- int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
+ int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg);
err = mailmessage_fetch(mailmsg,&target,&length);
if (mailmsg)
mailmessage_free(mailmsg);
if (target) {
res = new encodedString(target,length);
}
return res;
}
MAILLIB::ATYPE NNTPwrapper::getType()const {
return account->getType();
}
const QString&NNTPwrapper::getName()const{
return account->getAccountName();
}
-void NNTPwrapper::deleteMail(const RecMail&) {
+void NNTPwrapper::deleteMail(const RecMailP&) {
}
int NNTPwrapper::deleteAllMail(const FolderP&) {
}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index d3a384a..a7e4b95 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -1,48 +1,48 @@
#ifndef __NNTPWRAPPER
#define __NNTPWRAPPER
#include "mailwrapper.h"
#include "genericwrapper.h"
#include <qstring.h>
#include <libetpan/clist.h>
class encodedString;
struct mailstorage;
struct mailfolder;
class NNTPwrapper : public Genericwrapper
{
Q_OBJECT
public:
NNTPwrapper( NNTPaccount *a );
virtual ~NNTPwrapper();
/* mailbox will be ignored */
- virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target );
/* should only get the subscribed one */
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
QStringList listAllNewsgroups(const QString&mask = QString::null);
- virtual void deleteMail(const RecMail&mail);
- virtual void answeredMail(const RecMail&mail);
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
+ virtual void deleteMail(const RecMailP&mail);
+ virtual void answeredMail(const RecMailP&mail);
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&);
- virtual RecBody fetchBody( const RecMail &mail );
- virtual encodedString* fetchRawBody(const RecMail&mail);
+ virtual RecBody fetchBody( const RecMailP &mail );
+ virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
static void nntp_progress( size_t current, size_t maximum );
protected:
void login();
NNTPaccount *account;
mailstorage* m_nntp;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 7bf7ed2..6737d6c 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,254 +1,256 @@
#include <stdlib.h>
#include "pop3wrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
#include <libetpan/libetpan.h>
#include <qpe/global.h>
#include <qfile.h>
//#include <qstring.h>
/* we don't fetch messages larger than 5 MB */
#define HARD_MSG_SIZE_LIMIT 5242880
POP3wrapper::POP3wrapper( POP3account *a )
: Genericwrapper() {
account = a;
m_pop3 = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
POP3wrapper::~POP3wrapper() {
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
qDebug( "POP3: %i of %i", current, maximum );
}
-RecBody POP3wrapper::fetchBody( const RecMail &mail ) {
+RecBody POP3wrapper::fetchBody( const RecMailP &mail ) {
int err = MAILPOP3_NO_ERROR;
char *message = 0;
size_t length = 0;
login();
if ( !m_pop3 ) {
return RecBody();
}
RecBody body;
mailmessage * mailmsg;
- if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
- qDebug("Message to large: %i",mail.Msgsize());
+ if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
+ qDebug("Message to large: %i",mail->Msgsize());
return body;
}
QFile msg_cache(msgTempName);
cleanMimeCache();
- if (mail.getNumber()!=last_msg_id) {
+ if (mail->getNumber()!=last_msg_id) {
if (msg_cache.exists()) {
msg_cache.remove();
}
msg_cache.open(IO_ReadWrite|IO_Truncate);
- last_msg_id = mail.getNumber();
- err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg);
+ last_msg_id = mail->getNumber();
+ err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
err = mailmessage_fetch(mailmsg,&message,&length);
msg_cache.writeBlock(message,length);
} else {
QString msg="";
msg_cache.open(IO_ReadOnly);
message = new char[4096];
memset(message,0,4096);
while (msg_cache.readBlock(message,4095)>0) {
msg+=message;
memset(message,0,4096);
}
delete message;
message = (char*)malloc(msg.length()+1*sizeof(char));
memset(message,0,msg.length()+1);
memcpy(message,msg.latin1(),msg.length());
/* transform to libetpan stuff */
mailmsg = mailmessage_new();
mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
generic_message_t * msg_data;
msg_data = (generic_message_t *)mailmsg->msg_data;
msg_data->msg_fetched = 1;
msg_data->msg_message = message;
msg_data->msg_length = strlen(message);
}
body = parseMail(mailmsg);
/* clean up */
if (mailmsg)
mailmessage_free(mailmsg);
if (message)
free(message);
return body;
}
-void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
+void POP3wrapper::listMessages(const QString &, QValueList<Opie::OSmartPointer<RecMail> > &target )
{
login();
if (!m_pop3)
return;
uint32_t res_messages,res_recent,res_unseen;
mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
parseList(target,m_pop3->sto_session,"INBOX");
Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
}
void POP3wrapper::login()
{
if (account->getOffline())
return;
/* we'll hold the line */
if ( m_pop3 != NULL )
return;
const char *server, *user, *pass;
uint16_t port;
int err = MAILPOP3_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
} else {
// cancel
qDebug( "POP3: Login canceled" );
return;
}
} else {
user = account->getUser().latin1();
pass = account->getPassword().latin1();
}
// bool ssl = account->getSSL();
m_pop3=mailstorage_new(NULL);
int conntypeset = account->ConnectionType();
int conntype = 0;
if ( conntypeset == 3 ) {
conntype = CONNECTION_TYPE_COMMAND;
} else if ( conntypeset == 2 ) {
conntype = CONNECTION_TYPE_TLS;
} else if ( conntypeset == 1 ) {
conntype = CONNECTION_TYPE_STARTTLS;
} else if ( conntypeset == 0 ) {
conntype = CONNECTION_TYPE_TRY_STARTTLS;
}
//(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
(char*)user,(char*)pass,0,0,0);
err = mailstorage_connect(m_pop3);
if (err != MAIL_NO_ERROR) {
qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
Global::statusMessage(tr("Error initializing folder"));
mailstorage_free(m_pop3);
m_pop3 = 0;
}
}
void POP3wrapper::logout()
{
- int err = MAILPOP3_NO_ERROR;
if ( m_pop3 == NULL )
return;
mailstorage_free(m_pop3);
m_pop3 = 0;
}
-QValueList<Opie::osmart_pointer<Folder> >* POP3wrapper::listFolders() {
- QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<FolderP>();
+QValueList<Opie::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
+ QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
FolderP inb=new Folder("INBOX","/");
folders->append(inb);
return folders;
}
-void POP3wrapper::deleteMail(const RecMail&mail) {
+void POP3wrapper::deleteMail(const RecMailP&mail) {
login();
if (!m_pop3)
return;
- int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber());
+ int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("error deleting mail"));
}
}
-void POP3wrapper::answeredMail(const RecMail&) {}
+void POP3wrapper::answeredMail(const RecMailP&) {}
int POP3wrapper::deleteAllMail(const FolderP&) {
login();
if (!m_pop3)
return 0;
int res = 1;
uint32_t result = 0;
int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error getting folder info"));
return 0;
}
for (unsigned int i = 0; i < result; ++i) {
err = mailsession_remove_message(m_pop3->sto_session,i+1);
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
res=0;
}
break;
}
return res;
}
void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
login();
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
if (!m_pop3)
return;
int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
+ if (r != MAIL_NO_ERROR) {
+ qDebug("error getting folter status.");
+ }
}
-encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) {
+encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) {
char*target=0;
size_t length=0;
encodedString*res = 0;
mailmessage * mailmsg = 0;
- int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg);
+ int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
err = mailmessage_fetch(mailmsg,&target,&length);
if (mailmsg)
mailmessage_free(mailmsg);
if (target) {
res = new encodedString(target,length);
}
return res;
}
MAILLIB::ATYPE POP3wrapper::getType()const {
return account->getType();
}
const QString&POP3wrapper::getName()const{
return account->getAccountName();
}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index e4afb94..31eb6f1 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,42 +1,42 @@
#ifndef __POP3WRAPPER
#define __POP3WRAPPER
#include "mailwrapper.h"
#include "genericwrapper.h"
#include <qstring.h>
class encodedString;
struct mailstorage;
struct mailfolder;
class POP3wrapper : public Genericwrapper
{
Q_OBJECT
public:
POP3wrapper( POP3account *a );
virtual ~POP3wrapper();
/* mailbox will be ignored */
- virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
- virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
+ virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target );
+ virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
- virtual void deleteMail(const RecMail&mail);
- virtual void answeredMail(const RecMail&mail);
- virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
+ virtual void deleteMail(const RecMailP&mail);
+ virtual void answeredMail(const RecMailP&mail);
+ virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&);
- virtual RecBody fetchBody( const RecMail &mail );
- virtual encodedString* fetchRawBody(const RecMail&mail);
+ virtual RecBody fetchBody( const RecMailP &mail );
+ virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
POP3account *account;
mailstorage*m_pop3;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index afc5618..86673aa 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -219,238 +219,236 @@ void SMTPwrapper::connect_server()
qDebug("Error init connection");
failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
result = 0;
}
/* switch to tls after init 'cause there it will send the ehlo */
if (result) {
err = mailsmtp_init( m_smtp );
if (err != MAILSMTP_NO_ERROR) {
result = 0;
failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
}
}
if (try_tls) {
err = start_smtp_tls();
if (err != MAILSMTP_NO_ERROR) {
try_tls = false;
} else {
err = mailesmtp_ehlo(m_smtp);
}
}
if (!try_tls && force_tls) {
result = 0;
failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err));
}
if (result==1 && m_SmtpAccount->getLogin() ) {
qDebug("smtp with auth");
if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
// get'em
LoginDialog login( m_SmtpAccount->getUser(),
m_SmtpAccount->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
} else {
result = 0;
failuretext=tr("Login aborted - storing mail to localfolder");
}
} else {
user = m_SmtpAccount->getUser().latin1();
pass = m_SmtpAccount->getPassword().latin1();
}
qDebug( "session->auth: %i", m_smtp->auth);
if (result) {
err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass );
if ( err == MAILSMTP_NO_ERROR ) {
qDebug("auth ok");
} else {
failuretext = tr("Authentification failed");
result = 0;
}
}
}
}
void SMTPwrapper::disc_server()
{
if (m_smtp) {
mailsmtp_quit( m_smtp );
mailsmtp_free( m_smtp );
m_smtp = 0;
}
}
int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
{
int err,result;
QString failuretext = "";
connect_server();
result = 1;
if (m_smtp) {
err = mailsmtp_send( m_smtp, from, rcpts, data, size );
if ( err != MAILSMTP_NO_ERROR ) {
failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err));
result = 0;
}
} else {
result = 0;
}
if (!result) {
storeFailedMail(data,size,failuretext);
} else {
qDebug( "Mail sent." );
storeMail(data,size,"Sent");
}
return result;
}
-void SMTPwrapper::sendMail(const Opie::osmart_pointer<Mail>&mail,bool later )
+void SMTPwrapper::sendMail(const Opie::OSmartPointer<Mail>&mail,bool later )
{
mailmime * mimeMail;
mimeMail = createMimeMail(mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later);
qDebug("Clean up done");
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
mailmime_free( mimeMail );
}
}
-int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) {
+int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
size_t curTok = 0;
mailimf_fields *fields = 0;
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
int res = 0;
- encodedString * data = wrap->fetchRawBody(*which);
+ encodedString * data = wrap->fetchRawBody(which);
if (!data)
return 0;
int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
if (err != MAILIMF_NO_ERROR) {
delete data;
delete wrap;
return 0;
}
rcpts = createRcptList( fields );
ffrom = getField(fields, MAILIMF_FIELD_FROM );
from = getFrom(ffrom);
if (rcpts && from) {
res = smtpSend(from,rcpts,data->Content(),data->Length());
}
if (fields) {
mailimf_fields_free(fields);
fields = 0;
}
if (data) {
delete data;
}
if (from) {
free(from);
}
if (rcpts) {
smtp_address_list_free( rcpts );
}
return res;
}
/* this is a special fun */
bool SMTPwrapper::flushOutbox() {
bool returnValue = true;
qDebug("Sending the queue");
if (!m_SmtpAccount) {
qDebug("No smtp account given");
return false;
}
bool reset_user_value = false;
QString localfolders = AbstractMail::defaultLocalfolder();
AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
if (!wrap) {
qDebug("memory error");
return false;
}
QString oldPw, oldUser;
- QList<RecMail> mailsToSend;
- QList<RecMail> mailsToRemove;
+ QValueList<RecMailP> mailsToSend;
+ QValueList<RecMailP> mailsToRemove;
QString mbox("Outgoing");
wrap->listMessages(mbox,mailsToSend);
if (mailsToSend.count()==0) {
delete wrap;
qDebug("No mails to send");
return false;
}
oldPw = m_SmtpAccount->getPassword();
oldUser = m_SmtpAccount->getUser();
if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) {
// get'em
QString user,pass;
LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
reset_user_value = true;
m_SmtpAccount->setUser(user);
m_SmtpAccount->setPassword(pass);
} else {
return true;
}
}
- mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(mailsToSend.count());
while (mailsToSend.count()>0) {
- if (sendQueuedMail(wrap,mailsToSend.at(0))==0) {
+ if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) {
QMessageBox::critical(0,tr("Error sending mail"),
tr("Error sending queued mail - breaking"));
returnValue = false;
break;
}
- mailsToRemove.append(mailsToSend.at(0));
- mailsToSend.removeFirst();
+ mailsToRemove.append((*mailsToSend.begin()));
+ mailsToSend.remove(mailsToSend.begin());
sendProgress->setCurrentMails(mailsToRemove.count());
}
if (reset_user_value) {
m_SmtpAccount->setUser(oldUser);
m_SmtpAccount->setPassword(oldPw);
}
Config cfg( "mail" );
cfg.setGroup( "Status" );
m_queuedMail = 0;
cfg.writeEntry( "outgoing", m_queuedMail );
emit queuedMails( m_queuedMail );
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
wrap->deleteMails(mbox,mailsToRemove);
- mailsToSend.setAutoDelete(true);
delete wrap;
return returnValue;
}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 08bde74..71ae35c 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -1,63 +1,63 @@
// -*- Mode: C++; -*-
#ifndef SMTPwrapper_H
#define SMTPwrapper_H
#include <qpe/applnk.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include <libetpan/clist.h>
#include "settings.h"
#include "generatemail.h"
-#include <opie2/osmart_pointer.h>
+#include <opie2/osmartpointer.h>
class SMTPaccount;
class AbstractMail;
class SMTPwrapper : public Generatemail
{
Q_OBJECT
public:
SMTPwrapper(SMTPaccount * aSmtp);
virtual ~SMTPwrapper();
- void sendMail(const Opie::osmart_pointer<Mail>& mail,bool later=false );
+ void sendMail(const Opie::OSmartPointer<Mail>& mail,bool later=false );
bool flushOutbox();
static progressMailSend*sendProgress;
signals:
void queuedMails( int );
protected:
mailsmtp *m_smtp;
SMTPaccount * m_SmtpAccount;
void connect_server();
void disc_server();
int start_smtp_tls();
void smtpSend( mailmime *mail,bool later);
static void storeMail(const char*mail, size_t length, const QString&box);
static QString mailsmtpError( int err );
static void progress( size_t current, size_t maximum );
int smtpSend(char*from,clist*rcpts,const char*data,size_t size);
void storeMail(mailmime*mail, const QString&box);
- int sendQueuedMail(AbstractMail*wrap,RecMail*which);
+ int sendQueuedMail(AbstractMail*wrap,const Opie::OSmartPointer<RecMail>&which);
void storeFailedMail(const char*data,unsigned int size, const char*failuremessage);
int m_queuedMail;
protected slots:
void emitQCop( int queued );
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp
index 052e0f1..595e7fc 100644
--- a/noncore/net/mail/libmailwrapper/storemail.cpp
+++ b/noncore/net/mail/libmailwrapper/storemail.cpp
@@ -1,90 +1,90 @@
#include "storemail.h"
#include "mailwrapper.h"
#include "settings.h"
#include "abstractmail.h"
#include <libetpan/libetpan.h>
#include <qstring.h>
#include <stdlib.h>
Storemail::Storemail(Account*aAccount,const QString&aFolder)
: Generatemail()
{
wrapper = 0;
m_Account = aAccount;
m_tfolder = aFolder;
wrapper = AbstractMail::getWrapper(m_Account);
if (wrapper) {
wrapper->createMbox(m_tfolder);
}
}
Storemail::Storemail(const QString&dir,const QString&aFolder)
: Generatemail()
{
wrapper = 0;
m_Account = 0;
m_tfolder = aFolder;
wrapper = AbstractMail::getWrapper(dir);
if (wrapper) {
wrapper->createMbox(m_tfolder);
}
}
Storemail::Storemail(const QString&aFolder)
: Generatemail()
{
wrapper = 0;
m_Account = 0;
m_tfolder = aFolder;
wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder());
if (wrapper) {
wrapper->createMbox(m_tfolder);
}
}
Storemail::~Storemail()
{
}
-int Storemail::storeMail(const Opie::osmart_pointer<Mail>&mail)
+int Storemail::storeMail(const Opie::OSmartPointer<Mail>&mail)
{
if (!wrapper) return 0;
int ret = 1;
mailmime * mimeMail = 0;
mimeMail = createMimeMail(mail );
if ( mimeMail == NULL ) {
qDebug( "storeMail: error creating mime mail" );
return 0;
}
char *data;
size_t size;
data = 0;
mailmessage * msg = 0;
msg = mime_message_init(mimeMail);
mime_message_set_tmpdir(msg,getenv( "HOME" ));
int r = mailmessage_fetch(msg,&data,&size);
mime_message_detach_mime(msg);
mailmessage_free(msg);
msg = 0;
if (r != MAIL_NO_ERROR || !data) {
qDebug("Error fetching mime...");
ret = 0;
}
if (ret) {
wrapper->storeMessage(data,size,m_tfolder);
}
if (data) {
free(data);
}
if (mimeMail) {
mailmime_free( mimeMail );
}
return ret;
}
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h
index 7d8ea3d..80c7431 100644
--- a/noncore/net/mail/libmailwrapper/storemail.h
+++ b/noncore/net/mail/libmailwrapper/storemail.h
@@ -1,29 +1,29 @@
#ifndef __STORE_MAIL_H
#define __STORE_MAIL_H
#include <qpe/applnk.h>
#include "generatemail.h"
class Account;
class Mail;
class AbstractMail;
class Storemail : public Generatemail
{
Q_OBJECT
public:
Storemail(Account*aAccount,const QString&aFolder);
Storemail(const QString&dir,const QString&aFolder);
Storemail(const QString&aFolder);
virtual ~Storemail();
- int storeMail(const Opie::osmart_pointer<Mail>&mail);
+ int storeMail(const Opie::OSmartPointer<Mail>&mail);
protected:
Account* m_Account;
QString m_tfolder;
AbstractMail*wrapper;
};
#endif
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp
index 75633ef..0b926da 100644
--- a/noncore/net/mail/mailistviewitem.cpp
+++ b/noncore/net/mail/mailistviewitem.cpp
@@ -1,72 +1,72 @@
#include "mailistviewitem.h"
#include <libmailwrapper/abstractmail.h>
#include <qtextstream.h>
#include <qpe/resource.h>
MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
:QListViewItem(parent,item),mail_data()
{
}
void MailListViewItem::showEntry()
{
- if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
+ if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
- } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
+ } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
/* I think it looks nicer if there are not such a log of icons but only on mails
replied or new - Alwin*/
//setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
} else {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
}
- double s = mail_data.Msgsize();
+ 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(1,mail_data->getSubject());
+ setText(2,mail_data->getFrom());
setText(3,fsize);
- setText(4,mail_data.getDate());
+ setText(4,mail_data->getDate());
}
-void MailListViewItem::storeData(const RecMail&data)
+void MailListViewItem::storeData(const RecMailP&data)
{
mail_data = data;
}
-const RecMail& MailListViewItem::data()const
+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();
+ if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED;
+ return mail_data->Wrapper()->getType();
}
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index f736de0..d953d83 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -1,23 +1,23 @@
#ifndef __MAILLISTVIEWITEM_H
#define __MAILLISTVIEWITEM_H
#include <qlistview.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/maildefines.h>
class MailListViewItem:public QListViewItem
{
public:
MailListViewItem(QListView * parent, MailListViewItem * after );
virtual ~MailListViewItem(){}
- void storeData(const RecMail&data);
- const RecMail&data()const;
+ void storeData(const RecMailP&data);
+ const RecMailP&data()const;
void showEntry();
MAILLIB::ATYPE wrapperType();
protected:
- RecMail mail_data;
+ RecMailP mail_data;
};
#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index bcf0866..c23ad3f 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -26,190 +26,191 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
addToolBar( toolBar );
toolBar->setHorizontalStretchable( true );
QLabel *spacer = new QLabel( toolBar );
spacer->setBackgroundMode( QWidget::PaletteButton );
toolBar->setStretchableWidget( spacer );
composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
0, 0, this );
composeMail->addTo( toolBar );
composeMail->addTo( mailMenu );
sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
0, 0, this );
sendQueued->addTo( toolBar );
sendQueued->addTo( mailMenu );
/*
syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
0, 0, this );
syncFolders->addTo( toolBar );
syncFolders->addTo( mailMenu );
*/
showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
0, 0, this, 0, true );
showFolders->addTo( toolBar );
showFolders->addTo( mailMenu );
showFolders->setOn( true );
connect(showFolders, SIGNAL( toggled(bool) ),
SLOT( slotShowFolders(bool) ) );
/*
searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ),
0, 0, this );
searchMails->addTo( toolBar );
searchMails->addTo( mailMenu );
*/
deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this);
deleteMails->addTo( toolBar );
deleteMails->addTo( mailMenu );
connect( deleteMails, SIGNAL( activated() ),
SLOT( slotDeleteMail() ) );
editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) ,
0, 0, this );
editSettings->addTo( settingsMenu );
connect( editSettings, SIGNAL( activated() ),
SLOT( slotEditSettings() ) );
editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
0, 0, this );
editAccounts->addTo( settingsMenu );
//setCentralWidget( view );
QVBox* wrapperBox = new QVBox( this );
setCentralWidget( wrapperBox );
QWidget *view = new QWidget( wrapperBox );
layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
folderView = new AccountView( view );
folderView->header()->hide();
folderView->setRootIsDecorated( true );
folderView->addColumn( tr( "Mailbox" ) );
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( tr( "" ) );
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->setSorting(-1);
statusWidget = new StatusWidget( wrapperBox );
statusWidget->hide();
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
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(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
+ 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&) ) );
#endif
QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
}
MainWindow::~MainWindow()
{
}
void MainWindow::appMessage(const QCString &, const QByteArray &)
{
qDebug("appMessage not reached");
}
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 )
{
qDebug( "slotShowFolders not reached" );
}
-void MainWindow::refreshMailView(QList<RecMail>*)
+void MainWindow::refreshMailView(const QValueList<RecMailP>&)
{
qDebug( "refreshMailView not reached" );
}
void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
{
qDebug( "mailLeftClicked not reached" );
}
void MainWindow::displayMail()
{
qDebug("displayMail not reached");
}
void MainWindow::slotDeleteMail()
{
qDebug("deleteMail not reached");
}
void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
{
qDebug("mailHold not reached");
}
void MainWindow::slotSendQueued()
{
}
-
+
void MainWindow::slotEditAccounts()
{
}
void MainWindow::slotComposeMail()
{
}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 1ba6299..8d004c6 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,53 +1,56 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qlistview.h>
#include <qaction.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include "accountview.h"
#include "statuswidget.h"
+#include <libmailwrapper/mailtypes.h>
+#include <opie2/osmartpointer.h>
+
class RecMail;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~MainWindow();
public slots:
virtual void slotAdjustColumns();
virtual void appMessage(const QCString &msg, const QByteArray &data);
virtual void slotComposeMail();
-
+
protected slots:
virtual void slotSendQueued();
virtual void slotEditAccounts();
virtual void slotShowFolders( bool show );
- virtual void refreshMailView(QList<RecMail>*);
+ virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void displayMail();
virtual void slotDeleteMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotAdjustLayout();
virtual void slotEditSettings();
virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
-
+
protected:
QToolBar *toolBar;
StatusWidget *statusWidget;
QMenuBar *menuBar;
QPopupMenu *mailMenu, *settingsMenu;
- QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
+ QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
QListView *mailView;
QBoxLayout *layout;
};
#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index d95b3c9..dd305df 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -52,227 +52,229 @@ 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()
{
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() == 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()
{
qDebug( "Search Mails" );
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
QPEApplication::execDialog( &settingsDialog );
}
void OpieMail::slotEditAccounts()
{
qDebug( "Edit Accounts" );
EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
eaDialog.slotAdjustColumns();
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();
+ RecMailP mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted )
{
folderView->refreshCurrent();
}
else
{
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
}
}
void OpieMail::slotDeleteMail()
{
if (!mailView->currentItem()) return;
- RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
- if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
+ 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 );
+ 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;}
qDebug("Event right/hold");
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 )
{
qDebug( "Show Folders" );
if ( show && folderView->isHidden() )
{
qDebug( "-> showing" );
folderView->show();
}
else if ( !show && !folderView->isHidden() )
{
qDebug( "-> hiding" );
folderView->hide();
}
}
-void OpieMail::refreshMailView(QList<RecMail>*list)
+void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
{
MailListViewItem*item = 0;
mailView->clear();
- for (unsigned int i = 0; i < list->count();++i)
+
+ QValueList<RecMailP>::ConstIterator it;
+ for (it = list.begin(); it != list.end();++it)
{
item = new MailListViewItem(mailView,item);
- item->storeData(*(list->at(i)));
+ item->storeData((*it));
item->showEntry();
}
}
void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
{
/* just LEFT button - or tap with stylus on pda */
if (button!=1) return;
if (!item) return;
if (folderView->currentisDraft()) {
reEditMail();
} else {
displayMail();
}
}
void OpieMail::slotMoveCopyMail()
{
if (!mailView->currentItem()) return;
- RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
+ 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) ||
+ 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());
+ 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 );
}
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 88c7ea1..b93bd60 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,40 +1,42 @@
#ifndef OPIEMAIL_H
#define OPIEMAIL_H
#include "mainwindow.h"
#include <libmailwrapper/settings.h>
+#include <opie2/osmartpointer.h>
+#include <libmailwrapper/mailtypes.h>
class OpieMail : public MainWindow
{
Q_OBJECT
public:
OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~OpieMail();
static QString appName() { return QString::fromLatin1("opiemail"); }
public slots:
virtual void slotwriteMail(const QString&name,const QString&email);
virtual void slotComposeMail();
virtual void appMessage(const QCString &msg, const QByteArray &data);
protected slots:
virtual void slotSendQueued();
virtual void slotSearchMails();
virtual void slotEditSettings();
virtual void slotEditAccounts();
virtual void displayMail();
virtual void slotDeleteMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotShowFolders( bool show );
- virtual void refreshMailView(QList<RecMail>*);
+ virtual void refreshMailView(const QValueList<RecMailP>&);
virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
virtual void slotMoveCopyMail();
virtual void reEditMail();
private:
Settings *settings;
};
#endif
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 78652d7..894a386 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -132,345 +132,345 @@ void ViewMail::setBody( RecBody body )
QString filename = "";
for (unsigned int i = 0; i < body.Parts().count();++i)
{
filename = "";
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 )
{
m_showHtml = state;
setText();
}
void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
{
if (!item )
return;
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() ] );
+ 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 )
+ 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() ] ) );
+ browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
}
}
break;
}
delete menu;
}
-void ViewMail::setMail( RecMail mail )
+void ViewMail::setMail( RecMailP 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_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();
+ 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)
{
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) ) );
attachments->setEnabled(m_gotBody);
connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
readConfig();
attachments->setSorting(-1);
}
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 )
{
toString += (*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 )
{
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>" );
}
// remove later in favor of a real handling
m_gotBody = true;
}
ViewMail::~ViewMail()
{
- m_recMail.Wrapper()->cleanMimeCache();
+ m_recMail->Wrapper()->cleanMimeCache();
hide();
}
void ViewMail::hide()
{
QWidget::hide();
if (_inLoop)
{
_inLoop = false;
qApp->exit_loop();
}
}
void ViewMail::exec()
{
show();
if (!_inLoop)
{
_inLoop = true;
qApp->enter_loop();
}
}
QString ViewMail::deHtml(const QString &string)
{
QString string_ = string;
string_.replace(QRegExp("&"), "&amp;");
string_.replace(QRegExp("<"), "&lt;");
string_.replace(QRegExp(">"), "&gt;");
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);
- if (m_recMail.Replyto().isEmpty()) {
- composer.setTo( m_recMail.getFrom());
+ if (m_recMail->Replyto().isEmpty()) {
+ composer.setTo( m_recMail->getFrom());
} else {
- composer.setTo( m_recMail.Replyto());
+ composer.setTo( m_recMail->Replyto());
}
composer.setSubject( prefix + m_mail[1] );
composer.setMessage( rtext );
- composer.setInReplyTo(m_recMail.Msgid());
+ composer.setInReplyTo(m_recMail->Msgid());
if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
{
- m_recMail.Wrapper()->answeredMail(m_recMail);
+ 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 );
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 )
{
- m_recMail.Wrapper()->deleteMail( m_recMail );
+ m_recMail->Wrapper()->deleteMail( m_recMail );
hide();
deleted = true;
}
}
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index abbd5b3..6875e3c 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -1,73 +1,73 @@
#ifndef VIEWMAIL_H
#define VIEWMAIL_H
#include <qlistview.h>
#include <qmap.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include "viewmailbase.h"
#include <libmailwrapper/mailtypes.h>
class AttachItem : public QListViewItem
{
public:
AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
const QString&fsize,int num,const QValueList<int>&path);
AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
const QString&fsize,int num,const QValueList<int>&path);
int Partnumber() { return _partNum; }
bool isParentof(const QValueList<int>&path);
private:
int _partNum;
/* needed for a better display of attachments */
QValueList<int> _path;
};
class ViewMail : public ViewMailBase
{
- Q_OBJECT
+ Q_OBJECT
public:
- ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
- ~ViewMail();
+ ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
+ ~ViewMail();
- void hide();
- void exec();
- void setMail( RecMail mail );
+ void hide();
+ void exec();
+ void setMail( RecMailP mail );
void setBody( RecBody body );
bool deleted;
protected:
- QString deHtml(const QString &string);
+ QString deHtml(const QString &string);
AttachItem* searchParent(const QValueList<int>&path);
AttachItem* lastChild(AttachItem*parent);
protected slots:
- void slotReply();
- void slotForward();
+ void slotReply();
+ void slotForward();
void setText();
void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
void slotDeleteMail( );
- void slotShowHtml( bool );
+ void slotShowHtml( bool );
private:
- void readConfig();
-
- bool _inLoop;
- QString m_mailHtml;
- bool m_gotBody;
+ void readConfig();
+
+ bool _inLoop;
+ QString m_mailHtml;
+ bool m_gotBody;
RecBody m_body;
- RecMail m_recMail;
- bool m_showHtml;
+ RecMailP m_recMail;
+ bool m_showHtml;
// 0 from 1 subject 2 bodytext 3 date
QMap <int,QString> m_mail;
// 0 to 1 cc 2 bcc
QMap <int,QStringList> m_mail2;
};
#endif