summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp64
-rw-r--r--noncore/net/mail/accountview.h18
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp8
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/libmailwrapper.pro6
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp18
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h11
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp330
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h50
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp3
12 files changed, 468 insertions, 48 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 9f4f358..62cbf62 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -578,5 +578,5 @@ AccountView::~AccountView()
{
imapAccounts.clear();
- mboxAccounts.clear();
+ mhAccounts.clear();
}
@@ -606,7 +606,7 @@ void AccountView::populate( QList<Account> list )
imapAccounts.clear();
- mboxAccounts.clear();
+ mhAccounts.clear();
- mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this));
+ mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
Account *it;
@@ -667,8 +667,8 @@ void AccountView::setupFolderselect(Selectstore*sels)
QStringList sFolders;
unsigned int i = 0;
- for (i=0; i < mboxAccounts.count();++i) {
- mboxAccounts[i]->refresh(false);
- sFolders = mboxAccounts[i]->subFolders();
- sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders);
+ 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) {
@@ -705,8 +705,8 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
/**
- * MBOX Account stuff
+ * MH Account stuff
*/
-MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent )
+MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
: AccountViewItem( parent )
{
@@ -719,20 +719,20 @@ MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent )
}
-MBOXviewItem::~MBOXviewItem()
+MHviewItem::~MHviewItem()
{
delete wrapper;
}
-AbstractMail *MBOXviewItem::getWrapper()
+AbstractMail *MHviewItem::getWrapper()
{
return wrapper;
}
-void MBOXviewItem::refresh( QList<RecMail> & )
+void MHviewItem::refresh( QList<RecMail> & )
{
refresh(false);
}
-void MBOXviewItem::refresh(bool force)
+void MHviewItem::refresh(bool force)
{
if (childCount()>0 && force==false) return;
@@ -747,5 +747,5 @@ void MBOXviewItem::refresh(bool force)
QListViewItem*item = 0;
for ( it = folders->first(); it; it = folders->next() ) {
- item = new MBOXfolderItem( it, this , item );
+ item = new MHfolderItem( it, this , item );
item->setSelectable(it->may_select());
}
@@ -755,11 +755,11 @@ void MBOXviewItem::refresh(bool force)
}
-RecBody MBOXviewItem::fetchBody( const RecMail &mail )
+RecBody MHviewItem::fetchBody( const RecMail &mail )
{
- qDebug( "MBOX fetchBody" );
+ qDebug( "MH fetchBody" );
return wrapper->fetchBody( mail );
}
-QPopupMenu * MBOXviewItem::getContextMenu()
+QPopupMenu * MHviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
@@ -771,5 +771,5 @@ QPopupMenu * MBOXviewItem::getContextMenu()
}
-void MBOXviewItem::createFolder()
+void MHviewItem::createFolder()
{
Newmdirdlg ndirdlg(0,0,true);
@@ -783,12 +783,12 @@ void MBOXviewItem::createFolder()
}
-QStringList MBOXviewItem::subFolders()
+QStringList MHviewItem::subFolders()
{
QStringList result;
QListViewItem *child = firstChild();
while ( child ) {
- MBOXfolderItem *tmp = (MBOXfolderItem*)child;
+ MHfolderItem *tmp = (MHfolderItem*)child;
child = child->nextSibling();
- result.append(tmp->getFolder()->getName());
+ result.append(tmp->getFolder()->getDisplayName());
}
qDebug("Size of result: %i",result.count());
@@ -796,5 +796,5 @@ QStringList MBOXviewItem::subFolders()
}
-void MBOXviewItem::contextMenuSelected(int which)
+void MHviewItem::contextMenuSelected(int which)
{
switch (which) {
@@ -810,10 +810,10 @@ void MBOXviewItem::contextMenuSelected(int which)
}
-MBOXfolderItem::~MBOXfolderItem()
+MHfolderItem::~MHfolderItem()
{
delete folder;
}
-MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after )
+MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
: AccountViewItem( parent,after )
{
@@ -830,10 +830,10 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList
}
-Folder*MBOXfolderItem::getFolder()
+Folder*MHfolderItem::getFolder()
{
return folder;
}
-void MBOXfolderItem::refresh(QList<RecMail>&target)
+void MHfolderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
@@ -841,10 +841,10 @@ void MBOXfolderItem::refresh(QList<RecMail>&target)
}
-RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
+RecBody MHfolderItem::fetchBody(const RecMail&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
-void MBOXfolderItem::deleteFolder()
+void MHfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
@@ -856,5 +856,5 @@ void MBOXfolderItem::deleteFolder()
if (mbox->getWrapper()->deleteMbox(folder)) {
QListView*v=listView();
- MBOXviewItem * box = mbox;
+ MHviewItem * box = mbox;
/* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
@@ -867,5 +867,5 @@ void MBOXfolderItem::deleteFolder()
}
-QPopupMenu * MBOXfolderItem::getContextMenu()
+QPopupMenu * MHfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
@@ -878,5 +878,5 @@ QPopupMenu * MBOXfolderItem::getContextMenu()
}
-void MBOXfolderItem::downloadMails()
+void MHfolderItem::downloadMails()
{
AccountView*bl = mbox->accountView();
@@ -885,5 +885,5 @@ void MBOXfolderItem::downloadMails()
}
-void MBOXfolderItem::contextMenuSelected(int which)
+void MHfolderItem::contextMenuSelected(int which)
{
switch(which) {
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index d9b5558..f5a2973 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -119,11 +119,11 @@ protected:
};
-class MBOXviewItem : public AccountViewItem
+class MHviewItem : public AccountViewItem
{
- friend class MBOXfolderItem;
+ friend class MHfolderItem;
public:
- MBOXviewItem( const QString&aMboxPath, AccountView *parent );
- virtual ~MBOXviewItem();
+ MHviewItem( const QString&aMboxPath, AccountView *parent );
+ virtual ~MHviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
@@ -141,10 +141,10 @@ protected:
};
-class MBOXfolderItem : public AccountViewItem
+class MHfolderItem : public AccountViewItem
{
public:
- MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after );
- virtual ~MBOXfolderItem();
+ MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after );
+ virtual ~MHfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
@@ -157,5 +157,5 @@ protected:
virtual void deleteFolder();
Folder *folder;
- MBOXviewItem *mbox;
+ MHviewItem *mbox;
};
@@ -185,5 +185,5 @@ protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
- QValueList<MBOXviewItem*> mboxAccounts;
+ QValueList<MHviewItem*> mhAccounts;
};
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 0280803..592cd5e 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -2,4 +2,5 @@
#include "imapwrapper.h"
#include "pop3wrapper.h"
+#include "mhwrapper.h"
#include "mboxwrapper.h"
#include "mailtypes.h"
@@ -24,5 +25,5 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
{
- return new MBOXwrapper(a,name);
+ return new MHwrapper(a,name);
}
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 2d1596d..b1e4459 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -7,8 +7,16 @@ Genericwrapper::Genericwrapper()
{
bodyCache.clear();
+ m_storage = 0;
+ m_folder = 0;
}
Genericwrapper::~Genericwrapper()
{
+ if (m_folder) {
+ mailfolder_free(m_folder);
+ }
+ if (m_storage) {
+ mailstorage_free(m_storage);
+ }
cleanMimeCache();
}
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index 1d65c0a..e471dc8 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -20,4 +20,6 @@ struct mailimf_group;
struct mailimf_address_list;
struct mailsession;
+struct mailstorage;
+struct mailfolder;
/* this class hold just the funs shared between
@@ -58,4 +60,6 @@ protected:
unsigned int last_msg_id;
QMap<QString,encodedString*> bodyCache;
+ mailstorage * m_storage;
+ mailfolder*m_folder;
};
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
index 18583bb..71f6cca 100644
--- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro
+++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
@@ -13,5 +13,6 @@ HEADERS = mailwrapper.h \
logindialog.h \
sendmailprogress.h \
- statusmail.h
+ statusmail.h \
+ mhwrapper.h
SOURCES = imapwrapper.cpp \
@@ -26,5 +27,6 @@ SOURCES = imapwrapper.cpp \
logindialog.cpp \
sendmailprogress.cpp \
- statusmail.cpp
+ statusmail.cpp \
+ mhwrapper.cpp
INTERFACES = logindialogui.ui \
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 75b9343..ebdbf4b 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -33,4 +33,5 @@ Folder::Folder(const QString&tmp_name, const QString&sep )
nameDisplay = name;
separator = sep;
+ prefix = "";
}
@@ -40,5 +41,5 @@ const QString& Folder::Separator()const
}
-IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix )
+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)
{
@@ -46,4 +47,5 @@ IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no
nameDisplay = IMAPFolder::decodeFolderName( name );
qDebug( "folder " + name + " - displayed as " + nameDisplay );
+ prefix = aprefix;
if (prefix.length()>0) {
@@ -147,2 +149,16 @@ Mail::Mail()
{
}
+
+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;
+}
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h
index a60777d..caaa3a2 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -70,4 +70,5 @@ public:
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;}
@@ -75,6 +76,12 @@ public:
protected:
- QString nameDisplay, name, separator;
-
+ QString nameDisplay, name, separator,prefix;
+};
+
+class MHFolder : public Folder
+{
+ Q_OBJECT
+public:
+ MHFolder(const QString&disp_name,const QString&mbox);
};
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 194ff86..a579a3d 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -13,4 +13,5 @@ class MBOXwrapper : public Genericwrapper
{
Q_OBJECT
+
public:
MBOXwrapper(const QString & dir,const QString&name);
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
new file mode 100644
index 0000000..85f9cf0
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -0,0 +1,330 @@
+#include "mhwrapper.h"
+#include "mailtypes.h"
+#include "mailwrapper.h"
+#include <libetpan/libetpan.h>
+#include <qdir.h>
+#include <stdlib.h>
+#include <qpe/global.h>
+
+const QString MHwrapper::wrapperType="MH";
+
+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 )
+{
+ init_storage();
+ if (!m_storage) {
+ return;
+ }
+ QString f = buildPath(mailbox);
+ int r = mailsession_select_folder(m_storage->sto_session,(char*)mailbox.latin1());
+ if (r!=MAIL_NO_ERROR) {
+ qDebug("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()
+{
+ QList<Folder> * folders = new QList<Folder>();
+ folders->setAutoDelete( false );
+ 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)
+{
+ init_storage();
+ if (!m_storage) {
+ return;
+ }
+ 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());
+ if (r != MAIL_NO_ERROR) {
+ qDebug("error deleting mail");
+ }
+}
+
+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);
+ 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*,const QString&,bool )
+{
+ init_storage();
+ if (!m_storage) {
+ return 0;
+ }
+ QString f = buildPath(folder);
+ int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
+ if (r != MAIL_NO_ERROR) {
+ qDebug("error creating folder");
+ return 0;
+ }
+ qDebug("Folder created");
+ mailstorage_disconnect(m_storage);
+ 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*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());
+ if (r!=MAIL_NO_ERROR) {
+ qDebug("error selecting folder!");
+ return result;
+ }
+ 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()));
+ return 0;
+ }
+ r = mailmessage_fetch(msg,&data,&size);
+ if (r != MAIL_NO_ERROR) {
+ 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)
+{
+#if 0
+ QString p = MHPath+"/";
+ 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);
+#endif
+}
+
+int MHwrapper::deleteAllMail(const Folder*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)
+{
+ init_storage();
+ if (!m_storage) {
+ return 0;
+ }
+ if (!tfolder) 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;
+ }
+ qDebug("mail box deleted");
+ mailstorage_disconnect(m_storage);
+ return 1;
+}
+
+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"));
+ }
+}
+
+const QString&MHwrapper::getType()const
+{
+ return wrapperType;
+}
+
+const QString&MHwrapper::getName()const
+{
+ return MHName;
+}
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
new file mode 100644
index 0000000..7f028b4
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -0,0 +1,50 @@
+#ifndef __MH_WRAPPER_H
+#define __MH_WRAPPER_H
+
+#include "genericwrapper.h"
+#include <qstring.h>
+
+class RecMail;
+class RecBody;
+class encodedString;
+struct mailmbox_folder;
+
+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 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 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 const QString&getType()const;
+ virtual const QString&getName()const;
+
+protected:
+ QString buildPath(const QString&p);
+ QString MHPath;
+ QString MHName;
+ static const QString wrapperType;
+
+ void init_storage();
+ void clean_storage();
+};
+
+#endif
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 281b88e..08f6bb7 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -15,5 +15,5 @@
#include "smtpwrapper.h"
#include "mailwrapper.h"
-#include "mboxwrapper.h"
+#include "abstractmail.h"
#include "logindialog.h"
#include "mailtypes.h"
@@ -491,4 +491,5 @@ void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box)
QString localfolders = AbstractMail::defaultLocalfolder();
AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
+ wrap->createMbox(box);
wrap->storeMessage(mail,length,box);
delete wrap;