author | alwin <alwin> | 2004-01-10 03:20:04 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-10 03:20:04 (UTC) |
commit | 6248e82bf1b077c54e3e2b85801a99fa0f86434d (patch) (unidiff) | |
tree | d223c9984c9e0d296ba4ae57654c1b15795c1e70 | |
parent | dcfd6e5e2e2021bc5ed0bcf42b1b0a7002c59a17 (diff) | |
download | opie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.zip opie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.tar.gz opie-6248e82bf1b077c54e3e2b85801a99fa0f86434d.tar.bz2 |
mh wrapper fully functional.
-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 | |||
@@ -3,8 +3,10 @@ | |||
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 <stdlib.h> | 7 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie/oprocess.h> | ||
8 | 10 | ||
9 | const QString MHwrapper::wrapperType="MH"; | 11 | const QString MHwrapper::wrapperType="MH"; |
10 | 12 | ||
@@ -80,6 +82,8 @@ QList<Folder>* MHwrapper::listFolders() | |||
80 | { | 82 | { |
81 | QList<Folder> * folders = new QList<Folder>(); | 83 | QList<Folder> * folders = new QList<Folder>(); |
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(); |
84 | if (!m_storage) { | 88 | if (!m_storage) { |
85 | return folders; | 89 | return folders; |
@@ -167,20 +171,28 @@ QString MHwrapper::buildPath(const QString&p) | |||
167 | return f; | 171 | return f; |
168 | } | 172 | } |
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 | { |
172 | init_storage(); | 176 | init_storage(); |
173 | if (!m_storage) { | 177 | if (!m_storage) { |
174 | return 0; | 178 | return 0; |
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; |
181 | } | 194 | } |
182 | qDebug("Folder created"); | 195 | qDebug("Folder created"); |
183 | mailstorage_disconnect(m_storage); | ||
184 | return 1; | 196 | return 1; |
185 | } | 197 | } |
186 | 198 | ||
@@ -295,16 +307,48 @@ int MHwrapper::deleteMbox(const Folder*tfolder) | |||
295 | return 0; | 307 | return 0; |
296 | } | 308 | } |
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) { |
300 | qDebug("error deleting mail box"); | 315 | qDebug("error deleting mail box"); |
301 | return 0; | 316 | return 0; |
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; |
306 | } | 338 | } |
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) |
309 | { | 353 | { |
310 | init_storage(); | 354 | init_storage(); |
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 | |||
@@ -8,6 +8,7 @@ class RecMail; | |||
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | class OProcess; | ||
11 | 12 | ||
12 | class MHwrapper : public Genericwrapper | 13 | class MHwrapper : public Genericwrapper |
13 | { | 14 | { |
@@ -39,6 +40,10 @@ public: | |||
39 | virtual const QString&getType()const; | 40 | virtual const QString&getType()const; |
40 | virtual const QString&getName()const; | 41 | virtual const QString&getName()const; |
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: |
43 | QString buildPath(const QString&p); | 48 | QString buildPath(const QString&p); |
44 | QString MHPath; | 49 | QString MHPath; |
@@ -47,6 +52,8 @@ protected: | |||
47 | 52 | ||
48 | void init_storage(); | 53 | void init_storage(); |
49 | void clean_storage(); | 54 | void clean_storage(); |
55 | |||
56 | bool removeMboxfailed; | ||
50 | }; | 57 | }; |
51 | 58 | ||
52 | #endif | 59 | #endif |