summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/mhwrapper.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 21e24a0..5eae31f 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -1,61 +1,59 @@
#include "mhwrapper.h"
#include "mailtypes.h"
#include "mailwrapper.h"
#include <libetpan/libetpan.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <stdlib.h>
#include <qpe/global.h>
#include <opie2/oprocess.h>
using namespace Opie::Core;
-using namespace Opie::Core;
-using namespace Opie::Core;
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()
@@ -276,99 +274,99 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder)
qDebug("error selecting folder!");
return 0;
}
mailmessage_list*l=0;
r = mailsession_get_messages_list(m_storage->sto_session,&l);
if (r != MAIL_NO_ERROR) {
qDebug("Error message list");
res = 0;
}
unsigned j = 0;
for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
mailmessage * msg;
msg = (mailmessage*)carray_get(l->msg_tab, i);
j = msg->msg_index;
r = mailsession_remove_message(m_storage->sto_session,j);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
res = 0;
break;
}
}
if (l) mailmessage_list_free(l);
return res;
}
int MHwrapper::deleteMbox(const FolderP&tfolder)
{
init_storage();
if (!m_storage) {
return 0;
}
if (!tfolder) return 0;
if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0;
int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail box");
return 0;
}
QString cmd = "rm -rf "+tfolder->getName();
QStringList command;
command << "/bin/sh";
command << "-c";
command << cmd.latin1();
OProcess *process = new OProcess();
connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
- this, SLOT( processEnded(OProcess*)));
+ this, SLOT( processEnded(Opie::Core::OProcess*)));
connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
- this, SLOT( oprocessStderr(OProcess*,char*,int)));
+ this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
*process << command;
removeMboxfailed = false;
if(!process->start(OProcess::Block, OProcess::All) ) {
qDebug("could not start process");
return 0;
}
qDebug("mail box deleted");
return 1;
}
void MHwrapper::processEnded(OProcess *p)
{
if (p) delete p;
}
void MHwrapper::oprocessStderr(OProcess*, char *buffer, int )
{
QString lineStr = buffer;
QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") );
removeMboxfailed = true;
}
void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
{
init_storage();
if (!m_storage) {
return;
}
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
QString f = buildPath(mailbox);
int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error retrieving status"));
}
}
MAILLIB::ATYPE MHwrapper::getType()const
{
return MAILLIB::A_MH;
}
const QString&MHwrapper::getName()const
{
return MHName;