summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2004-01-10 03:20:04 (UTC)
committer alwin <alwin>2004-01-10 03:20:04 (UTC)
commit6248e82bf1b077c54e3e2b85801a99fa0f86434d (patch) (side-by-side diff)
treed223c9984c9e0d296ba4ae57654c1b15795c1e70 /noncore
parentdcfd6e5e2e2021bc5ed0bcf42b1b0a7002c59a17 (diff)
downloadopie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.zip
opie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.tar.gz
opie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.tar.bz2
mh wrapper fully functional.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp54
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h7
2 files changed, 56 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 512f778..5090f4a 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -5,4 +5,6 @@
#include <qdir.h>
+#include <qmessagebox.h>
#include <stdlib.h>
#include <qpe/global.h>
+#include <opie/oprocess.h>
@@ -82,2 +84,4 @@ QList<Folder>* MHwrapper::listFolders()
folders->setAutoDelete( false );
+ /* this is needed! */
+ if (m_storage) mailstorage_disconnect(m_storage);
init_storage();
@@ -169,3 +173,3 @@ QString MHwrapper::buildPath(const QString&p)
-int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
+int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool )
{
@@ -175,6 +179,15 @@ int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool
}
- QString f = buildPath(folder);
+ 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");
+ qDebug("error creating folder %i",r);
return 0;
@@ -182,3 +195,2 @@ int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool
qDebug("Folder created");
- mailstorage_disconnect(m_storage);
return 1;
@@ -297,3 +309,6 @@ int MHwrapper::deleteMbox(const Folder*tfolder)
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) {
@@ -302,4 +317,21 @@ int MHwrapper::deleteMbox(const Folder*tfolder)
}
+ 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");
- mailstorage_disconnect(m_storage);
return 1;
@@ -307,2 +339,14 @@ int MHwrapper::deleteMbox(const Folder*tfolder)
+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)
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
index 79dec30..b8e380c 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -10,2 +10,3 @@ class encodedString;
struct mailmbox_folder;
+class OProcess;
@@ -41,2 +42,6 @@ public:
+public slots:
+ /* for deleting maildirs we are using a system call */
+ virtual void oprocessStderr(OProcess*, char *buffer, int );
+ virtual void processEnded(OProcess *);
protected:
@@ -49,2 +54,4 @@ protected:
void clean_storage();
+
+ bool removeMboxfailed;
};