-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 | |||
@@ -8,44 +8,44 @@ class RecMail; | |||
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | 14 | ||
15 | class AbstractMail:public QObject | 15 | class AbstractMail:public QObject |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | public: | 18 | public: |
19 | AbstractMail(){}; | 19 | AbstractMail(){}; |
20 | virtual ~AbstractMail(){} | 20 | virtual ~AbstractMail(){} |
21 | virtual QList<Folder>* listFolders()=0; | 21 | virtual QList<Folder>* listFolders()=0; |
22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
23 | virtual RecBody fetchBody(const RecMail&mail)=0; | 23 | virtual RecBody fetchBody(const RecMail&mail)=0; |
24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
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 | ||
46 | protected: | 46 | protected: |
47 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 47 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
48 | static QString convert_String(const char*text); | 48 | static QString convert_String(const char*text); |
49 | static QString gen_attachment_id(); | 49 | static QString gen_attachment_id(); |
50 | }; | 50 | }; |
51 | #endif | 51 | #endif |
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 | |||
@@ -63,48 +63,73 @@ POP3folderItem::~POP3folderItem() | |||
63 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 63 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
64 | : AccountViewItem( parent,after ) | 64 | : AccountViewItem( parent,after ) |
65 | { | 65 | { |
66 | folder = folderInit; | 66 | folder = folderInit; |
67 | pop3 = parent; | 67 | pop3 = parent; |
68 | if (folder->getDisplayName().lower()!="inbox") { | 68 | if (folder->getDisplayName().lower()!="inbox") { |
69 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 69 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
70 | } else { | 70 | } else { |
71 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 71 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
72 | } | 72 | } |
73 | setText( 0, folder->getDisplayName() ); | 73 | setText( 0, folder->getDisplayName() ); |
74 | } | 74 | } |
75 | 75 | ||
76 | void POP3folderItem::refresh(QList<RecMail>&target) | 76 | void POP3folderItem::refresh(QList<RecMail>&target) |
77 | { | 77 | { |
78 | if (folder->may_select()) | 78 | if (folder->may_select()) |
79 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 79 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
80 | } | 80 | } |
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 | { |
93 | account = a; | 118 | account = a; |
94 | wrapper = AbstractMail::getWrapper( account ); | 119 | wrapper = AbstractMail::getWrapper( account ); |
95 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 120 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
96 | setText( 0, account->getAccountName() ); | 121 | setText( 0, account->getAccountName() ); |
97 | setOpen( true ); | 122 | setOpen( true ); |
98 | } | 123 | } |
99 | 124 | ||
100 | IMAPviewItem::~IMAPviewItem() | 125 | IMAPviewItem::~IMAPviewItem() |
101 | { | 126 | { |
102 | delete wrapper; | 127 | delete wrapper; |
103 | } | 128 | } |
104 | 129 | ||
105 | AbstractMail *IMAPviewItem::getWrapper() | 130 | AbstractMail *IMAPviewItem::getWrapper() |
106 | { | 131 | { |
107 | return wrapper; | 132 | return wrapper; |
108 | } | 133 | } |
109 | 134 | ||
110 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | 135 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) |
@@ -283,126 +308,128 @@ void IMAPfolderItem::refresh(QList<RecMail>&target) | |||
283 | 308 | ||
284 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 309 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
285 | { | 310 | { |
286 | return imap->getWrapper()->fetchBody(aMail); | 311 | return imap->getWrapper()->fetchBody(aMail); |
287 | } | 312 | } |
288 | 313 | ||
289 | QPopupMenu * IMAPfolderItem::getContextMenu() | 314 | QPopupMenu * IMAPfolderItem::getContextMenu() |
290 | { | 315 | { |
291 | QPopupMenu *m = new QPopupMenu(0); | 316 | QPopupMenu *m = new QPopupMenu(0); |
292 | if (m) { | 317 | if (m) { |
293 | if (folder->may_select()) { | 318 | if (folder->may_select()) { |
294 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 319 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
295 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 320 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
296 | } | 321 | } |
297 | if (folder->no_inferior()==false) { | 322 | if (folder->no_inferior()==false) { |
298 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 323 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
299 | } | 324 | } |
300 | if (folder->getDisplayName().lower()!="inbox") { | 325 | if (folder->getDisplayName().lower()!="inbox") { |
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(); |
328 | bool makesubs = ndirdlg.subpossible(); | 338 | bool makesubs = ndirdlg.subpossible(); |
329 | QString delemiter = Delemiter(); | 339 | QString delemiter = Delemiter(); |
330 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | 340 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { |
331 | imap->refreshFolders(true); | 341 | imap->refreshFolders(true); |
332 | } | 342 | } |
333 | } | 343 | } |
334 | } | 344 | } |
335 | 345 | ||
336 | void IMAPfolderItem::deleteFolder() | 346 | void IMAPfolderItem::deleteFolder() |
337 | { | 347 | { |
338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 348 | 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>",contextName).arg(folder->getDisplayName()), | 349 | 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",contextName), | 350 | QObject::tr("Yes",contextName), |
341 | QObject::tr("No",contextName),QString::null,1,1); | 351 | QObject::tr("No",contextName),QString::null,1,1); |
342 | qDebug("Auswahl: %i",yesno); | 352 | qDebug("Auswahl: %i",yesno); |
343 | if (yesno == 0) { | 353 | if (yesno == 0) { |
344 | if (imap->getWrapper()->deleteMbox(folder)) { | 354 | if (imap->getWrapper()->deleteMbox(folder)) { |
345 | QListView*v=listView(); | 355 | QListView*v=listView(); |
346 | IMAPviewItem * box = imap; | 356 | IMAPviewItem * box = imap; |
347 | /* be carefull - after that this object is destroyd so don't use | 357 | /* be carefull - after that this object is destroyd so don't use |
348 | * any member of it after that call!!*/ | 358 | * any member of it after that call!!*/ |
349 | imap->refreshFolders(true); | 359 | imap->refreshFolders(true); |
350 | if (v) { | 360 | if (v) { |
351 | v->setSelected(box,true); | 361 | v->setSelected(box,true); |
352 | } | 362 | } |
353 | } | 363 | } |
354 | } | 364 | } |
355 | } | 365 | } |
356 | 366 | ||
357 | void IMAPfolderItem::contextMenuSelected(int id) | 367 | void IMAPfolderItem::contextMenuSelected(int id) |
358 | { | 368 | { |
359 | qDebug("Selected id: %i",id); | 369 | qDebug("Selected id: %i",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(); |
373 | break; | 383 | break; |
374 | default: | 384 | default: |
375 | break; | 385 | break; |
376 | } | 386 | } |
377 | } | 387 | } |
378 | 388 | ||
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, |
391 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 418 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
392 | 419 | ||
393 | setSorting(0); | 420 | setSorting(0); |
394 | } | 421 | } |
395 | 422 | ||
396 | void AccountView::slotContextMenu(int id) | 423 | void AccountView::slotContextMenu(int id) |
397 | { | 424 | { |
398 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 425 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
399 | if (!view) return; | 426 | if (!view) return; |
400 | view->contextMenuSelected(id); | 427 | view->contextMenuSelected(id); |
401 | } | 428 | } |
402 | 429 | ||
403 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) | 430 | void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) |
404 | { | 431 | { |
405 | if (button==1) {return;} | 432 | if (button==1) {return;} |
406 | if (!item) return; | 433 | if (!item) return; |
407 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 434 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
408 | QPopupMenu*m = view->getContextMenu(); | 435 | QPopupMenu*m = view->getContextMenu(); |
@@ -573,83 +600,68 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList | |||
573 | { | 600 | { |
574 | folder = folderInit; | 601 | folder = folderInit; |
575 | mbox = parent; | 602 | mbox = parent; |
576 | if (folder->getDisplayName().lower() == "outgoing") { | 603 | if (folder->getDisplayName().lower() == "outgoing") { |
577 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 604 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
578 | } else if (folder->getDisplayName().lower() == "inbox") { | 605 | } else if (folder->getDisplayName().lower() == "inbox") { |
579 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 606 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
580 | } else { | 607 | } else { |
581 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 608 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
582 | } | 609 | } |
583 | setText( 0, folder->getDisplayName() ); | 610 | setText( 0, folder->getDisplayName() ); |
584 | } | 611 | } |
585 | 612 | ||
586 | void MBOXfolderItem::refresh(QList<RecMail>&target) | 613 | void MBOXfolderItem::refresh(QList<RecMail>&target) |
587 | { | 614 | { |
588 | if (folder->may_select()) | 615 | if (folder->may_select()) |
589 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 616 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
590 | } | 617 | } |
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); |
618 | qDebug("Auswahl: %i",yesno); | 630 | qDebug("Auswahl: %i",yesno); |
619 | if (yesno == 0) { | 631 | if (yesno == 0) { |
620 | if (mbox->getWrapper()->deleteMbox(folder)) { | 632 | if (mbox->getWrapper()->deleteMbox(folder)) { |
621 | QListView*v=listView(); | 633 | QListView*v=listView(); |
622 | MBOXviewItem * box = mbox; | 634 | MBOXviewItem * box = mbox; |
623 | /* be carefull - after that this object is destroyd so don't use | 635 | /* be carefull - after that this object is destroyd so don't use |
624 | * any member of it after that call!!*/ | 636 | * any member of it after that call!!*/ |
625 | mbox->refresh(true); | 637 | mbox->refresh(true); |
626 | if (v) { | 638 | if (v) { |
627 | v->setSelected(box,true); | 639 | v->setSelected(box,true); |
628 | } | 640 | } |
629 | } | 641 | } |
630 | } | 642 | } |
631 | } | 643 | } |
632 | 644 | ||
633 | QPopupMenu * MBOXfolderItem::getContextMenu() | 645 | QPopupMenu * MBOXfolderItem::getContextMenu() |
634 | { | 646 | { |
635 | QPopupMenu *m = new QPopupMenu(0); | 647 | QPopupMenu *m = new QPopupMenu(0); |
636 | if (m) { | 648 | if (m) { |
637 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 649 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
638 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 650 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
639 | } | 651 | } |
640 | return m; | 652 | return m; |
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; |
654 | } | 666 | } |
655 | } | 667 | } |
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 | |||
@@ -4,164 +4,166 @@ | |||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
9 | #include "abstractmail.h" | 9 | #include "abstractmail.h" |
10 | 10 | ||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | 15 | ||
16 | class AccountViewItem : public QListViewItem | 16 | class AccountViewItem : public QListViewItem |
17 | { | 17 | { |
18 | 18 | ||
19 | public: | 19 | public: |
20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} |
21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} | 21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} |
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 | ||
34 | public: | 35 | public: |
35 | POP3viewItem( POP3account *a, QListView *parent ); | 36 | POP3viewItem( POP3account *a, QListView *parent ); |
36 | ~POP3viewItem(); | 37 | ~POP3viewItem(); |
37 | virtual void refresh( QList<RecMail> &target ); | 38 | virtual void refresh( QList<RecMail> &target ); |
38 | virtual RecBody fetchBody( const RecMail &mail ); | 39 | virtual RecBody fetchBody( const RecMail &mail ); |
39 | AbstractMail *getWrapper(); | 40 | AbstractMail *getWrapper(); |
40 | private: | 41 | private: |
41 | POP3account *account; | 42 | POP3account *account; |
42 | AbstractMail *wrapper; | 43 | AbstractMail *wrapper; |
43 | 44 | ||
44 | }; | 45 | }; |
45 | 46 | ||
46 | class POP3folderItem : public AccountViewItem | 47 | class POP3folderItem : public AccountViewItem |
47 | { | 48 | { |
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; |
60 | 64 | ||
61 | class IMAPviewItem : public AccountViewItem | 65 | class IMAPviewItem : public AccountViewItem |
62 | { | 66 | { |
63 | friend class IMAPfolderItem; | 67 | friend class IMAPfolderItem; |
64 | public: | 68 | public: |
65 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 69 | IMAPviewItem( IMAPaccount *a, QListView *parent ); |
66 | ~IMAPviewItem(); | 70 | ~IMAPviewItem(); |
67 | virtual void refresh(QList<RecMail>&); | 71 | virtual void refresh(QList<RecMail>&); |
68 | virtual RecBody fetchBody(const RecMail&); | 72 | virtual RecBody fetchBody(const RecMail&); |
69 | AbstractMail *getWrapper(); | 73 | AbstractMail *getWrapper(); |
70 | virtual QPopupMenu * getContextMenu(); | 74 | virtual QPopupMenu * getContextMenu(); |
71 | virtual void contextMenuSelected(int); | 75 | virtual void contextMenuSelected(int); |
72 | 76 | ||
73 | protected: | 77 | protected: |
74 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | 78 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); |
75 | virtual void refreshFolders(bool force=false); | 79 | virtual void refreshFolders(bool force=false); |
76 | virtual void createNewFolder(); | 80 | virtual void createNewFolder(); |
77 | 81 | ||
78 | private: | 82 | private: |
79 | IMAPaccount *account; | 83 | IMAPaccount *account; |
80 | AbstractMail *wrapper; | 84 | AbstractMail *wrapper; |
81 | }; | 85 | }; |
82 | 86 | ||
83 | class IMAPfolderItem : public AccountViewItem | 87 | class IMAPfolderItem : public AccountViewItem |
84 | { | 88 | { |
85 | 89 | ||
86 | public: | 90 | public: |
87 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 91 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
88 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 92 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
89 | ~IMAPfolderItem(); | 93 | ~IMAPfolderItem(); |
90 | virtual void refresh(QList<RecMail>&); | 94 | virtual void refresh(QList<RecMail>&); |
91 | virtual RecBody fetchBody(const RecMail&); | 95 | virtual RecBody fetchBody(const RecMail&); |
92 | bool matchName(const QString&name)const; | 96 | bool matchName(const QString&name)const; |
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 | ||
106 | class MBOXviewItem : public AccountViewItem | 109 | class MBOXviewItem : public AccountViewItem |
107 | { | 110 | { |
108 | friend class MBOXfolderItem; | 111 | friend class MBOXfolderItem; |
109 | 112 | ||
110 | public: | 113 | public: |
111 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); | 114 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); |
112 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); | 115 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); |
113 | ~MBOXviewItem(); | 116 | ~MBOXviewItem(); |
114 | virtual void refresh( QList<RecMail> &target ); | 117 | virtual void refresh( QList<RecMail> &target ); |
115 | virtual RecBody fetchBody( const RecMail &mail ); | 118 | virtual RecBody fetchBody( const RecMail &mail ); |
116 | AbstractMail *getWrapper(); | 119 | AbstractMail *getWrapper(); |
117 | virtual QPopupMenu * getContextMenu(); | 120 | virtual QPopupMenu * getContextMenu(); |
118 | virtual void contextMenuSelected(int); | 121 | virtual void contextMenuSelected(int); |
119 | 122 | ||
120 | protected: | 123 | protected: |
121 | virtual void refresh(bool force=false); | 124 | virtual void refresh(bool force=false); |
122 | virtual void createFolder(); | 125 | virtual void createFolder(); |
123 | 126 | ||
124 | private: | 127 | private: |
125 | // MBOXaccount *account; | 128 | // MBOXaccount *account; |
126 | QString m_Path; | 129 | QString m_Path; |
127 | AbstractMail *wrapper; | 130 | AbstractMail *wrapper; |
128 | 131 | ||
129 | }; | 132 | }; |
130 | 133 | ||
131 | class MBOXfolderItem : public AccountViewItem | 134 | class MBOXfolderItem : public AccountViewItem |
132 | { | 135 | { |
133 | 136 | ||
134 | public: | 137 | public: |
135 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 138 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
136 | ~MBOXfolderItem(); | 139 | ~MBOXfolderItem(); |
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 | ||
150 | class AccountView : public QListView | 152 | class AccountView : public QListView |
151 | { | 153 | { |
152 | Q_OBJECT | 154 | Q_OBJECT |
153 | 155 | ||
154 | public: | 156 | public: |
155 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 157 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
156 | void populate( QList<Account> list ); | 158 | void populate( QList<Account> list ); |
157 | RecBody fetchBody(const RecMail&aMail); | 159 | RecBody fetchBody(const RecMail&aMail); |
158 | 160 | ||
159 | public slots: | 161 | public slots: |
160 | virtual void refreshAll(); | 162 | virtual void refreshAll(); |
161 | virtual void refresh(QListViewItem *item); | 163 | virtual void refresh(QListViewItem *item); |
162 | virtual void refreshCurrent(); | 164 | virtual void refreshCurrent(); |
163 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 165 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
164 | virtual void slotContextMenu(int id); | 166 | virtual void slotContextMenu(int id); |
165 | 167 | ||
166 | signals: | 168 | signals: |
167 | void refreshMailview(QList<RecMail>*); | 169 | void refreshMailview(QList<RecMail>*); |
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 | |||
@@ -8,44 +8,44 @@ class RecMail; | |||
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | 14 | ||
15 | class AbstractMail:public QObject | 15 | class AbstractMail:public QObject |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | public: | 18 | public: |
19 | AbstractMail(){}; | 19 | AbstractMail(){}; |
20 | virtual ~AbstractMail(){} | 20 | virtual ~AbstractMail(){} |
21 | virtual QList<Folder>* listFolders()=0; | 21 | virtual QList<Folder>* listFolders()=0; |
22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
23 | virtual RecBody fetchBody(const RecMail&mail)=0; | 23 | virtual RecBody fetchBody(const RecMail&mail)=0; |
24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
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 | ||
46 | protected: | 46 | protected: |
47 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 47 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
48 | static QString convert_String(const char*text); | 48 | static QString convert_String(const char*text); |
49 | static QString gen_attachment_id(); | 49 | static QString gen_attachment_id(); |
50 | }; | 50 | }; |
51 | #endif | 51 | #endif |
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 | |||
@@ -185,47 +185,70 @@ void POP3wrapper::login() | |||
185 | // login | 185 | // login |
186 | // TODO: decide if apop or plain login should be used | 186 | // TODO: decide if apop or plain login should be used |
187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
188 | if ( err != MAILPOP3_NO_ERROR ) { | 188 | if ( err != MAILPOP3_NO_ERROR ) { |
189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
190 | logout(); | 190 | logout(); |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | qDebug( "POP3: logged in!" ); | 194 | qDebug( "POP3: logged in!" ); |
195 | } | 195 | } |
196 | 196 | ||
197 | void POP3wrapper::logout() | 197 | void POP3wrapper::logout() |
198 | { | 198 | { |
199 | int err = MAILPOP3_NO_ERROR; | 199 | int err = MAILPOP3_NO_ERROR; |
200 | if ( m_pop3 == NULL ) return; | 200 | if ( m_pop3 == NULL ) return; |
201 | err = mailpop3_quit( m_pop3 ); | 201 | err = mailpop3_quit( m_pop3 ); |
202 | mailpop3_free( m_pop3 ); | 202 | mailpop3_free( m_pop3 ); |
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 | } |
218 | 215 | ||
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 | |||
@@ -1,33 +1,34 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | 8 | ||
9 | class POP3wrapper : public Genericwrapper | 9 | class POP3wrapper : public Genericwrapper |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | POP3wrapper( POP3account *a ); | 14 | POP3wrapper( POP3account *a ); |
15 | virtual ~POP3wrapper(); | 15 | virtual ~POP3wrapper(); |
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(); |
28 | void logout(); | 29 | void logout(); |
29 | POP3account *account; | 30 | POP3account *account; |
30 | mailpop3 *m_pop3; | 31 | mailpop3 *m_pop3; |
31 | }; | 32 | }; |
32 | 33 | ||
33 | #endif | 34 | #endif |
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 | |||
@@ -185,47 +185,70 @@ void POP3wrapper::login() | |||
185 | // login | 185 | // login |
186 | // TODO: decide if apop or plain login should be used | 186 | // TODO: decide if apop or plain login should be used |
187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 187 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
188 | if ( err != MAILPOP3_NO_ERROR ) { | 188 | if ( err != MAILPOP3_NO_ERROR ) { |
189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 189 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
190 | logout(); | 190 | logout(); |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | qDebug( "POP3: logged in!" ); | 194 | qDebug( "POP3: logged in!" ); |
195 | } | 195 | } |
196 | 196 | ||
197 | void POP3wrapper::logout() | 197 | void POP3wrapper::logout() |
198 | { | 198 | { |
199 | int err = MAILPOP3_NO_ERROR; | 199 | int err = MAILPOP3_NO_ERROR; |
200 | if ( m_pop3 == NULL ) return; | 200 | if ( m_pop3 == NULL ) return; |
201 | err = mailpop3_quit( m_pop3 ); | 201 | err = mailpop3_quit( m_pop3 ); |
202 | mailpop3_free( m_pop3 ); | 202 | mailpop3_free( m_pop3 ); |
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 | } |
218 | 215 | ||
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 | |||
@@ -1,33 +1,34 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | 8 | ||
9 | class POP3wrapper : public Genericwrapper | 9 | class POP3wrapper : public Genericwrapper |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | POP3wrapper( POP3account *a ); | 14 | POP3wrapper( POP3account *a ); |
15 | virtual ~POP3wrapper(); | 15 | virtual ~POP3wrapper(); |
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(); |
28 | void logout(); | 29 | void logout(); |
29 | POP3account *account; | 30 | POP3account *account; |
30 | mailpop3 *m_pop3; | 31 | mailpop3 *m_pop3; |
31 | }; | 32 | }; |
32 | 33 | ||
33 | #endif | 34 | #endif |