-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 54 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.h | 7 |
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 @@ | |||
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qmessagebox.h> | ||
6 | #include <stdlib.h> | 7 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie/oprocess.h> | ||
8 | 10 | ||
@@ -82,2 +84,4 @@ QList<Folder>* MHwrapper::listFolders() | |||
82 | folders->setAutoDelete( false ); | 84 | folders->setAutoDelete( false ); |
85 | /* this is needed! */ | ||
86 | if (m_storage) mailstorage_disconnect(m_storage); | ||
83 | init_storage(); | 87 | init_storage(); |
@@ -169,3 +173,3 @@ QString MHwrapper::buildPath(const QString&p) | |||
169 | 173 | ||
170 | int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) | 174 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) |
171 | { | 175 | { |
@@ -175,6 +179,15 @@ int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool | |||
175 | } | 179 | } |
176 | QString f = buildPath(folder); | 180 | QString f; |
181 | if (!pfolder) { | ||
182 | // toplevel folder | ||
183 | f = buildPath(folder); | ||
184 | } else { | ||
185 | f = pfolder->getName(); | ||
186 | f+="/"; | ||
187 | f+=folder; | ||
188 | } | ||
189 | qDebug(f); | ||
177 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 190 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
178 | if (r != MAIL_NO_ERROR) { | 191 | if (r != MAIL_NO_ERROR) { |
179 | qDebug("error creating folder"); | 192 | qDebug("error creating folder %i",r); |
180 | return 0; | 193 | return 0; |
@@ -182,3 +195,2 @@ int MHwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool | |||
182 | qDebug("Folder created"); | 195 | qDebug("Folder created"); |
183 | mailstorage_disconnect(m_storage); | ||
184 | return 1; | 196 | return 1; |
@@ -297,3 +309,6 @@ int MHwrapper::deleteMbox(const Folder*tfolder) | |||
297 | if (!tfolder) return 0; | 309 | if (!tfolder) return 0; |
310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | ||
311 | |||
298 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
313 | |||
299 | if (r != MAIL_NO_ERROR) { | 314 | if (r != MAIL_NO_ERROR) { |
@@ -302,4 +317,21 @@ int MHwrapper::deleteMbox(const Folder*tfolder) | |||
302 | } | 317 | } |
318 | QString cmd = "rm -rf "+tfolder->getName(); | ||
319 | QStringList command; | ||
320 | command << "/bin/sh"; | ||
321 | command << "-c"; | ||
322 | command << cmd.latin1(); | ||
323 | OProcess *process = new OProcess(); | ||
324 | |||
325 | connect(process, SIGNAL(processExited(OProcess *)), | ||
326 | this, SLOT( processEnded(OProcess *))); | ||
327 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | ||
328 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | ||
329 | |||
330 | *process << command; | ||
331 | removeMboxfailed = false; | ||
332 | if(!process->start(OProcess::Block, OProcess::All) ) { | ||
333 | qDebug("could not start process"); | ||
334 | return 0; | ||
335 | } | ||
303 | qDebug("mail box deleted"); | 336 | qDebug("mail box deleted"); |
304 | mailstorage_disconnect(m_storage); | ||
305 | return 1; | 337 | return 1; |
@@ -307,2 +339,14 @@ int MHwrapper::deleteMbox(const Folder*tfolder) | |||
307 | 339 | ||
340 | void MHwrapper::processEnded(OProcess *p) | ||
341 | { | ||
342 | if (p) delete p; | ||
343 | } | ||
344 | |||
345 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | ||
346 | { | ||
347 | QString lineStr = buffer; | ||
348 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | ||
349 | removeMboxfailed = true; | ||
350 | } | ||
351 | |||
308 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 352 | 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; | |||
10 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | class OProcess; | ||
11 | 12 | ||
@@ -41,2 +42,6 @@ public: | |||
41 | 42 | ||
43 | public slots: | ||
44 | /* for deleting maildirs we are using a system call */ | ||
45 | virtual void oprocessStderr(OProcess*, char *buffer, int ); | ||
46 | virtual void processEnded(OProcess *); | ||
42 | protected: | 47 | protected: |
@@ -49,2 +54,4 @@ protected: | |||
49 | void clean_storage(); | 54 | void clean_storage(); |
55 | |||
56 | bool removeMboxfailed; | ||
50 | }; | 57 | }; |