-rw-r--r-- | noncore/net/mail/abstractmail.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 76 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 31 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 1 |
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: | |||
30 | virtual void cleanMimeCache(){}; | 30 | virtual void cleanMimeCache(){}; |
31 | virtual int deleteAllMail(const Folder*){return 1;} | 31 | virtual int deleteAllMail(const Folder*){return 1;} |
32 | virtual int deleteMbox(const Folder*){return 1;} | ||
32 | 33 | ||
33 | /* mail box methods */ | 34 | /* mail box methods */ |
@@ -37,5 +38,4 @@ public: | |||
37 | */ | 38 | */ |
38 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} | 39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} |
39 | virtual int deleteMbox(const Folder*){return 1;} | ||
40 | 40 | ||
41 | static AbstractMail* getWrapper(IMAPaccount *a); | 41 | 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) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | QPopupMenu * POP3folderItem::getContextMenu() | ||
88 | { | ||
89 | QPopupMenu *m = new QPopupMenu(0); | ||
90 | if (m) { | ||
91 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
92 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | ||
93 | } | ||
94 | return m; | ||
95 | } | ||
96 | |||
97 | void POP3folderItem::contextMenuSelected(int which) | ||
98 | { | ||
99 | AccountView * view = (AccountView*)listView(); | ||
100 | switch (which) { | ||
101 | case 0: | ||
102 | view->refreshCurrent(); | ||
103 | break; | ||
104 | case 1: | ||
105 | deleteAllMail(pop3->getWrapper(),folder); | ||
106 | break; | ||
107 | default: | ||
108 | break; | ||
109 | } | ||
110 | } | ||
111 | |||
87 | /** | 112 | /** |
88 | * IMAP Account stuff | 113 | * IMAP Account stuff |
@@ -305,19 +330,4 @@ QPopupMenu * IMAPfolderItem::getContextMenu() | |||
305 | } | 330 | } |
306 | 331 | ||
307 | void IMAPfolderItem::deleteAllMails() | ||
308 | { | ||
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>",contextName).arg(folder->getDisplayName()), | ||
311 | QObject::tr("Yes",contextName), | ||
312 | QObject::tr("No",contextName),QString::null,1,1); | ||
313 | qDebug("Auswahl: %i",yesno); | ||
314 | if (yesno == 0) { | ||
315 | if (imap->getWrapper()->deleteAllMail(folder)) { | ||
316 | AccountView * view = (AccountView*)listView(); | ||
317 | if (view) view->refreshCurrent(); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | |||
322 | void IMAPfolderItem::createNewFolder() | 332 | void IMAPfolderItem::createNewFolder() |
323 | { | 333 | { |
@@ -364,5 +374,5 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
364 | break; | 374 | break; |
365 | case 1: | 375 | case 1: |
366 | deleteAllMails(); | 376 | deleteAllMail(imap->getWrapper(),folder); |
367 | break; | 377 | break; |
368 | case 2: | 378 | case 2: |
@@ -383,4 +393,21 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
383 | const QString AccountViewItem::contextName="AccountViewItem"; | 393 | const QString AccountViewItem::contextName="AccountViewItem"; |
384 | 394 | ||
395 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | ||
396 | { | ||
397 | if (!wrapper) return; | ||
398 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
399 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | ||
400 | arg((folder?folder->getDisplayName():"")), | ||
401 | QObject::tr("Yes",contextName), | ||
402 | QObject::tr("No",contextName),QString::null,1,1); | ||
403 | qDebug("Auswahl: %i",yesno); | ||
404 | if (yesno == 0) { | ||
405 | if (wrapper->deleteAllMail(folder)) { | ||
406 | AccountView * view = (AccountView*)listView(); | ||
407 | if (view) view->refreshCurrent(); | ||
408 | } | ||
409 | } | ||
410 | } | ||
411 | |||
385 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 412 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
386 | : QListView( parent, name, flags ) | 413 | : QListView( parent, name, flags ) |
@@ -595,19 +622,4 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | |||
595 | } | 622 | } |
596 | 623 | ||
597 | void 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 | |||
612 | void MBOXfolderItem::deleteFolder() | 624 | void MBOXfolderItem::deleteFolder() |
613 | { | 625 | { |
@@ -645,5 +657,5 @@ void MBOXfolderItem::contextMenuSelected(int which) | |||
645 | switch(which) { | 657 | switch(which) { |
646 | case 0: | 658 | case 0: |
647 | deleteAllMails(); | 659 | deleteAllMail(mbox->getWrapper(),folder); |
648 | break; | 660 | break; |
649 | case 1: | 661 | 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: | |||
26 | virtual void contextMenuSelected(int){} | 26 | virtual void contextMenuSelected(int){} |
27 | protected: | 27 | protected: |
28 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | ||
28 | static const QString contextName; | 29 | static const QString contextName; |
29 | }; | 30 | }; |
@@ -52,4 +53,7 @@ public: | |||
52 | virtual void refresh(QList<RecMail>&); | 53 | virtual void refresh(QList<RecMail>&); |
53 | virtual RecBody fetchBody(const RecMail&); | 54 | virtual RecBody fetchBody(const RecMail&); |
55 | virtual QPopupMenu * getContextMenu(); | ||
56 | virtual void contextMenuSelected(int); | ||
57 | |||
54 | private: | 58 | private: |
55 | Folder *folder; | 59 | Folder *folder; |
@@ -97,5 +101,4 @@ protected: | |||
97 | virtual void createNewFolder(); | 101 | virtual void createNewFolder(); |
98 | virtual void deleteFolder(); | 102 | virtual void deleteFolder(); |
99 | virtual void deleteAllMails(); | ||
100 | 103 | ||
101 | private: | 104 | private: |
@@ -141,5 +144,4 @@ public: | |||
141 | 144 | ||
142 | protected: | 145 | protected: |
143 | virtual void deleteAllMails(); | ||
144 | virtual void deleteFolder(); | 146 | virtual void deleteFolder(); |
145 | private: | 147 | 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: | |||
30 | virtual void cleanMimeCache(){}; | 30 | virtual void cleanMimeCache(){}; |
31 | virtual int deleteAllMail(const Folder*){return 1;} | 31 | virtual int deleteAllMail(const Folder*){return 1;} |
32 | virtual int deleteMbox(const Folder*){return 1;} | ||
32 | 33 | ||
33 | /* mail box methods */ | 34 | /* mail box methods */ |
@@ -37,5 +38,4 @@ public: | |||
37 | */ | 38 | */ |
38 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} | 39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} |
39 | virtual int deleteMbox(const Folder*){return 1;} | ||
40 | 40 | ||
41 | static AbstractMail* getWrapper(IMAPaccount *a); | 41 | 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() | |||
207 | QList<Folder>* POP3wrapper::listFolders() | 207 | QList<Folder>* POP3wrapper::listFolders() |
208 | { | 208 | { |
209 | /* TODO: integrate MH directories | ||
210 | but not before version 0.1 ;) | ||
211 | */ | ||
212 | QList<Folder> * folders = new QList<Folder>(); | 209 | QList<Folder> * folders = new QList<Folder>(); |
213 | folders->setAutoDelete( false ); | 210 | folders->setAutoDelete( false ); |
@@ -223,5 +220,5 @@ void POP3wrapper::deleteMail(const RecMail&mail) | |||
223 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | 220 | int err = mailpop3_dele(m_pop3,mail.getNumber()); |
224 | if (err != MAILPOP3_NO_ERROR) { | 221 | if (err != MAILPOP3_NO_ERROR) { |
225 | qDebug("error deleting mail"); | 222 | Global::statusMessage(tr("error deleting mail")); |
226 | } | 223 | } |
227 | } | 224 | } |
@@ -230,2 +227,28 @@ void POP3wrapper::answeredMail(const RecMail&) | |||
230 | { | 227 | { |
231 | } | 228 | } |
229 | |||
230 | int POP3wrapper::deleteAllMail(const Folder*) | ||
231 | { | ||
232 | login(); | ||
233 | if (!m_pop3) return 0; | ||
234 | carray * messages = 0; | ||
235 | |||
236 | /* if connected this info is cached! */ | ||
237 | int err = 0; | ||
238 | mailpop3_list( m_pop3, &messages ); | ||
239 | |||
240 | int res = 1; | ||
241 | for (unsigned int i = 0; messages!=0 && i < carray_count(messages);++i) { | ||
242 | mailpop3_msg_info *info; | ||
243 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | ||
244 | if (info->msg_deleted) | ||
245 | continue; | ||
246 | err = mailpop3_dele(m_pop3,i+1); | ||
247 | if (err != MAILPOP3_NO_ERROR) { | ||
248 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
249 | res = 0; | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | return res; | ||
254 | } | ||
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: | |||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | virtual int deleteAllMail(const Folder*); | ||
22 | 23 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 24 | 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() | |||
207 | QList<Folder>* POP3wrapper::listFolders() | 207 | QList<Folder>* POP3wrapper::listFolders() |
208 | { | 208 | { |
209 | /* TODO: integrate MH directories | ||
210 | but not before version 0.1 ;) | ||
211 | */ | ||
212 | QList<Folder> * folders = new QList<Folder>(); | 209 | QList<Folder> * folders = new QList<Folder>(); |
213 | folders->setAutoDelete( false ); | 210 | folders->setAutoDelete( false ); |
@@ -223,5 +220,5 @@ void POP3wrapper::deleteMail(const RecMail&mail) | |||
223 | int err = mailpop3_dele(m_pop3,mail.getNumber()); | 220 | int err = mailpop3_dele(m_pop3,mail.getNumber()); |
224 | if (err != MAILPOP3_NO_ERROR) { | 221 | if (err != MAILPOP3_NO_ERROR) { |
225 | qDebug("error deleting mail"); | 222 | Global::statusMessage(tr("error deleting mail")); |
226 | } | 223 | } |
227 | } | 224 | } |
@@ -230,2 +227,28 @@ void POP3wrapper::answeredMail(const RecMail&) | |||
230 | { | 227 | { |
231 | } | 228 | } |
229 | |||
230 | int POP3wrapper::deleteAllMail(const Folder*) | ||
231 | { | ||
232 | login(); | ||
233 | if (!m_pop3) return 0; | ||
234 | carray * messages = 0; | ||
235 | |||
236 | /* if connected this info is cached! */ | ||
237 | int err = 0; | ||
238 | mailpop3_list( m_pop3, &messages ); | ||
239 | |||
240 | int res = 1; | ||
241 | for (unsigned int i = 0; messages!=0 && i < carray_count(messages);++i) { | ||
242 | mailpop3_msg_info *info; | ||
243 | err = mailpop3_get_msg_info(m_pop3,i+1,&info); | ||
244 | if (info->msg_deleted) | ||
245 | continue; | ||
246 | err = mailpop3_dele(m_pop3,i+1); | ||
247 | if (err != MAILPOP3_NO_ERROR) { | ||
248 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | ||
249 | res = 0; | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | return res; | ||
254 | } | ||
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: | |||
20 | virtual void deleteMail(const RecMail&mail); | 20 | virtual void deleteMail(const RecMail&mail); |
21 | virtual void answeredMail(const RecMail&mail); | 21 | virtual void answeredMail(const RecMail&mail); |
22 | virtual int deleteAllMail(const Folder*); | ||
22 | 23 | ||
23 | virtual RecBody fetchBody( const RecMail &mail ); | 24 | virtual RecBody fetchBody( const RecMail &mail ); |