summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/mhwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/mhwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 0b00a2e..21e24a0 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -1,22 +1,25 @@
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
11using namespace Opie::Core;
12using namespace Opie::Core;
13using namespace Opie::Core;
11MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
12 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
13{ 16{
14 if (MHPath.length()>0) { 17 if (MHPath.length()>0) {
15 if (MHPath[MHPath.length()-1]=='/') { 18 if (MHPath[MHPath.length()-1]=='/') {
16 MHPath=MHPath.left(MHPath.length()-1); 19 MHPath=MHPath.left(MHPath.length()-1);
17 } 20 }
18 qDebug(MHPath); 21 qDebug(MHPath);
19 QDir dir(MHPath); 22 QDir dir(MHPath);
20 if (!dir.exists()) { 23 if (!dir.exists()) {
21 dir.mkdir(MHPath); 24 dir.mkdir(MHPath);
22 } 25 }
@@ -51,43 +54,43 @@ void MHwrapper::clean_storage()
51 if (m_storage) { 54 if (m_storage) {
52 mailstorage_disconnect(m_storage); 55 mailstorage_disconnect(m_storage);
53 mailstorage_free(m_storage); 56 mailstorage_free(m_storage);
54 m_storage = 0; 57 m_storage = 0;
55 } 58 }
56} 59}
57 60
58MHwrapper::~MHwrapper() 61MHwrapper::~MHwrapper()
59{ 62{
60 clean_storage(); 63 clean_storage();
61} 64}
62 65
63void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ) 66void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
64{ 67{
65 init_storage(); 68 init_storage();
66 if (!m_storage) { 69 if (!m_storage) {
67 return; 70 return;
68 } 71 }
69 QString f = buildPath(mailbox); 72 QString f = buildPath(mailbox);
70 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 73 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
71 if (r!=MAIL_NO_ERROR) { 74 if (r!=MAIL_NO_ERROR) {
72 qDebug("listMessages: error selecting folder!"); 75 qDebug("listMessages: error selecting folder!");
73 return; 76 return;
74 } 77 }
75 parseList(target,m_storage->sto_session,f); 78 parseList(target,m_storage->sto_session,f);
76 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 79 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
77} 80}
78 81
79QValueList<Opie::OSmartPointer<Folder> >* MHwrapper::listFolders() 82QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
80{ 83{
81 QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); 84 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
82 /* this is needed! */ 85 /* this is needed! */
83 if (m_storage) mailstorage_disconnect(m_storage); 86 if (m_storage) mailstorage_disconnect(m_storage);
84 init_storage(); 87 init_storage();
85 if (!m_storage) { 88 if (!m_storage) {
86 return folders; 89 return folders;
87 } 90 }
88 mail_list*flist = 0; 91 mail_list*flist = 0;
89 clistcell*current=0; 92 clistcell*current=0;
90 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 93 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
91 if (r != MAIL_NO_ERROR || !flist) { 94 if (r != MAIL_NO_ERROR || !flist) {
92 qDebug("error getting folder list"); 95 qDebug("error getting folder list");
93 return folders; 96 return folders;
@@ -308,27 +311,27 @@ int MHwrapper::deleteMbox(const FolderP&tfolder)
308 311
309 if (r != MAIL_NO_ERROR) { 312 if (r != MAIL_NO_ERROR) {
310 qDebug("error deleting mail box"); 313 qDebug("error deleting mail box");
311 return 0; 314 return 0;
312 } 315 }
313 QString cmd = "rm -rf "+tfolder->getName(); 316 QString cmd = "rm -rf "+tfolder->getName();
314 QStringList command; 317 QStringList command;
315 command << "/bin/sh"; 318 command << "/bin/sh";
316 command << "-c"; 319 command << "-c";
317 command << cmd.latin1(); 320 command << cmd.latin1();
318 OProcess *process = new OProcess(); 321 OProcess *process = new OProcess();
319 322
320 connect(process, SIGNAL(processExited(OProcess*)), 323 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
321 this, SLOT( processEnded(OProcess*))); 324 this, SLOT( processEnded(OProcess*)));
322 connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), 325 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
323 this, SLOT( oprocessStderr(OProcess*,char*,int))); 326 this, SLOT( oprocessStderr(OProcess*,char*,int)));
324 327
325 *process << command; 328 *process << command;
326 removeMboxfailed = false; 329 removeMboxfailed = false;
327 if(!process->start(OProcess::Block, OProcess::All) ) { 330 if(!process->start(OProcess::Block, OProcess::All) ) {
328 qDebug("could not start process"); 331 qDebug("could not start process");
329 return 0; 332 return 0;
330 } 333 }
331 qDebug("mail box deleted"); 334 qDebug("mail box deleted");
332 return 1; 335 return 1;
333} 336}
334 337