summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2003-12-28 02:45:07 (UTC)
committer alwin <alwin>2003-12-28 02:45:07 (UTC)
commitd1a7eb08cad465c5fc0de53f75aaecf7803f0945 (patch) (side-by-side diff)
tree422b73af760cdd44e4fbbc96bd6876a15939ff19 /noncore
parente889485e945d8fa9564566f286114be10d2a1ce5 (diff)
downloadopie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.zip
opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.gz
opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.bz2
- dir handling for mbox accounts (delete, new, delete all mail)
- fixed memory leaks in mbox account class - reduced count of used string constants while using "tr" with context string - mbox displays messages into global status bar - fixed a possible raise condition when deleting a mail directory
Diffstat (limited to 'noncore') (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()
if (m) {
- m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0);
- m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1);
+ m->insertItem(QObject::tr("Refresh folder list",contextName),0);
+ m->insertItem(QObject::tr("Create new folder",contextName),1);
m->insertSeparator();
- m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2);
+ m->insertItem(QObject::tr("Disconnect",contextName),2);
}
@@ -293,10 +293,10 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
if (folder->may_select()) {
- m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0);
- m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1);
+ m->insertItem(QObject::tr("Refresh header list",contextName),0);
+ m->insertItem(QObject::tr("Delete all mails",contextName),1);
}
if (folder->no_inferior()==false) {
- m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2);
+ m->insertItem(QObject::tr("Create new subfolder",contextName),2);
}
if (folder->getDisplayName().lower()!="inbox") {
- m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3);
+ m->insertItem(QObject::tr("Delete folder",contextName),3);
}
@@ -308,6 +308,6 @@ void IMAPfolderItem::deleteAllMails()
{
- int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"),
- QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()),
- QObject::tr("Yes","IMAPfolderItem"),
- QObject::tr("No","IMAPfolderItem"),QString::null,1,1);
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
+ QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
@@ -337,6 +337,6 @@ void IMAPfolderItem::deleteFolder()
{
- int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"),
- QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()),
- QObject::tr("Yes","IMAPfolderItem"),
- QObject::tr("No","IMAPfolderItem"),QString::null,1,1);
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
+ QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
@@ -344,5 +344,10 @@ void IMAPfolderItem::deleteFolder()
if (imap->getWrapper()->deleteMbox(folder)) {
- /* be carefull - after that this object is destroyd so don't call
+ QListView*v=listView();
+ IMAPviewItem * box = imap;
+ /* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
imap->refreshFolders(true);
+ if (v) {
+ v->setSelected(box,true);
+ }
}
@@ -377,2 +382,4 @@ void IMAPfolderItem::contextMenuSelected(int id)
+const QString AccountViewItem::contextName="AccountViewItem";
+
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
@@ -492,2 +499,8 @@ void MBOXviewItem::refresh( QList<RecMail> & )
{
+ refresh(false);
+}
+
+void MBOXviewItem::refresh(bool force)
+{
+ if (childCount()>0 && force==false) return;
QList<Folder> *folders = wrapper->listFolders();
@@ -512,3 +525,3 @@ RecBody MBOXviewItem::fetchBody( const RecMail &mail )
{
- qDebug( "POP3 fetchBody" );
+ qDebug( "MBOX fetchBody" );
return wrapper->fetchBody( mail );
@@ -516,2 +529,38 @@ RecBody MBOXviewItem::fetchBody( const RecMail &mail )
+QPopupMenu * MBOXviewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Refresh folder list",contextName),0);
+ m->insertItem(QObject::tr("Create new folder",contextName),1);
+ }
+ return m;
+}
+
+void MBOXviewItem::createFolder()
+{
+ Newmdirdlg ndirdlg(0,0,true);
+ ndirdlg.showMaximized();
+ if (ndirdlg.exec()) {
+ QString ndir = ndirdlg.Newdir();
+ if (wrapper->createMbox(ndir)) {
+ refresh(true);
+ }
+ }
+}
+
+void MBOXviewItem::contextMenuSelected(int which)
+{
+ switch (which) {
+ case 0:
+ refresh(true);
+ break;
+ case 1:
+ createFolder();
+ break;
+ default:
+ break;
+ }
+}
+
MBOXfolderItem::~MBOXfolderItem()
@@ -546 +595,61 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
}
+
+void MBOXfolderItem::deleteAllMails()
+{
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
+ QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (mbox->getWrapper()->deleteAllMail(folder)) {
+ AccountView * view = (AccountView*)listView();
+ if (view) view->refreshCurrent();
+ }
+ }
+}
+
+void MBOXfolderItem::deleteFolder()
+{
+ int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
+ QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (mbox->getWrapper()->deleteMbox(folder)) {
+ QListView*v=listView();
+ MBOXviewItem * box = mbox;
+ /* be carefull - after that this object is destroyd so don't use
+ * any member of it after that call!!*/
+ mbox->refresh(true);
+ if (v) {
+ v->setSelected(box,true);
+ }
+ }
+ }
+}
+
+QPopupMenu * MBOXfolderItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Delete all mails",contextName),0);
+ m->insertItem(QObject::tr("Delete folder",contextName),1);
+ }
+ return m;
+}
+
+void MBOXfolderItem::contextMenuSelected(int which)
+{
+ switch(which) {
+ case 0:
+ deleteAllMails();
+ break;
+ case 1:
+ deleteFolder();
+ break;
+ default:
+ break;
+ }
+}
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:
virtual void contextMenuSelected(int){}
+protected:
+ static const QString contextName;
};
@@ -90,3 +92,2 @@ public:
bool matchName(const QString&name)const;
- virtual void deleteAllMails();
virtual QPopupMenu * getContextMenu();
@@ -97,2 +98,3 @@ protected:
virtual void deleteFolder();
+ virtual void deleteAllMails();
@@ -105,2 +107,3 @@ class MBOXviewItem : public AccountViewItem
{
+ friend class MBOXfolderItem;
@@ -113,2 +116,9 @@ public:
AbstractMail *getWrapper();
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+
+protected:
+ virtual void refresh(bool force=false);
+ virtual void createFolder();
+
private:
@@ -128,2 +138,8 @@ public:
virtual RecBody fetchBody(const RecMail&);
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+
+protected:
+ virtual void deleteAllMails();
+ virtual void deleteFolder();
private:
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:
- POP3account *account;
- mailpop3 *m_pop3;
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:
- POP3account *account;
- mailpop3 *m_pop3;
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 @@
#include <libetpan/libetpan.h>
-#include <libetpan/mailstorage.h>
#include <qdir.h>
#include <stdlib.h>
+#include <qpe/global.h>
@@ -26,9 +26,6 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
p+=mailbox;
- char*fname = 0;
-
- fname = strdup(p.latin1());
-
- int r = mbox_mailstorage_init(storage,fname,0,0,0);
+
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,fname,NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -38,3 +35,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -47,3 +43,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -58,3 +53,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -63,3 +57,4 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
- for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) {
+ uint32_t i = 0;
+ for(; i < carray_count(env_list->msg_tab) ; ++i) {
mailmessage * msg;
@@ -112,3 +107,3 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
+ Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i));
}
@@ -136,6 +131,5 @@ void MBOXwrapper::deleteMail(const RecMail&mail)
p+=mail.getMbox();
- mailmessage * msg;
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -169,5 +163,5 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -207,4 +201,18 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
-void MBOXwrapper::createFolder(const QString&)
+int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
{
+ QString p = MBOXPath+"/";
+ p+=folder;
+ QFileInfo fi(p);
+ if (fi.exists()) {
+ Global::statusMessage(tr("Mailbox exists."));
+ return 0;
+ }
+ mailmbox_folder*f = 0;
+ if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error init folder"));
+ return 0;
+ }
+ if (f) mailmbox_done(f);
+ return 1;
}
@@ -218,3 +226,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
if (r != MAIL_NO_ERROR) {
- qDebug("Error init folder");
+ Global::statusMessage(tr("Error init folder"));
return;
@@ -223,3 +231,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
if (r != MAIL_NO_ERROR) {
- qDebug("Error writing message folder");
+ Global::statusMessage(tr("Error writing to message folder"));
}
@@ -238,8 +246,8 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
- qDebug("Error initializing mbox");
+ Global::statusMessage(tr("Error initializing mbox"));
mailfolder_free(folder);
@@ -250,3 +258,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
@@ -257,3 +265,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
@@ -280,2 +288,10 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
}
+ deleteMails(f,target);
+ mailmbox_done(f);
+}
+
+void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
+{
+ if (!f) return;
+ int r;
for (unsigned int i=0; i < target.count();++i) {
@@ -290,3 +306,61 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
}
- mailmbox_done(f);
+}
+
+int MBOXwrapper::deleteAllMail(const Folder*tfolder)
+{
+ if (!tfolder) return 0;
+ QString p = MBOXPath+tfolder->getDisplayName();
+ int res = 1;
+
+ mailfolder*folder = 0;
+ mailmessage_list*l=0;
+ mailstorage*storage = mailstorage_new(NULL);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error initializing mbox"));
+ res = 0;
+ }
+ if (res) {
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
+ r = mailfolder_connect(folder);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error initializing mbox"));
+ res = 0;
+ }
+ }
+ if (res) {
+ r = mailsession_get_messages_list(folder->fld_session,&l);
+ if (r != MAIL_NO_ERROR) {
+ qDebug("Error message list");
+ res=0;
+ }
+ }
+ for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
+ r = mailsession_remove_message(folder->fld_session,i+1);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
+ res = 0;
+ break;
+ }
+ }
+ if (l) mailmessage_list_free(l);
+ if (folder) mailfolder_free(folder);
+ if (storage) mailstorage_free(storage);
+ return res;
+}
+
+int MBOXwrapper::deleteMbox(const Folder*tfolder)
+{
+ if (!tfolder) return 0;
+ QString p = MBOXPath+tfolder->getDisplayName();
+ QFile fi(p);
+ if (!fi.exists()) {
+ Global::statusMessage(tr("Mailbox doesn't exist."));
+ return 0;
+ }
+ if (!fi.remove()) {
+ Global::statusMessage(tr("Error deleting Mailbox."));
+ return 0;
+ }
+ return 1;
}
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;
class RecBody;
+struct mailmbox_folder;
@@ -21,3 +22,6 @@ public:
virtual void answeredMail(const RecMail&mail);
- virtual void createFolder(const QString&aFolder);
+
+ virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
+ virtual int deleteMbox(const Folder*);
+
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
@@ -29,4 +33,6 @@ public:
virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
+ virtual int deleteAllMail(const Folder*);
protected:
+ static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
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 @@
#include "logindialog.h"
-#include <libetpan/mailpop3.h>
-#include <libetpan/mailmime.h>
-#include <libetpan/data_message_driver.h>
+#include <libetpan/libetpan.h>
+#include <qpe/global.h>
#include <qfile.h>
@@ -114,2 +113,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
if (!m_pop3) return;
+
mailpop3_list( m_pop3, &messages );
@@ -134,2 +134,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
}
+ Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count));
}
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:
void logout();
-
+ POP3account *account;
+ mailpop3 *m_pop3;
};
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 @@
#include <libetpan/libetpan.h>
-#include <libetpan/mailstorage.h>
#include <qdir.h>
#include <stdlib.h>
+#include <qpe/global.h>
@@ -26,9 +26,6 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
p+=mailbox;
- char*fname = 0;
-
- fname = strdup(p.latin1());
-
- int r = mbox_mailstorage_init(storage,fname,0,0,0);
+
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,fname,NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -38,3 +35,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -47,3 +43,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -58,3 +53,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
return;
@@ -63,3 +57,4 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
- for(int i = 0 ; i < carray_count(env_list->msg_tab) ; ++i) {
+ uint32_t i = 0;
+ for(; i < carray_count(env_list->msg_tab) ; ++i) {
mailmessage * msg;
@@ -112,3 +107,3 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
mailstorage_free(storage);
- free(fname);
+ Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i));
}
@@ -136,6 +131,5 @@ void MBOXwrapper::deleteMail(const RecMail&mail)
p+=mail.getMbox();
- mailmessage * msg;
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -169,5 +163,5 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
@@ -207,4 +201,18 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
-void MBOXwrapper::createFolder(const QString&)
+int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
{
+ QString p = MBOXPath+"/";
+ p+=folder;
+ QFileInfo fi(p);
+ if (fi.exists()) {
+ Global::statusMessage(tr("Mailbox exists."));
+ return 0;
+ }
+ mailmbox_folder*f = 0;
+ if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error init folder"));
+ return 0;
+ }
+ if (f) mailmbox_done(f);
+ return 1;
}
@@ -218,3 +226,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
if (r != MAIL_NO_ERROR) {
- qDebug("Error init folder");
+ Global::statusMessage(tr("Error init folder"));
return;
@@ -223,3 +231,3 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
if (r != MAIL_NO_ERROR) {
- qDebug("Error writing message folder");
+ Global::statusMessage(tr("Error writing to message folder"));
}
@@ -238,8 +246,8 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
- int r = mbox_mailstorage_init(storage,strdup(p.latin1()),0,0,0);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
mailfolder*folder;
- folder = mailfolder_new( storage,strdup(p.latin1()),NULL);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
- qDebug("Error initializing mbox");
+ Global::statusMessage(tr("Error initializing mbox"));
mailfolder_free(folder);
@@ -250,3 +258,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
@@ -257,3 +265,3 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
if (r != MAIL_NO_ERROR) {
- qDebug("Error fetching mail %i",mail.getNumber());
+ Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
@@ -280,2 +288,10 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
}
+ deleteMails(f,target);
+ mailmbox_done(f);
+}
+
+void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
+{
+ if (!f) return;
+ int r;
for (unsigned int i=0; i < target.count();++i) {
@@ -290,3 +306,61 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
}
- mailmbox_done(f);
+}
+
+int MBOXwrapper::deleteAllMail(const Folder*tfolder)
+{
+ if (!tfolder) return 0;
+ QString p = MBOXPath+tfolder->getDisplayName();
+ int res = 1;
+
+ mailfolder*folder = 0;
+ mailmessage_list*l=0;
+ mailstorage*storage = mailstorage_new(NULL);
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error initializing mbox"));
+ res = 0;
+ }
+ if (res) {
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
+ r = mailfolder_connect(folder);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error initializing mbox"));
+ res = 0;
+ }
+ }
+ if (res) {
+ r = mailsession_get_messages_list(folder->fld_session,&l);
+ if (r != MAIL_NO_ERROR) {
+ qDebug("Error message list");
+ res=0;
+ }
+ }
+ for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
+ r = mailsession_remove_message(folder->fld_session,i+1);
+ if (r != MAIL_NO_ERROR) {
+ Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
+ res = 0;
+ break;
+ }
+ }
+ if (l) mailmessage_list_free(l);
+ if (folder) mailfolder_free(folder);
+ if (storage) mailstorage_free(storage);
+ return res;
+}
+
+int MBOXwrapper::deleteMbox(const Folder*tfolder)
+{
+ if (!tfolder) return 0;
+ QString p = MBOXPath+tfolder->getDisplayName();
+ QFile fi(p);
+ if (!fi.exists()) {
+ Global::statusMessage(tr("Mailbox doesn't exist."));
+ return 0;
+ }
+ if (!fi.remove()) {
+ Global::statusMessage(tr("Error deleting Mailbox."));
+ return 0;
+ }
+ return 1;
}
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;
class RecBody;
+struct mailmbox_folder;
@@ -21,3 +22,6 @@ public:
virtual void answeredMail(const RecMail&mail);
- virtual void createFolder(const QString&aFolder);
+
+ virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
+ virtual int deleteMbox(const Folder*);
+
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
@@ -29,4 +33,6 @@ public:
virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
+ virtual int deleteAllMail(const Folder*);
protected:
+ static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
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 @@
-Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name)
+Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub)
: Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false)
{
+ if (no_sub) {
+ subdirsPossibleBox->setChecked(false);
+ subdirsPossibleBox->hide();
+ }
}
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
public:
- Newmdirdlg( QWidget* parent = 0, const char* name = 0);
+ Newmdirdlg( QWidget* parent = 0, const char* name = 0,bool no_sub=false);
~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 @@
#include "logindialog.h"
-#include <libetpan/mailpop3.h>
-#include <libetpan/mailmime.h>
-#include <libetpan/data_message_driver.h>
+#include <libetpan/libetpan.h>
+#include <qpe/global.h>
#include <qfile.h>
@@ -114,2 +113,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
if (!m_pop3) return;
+
mailpop3_list( m_pop3, &messages );
@@ -134,2 +134,3 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
}
+ Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(carray_count(messages)-m_pop3->pop3_deleted_count));
}
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:
void logout();
-
+ POP3account *account;
+ mailpop3 *m_pop3;
};