summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-12 14:12:00 (UTC)
committer alwin <alwin>2004-03-12 14:12:00 (UTC)
commitd1929ef43f0eaaa17aa42196384d1ed925132873 (patch) (side-by-side diff)
treeeff911f93fe7919d7820e5a2e68b72f2f76143da
parentd38384a6edb0110117e0297864f813b379d52789 (diff)
downloadopie-d1929ef43f0eaaa17aa42196384d1ed925132873.zip
opie-d1929ef43f0eaaa17aa42196384d1ed925132873.tar.gz
opie-d1929ef43f0eaaa17aa42196384d1ed925132873.tar.bz2
some pointers embedded into osmart_pointer handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp115
-rw-r--r--noncore/net/mail/accountitem.h23
-rw-r--r--noncore/net/mail/accountview.cpp2
-rw-r--r--noncore/net/mail/accountview.h7
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h16
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp14
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h20
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h16
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp39
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h13
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp24
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h20
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h4
-rw-r--r--noncore/net/mail/viewmail.cpp7
21 files changed, 190 insertions, 172 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 396dcb7..3e12563 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -36,65 +36,63 @@ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
}
#endif
setText( 0, account->getAccountName() );
setOpen( true );
}
POP3viewItem::~POP3viewItem()
{
delete wrapper;
}
AbstractMail *POP3viewItem::getWrapper()
{
return wrapper;
}
void POP3viewItem::refresh( QList<RecMail> & )
{
refresh();
}
void POP3viewItem::refresh()
{
if (account->getOffline()) return;
- QList<Folder> *folders = wrapper->listFolders();
+ QValueList<FolderP> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
- Folder *it;
+ QValueList<FolderP>::ConstIterator it;
QListViewItem*item = 0;
- for ( it = folders->first(); it; it = folders->next() )
+ for ( it = folders->begin(); it!=folders->end(); ++it)
{
- item = new POP3folderItem( it, this , item );
- item->setSelectable(it->may_select());
+ item = new POP3folderItem( (*it), this , item );
+ item->setSelectable( (*it)->may_select());
}
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
delete folders;
}
RecBody POP3viewItem::fetchBody( const RecMail &mail )
{
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * POP3viewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (!account->getOffline())
{
m->insertItem(QObject::tr("Disconnect",contextName),0);
m->insertItem(QObject::tr("Set offline",contextName),1);
}
else
{
m->insertItem(QObject::tr("Set online",contextName),1);
}
}
@@ -120,52 +118,51 @@ void POP3viewItem::setOnOffline()
disconnect();
}
account->setOffline(!account->getOffline());
account->save();
SETPIX(PIXMAP_POP3FOLDER);
refresh();
}
void POP3viewItem::contextMenuSelected(int which)
{
switch (which)
{
case 0:
disconnect();
break;
case 1:
setOnOffline();
break;
}
}
POP3folderItem::~POP3folderItem()
{}
-POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
- : AccountViewItem( parent,after )
+POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after )
+ : AccountViewItem(folderInit,parent,after )
{
- folder = folderInit;
pop3 = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_POP3FOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
void POP3folderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
pop3->getWrapper()->listMessages( folder->getName(),target );
}
RecBody POP3folderItem::fetchBody(const RecMail&aMail)
{
return pop3->getWrapper()->fetchBody(aMail);
}
QPopupMenu * POP3folderItem::getContextMenu()
@@ -229,65 +226,64 @@ NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
}
#endif
setText( 0, account->getAccountName() );
setOpen( true );
}
NNTPviewItem::~NNTPviewItem()
{
delete wrapper;
}
AbstractMail *NNTPviewItem::getWrapper()
{
return wrapper;
}
void NNTPviewItem::refresh( QList<RecMail> & )
{
refresh();
}
void NNTPviewItem::refresh()
{
if (account->getOffline()) return;
- QList<Folder> *folders = wrapper->listFolders();
+ QValueList<FolderP> *folders = wrapper->listFolders();
+
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
- Folder *it;
+ QValueList<FolderP>::ConstIterator it;
QListViewItem*item = 0;
- for ( it = folders->first(); it; it = folders->next() )
+ for ( it = folders->begin(); it!=folders->end(); ++it)
{
- item = new NNTPfolderItem( it, this , item );
- item->setSelectable(it->may_select());
+ item = new NNTPfolderItem( (*it), this , item );
+ item->setSelectable( (*it)->may_select());
}
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
delete folders;
}
RecBody NNTPviewItem::fetchBody( const RecMail &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);
}
@@ -326,52 +322,51 @@ void NNTPviewItem::setOnOffline()
//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( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent,after )
+NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after )
+ : AccountViewItem( folderInit, parent,after )
{
- folder = folderInit;
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)
{
if (folder->may_select())
nntp->getWrapper()->listMessages( folder->getName(),target );
}
RecBody NNTPfolderItem::fetchBody(const RecMail&aMail)
{
return nntp->getWrapper()->fetchBody(aMail);
}
QPopupMenu * NNTPfolderItem::getContextMenu()
@@ -429,89 +424,87 @@ IMAPviewItem::~IMAPviewItem()
}
AbstractMail *IMAPviewItem::getWrapper()
{
return wrapper;
}
void IMAPviewItem::refresh(QList<RecMail>&)
{
refreshFolders(false);
}
const QStringList&IMAPviewItem::subFolders()
{
return currentFolders;
}
void IMAPviewItem::refreshFolders(bool force)
{
if (childCount()>0 && force==false) return;
if (account->getOffline()) return;
removeChilds();
currentFolders.clear();
- QList<Folder> *folders = wrapper->listFolders();
+ QValueList<FolderP> * folders = wrapper->listFolders();
- Folder *it;
+ QValueList<FolderP>::Iterator it;
QListViewItem*item = 0;
QListViewItem*titem = 0;
QString fname,del,search;
int pos;
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
- for ( it = folders->first(); it; it = folders->next() )
+ for ( it = folders->begin(); it!=folders->end(); ++it)
{
- if (it->getDisplayName().lower()=="inbox")
+ if ((*it)->getDisplayName().lower()=="inbox")
{
- item = new IMAPfolderItem( it, this , item );
+ item = new IMAPfolderItem( (*it), this , item );
folders->remove(it);
qDebug("inbox found");
break;
}
}
- for ( it = folders->first(); it; it = folders->next() )
+ for ( it = folders->begin(); it!=folders->end(); ++it)
{
- fname = it->getDisplayName();
- currentFolders.append(it->getName());
- pos = fname.findRev(it->Separator());
+ 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);
+ item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
/* setup the short name */
- item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
+ item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1));
item = titem;
}
else
{
- item = new IMAPfolderItem( it, this , item );
+ 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;
@@ -557,68 +550,66 @@ void IMAPviewItem::contextMenuSelected(int id)
{
removeChilds();
wrapper->logout();
}
account->setOffline(!account->getOffline());
account->save();
SETPIX(PIXMAP_IMAPFOLDER);
refreshFolders(false);
break;
default:
break;
}
}
RecBody IMAPviewItem::fetchBody(const RecMail&)
{
return RecBody();
}
bool IMAPviewItem::offline()
{
return account->getOffline();
}
-IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent , after )
+IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
+ : AccountViewItem( folderInit, parent , after )
{
- folder = folderInit;
imap = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_IMAPFOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
-IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
- : AccountViewItem( parent,after )
+IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
+ : AccountViewItem(folderInit, parent,after )
{
- folder = folderInit;
imap = master;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_IMAPFOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
IMAPfolderItem::~IMAPfolderItem()
{}
const QString& IMAPfolderItem::Delemiter()const
{
return folder->Separator();
}
void IMAPfolderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
{
@@ -747,87 +738,85 @@ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
folder = 0;
}
MHviewItem::~MHviewItem()
{
delete wrapper;
}
AbstractMail *MHviewItem::getWrapper()
{
return wrapper;
}
void MHviewItem::refresh( QList<RecMail> & target)
{
refresh(false);
getWrapper()->listMessages( "",target );
}
void MHviewItem::refresh(bool force)
{
if (childCount()>0 && force==false) return;
removeChilds();
currentFolders.clear();
- QList<Folder> *folders = wrapper->listFolders();
- Folder *it;
+ QValueList<FolderP> *folders = wrapper->listFolders();
+ QValueList<FolderP>::ConstIterator it;
MHfolderItem*item = 0;
MHfolderItem*pmaster = 0;
QString fname = "";
int pos;
- for ( it = folders->first(); it; it = folders->next() )
+ for ( it = folders->begin(); it!=folders->end(); ++it)
{
- fname = it->getDisplayName();
+ fname = (*it)->getDisplayName();
/* this folder itself */
if (fname=="/")
{
currentFolders.append(fname);
- folder = it;
+ 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 );
+ item = new MHfolderItem( (*it), pmaster, item, this );
}
else
{
- item = new MHfolderItem( it, this , item );
+ item = new MHfolderItem( (*it), this , item );
}
- item->setSelectable(it->may_select());
+ item->setSelectable((*it)->may_select());
}
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- folders->setAutoDelete(false);
delete folders;
}
RecBody MHviewItem::fetchBody( const RecMail &mail )
{
qDebug( "MH fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * MHviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Refresh folder list",contextName),0);
m->insertItem(QObject::tr("Create new folder",contextName),1);
m->insertItem(QObject::tr("Delete all mails",contextName),2);
m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
}
return m;
}
void MHviewItem::createFolder()
{
@@ -857,92 +846,91 @@ QStringList MHviewItem::subFolders()
void MHviewItem::contextMenuSelected(int which)
{
switch (which)
{
case 0:
refresh(true);
break;
case 1:
createFolder();
break;
case 2:
deleteAllMail(getWrapper(),folder);
break;
case 3:
downloadMails();
break;
default:
break;
}
}
MHfolderItem::~MHfolderItem()
{}
-MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent,after )
+MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
+ : AccountViewItem(folderInit, parent,after )
{
- folder = folderInit;
mbox = parent;
initName();
}
-MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
- : AccountViewItem( parent,after )
+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 );
}
-Folder*MHfolderItem::getFolder()
+const FolderP&MHfolderItem::getFolder()const
{
return folder;
}
void MHfolderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
mbox->getWrapper()->listMessages( folder->getName(),target );
}
RecBody MHfolderItem::fetchBody(const RecMail&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
void MHfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
QObject::tr("Yes",contextName),
QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
if (yesno == 0)
{
@@ -1022,76 +1010,81 @@ void MHfolderItem::contextMenuSelected(int which)
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)
+ : QListViewItem( parent),folder(0)
{
init();
}
AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
- :QListViewItem( parent,after )
+ :QListViewItem( parent,after ),folder(0)
+{
+ init();
+}
+
+AccountViewItem::AccountViewItem( const Opie::osmart_pointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
+ :QListViewItem( parent,after ),folder(folderInit)
{
init();
}
void AccountViewItem::init()
{
m_Backlink = 0;
- folder = 0;
}
AccountViewItem::~AccountViewItem()
{
- if (folder) delete folder;
+ folder = 0;
}
AccountView*AccountViewItem::accountView()
{
return m_Backlink;
}
-void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
+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 )
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index eb3baa3..8f712f5 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -1,207 +1,210 @@
#ifndef __ACCOUNT_ITEM
#define __ACCOUNT_ITEM
#include <qlistview.h>
#include <qlist.h>
+#include <opie2/osmart_pointer.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 );
+
virtual ~AccountViewItem();
virtual void refresh(QList<RecMail>&)=0;
virtual RecBody fetchBody(const RecMail&)=0;
virtual QPopupMenu * getContextMenu(){return 0;};
virtual void contextMenuSelected(int){}
virtual AccountView*accountView();
virtual bool matchName(const QString&name)const;
virtual bool isDraftfolder();
protected:
AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
virtual void init();
virtual void removeChilds();
- virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
+ virtual void deleteAllMail(AbstractMail*wrapper,const Opie::osmart_pointer<Folder>&f);
static const QString contextName;
AccountView*m_Backlink;
- Folder *folder;
+ Opie::osmart_pointer<Folder> folder;
};
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, AccountView *parent );
virtual ~POP3viewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
POP3account *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
};
class POP3folderItem : public AccountViewItem
{
public:
- POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
+ POP3folderItem( const Opie::osmart_pointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
virtual ~POP3folderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
POP3viewItem *pop3;
};
class NNTPviewItem : public AccountViewItem
{
public:
NNTPviewItem( NNTPaccount *a, AccountView *parent );
virtual ~NNTPviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const 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( Folder *folder, NNTPviewItem *parent , QListViewItem*after );
+ NNTPfolderItem(const Opie::osmart_pointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
virtual ~NNTPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const 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&);
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
const QStringList&subFolders();
virtual void refreshFolders(bool force=false);
bool offline();
protected:
virtual void createNewFolder();
IMAPaccount *account;
AbstractMail *wrapper;
QStringList currentFolders;
};
class IMAPfolderItem : public AccountViewItem
{
public:
- IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
- IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
+ IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
+ IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
virtual ~IMAPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
virtual void downloadMails();
IMAPviewItem *imap;
};
class MHviewItem : public AccountViewItem
{
friend class MHfolderItem;
public:
MHviewItem( const QString&aMboxPath, AccountView *parent );
virtual ~MHviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
QStringList subFolders();
virtual void refresh(bool force=false);
protected:
void downloadMails();
virtual void createFolder();
QString m_Path;
AbstractMail *wrapper;
QStringList currentFolders;
};
class MHfolderItem : public AccountViewItem
{
public:
- MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after );
- MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
+ MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
+ MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
virtual ~MHfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
- virtual Folder*getFolder();
+ virtual const Opie::osmart_pointer<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 7938d4f..297f553 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -122,49 +122,49 @@ RecBody AccountView::fetchBody(const RecMail&aMail)
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(Folder*fromFolder,AbstractMail*fromWrapper)
+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();
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 5000202..3478c0b 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,45 +1,46 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
#include <qlistview.h>
#include <qlist.h>
+#include <opie2/osmart_pointer.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(Folder*fromFolder,AbstractMail*fromWrapper);
+ virtual void downloadMails(const Opie::osmart_pointer<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(QList<RecMail>*);
-protected:
+protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
QValueList<MHviewItem*> mhAccounts;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index ac6f380..7e6d383 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -90,71 +90,72 @@ QString AbstractMail::convert_String(const char*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 Folder*,const QString& delemiter,bool)
+int AbstractMail::createMbox(const QString&,const FolderP&,const QString& delemiter,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::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
QList<RecMail> t;
listMessages(fromFolder->getName(),t);
encodedString*st = 0;
while (t.count()>0) {
RecMail*r = t.at(0);
st = fetchRawBody(*r);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
t.removeFirst();
}
if (moveit) {
deleteAllMail(fromFolder);
}
}
void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
encodedString*st = 0;
st = fetchRawBody(mail);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index d377452..d911468 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,70 +1,74 @@
#ifndef __abstract_mail_
#define __abstract_mail_
#include "maildefines.h"
-#include <qobject.h>
#include "settings.h"
+#include <qobject.h>
+#include <opie2/osmart_pointer.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 QList<Folder>* listFolders()=0;
+ virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders()=0;
virtual void listMessages(const QString & mailbox,QList<RecMail>&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 void deleteMail(const RecMail&mail)=0;
virtual void answeredMail(const RecMail&mail)=0;
- virtual int deleteAllMail(const Folder*)=0;
+ virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&)=0;
virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
- virtual int deleteMbox(const Folder*)=0;
+ virtual int deleteMbox(const Opie::osmart_pointer<Folder>&)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
- virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void mvcpMail(const RecMail&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 Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
+ virtual int createMbox(const QString&,const Opie::osmart_pointer<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/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index b3cd4fe..d0db45a 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -17,49 +17,49 @@ 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 void cleanMimeCache();
- virtual int deleteMbox(const Folder*){return 1;}
+ virtual int deleteMbox(const Opie::osmart_pointer<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);
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;
};
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index e29a0a0..3b3be0f 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -245,59 +245,58 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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);
}
-QList<Folder>* IMAPwrapper::listFolders()
+QValueList<Opie::osmart_pointer<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;
- QList<Folder> * folders = new QList<Folder>();
- folders->setAutoDelete( false );
+ 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;
@@ -945,120 +944,120 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path
}
delete r;
}
return body;
}
QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
{
return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
}
encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&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)
{
return fetchRawPart(mail,part.Positionlist(),false);
}
-int IMAPwrapper::deleteAllMail(const Folder*folder)
+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 Folder*parentfolder,const QString& delemiter,bool getsubfolder)
+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 Folder*folder)
+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) {
@@ -1102,49 +1101,50 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde
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)
{
// dummy
QValueList<int> path;
return fetchRawPart(mail,path,false);
}
-void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+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;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 2623725..15f049f 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -2,77 +2,79 @@
#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 QList<Folder>* listFolders();
+ virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders();
virtual void listMessages(const QString & mailbox,QList<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 Folder*folder);
+ virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void mvcpMail(const RecMail&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 int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
- virtual int deleteMbox(const Folder*folder);
-
+ virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0,
+ const QString& delemiter="/",bool getsubfolder=false);
+ virtual int deleteMbox(const Opie::osmart_pointer<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);
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);
-
+
/* 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.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 17c6db9..10d367f 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -1,35 +1,34 @@
#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 <qlist.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
{
public:
RecMail();
RecMail(const RecMail&old);
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 6bd98f6..c71d69f 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -14,70 +14,78 @@
#define MAXLINE 76
#define UTF16MASK 0x03FFUL
#define UTF16SHIFT 10
#define UTF16BASE 0x10000UL
#define UTF16HIGHSTART 0xD800UL
#define UTF16HIGHEND 0xDBFFUL
#define UTF16LOSTART 0xDC00UL
#define UTF16LOEND 0xDFFFUL
Attachment::Attachment( DocLnk lnk )
{
doc = lnk;
size = QFileInfo( doc.file() ).size();
}
Folder::Folder(const QString&tmp_name, const QString&sep )
{
name = tmp_name;
nameDisplay = name;
separator = sep;
prefix = "";
}
+Folder::~Folder()
+{
+}
+
const QString& Folder::Separator()const
{
return separator;
}
IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix )
: Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
{
// Decode IMAP foldername
nameDisplay = IMAPFolder::decodeFolderName( name );
/*
qDebug( "folder " + name + " - displayed as " + nameDisplay );
*/
prefix = aprefix;
if (prefix.length()>0) {
if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
}
}
}
+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 ()) {
@@ -143,24 +151,28 @@ QString IMAPFolder::decodeFolderName( const QString &name )
}
}
return QString::fromUtf8( dst.data() );
}
Mail::Mail()
:Opie::oref_count(),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 c66572c..3b3bb32 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -1,104 +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>
class Attachment
{
public:
- Attachment( DocLnk lnk );
+ 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
{
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 ); }
+ 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 QObject
+class Folder:public Opie::oref_count
{
- Q_OBJECT
-
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;
+
class MHFolder : public Folder
{
- Q_OBJECT
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 abe4bb6..9ff3de2 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -1,209 +1,208 @@
#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 )
{
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);
+ 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()));
}
-QList<Folder>* MBOXwrapper::listFolders()
+QValueList<Opie::osmart_pointer<Folder> >* MBOXwrapper::listFolders()
{
- QList<Folder> * folders = new QList<Folder>();
- folders->setAutoDelete( false );
+ QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<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) {
- Folder*inb=new Folder(*it,"/");
+ FolderP inb=new Folder(*it,"/");
folders->append(inb);
}
return folders;
}
void MBOXwrapper::deleteMail(const RecMail&mail)
{
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
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);
+ 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());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail");
}
mailfolder_free(folder);
mailstorage_free(storage);
}
void MBOXwrapper::answeredMail(const RecMail&)
{
}
RecBody MBOXwrapper::fetchBody( const RecMail &mail )
{
RecBody body;
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
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);
+ 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);
if (r != MAIL_NO_ERROR) {
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());
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return body;
}
- body = parseMail(msg);
+ 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 Folder*,const QString&,bool )
+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)
{
RecBody body;
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
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);
+ 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);
if (r != MAIL_NO_ERROR) {
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()));
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return 0;
}
encodedString*result = new encodedString(data,size);
@@ -222,114 +221,114 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
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)
{
if (!f) return;
int r;
for (unsigned int i=0; i < target.count();++i) {
r = mailmbox_delete_msg(f,target.at(i)->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 Folder*tfolder)
+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);
+ 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 Folder*tfolder)
+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);
+ 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;
}
const QString&MBOXwrapper::getName()const
{
return MBOXName;
}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 7e7f359..c3d9b50 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -1,47 +1,48 @@
#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 QList<Folder>* listFolders();
+ virtual QValueList<Opie::osmart_pointer<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 int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
- virtual int deleteMbox(const Folder*);
+
+ virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0,
+ const QString&d="",bool s=false);
+ virtual int deleteMbox(const Opie::osmart_pointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual RecBody fetchBody( const RecMail &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 Folder*);
+ virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
protected:
static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
QString MBOXPath;
QString MBOXName;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 560eab0..aaaa20a 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -55,52 +55,51 @@ void MHwrapper::clean_storage()
}
}
MHwrapper::~MHwrapper()
{
clean_storage();
}
void MHwrapper::listMessages(const QString & mailbox, QList<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()));
}
-QList<Folder>* MHwrapper::listFolders()
+QValueList<Opie::osmart_pointer<Folder> >* MHwrapper::listFolders()
{
- QList<Folder> * folders = new QList<Folder>();
- folders->setAutoDelete( false );
+ QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<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)
{
@@ -123,74 +122,74 @@ void MHwrapper::answeredMail(const RecMail&)
{
}
RecBody MHwrapper::fetchBody( const RecMail &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());
if (r != MAIL_NO_ERROR) {
return body;
}
r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
qDebug("Error fetching mail %i",mail.getNumber());
return body;
}
- body = parseMail(msg);
+ 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 Folder*pfolder,const QString&,bool )
+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;
}
@@ -242,105 +241,105 @@ encodedString* MHwrapper::fetchRawBody(const RecMail&mail)
result = new encodedString(data,size);
if (msg) mailmessage_free(msg);
return result;
}
void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &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());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail");
break;
}
}
}
-int MHwrapper::deleteAllMail(const Folder*tfolder)
+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 Folder*tfolder)
+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") );
@@ -365,64 +364,65 @@ void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
}
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)
{
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());
} else {
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(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+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) {
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
index b7c23af..c7c8183 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -1,60 +1,62 @@
#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 QList<Folder>* listFolders();
+ virtual QValueList<Opie::osmart_pointer<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(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
-
- virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
- virtual int deleteMbox(const Folder*);
+ virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder,
+ const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+
+ virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0,
+ const QString&d="",bool s=false);
+ virtual int deleteMbox(const Opie::osmart_pointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual RecBody fetchBody( const RecMail &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 Folder*);
+ virtual int deleteAllMail(const Opie::osmart_pointer<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 1956c61..2ec052c 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -167,65 +167,64 @@ void NNTPwrapper::login()
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;
}
-QList<Folder>* NNTPwrapper::listFolders() {
+QValueList<Opie::osmart_pointer<Folder> >* NNTPwrapper::listFolders() {
- QList<Folder> * folders = new QList<Folder>();
- folders->setAutoDelete( false );
+ QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<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++
+ * 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;
@@ -259,26 +258,26 @@ encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) {
size_t length=0;
encodedString*res = 0;
mailmessage * mailmsg = 0;
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&) {
}
-int NNTPwrapper::deleteAllMail(const Folder*) {
+int NNTPwrapper::deleteAllMail(const FolderP&) {
}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index 955b9f1..d3a384a 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 );
/* should only get the subscribed one */
- virtual QList<Folder>* listFolders();
+ virtual QValueList<Opie::osmart_pointer<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 Folder*);
+ virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
virtual RecBody fetchBody( const RecMail &mail );
virtual encodedString* fetchRawBody(const RecMail&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 0939b22..7bf7ed2 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -156,69 +156,68 @@ void POP3wrapper::login()
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;
}
-QList<Folder>* POP3wrapper::listFolders() {
- QList<Folder> * folders = new QList<Folder>();
- folders->setAutoDelete( false );
- Folder*inb=new Folder("INBOX","/");
+QValueList<Opie::osmart_pointer<Folder> >* POP3wrapper::listFolders() {
+ QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<FolderP>();
+ FolderP inb=new Folder("INBOX","/");
folders->append(inb);
return folders;
}
void POP3wrapper::deleteMail(const RecMail&mail) {
login();
if (!m_pop3)
return;
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&) {}
-int POP3wrapper::deleteAllMail(const Folder*) {
+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();
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 391c841..e4afb94 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 QList<Folder>* listFolders();
+ virtual QValueList<Opie::osmart_pointer<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 Folder*);
+ virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&);
virtual RecBody fetchBody( const RecMail &mail );
virtual encodedString* fetchRawBody(const RecMail&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/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index aa8f37a..78652d7 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -112,48 +112,49 @@ void ViewMail::setBody( RecBody body )
case 2:
q="M";
break;
default:
break;
}
{
/* I did not found a method to make a CONTENT reset on a QTextStream
so I use this construct that the stream will re-constructed in each
loop. To let it work, the textstream is packed into a own area of
code is it will be destructed after finishing its small job.
*/
QTextOStream o(&fsize);
if (w>0) o.precision(2); else o.precision(0);
o.setf(QTextStream::fixed);
o << s << " " << q << "Byte";
}
curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
QString filename = "";
for (unsigned int i = 0; i < body.Parts().count();++i)
{
+ 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:
@@ -374,76 +375,76 @@ void ViewMail::exec()
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
+ 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
+ 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());
} else {
composer.setTo( m_recMail.Replyto());
}
composer.setSubject( prefix + m_mail[1] );
composer.setMessage( rtext );
composer.setInReplyTo(m_recMail.Msgid());
-
+
if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
{
m_recMail.Wrapper()->answeredMail(m_recMail);
}
}
void ViewMail::slotForward()
{
if (!m_gotBody)
{
QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
return;
}
QString ftext;
ftext += QString("\n----- Forwarded message from %1 -----\n\n")
.arg( m_mail[0] );
if (!m_mail[3].isNull())
ftext += QString("Date: %1\n")
.arg( m_mail[3] );
if (!m_mail[0].isNull())
ftext += QString("From: %1\n")
.arg( m_mail[0] );
if (!m_mail[1].isNull())