Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 6 |
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,37 +1,35 @@ | |||
1 | #include "mhwrapper.h" | 1 | #include "mhwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie2/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | using namespace Opie::Core; | ||
13 | using namespace Opie::Core; | ||
14 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 12 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
15 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 13 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
16 | { | 14 | { |
17 | if (MHPath.length()>0) { | 15 | if (MHPath.length()>0) { |
18 | if (MHPath[MHPath.length()-1]=='/') { | 16 | if (MHPath[MHPath.length()-1]=='/') { |
19 | MHPath=MHPath.left(MHPath.length()-1); | 17 | MHPath=MHPath.left(MHPath.length()-1); |
20 | } | 18 | } |
21 | qDebug(MHPath); | 19 | qDebug(MHPath); |
22 | QDir dir(MHPath); | 20 | QDir dir(MHPath); |
23 | if (!dir.exists()) { | 21 | if (!dir.exists()) { |
24 | dir.mkdir(MHPath); | 22 | dir.mkdir(MHPath); |
25 | } | 23 | } |
26 | init_storage(); | 24 | init_storage(); |
27 | } | 25 | } |
28 | } | 26 | } |
29 | 27 | ||
30 | void MHwrapper::init_storage() | 28 | void MHwrapper::init_storage() |
31 | { | 29 | { |
32 | int r; | 30 | int r; |
33 | QString pre = MHPath; | 31 | QString pre = MHPath; |
34 | if (!m_storage) { | 32 | if (!m_storage) { |
35 | m_storage = mailstorage_new(NULL); | 33 | m_storage = mailstorage_new(NULL); |
36 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 34 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
37 | if (r != MAIL_NO_ERROR) { | 35 | if (r != MAIL_NO_ERROR) { |
@@ -300,51 +298,51 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder) | |||
300 | 298 | ||
301 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 299 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
302 | { | 300 | { |
303 | init_storage(); | 301 | init_storage(); |
304 | if (!m_storage) { | 302 | if (!m_storage) { |
305 | return 0; | 303 | return 0; |
306 | } | 304 | } |
307 | if (!tfolder) return 0; | 305 | if (!tfolder) return 0; |
308 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 306 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
309 | 307 | ||
310 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 308 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
311 | 309 | ||
312 | if (r != MAIL_NO_ERROR) { | 310 | if (r != MAIL_NO_ERROR) { |
313 | qDebug("error deleting mail box"); | 311 | qDebug("error deleting mail box"); |
314 | return 0; | 312 | return 0; |
315 | } | 313 | } |
316 | QString cmd = "rm -rf "+tfolder->getName(); | 314 | QString cmd = "rm -rf "+tfolder->getName(); |
317 | QStringList command; | 315 | QStringList command; |
318 | command << "/bin/sh"; | 316 | command << "/bin/sh"; |
319 | command << "-c"; | 317 | command << "-c"; |
320 | command << cmd.latin1(); | 318 | command << cmd.latin1(); |
321 | OProcess *process = new OProcess(); | 319 | OProcess *process = new OProcess(); |
322 | 320 | ||
323 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 321 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
324 | this, SLOT( processEnded(OProcess*))); | 322 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
325 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 323 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
326 | this, SLOT( oprocessStderr(OProcess*,char*,int))); | 324 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
327 | 325 | ||
328 | *process << command; | 326 | *process << command; |
329 | removeMboxfailed = false; | 327 | removeMboxfailed = false; |
330 | if(!process->start(OProcess::Block, OProcess::All) ) { | 328 | if(!process->start(OProcess::Block, OProcess::All) ) { |
331 | qDebug("could not start process"); | 329 | qDebug("could not start process"); |
332 | return 0; | 330 | return 0; |
333 | } | 331 | } |
334 | qDebug("mail box deleted"); | 332 | qDebug("mail box deleted"); |
335 | return 1; | 333 | return 1; |
336 | } | 334 | } |
337 | 335 | ||
338 | void MHwrapper::processEnded(OProcess *p) | 336 | void MHwrapper::processEnded(OProcess *p) |
339 | { | 337 | { |
340 | if (p) delete p; | 338 | if (p) delete p; |
341 | } | 339 | } |
342 | 340 | ||
343 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 341 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
344 | { | 342 | { |
345 | QString lineStr = buffer; | 343 | QString lineStr = buffer; |
346 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 344 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
347 | removeMboxfailed = true; | 345 | removeMboxfailed = true; |
348 | } | 346 | } |
349 | 347 | ||
350 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 348 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |