summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp143
-rw-r--r--noncore/net/mail/accountview.h18
-rw-r--r--noncore/net/mail/genericwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp126
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h8
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h3
-rw-r--r--noncore/net/mail/mboxwrapper.cpp126
-rw-r--r--noncore/net/mail/mboxwrapper.h8
-rw-r--r--noncore/net/mail/newmaildir.cpp6
-rw-r--r--noncore/net/mail/newmaildir.h2
-rw-r--r--noncore/net/mail/pop3wrapper.cpp7
-rw-r--r--noncore/net/mail/pop3wrapper.h3
14 files changed, 375 insertions, 86 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 8aac14b..30765cf 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -187,6 +187,6 @@ QPopupMenu * IMAPviewItem::getContextMenu()
187 if (m) { 187 if (m) {
188 m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); 188 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
189 m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); 189 m->insertItem(QObject::tr("Create new folder",contextName),1);
190 m->insertSeparator(); 190 m->insertSeparator();
191 m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); 191 m->insertItem(QObject::tr("Disconnect",contextName),2);
192 } 192 }
@@ -293,10 +293,10 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
293 if (folder->may_select()) { 293 if (folder->may_select()) {
294 m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); 294 m->insertItem(QObject::tr("Refresh header list",contextName),0);
295 m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); 295 m->insertItem(QObject::tr("Delete all mails",contextName),1);
296 } 296 }
297 if (folder->no_inferior()==false) { 297 if (folder->no_inferior()==false) {
298 m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); 298 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
299 } 299 }
300 if (folder->getDisplayName().lower()!="inbox") { 300 if (folder->getDisplayName().lower()!="inbox") {
301 m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); 301 m->insertItem(QObject::tr("Delete folder",contextName),3);
302 } 302 }
@@ -308,6 +308,6 @@ void IMAPfolderItem::deleteAllMails()
308{ 308{
309 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), 309 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
310 QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), 310 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()),
311 QObject::tr("Yes","IMAPfolderItem"), 311 QObject::tr("Yes",contextName),
312 QObject::tr("No","IMAPfolderItem"),QString::null,1,1); 312 QObject::tr("No",contextName),QString::null,1,1);
313 qDebug("Auswahl: %i",yesno); 313 qDebug("Auswahl: %i",yesno);
@@ -337,6 +337,6 @@ void IMAPfolderItem::deleteFolder()
337{ 337{
338 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), 338 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
339 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), 339 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
340 QObject::tr("Yes","IMAPfolderItem"), 340 QObject::tr("Yes",contextName),
341 QObject::tr("No","IMAPfolderItem"),QString::null,1,1); 341 QObject::tr("No",contextName),QString::null,1,1);
342 qDebug("Auswahl: %i",yesno); 342 qDebug("Auswahl: %i",yesno);
@@ -344,5 +344,10 @@ void IMAPfolderItem::deleteFolder()
344 if (imap->getWrapper()->deleteMbox(folder)) { 344 if (imap->getWrapper()->deleteMbox(folder)) {
345 /* be carefull - after that this object is destroyd so don't call 345 QListView*v=listView();
346 IMAPviewItem * box = imap;
347 /* be carefull - after that this object is destroyd so don't use
346 * any member of it after that call!!*/ 348 * any member of it after that call!!*/
347 imap->refreshFolders(true); 349 imap->refreshFolders(true);
350 if (v) {
351 v->setSelected(box,true);
352 }
348 } 353 }
@@ -377,2 +382,4 @@ void IMAPfolderItem::contextMenuSelected(int id)
377 382
383const QString AccountViewItem::contextName="AccountViewItem";
384
378AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 385AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
@@ -492,2 +499,8 @@ void MBOXviewItem::refresh( QList<RecMail> & )
492{ 499{
500 refresh(false);
501}
502
503void MBOXviewItem::refresh(bool force)
504{
505 if (childCount()>0 && force==false) return;
493 QList<Folder> *folders = wrapper->listFolders(); 506 QList<Folder> *folders = wrapper->listFolders();
@@ -512,3 +525,3 @@ RecBody MBOXviewItem::fetchBody( const RecMail &mail )
512{ 525{
513 qDebug( "POP3 fetchBody" ); 526 qDebug( "MBOX fetchBody" );
514 return wrapper->fetchBody( mail ); 527 return wrapper->fetchBody( mail );
@@ -516,2 +529,38 @@ RecBody MBOXviewItem::fetchBody( const RecMail &mail )
516 529
530QPopupMenu * MBOXviewItem::getContextMenu()
531{
532 QPopupMenu *m = new QPopupMenu(0);
533 if (m) {
534 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
535 m->insertItem(QObject::tr("Create new folder",contextName),1);
536 }
537 return m;
538}
539
540void MBOXviewItem::createFolder()
541{
542 Newmdirdlg ndirdlg(0,0,true);
543 ndirdlg.showMaximized();
544 if (ndirdlg.exec()) {
545 QString ndir = ndirdlg.Newdir();
546 if (wrapper->createMbox(ndir)) {
547 refresh(true);
548 }
549 }
550}
551
552void MBOXviewItem::contextMenuSelected(int which)
553{
554 switch (which) {
555 case 0:
556 refresh(true);
557 break;
558 case 1:
559 createFolder();
560 break;
561 default:
562 break;
563 }
564}
565
517MBOXfolderItem::~MBOXfolderItem() 566MBOXfolderItem::~MBOXfolderItem()
@@ -546 +595,61 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
546} 595}
596
597void MBOXfolderItem::deleteAllMails()
598{
599 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
600 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()),
601 QObject::tr("Yes",contextName),
602 QObject::tr("No",contextName),QString::null,1,1);
603 qDebug("Auswahl: %i",yesno);
604 if (yesno == 0) {
605 if (mbox->getWrapper()->deleteAllMail(folder)) {
606 AccountView * view = (AccountView*)listView();
607 if (view) view->refreshCurrent();
608 }
609 }
610}
611
612void MBOXfolderItem::deleteFolder()
613{
614 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
615 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
616 QObject::tr("Yes",contextName),
617 QObject::tr("No",contextName),QString::null,1,1);
618 qDebug("Auswahl: %i",yesno);
619 if (yesno == 0) {
620 if (mbox->getWrapper()->deleteMbox(folder)) {
621 QListView*v=listView();
622 MBOXviewItem * box = mbox;
623 /* be carefull - after that this object is destroyd so don't use
624 * any member of it after that call!!*/
625 mbox->refresh(true);
626 if (v) {
627 v->setSelected(box,true);
628 }
629 }
630 }
631}
632
633QPopupMenu * MBOXfolderItem::getContextMenu()
634{
635 QPopupMenu *m = new QPopupMenu(0);
636 if (m) {
637 m->insertItem(QObject::tr("Delete all mails",contextName),0);
638 m->insertItem(QObject::tr("Delete folder",contextName),1);
639 }
640 return m;
641}
642
643void MBOXfolderItem::contextMenuSelected(int which)
644{
645 switch(which) {
646 case 0:
647 deleteAllMails();
648 break;
649 case 1:
650 deleteFolder();
651 break;
652 default:
653 break;
654 }
655}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index e7fe038..98abf44 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -26,2 +26,4 @@ public:
26 virtual void contextMenuSelected(int){} 26 virtual void contextMenuSelected(int){}
27protected:
28 static const QString contextName;
27}; 29};
@@ -90,3 +92,2 @@ public:
90 bool matchName(const QString&name)const; 92 bool matchName(const QString&name)const;
91 virtual void deleteAllMails();
92 virtual QPopupMenu * getContextMenu(); 93 virtual QPopupMenu * getContextMenu();
@@ -97,2 +98,3 @@ protected:
97 virtual void deleteFolder(); 98 virtual void deleteFolder();
99 virtual void deleteAllMails();
98 100
@@ -105,2 +107,3 @@ class MBOXviewItem : public AccountViewItem
105{ 107{
108 friend class MBOXfolderItem;
106 109
@@ -113,2 +116,9 @@ public:
113 AbstractMail *getWrapper(); 116 AbstractMail *getWrapper();
117 virtual QPopupMenu * getContextMenu();
118 virtual void contextMenuSelected(int);
119
120protected:
121 virtual void refresh(bool force=false);
122 virtual void createFolder();
123
114private: 124private:
@@ -128,2 +138,8 @@ public:
128 virtual RecBody fetchBody(const RecMail&); 138 virtual RecBody fetchBody(const RecMail&);
139 virtual QPopupMenu * getContextMenu();
140 virtual void contextMenuSelected(int);
141
142protected:
143 virtual void deleteAllMails();
144 virtual void deleteFolder();
129private: 145private:
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h
index 12f6928..90c4b50 100644
--- a/noncore/net/mail/genericwrapper.h
+++ b/noncore/net/mail/genericwrapper.h
@@ -51,4 +51,2 @@ protected:
51 51
52 POP3account *account;
53 mailpop3 *m_pop3;
54 QString msgTempName; 52 QString msgTempName;
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index 12f6928..90c4b50 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -51,4 +51,2 @@ protected:
51 51
52 POP3account *account;
53 mailpop3 *m_pop3;
54 QString msgTempName; 52 QString msgTempName;
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 6d69263..162a0c9 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -4,5 +4,5 @@
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5#include <libetpan/mailstorage.h>
6#include <qdir.h> 5#include <qdir.h>
7#include <stdlib.h> 6#include <stdlib.h>
7#include <qpe/global.h>
8 8
@@ -26,9 +26,6 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
26 p+=mailbox; 26 p+=mailbox;
27 char*fname = 0; 27
28 28 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
29 fname = strdup(p.latin1());
30
31 int r = mbox_mailstorage_init(storage,fname,0,0,0);
32 mailfolder*folder; 29 mailfolder*folder;
33 folder = mailfolder_new( storage,fname,NULL); 30 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
34 r = mailfolder_connect(folder); 31 r = mailfolder_connect(folder);
@@ -38,3 +35,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
38 mailstorage_free(storage); 35 mailstorage_free(storage);
39 free(fname);
40 return; 36 return;
@@ -47,3 +43,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
47 mailstorage_free(storage); 43 mailstorage_free(storage);
48 free(fname);
49 return; 44 return;
@@ -58,3 +53,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
58 mailstorage_free(storage); 53 mailstorage_free(storage);
59 free(fname);
60 return; 54 return;
@@ -63,3 +57,4 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
63 57
64 for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { 58 uint32_t i = 0;
59 for(; i < carray_count(env_list->msg_tab) ; ++i) {
65 mailmessage * msg; 60 mailmessage * msg;
@@ -112,3 +107,3 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
112 mailstorage_free(storage); 107 mailstorage_free(storage);
113 free(fname); 108 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i));
114} 109}
@@ -136,6 +131,5 @@ void MBOXwrapper::deleteMail(const RecMail&mail)
136 p+=mail.getMbox(); 131 p+=mail.getMbox();
137 mailmessage * msg; 132 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
138 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
139 mailfolder*folder; 133 mailfolder*folder;
140 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 134 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
141 r = mailfolder_connect(folder); 135 r = mailfolder_connect(folder);
@@ -169,5 +163,5 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
169 163
170 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); 164 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
171 mailfolder*folder; 165 mailfolder*folder;
172 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 166 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
173 r = mailfolder_connect(folder); 167 r = mailfolder_connect(folder);
@@ -207,4 +201,18 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
207 201
208void MBOXwrapper::createFolder(const QString&) 202int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
209{ 203{
204 QString p = MBOXPath+"/";
205 p+=folder;
206 QFileInfo fi(p);
207 if (fi.exists()) {
208 Global::statusMessage(tr("Mailbox exists."));
209 return 0;
210 }
211 mailmbox_folder*f = 0;
212 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
213 Global::statusMessage(tr("Error init folder"));
214 return 0;
215 }
216 if (f) mailmbox_done(f);
217 return 1;
210} 218}
@@ -218,3 +226,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
218 if (r != MAIL_NO_ERROR) { 226 if (r != MAIL_NO_ERROR) {
219 qDebug("Error init folder"); 227 Global::statusMessage(tr("Error init folder"));
220 return; 228 return;
@@ -223,3 +231,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
223 if (r != MAIL_NO_ERROR) { 231 if (r != MAIL_NO_ERROR) {
224 qDebug("Error writing message folder"); 232 Global::statusMessage(tr("Error writing to message folder"));
225 } 233 }
@@ -238,8 +246,8 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
238 246
239 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); 247 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
240 mailfolder*folder; 248 mailfolder*folder;
241 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 249 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
242 r = mailfolder_connect(folder); 250 r = mailfolder_connect(folder);
243 if (r != MAIL_NO_ERROR) { 251 if (r != MAIL_NO_ERROR) {
244 qDebug("Error initializing mbox"); 252 Global::statusMessage(tr("Error initializing mbox"));
245 mailfolder_free(folder); 253 mailfolder_free(folder);
@@ -250,3 +258,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
250 if (r != MAIL_NO_ERROR) { 258 if (r != MAIL_NO_ERROR) {
251 qDebug("Error fetching mail %i",mail.getNumber()); 259 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
252 mailfolder_free(folder); 260 mailfolder_free(folder);
@@ -257,3 +265,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
257 if (r != MAIL_NO_ERROR) { 265 if (r != MAIL_NO_ERROR) {
258 qDebug("Error fetching mail %i",mail.getNumber()); 266 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
259 mailfolder_free(folder); 267 mailfolder_free(folder);
@@ -280,2 +288,10 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
280 } 288 }
289 deleteMails(f,target);
290 mailmbox_done(f);
291}
292
293void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
294{
295 if (!f) return;
296 int r;
281 for (unsigned int i=0; i < target.count();++i) { 297 for (unsigned int i=0; i < target.count();++i) {
@@ -290,3 +306,61 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
290 } 306 }
291 mailmbox_done(f); 307}
308
309int MBOXwrapper::deleteAllMail(const Folder*tfolder)
310{
311 if (!tfolder) return 0;
312 QString p = MBOXPath+tfolder->getDisplayName();
313 int res = 1;
314
315 mailfolder*folder = 0;
316 mailmessage_list*l=0;
317 mailstorage*storage = mailstorage_new(NULL);
318 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
319 if (r != MAIL_NO_ERROR) {
320 Global::statusMessage(tr("Error initializing mbox"));
321 res = 0;
322 }
323 if (res) {
324 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
325 r = mailfolder_connect(folder);
326 if (r != MAIL_NO_ERROR) {
327 Global::statusMessage(tr("Error initializing mbox"));
328 res = 0;
329 }
330 }
331 if (res) {
332 r = mailsession_get_messages_list(folder->fld_session,&l);
333 if (r != MAIL_NO_ERROR) {
334 qDebug("Error message list");
335 res=0;
336 }
337 }
338 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
339 r = mailsession_remove_message(folder->fld_session,i+1);
340 if (r != MAIL_NO_ERROR) {
341 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
342 res = 0;
343 break;
344 }
345 }
346 if (l) mailmessage_list_free(l);
347 if (folder) mailfolder_free(folder);
348 if (storage) mailstorage_free(storage);
349 return res;
350}
351
352int MBOXwrapper::deleteMbox(const Folder*tfolder)
353{
354 if (!tfolder) return 0;
355 QString p = MBOXPath+tfolder->getDisplayName();
356 QFile fi(p);
357 if (!fi.exists()) {
358 Global::statusMessage(tr("Mailbox doesn't exist."));
359 return 0;
360 }
361 if (!fi.remove()) {
362 Global::statusMessage(tr("Error deleting Mailbox."));
363 return 0;
364 }
365 return 1;
292} 366}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index f64ad52..226a544 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -8,2 +8,3 @@ class RecMail;
8class RecBody; 8class RecBody;
9struct mailmbox_folder;
9 10
@@ -21,3 +22,6 @@ public:
21 virtual void answeredMail(const RecMail&mail); 22 virtual void answeredMail(const RecMail&mail);
22 virtual void createFolder(const QString&aFolder); 23
24 virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
25 virtual int deleteMbox(const Folder*);
26
23 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 27 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
@@ -29,4 +33,6 @@ public:
29 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); 33 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
34 virtual int deleteAllMail(const Folder*);
30 35
31protected: 36protected:
37 static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
32 QString MBOXPath; 38 QString MBOXPath;
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index efd83ba..b85fbf6 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -4,5 +4,4 @@
4#include "logindialog.h" 4#include "logindialog.h"
5#include <libetpan/mailpop3.h> 5#include <libetpan/libetpan.h>
6#include <libetpan/mailmime.h> 6#include <qpe/global.h>
7#include <libetpan/data_message_driver.h>
8#include <qfile.h> 7#include <qfile.h>
@@ -114,2 +113,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
114 if (!m_pop3) return; 113 if (!m_pop3) return;
114
115 mailpop3_list( m_pop3, &messages ); 115 mailpop3_list( m_pop3, &messages );
@@ -134,2 +134,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
134 } 134 }
135 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count));
135} 136}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index b738cca..7502720 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -28,3 +28,4 @@ protected:
28 void logout(); 28 void logout();
29 29 POP3account *account;
30 mailpop3 *m_pop3;
30}; 31};
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp
index 6d69263..162a0c9 100644
--- a/noncore/net/mail/mboxwrapper.cpp
+++ b/noncore/net/mail/mboxwrapper.cpp
@@ -4,5 +4,5 @@
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5#include <libetpan/mailstorage.h>
6#include <qdir.h> 5#include <qdir.h>
7#include <stdlib.h> 6#include <stdlib.h>
7#include <qpe/global.h>
8 8
@@ -26,9 +26,6 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
26 p+=mailbox; 26 p+=mailbox;
27 char*fname = 0; 27
28 28 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
29 fname = strdup(p.latin1());
30
31 int r = mbox_mailstorage_init(storage,fname,0,0,0);
32 mailfolder*folder; 29 mailfolder*folder;
33 folder = mailfolder_new( storage,fname,NULL); 30 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
34 r = mailfolder_connect(folder); 31 r = mailfolder_connect(folder);
@@ -38,3 +35,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
38 mailstorage_free(storage); 35 mailstorage_free(storage);
39 free(fname);
40 return; 36 return;
@@ -47,3 +43,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
47 mailstorage_free(storage); 43 mailstorage_free(storage);
48 free(fname);
49 return; 44 return;
@@ -58,3 +53,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
58 mailstorage_free(storage); 53 mailstorage_free(storage);
59 free(fname);
60 return; 54 return;
@@ -63,3 +57,4 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
63 57
64 for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) { 58 uint32_t i = 0;
59 for(; i < carray_count(env_list->msg_tab) ; ++i) {
65 mailmessage * msg; 60 mailmessage * msg;
@@ -112,3 +107,3 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
112 mailstorage_free(storage); 107 mailstorage_free(storage);
113 free(fname); 108 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i));
114} 109}
@@ -136,6 +131,5 @@ void MBOXwrapper::deleteMail(const RecMail&mail)
136 p+=mail.getMbox(); 131 p+=mail.getMbox();
137 mailmessage * msg; 132 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
138 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
139 mailfolder*folder; 133 mailfolder*folder;
140 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 134 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
141 r = mailfolder_connect(folder); 135 r = mailfolder_connect(folder);
@@ -169,5 +163,5 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
169 163
170 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); 164 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
171 mailfolder*folder; 165 mailfolder*folder;
172 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 166 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
173 r = mailfolder_connect(folder); 167 r = mailfolder_connect(folder);
@@ -207,4 +201,18 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
207 201
208void MBOXwrapper::createFolder(const QString&) 202int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
209{ 203{
204 QString p = MBOXPath+"/";
205 p+=folder;
206 QFileInfo fi(p);
207 if (fi.exists()) {
208 Global::statusMessage(tr("Mailbox exists."));
209 return 0;
210 }
211 mailmbox_folder*f = 0;
212 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
213 Global::statusMessage(tr("Error init folder"));
214 return 0;
215 }
216 if (f) mailmbox_done(f);
217 return 1;
210} 218}
@@ -218,3 +226,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
218 if (r != MAIL_NO_ERROR) { 226 if (r != MAIL_NO_ERROR) {
219 qDebug("Error init folder"); 227 Global::statusMessage(tr("Error init folder"));
220 return; 228 return;
@@ -223,3 +231,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
223 if (r != MAIL_NO_ERROR) { 231 if (r != MAIL_NO_ERROR) {
224 qDebug("Error writing message folder"); 232 Global::statusMessage(tr("Error writing to message folder"));
225 } 233 }
@@ -238,8 +246,8 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
238 246
239 int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0); 247 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
240 mailfolder*folder; 248 mailfolder*folder;
241 folder = mailfolder_new( storage,strdup(p.latin1()),NULL); 249 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
242 r = mailfolder_connect(folder); 250 r = mailfolder_connect(folder);
243 if (r != MAIL_NO_ERROR) { 251 if (r != MAIL_NO_ERROR) {
244 qDebug("Error initializing mbox"); 252 Global::statusMessage(tr("Error initializing mbox"));
245 mailfolder_free(folder); 253 mailfolder_free(folder);
@@ -250,3 +258,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
250 if (r != MAIL_NO_ERROR) { 258 if (r != MAIL_NO_ERROR) {
251 qDebug("Error fetching mail %i",mail.getNumber()); 259 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
252 mailfolder_free(folder); 260 mailfolder_free(folder);
@@ -257,3 +265,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
257 if (r != MAIL_NO_ERROR) { 265 if (r != MAIL_NO_ERROR) {
258 qDebug("Error fetching mail %i",mail.getNumber()); 266 Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
259 mailfolder_free(folder); 267 mailfolder_free(folder);
@@ -280,2 +288,10 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
280 } 288 }
289 deleteMails(f,target);
290 mailmbox_done(f);
291}
292
293void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
294{
295 if (!f) return;
296 int r;
281 for (unsigned int i=0; i < target.count();++i) { 297 for (unsigned int i=0; i < target.count();++i) {
@@ -290,3 +306,61 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
290 } 306 }
291 mailmbox_done(f); 307}
308
309int MBOXwrapper::deleteAllMail(const Folder*tfolder)
310{
311 if (!tfolder) return 0;
312 QString p = MBOXPath+tfolder->getDisplayName();
313 int res = 1;
314
315 mailfolder*folder = 0;
316 mailmessage_list*l=0;
317 mailstorage*storage = mailstorage_new(NULL);
318 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
319 if (r != MAIL_NO_ERROR) {
320 Global::statusMessage(tr("Error initializing mbox"));
321 res = 0;
322 }
323 if (res) {
324 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
325 r = mailfolder_connect(folder);
326 if (r != MAIL_NO_ERROR) {
327 Global::statusMessage(tr("Error initializing mbox"));
328 res = 0;
329 }
330 }
331 if (res) {
332 r = mailsession_get_messages_list(folder->fld_session,&l);
333 if (r != MAIL_NO_ERROR) {
334 qDebug("Error message list");
335 res=0;
336 }
337 }
338 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
339 r = mailsession_remove_message(folder->fld_session,i+1);
340 if (r != MAIL_NO_ERROR) {
341 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
342 res = 0;
343 break;
344 }
345 }
346 if (l) mailmessage_list_free(l);
347 if (folder) mailfolder_free(folder);
348 if (storage) mailstorage_free(storage);
349 return res;
350}
351
352int MBOXwrapper::deleteMbox(const Folder*tfolder)
353{
354 if (!tfolder) return 0;
355 QString p = MBOXPath+tfolder->getDisplayName();
356 QFile fi(p);
357 if (!fi.exists()) {
358 Global::statusMessage(tr("Mailbox doesn't exist."));
359 return 0;
360 }
361 if (!fi.remove()) {
362 Global::statusMessage(tr("Error deleting Mailbox."));
363 return 0;
364 }
365 return 1;
292} 366}
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h
index f64ad52..226a544 100644
--- a/noncore/net/mail/mboxwrapper.h
+++ b/noncore/net/mail/mboxwrapper.h
@@ -8,2 +8,3 @@ class RecMail;
8class RecBody; 8class RecBody;
9struct mailmbox_folder;
9 10
@@ -21,3 +22,6 @@ public:
21 virtual void answeredMail(const RecMail&mail); 22 virtual void answeredMail(const RecMail&mail);
22 virtual void createFolder(const QString&aFolder); 23
24 virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
25 virtual int deleteMbox(const Folder*);
26
23 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 27 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
@@ -29,4 +33,6 @@ public:
29 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); 33 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
34 virtual int deleteAllMail(const Folder*);
30 35
31protected: 36protected:
37 static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
32 QString MBOXPath; 38 QString MBOXPath;
diff --git a/noncore/net/mail/newmaildir.cpp b/noncore/net/mail/newmaildir.cpp
index 3fc66f4..ab0d4e3 100644
--- a/noncore/net/mail/newmaildir.cpp
+++ b/noncore/net/mail/newmaildir.cpp
@@ -6,5 +6,9 @@
6 6
7Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name) 7Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub)
8 : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) 8 : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false)
9{ 9{
10 if (no_sub) {
11 subdirsPossibleBox->setChecked(false);
12 subdirsPossibleBox->hide();
13 }
10} 14}
diff --git a/noncore/net/mail/newmaildir.h b/noncore/net/mail/newmaildir.h
index 1eb904e..496eaf4 100644
--- a/noncore/net/mail/newmaildir.h
+++ b/noncore/net/mail/newmaildir.h
@@ -7,3 +7,3 @@ class Newmdirdlg : public Newmdirdlgui
7public: 7public:
8 Newmdirdlg( QWidget* parent = 0, const char* name = 0); 8 Newmdirdlg( QWidget* parent = 0, const char* name = 0,bool no_sub=false);
9 ~Newmdirdlg(); 9 ~Newmdirdlg();
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index efd83ba..b85fbf6 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -4,5 +4,4 @@
4#include "logindialog.h" 4#include "logindialog.h"
5#include <libetpan/mailpop3.h> 5#include <libetpan/libetpan.h>
6#include <libetpan/mailmime.h> 6#include <qpe/global.h>
7#include <libetpan/data_message_driver.h>
8#include <qfile.h> 7#include <qfile.h>
@@ -114,2 +113,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
114 if (!m_pop3) return; 113 if (!m_pop3) return;
114
115 mailpop3_list( m_pop3, &messages ); 115 mailpop3_list( m_pop3, &messages );
@@ -134,2 +134,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
134 } 134 }
135 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count));
135} 136}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index b738cca..7502720 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -28,3 +28,4 @@ protected:
28 void logout(); 28 void logout();
29 29 POP3account *account;
30 mailpop3 *m_pop3;
30}; 31};