author | alwin <alwin> | 2003-12-28 12:57:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 12:57:44 (UTC) |
commit | b41e3eb92eab8bf61fd20db70d0317c816b1c2f0 (patch) (unidiff) | |
tree | 5795854d7de75edc4385edc6ee7389809f98f4e1 | |
parent | b834b22bade330b2d684c59b7fc1031a8bf650c5 (diff) | |
download | opie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.zip opie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.tar.gz opie-b41e3eb92eab8bf61fd20db70d0317c816b1c2f0.tar.bz2 |
basic folder handling for pop3 accounts
some code dups reduced
-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 | |||
@@ -26,20 +26,20 @@ public: | |||
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
27 | 27 | ||
28 | virtual void deleteMail(const RecMail&mail)=0; | 28 | virtual void deleteMail(const RecMail&mail)=0; |
29 | virtual void answeredMail(const RecMail&mail)=0; | 29 | virtual void answeredMail(const RecMail&mail)=0; |
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 */ |
34 | /* parameter is the box to create. | 35 | /* parameter is the box to create. |
35 | * if the implementing subclass has prefixes, | 36 | * if the implementing subclass has prefixes, |
36 | * them has to be appended automatic. | 37 | * them has to be appended automatic. |
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); |
42 | static AbstractMail* getWrapper(POP3account *a); | 42 | static AbstractMail* getWrapper(POP3account *a); |
43 | /* mbox only! */ | 43 | /* mbox only! */ |
44 | static AbstractMail* getWrapper(const QString&a); | 44 | static AbstractMail* getWrapper(const QString&a); |
45 | 45 | ||
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 | |||
@@ -81,12 +81,37 @@ void POP3folderItem::refresh(QList<RecMail>&target) | |||
81 | 81 | ||
82 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 82 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
83 | { | 83 | { |
84 | return pop3->getWrapper()->fetchBody(aMail); | 84 | return pop3->getWrapper()->fetchBody(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 |
89 | */ | 114 | */ |
90 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 115 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
91 | : AccountViewItem( parent ) | 116 | : AccountViewItem( parent ) |
92 | { | 117 | { |
@@ -301,27 +326,12 @@ QPopupMenu * IMAPfolderItem::getContextMenu() | |||
301 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 326 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
302 | } | 327 | } |
303 | } | 328 | } |
304 | return m; | 329 | return m; |
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 | { |
324 | Newmdirdlg ndirdlg; | 334 | Newmdirdlg ndirdlg; |
325 | ndirdlg.showMaximized(); | 335 | ndirdlg.showMaximized(); |
326 | if (ndirdlg.exec()) { | 336 | if (ndirdlg.exec()) { |
327 | QString ndir = ndirdlg.Newdir(); | 337 | QString ndir = ndirdlg.Newdir(); |
@@ -360,13 +370,13 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
360 | AccountView * view = (AccountView*)listView(); | 370 | AccountView * view = (AccountView*)listView(); |
361 | switch(id) { | 371 | switch(id) { |
362 | case 0: | 372 | case 0: |
363 | view->refreshCurrent(); | 373 | view->refreshCurrent(); |
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: |
369 | createNewFolder(); | 379 | createNewFolder(); |
370 | break; | 380 | break; |
371 | case 3: | 381 | case 3: |
372 | deleteFolder(); | 382 | deleteFolder(); |
@@ -379,12 +389,29 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
379 | /** | 389 | /** |
380 | * Generic stuff | 390 | * Generic stuff |
381 | */ | 391 | */ |
382 | 392 | ||
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 ) |
387 | { | 414 | { |
388 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), | 415 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
389 | SLOT( refresh( QListViewItem * ) ) ); | 416 | SLOT( refresh( QListViewItem * ) ) ); |
390 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 417 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
@@ -591,27 +618,12 @@ void MBOXfolderItem::refresh(QList<RecMail>&target) | |||
591 | 618 | ||
592 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | 619 | RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) |
593 | { | 620 | { |
594 | return mbox->getWrapper()->fetchBody(aMail); | 621 | return mbox->getWrapper()->fetchBody(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 | { |
614 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 626 | 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()), | 627 | 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), | 628 | QObject::tr("Yes",contextName), |
617 | QObject::tr("No",contextName),QString::null,1,1); | 629 | QObject::tr("No",contextName),QString::null,1,1); |
@@ -641,13 +653,13 @@ QPopupMenu * MBOXfolderItem::getContextMenu() | |||
641 | } | 653 | } |
642 | 654 | ||
643 | void MBOXfolderItem::contextMenuSelected(int which) | 655 | void MBOXfolderItem::contextMenuSelected(int which) |
644 | { | 656 | { |
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: |
650 | deleteFolder(); | 662 | deleteFolder(); |
651 | break; | 663 | break; |
652 | default: | 664 | default: |
653 | break; | 665 | break; |
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 | |||
@@ -22,12 +22,13 @@ public: | |||
22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} | 22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} |
23 | virtual void refresh(QList<RecMail>&)=0; | 23 | virtual void refresh(QList<RecMail>&)=0; |
24 | virtual RecBody fetchBody(const RecMail&)=0; | 24 | virtual RecBody fetchBody(const RecMail&)=0; |
25 | virtual QPopupMenu * getContextMenu(){return 0;}; | 25 | virtual QPopupMenu * getContextMenu(){return 0;}; |
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 | }; |
30 | 31 | ||
31 | class POP3viewItem : public AccountViewItem | 32 | class POP3viewItem : public AccountViewItem |
32 | { | 33 | { |
33 | 34 | ||
@@ -48,12 +49,15 @@ class POP3folderItem : public AccountViewItem | |||
48 | 49 | ||
49 | public: | 50 | public: |
50 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 51 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); |
51 | ~POP3folderItem(); | 52 | ~POP3folderItem(); |
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; |
56 | POP3viewItem *pop3; | 60 | POP3viewItem *pop3; |
57 | }; | 61 | }; |
58 | 62 | ||
59 | class IMAPfolderItem; | 63 | class IMAPfolderItem; |
@@ -93,13 +97,12 @@ public: | |||
93 | virtual QPopupMenu * getContextMenu(); | 97 | virtual QPopupMenu * getContextMenu(); |
94 | virtual void contextMenuSelected(int); | 98 | virtual void contextMenuSelected(int); |
95 | virtual const QString& Delemiter()const; | 99 | virtual const QString& Delemiter()const; |
96 | protected: | 100 | 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: |
102 | Folder *folder; | 105 | Folder *folder; |
103 | IMAPviewItem *imap; | 106 | IMAPviewItem *imap; |
104 | }; | 107 | }; |
105 | 108 | ||
@@ -137,13 +140,12 @@ public: | |||
137 | virtual void refresh(QList<RecMail>&); | 140 | virtual void refresh(QList<RecMail>&); |
138 | virtual RecBody fetchBody(const RecMail&); | 141 | virtual RecBody fetchBody(const RecMail&); |
139 | virtual QPopupMenu * getContextMenu(); | 142 | virtual QPopupMenu * getContextMenu(); |
140 | virtual void contextMenuSelected(int); | 143 | virtual void contextMenuSelected(int); |
141 | 144 | ||
142 | protected: | 145 | protected: |
143 | virtual void deleteAllMails(); | ||
144 | virtual void deleteFolder(); | 146 | virtual void deleteFolder(); |
145 | private: | 147 | private: |
146 | Folder *folder; | 148 | Folder *folder; |
147 | MBOXviewItem *mbox; | 149 | MBOXviewItem *mbox; |
148 | }; | 150 | }; |
149 | 151 | ||
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 | |||
@@ -26,20 +26,20 @@ public: | |||
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
27 | 27 | ||
28 | virtual void deleteMail(const RecMail&mail)=0; | 28 | virtual void deleteMail(const RecMail&mail)=0; |
29 | virtual void answeredMail(const RecMail&mail)=0; | 29 | virtual void answeredMail(const RecMail&mail)=0; |
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 */ |
34 | /* parameter is the box to create. | 35 | /* parameter is the box to create. |
35 | * if the implementing subclass has prefixes, | 36 | * if the implementing subclass has prefixes, |
36 | * them has to be appended automatic. | 37 | * them has to be appended automatic. |
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); |
42 | static AbstractMail* getWrapper(POP3account *a); | 42 | static AbstractMail* getWrapper(POP3account *a); |
43 | /* mbox only! */ | 43 | /* mbox only! */ |
44 | static AbstractMail* getWrapper(const QString&a); | 44 | static AbstractMail* getWrapper(const QString&a); |
45 | 45 | ||
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 | |||
@@ -203,15 +203,12 @@ void POP3wrapper::logout() | |||
203 | m_pop3 = NULL; | 203 | m_pop3 = NULL; |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
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 ); |
214 | Folder*inb=new Folder("INBOX","/"); | 211 | Folder*inb=new Folder("INBOX","/"); |
215 | folders->append(inb); | 212 | folders->append(inb); |
216 | return folders; | 213 | return folders; |
217 | } | 214 | } |
@@ -219,13 +216,39 @@ QList<Folder>* POP3wrapper::listFolders() | |||
219 | void POP3wrapper::deleteMail(const RecMail&mail) | 216 | void POP3wrapper::deleteMail(const RecMail&mail) |
220 | { | 217 | { |
221 | login(); | 218 | login(); |
222 | if (!m_pop3) return; | 219 | if (!m_pop3) return; |
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 | } |
228 | 225 | ||
229 | void POP3wrapper::answeredMail(const RecMail&) | 226 | 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 | |||
@@ -16,12 +16,13 @@ public: | |||
16 | /* mailbox will be ignored */ | 16 | /* mailbox will be ignored */ |
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
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 ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 25 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 26 | ||
26 | protected: | 27 | protected: |
27 | void login(); | 28 | void login(); |
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 | |||
@@ -203,15 +203,12 @@ void POP3wrapper::logout() | |||
203 | m_pop3 = NULL; | 203 | m_pop3 = NULL; |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
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 ); |
214 | Folder*inb=new Folder("INBOX","/"); | 211 | Folder*inb=new Folder("INBOX","/"); |
215 | folders->append(inb); | 212 | folders->append(inb); |
216 | return folders; | 213 | return folders; |
217 | } | 214 | } |
@@ -219,13 +216,39 @@ QList<Folder>* POP3wrapper::listFolders() | |||
219 | void POP3wrapper::deleteMail(const RecMail&mail) | 216 | void POP3wrapper::deleteMail(const RecMail&mail) |
220 | { | 217 | { |
221 | login(); | 218 | login(); |
222 | if (!m_pop3) return; | 219 | if (!m_pop3) return; |
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 | } |
228 | 225 | ||
229 | void POP3wrapper::answeredMail(const RecMail&) | 226 | 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 | |||
@@ -16,12 +16,13 @@ public: | |||
16 | /* mailbox will be ignored */ | 16 | /* mailbox will be ignored */ |
17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 17 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
18 | virtual QList<Folder>* listFolders(); | 18 | virtual QList<Folder>* listFolders(); |
19 | 19 | ||
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 ); |
24 | static void pop3_progress( size_t current, size_t maximum ); | 25 | static void pop3_progress( size_t current, size_t maximum ); |
25 | 26 | ||
26 | protected: | 27 | protected: |
27 | void login(); | 28 | void login(); |