summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/mhwrapper.cpp
authorzautrix <zautrix>2004-10-31 08:38:17 (UTC)
committer zautrix <zautrix>2004-10-31 08:38:17 (UTC)
commitf77a9457e676a11520c8f52b33265cd825db0c79 (patch) (side-by-side diff)
treed35fc3ef29edf54f413c40621ae760407f659d0c /kmicromail/libmailwrapper/mhwrapper.cpp
parentc48af43f15e8917a441fc8ca4e1bc3adfd1d822e (diff)
downloadkdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.zip
kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.gz
kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.bz2
added delete dir to ompi
Diffstat (limited to 'kmicromail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp57
1 files changed, 33 insertions, 24 deletions
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index de6d220..90b5d23 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -300,5 +300,32 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder)
return res;
}
-
+bool MHwrapper::rmDir(QString folder) // absolute path!
+{
+ QDir dir ( folder );
+ if ( !dir.exists() )
+ return false;
+ int i;
+ // qDebug("rmdir %s ",folder.latin1());
+ QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden );
+ for (i=0; i<list.count(); i++ ) {
+ bool result = true;
+ QString entry = folder+"/"+ list[i] ;
+ //qDebug("entry %s ",entry.latin1() );
+
+ QFileInfo fi ( entry );
+ if ( fi.isFile() ) {
+ //qDebug("file %s ",entry.latin1() );
+ result = QFile::remove ( entry ) ;
+ } else {
+ //qDebug("dir %s ",entry.latin1());
+ if ( list[i] != "." && list[i] != ".." )
+ result = rmDir( entry );
+ }
+ if ( ! result )
+ return false;
+ }
+ //qDebug("removing... ");
+ return QDir::root().rmdir ( folder, true );
+}
int MHwrapper::deleteMbox(const FolderP&tfolder)
{
@@ -316,28 +343,10 @@ int MHwrapper::deleteMbox(const FolderP&tfolder)
return 0;
}
- QString delDir = locateLocal( "apps", "kopiemail")+ "localmail";
- qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() );
-#if 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(Opie::Core::OProcess*)));
- connect(process, SIGNAL( receivedStderr(Opie::Core::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("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() );
+ if ( !rmDir( tfolder->getName() )) {
+ qDebug("error deleteing folder %s ",tfolder->getName().latin1());
}
-#endif
- qDebug("mail box deleted ");
+ else
+ qDebug("mail box deleted %s ", tfolder->getName().latin1());
return 1;
}