summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-28 12:57:44 (UTC)
committer alwin <alwin>2003-12-28 12:57:44 (UTC)
commitb41e3eb92eab8bf61fd20db70d0317c816b1c2f0 (patch) (side-by-side diff)
tree5795854d7de75edc4385edc6ee7389809f98f4e1
parentb834b22bade330b2d684c59b7fc1031a8bf650c5 (diff)
downloadopie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.zip
opie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.tar.gz
opie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.tar.bz2
basic folder handling for pop3 accounts
some code dups reduced
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.h2
-rw-r--r--noncore/net/mail/accountview.cpp76
-rw-r--r--noncore/net/mail/accountview.h6
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp31
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/pop3wrapper.cpp31
-rw-r--r--noncore/net/mail/pop3wrapper.h1
8 files changed, 106 insertions, 44 deletions
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index b609aa7..5dc4cab 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -30,4 +30,5 @@ public:
virtual void cleanMimeCache(){};
virtual int deleteAllMail(const Folder*){return 1;}
+ virtual int deleteMbox(const Folder*){return 1;}
/* mail box methods */
@@ -37,5 +38,4 @@ public:
*/
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;}
- virtual int deleteMbox(const Folder*){return 1;}
static AbstractMail* getWrapper(IMAPaccount *a);
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 30765cf..f861c20 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -85,4 +85,29 @@ RecBody POP3folderItem::fetchBody(const RecMail&aMail)
}
+QPopupMenu * POP3folderItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(QObject::tr("Refresh header list",contextName),0);
+ m->insertItem(QObject::tr("Delete all mails",contextName),1);
+ }
+ return m;
+}
+
+void POP3folderItem::contextMenuSelected(int which)
+{
+ AccountView * view = (AccountView*)listView();
+ switch (which) {
+ case 0:
+ view->refreshCurrent();
+ break;
+ case 1:
+ deleteAllMail(pop3->getWrapper(),folder);
+ break;
+ default:
+ break;
+ }
+}
+
/**
* IMAP Account stuff
@@ -305,19 +330,4 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
}
-void IMAPfolderItem::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 (imap->getWrapper()->deleteAllMail(folder)) {
- AccountView * view = (AccountView*)listView();
- if (view) view->refreshCurrent();
- }
- }
-}
-
void IMAPfolderItem::createNewFolder()
{
@@ -364,5 +374,5 @@ void IMAPfolderItem::contextMenuSelected(int id)
break;
case 1:
- deleteAllMails();
+ deleteAllMail(imap->getWrapper(),folder);
break;
case 2:
@@ -383,4 +393,21 @@ void IMAPfolderItem::contextMenuSelected(int id)
const QString AccountViewItem::contextName="AccountViewItem";
+void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
+{
+ if (!wrapper) return;
+ 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?folder->getDisplayName():"")),
+ QObject::tr("Yes",contextName),
+ QObject::tr("No",contextName),QString::null,1,1);
+ qDebug("Auswahl: %i",yesno);
+ if (yesno == 0) {
+ if (wrapper->deleteAllMail(folder)) {
+ AccountView * view = (AccountView*)listView();
+ if (view) view->refreshCurrent();
+ }
+ }
+}
+
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
@@ -595,19 +622,4 @@ 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()
{
@@ -645,5 +657,5 @@ void MBOXfolderItem::contextMenuSelected(int which)
switch(which) {
case 0:
- deleteAllMails();
+ deleteAllMail(mbox->getWrapper(),folder);
break;
case 1:
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 98abf44..361dd86 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -26,4 +26,5 @@ public:
virtual void contextMenuSelected(int){}
protected:
+ virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
static const QString contextName;
};
@@ -52,4 +53,7 @@ public:
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+
private:
Folder *folder;
@@ -97,5 +101,4 @@ protected:
virtual void createNewFolder();
virtual void deleteFolder();
- virtual void deleteAllMails();
private:
@@ -141,5 +144,4 @@ public:
protected:
- virtual void deleteAllMails();
virtual void deleteFolder();
private:
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index b609aa7..5dc4cab 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -30,4 +30,5 @@ public:
virtual void cleanMimeCache(){};
virtual int deleteAllMail(const Folder*){return 1;}
+ virtual int deleteMbox(const Folder*){return 1;}
/* mail box methods */
@@ -37,5 +38,4 @@ public:
*/
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;}
- virtual int deleteMbox(const Folder*){return 1;}
static AbstractMail* getWrapper(IMAPaccount *a);
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index b85fbf6..2e70dee 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -207,7 +207,4 @@ void POP3wrapper::logout()
QList<Folder>* POP3wrapper::listFolders()
{
- /* TODO: integrate MH directories
- but not before version 0.1 ;)
- */
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( false );
@@ -223,5 +220,5 @@ void POP3wrapper::deleteMail(const RecMail&mail)
int err = mailpop3_dele(m_pop3,mail.getNumber());
if (err != MAILPOP3_NO_ERROR) {
- qDebug("error deleting mail");
+ Global::statusMessage(tr("error deleting mail"));
}
}
@@ -230,2 +227,28 @@ void POP3wrapper::answeredMail(const RecMail&)
{
}
+
+int POP3wrapper::deleteAllMail(const Folder*)
+{
+ login();
+ if (!m_pop3) return 0;
+ carray * messages = 0;
+
+ /* if connected this info is cached! */
+ int err = 0;
+ mailpop3_list( m_pop3, &messages );
+
+ int res = 1;
+ for (unsigned int i = 0; messages!=0 && i < carray_count(messages);++i) {
+ mailpop3_msg_info *info;
+ err = mailpop3_get_msg_info(m_pop3,i+1,&info);
+ if (info->msg_deleted)
+ continue;
+ err = mailpop3_dele(m_pop3,i+1);
+ if (err != MAILPOP3_NO_ERROR) {
+ Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
+ res = 0;
+ break;
+ }
+ }
+ return res;
+}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 7502720..2efffdd 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -20,4 +20,5 @@ public:
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
+ virtual int deleteAllMail(const Folder*);
virtual RecBody fetchBody( const RecMail &mail );
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index b85fbf6..2e70dee 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -207,7 +207,4 @@ void POP3wrapper::logout()
QList<Folder>* POP3wrapper::listFolders()
{
- /* TODO: integrate MH directories
- but not before version 0.1 ;)
- */
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( false );
@@ -223,5 +220,5 @@ void POP3wrapper::deleteMail(const RecMail&mail)
int err = mailpop3_dele(m_pop3,mail.getNumber());
if (err != MAILPOP3_NO_ERROR) {
- qDebug("error deleting mail");
+ Global::statusMessage(tr("error deleting mail"));
}
}
@@ -230,2 +227,28 @@ void POP3wrapper::answeredMail(const RecMail&)
{
}
+
+int POP3wrapper::deleteAllMail(const Folder*)
+{
+ login();
+ if (!m_pop3) return 0;
+ carray * messages = 0;
+
+ /* if connected this info is cached! */
+ int err = 0;
+ mailpop3_list( m_pop3, &messages );
+
+ int res = 1;
+ for (unsigned int i = 0; messages!=0 && i < carray_count(messages);++i) {
+ mailpop3_msg_info *info;
+ err = mailpop3_get_msg_info(m_pop3,i+1,&info);
+ if (info->msg_deleted)
+ continue;
+ err = mailpop3_dele(m_pop3,i+1);
+ if (err != MAILPOP3_NO_ERROR) {
+ Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
+ res = 0;
+ break;
+ }
+ }
+ return res;
+}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index 7502720..2efffdd 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -20,4 +20,5 @@ public:
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
+ virtual int deleteAllMail(const Folder*);
virtual RecBody fetchBody( const RecMail &mail );