-rw-r--r-- | noncore/net/mail/accountview.cpp | 234 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 71 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.cpp | 53 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.h | 18 | ||||
-rw-r--r-- | noncore/net/mail/selectstoreui.ui | 43 |
17 files changed, 415 insertions, 78 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index faa6982..eea021f 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -10,7 +10,7 @@ | |||
10 | /** | 10 | /** |
11 | * POP3 Account stuff | 11 | * POP3 Account stuff |
12 | */ | 12 | */ |
13 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 13 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
14 | : AccountViewItem( parent ) | 14 | : AccountViewItem( parent ) |
15 | { | 15 | { |
16 | account = a; | 16 | account = a; |
@@ -32,6 +32,7 @@ AbstractMail *POP3viewItem::getWrapper() | |||
32 | 32 | ||
33 | void POP3viewItem::refresh( QList<RecMail> & ) | 33 | void POP3viewItem::refresh( QList<RecMail> & ) |
34 | { | 34 | { |
35 | if (account->getOffline()) return; | ||
35 | QList<Folder> *folders = wrapper->listFolders(); | 36 | QList<Folder> *folders = wrapper->listFolders(); |
36 | QListViewItem *child = firstChild(); | 37 | QListViewItem *child = firstChild(); |
37 | while ( child ) { | 38 | while ( child ) { |
@@ -56,6 +57,52 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail ) | |||
56 | return wrapper->fetchBody( mail ); | 57 | return wrapper->fetchBody( mail ); |
57 | } | 58 | } |
58 | 59 | ||
60 | QPopupMenu * POP3viewItem::getContextMenu() | ||
61 | { | ||
62 | QPopupMenu *m = new QPopupMenu(0); | ||
63 | if (m) { | ||
64 | if (!account->getOffline()) { | ||
65 | m->insertItem(QObject::tr("Disconnect",contextName),0); | ||
66 | m->insertItem(QObject::tr("Set offline",contextName),1); | ||
67 | } else { | ||
68 | m->insertItem(QObject::tr("Set online",contextName),1); | ||
69 | } | ||
70 | } | ||
71 | return m; | ||
72 | } | ||
73 | |||
74 | void POP3viewItem::disconnect() | ||
75 | { | ||
76 | QListViewItem *child = firstChild(); | ||
77 | while ( child ) { | ||
78 | QListViewItem *tmp = child; | ||
79 | child = child->nextSibling(); | ||
80 | delete tmp; | ||
81 | } | ||
82 | wrapper->logout(); | ||
83 | } | ||
84 | |||
85 | void POP3viewItem::setOnOffline() | ||
86 | { | ||
87 | if (!account->getOffline()) { | ||
88 | disconnect(); | ||
89 | } | ||
90 | account->setOffline(!account->getOffline()); | ||
91 | account->save(); | ||
92 | } | ||
93 | |||
94 | void POP3viewItem::contextMenuSelected(int which) | ||
95 | { | ||
96 | switch (which) { | ||
97 | case 0: | ||
98 | disconnect(); | ||
99 | break; | ||
100 | case 1: | ||
101 | setOnOffline(); | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | |||
59 | POP3folderItem::~POP3folderItem() | 106 | POP3folderItem::~POP3folderItem() |
60 | { | 107 | { |
61 | delete folder; | 108 | delete folder; |
@@ -91,16 +138,16 @@ QPopupMenu * POP3folderItem::getContextMenu() | |||
91 | if (m) { | 138 | if (m) { |
92 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 139 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
93 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 140 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
94 | m->insertItem(QObject::tr("Download all mails",contextName),2); | 141 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
95 | } | 142 | } |
96 | return m; | 143 | return m; |
97 | } | 144 | } |
98 | 145 | ||
99 | void POP3folderItem::downloadMails() | 146 | void POP3folderItem::downloadMails() |
100 | { | 147 | { |
101 | Selectstore sels; | 148 | AccountView*bl = pop3->accountView(); |
102 | sels.showMaximized(); | 149 | if (!bl) return; |
103 | sels.exec(); | 150 | bl->downloadMails(folder,pop3->getWrapper()); |
104 | } | 151 | } |
105 | 152 | ||
106 | void POP3folderItem::contextMenuSelected(int which) | 153 | void POP3folderItem::contextMenuSelected(int which) |
@@ -126,7 +173,7 @@ void POP3folderItem::contextMenuSelected(int which) | |||
126 | /** | 173 | /** |
127 | * IMAP Account stuff | 174 | * IMAP Account stuff |
128 | */ | 175 | */ |
129 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 176 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
130 | : AccountViewItem( parent ) | 177 | : AccountViewItem( parent ) |
131 | { | 178 | { |
132 | account = a; | 179 | account = a; |
@@ -183,12 +230,18 @@ void IMAPviewItem::removeChilds() | |||
183 | 230 | ||
184 | } | 231 | } |
185 | 232 | ||
233 | const QStringList&IMAPviewItem::subFolders() | ||
234 | { | ||
235 | return currentFolders; | ||
236 | } | ||
237 | |||
186 | void IMAPviewItem::refreshFolders(bool force) | 238 | void IMAPviewItem::refreshFolders(bool force) |
187 | { | 239 | { |
188 | if (childCount()>0 && force==false) return; | 240 | if (childCount()>0 && force==false) return; |
189 | 241 | if (account->getOffline()) return; | |
190 | removeChilds(); | ||
191 | 242 | ||
243 | removeChilds(); | ||
244 | currentFolders.clear(); | ||
192 | QList<Folder> *folders = wrapper->listFolders(); | 245 | QList<Folder> *folders = wrapper->listFolders(); |
193 | 246 | ||
194 | Folder *it; | 247 | Folder *it; |
@@ -209,6 +262,7 @@ void IMAPviewItem::refreshFolders(bool force) | |||
209 | } | 262 | } |
210 | for ( it = folders->first(); it; it = folders->next() ) { | 263 | for ( it = folders->first(); it; it = folders->next() ) { |
211 | fname = it->getDisplayName(); | 264 | fname = it->getDisplayName(); |
265 | currentFolders.append(it->getName()); | ||
212 | pos = fname.findRev(it->Separator()); | 266 | pos = fname.findRev(it->Separator()); |
213 | if (pos != -1) { | 267 | if (pos != -1) { |
214 | fname = fname.left(pos); | 268 | fname = fname.left(pos); |
@@ -231,10 +285,15 @@ QPopupMenu * IMAPviewItem::getContextMenu() | |||
231 | { | 285 | { |
232 | QPopupMenu *m = new QPopupMenu(0); | 286 | QPopupMenu *m = new QPopupMenu(0); |
233 | if (m) { | 287 | if (m) { |
234 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 288 | if (!account->getOffline()) { |
235 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 289 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
236 | m->insertSeparator(); | 290 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
237 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 291 | m->insertSeparator(); |
292 | m->insertItem(QObject::tr("Disconnect",contextName),2); | ||
293 | m->insertItem(QObject::tr("Set offline",contextName),3); | ||
294 | } else { | ||
295 | m->insertItem(QObject::tr("Set online",contextName),3); | ||
296 | } | ||
238 | } | 297 | } |
239 | return m; | 298 | return m; |
240 | } | 299 | } |
@@ -271,6 +330,15 @@ void IMAPviewItem::contextMenuSelected(int id) | |||
271 | removeChilds(); | 330 | removeChilds(); |
272 | wrapper->logout(); | 331 | wrapper->logout(); |
273 | break; | 332 | break; |
333 | case 3: | ||
334 | if (account->getOffline()==false) { | ||
335 | removeChilds(); | ||
336 | wrapper->logout(); | ||
337 | } | ||
338 | account->setOffline(!account->getOffline()); | ||
339 | account->save(); | ||
340 | refreshFolders(false); | ||
341 | break; | ||
274 | default: | 342 | default: |
275 | break; | 343 | break; |
276 | } | 344 | } |
@@ -281,9 +349,9 @@ RecBody IMAPviewItem::fetchBody(const RecMail&) | |||
281 | return RecBody(); | 349 | return RecBody(); |
282 | } | 350 | } |
283 | 351 | ||
284 | IMAPfolderItem::~IMAPfolderItem() | 352 | bool IMAPviewItem::offline() |
285 | { | 353 | { |
286 | delete folder; | 354 | return account->getOffline(); |
287 | } | 355 | } |
288 | 356 | ||
289 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 357 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
@@ -312,6 +380,11 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi | |||
312 | setText( 0, folder->getDisplayName() ); | 380 | setText( 0, folder->getDisplayName() ); |
313 | } | 381 | } |
314 | 382 | ||
383 | IMAPfolderItem::~IMAPfolderItem() | ||
384 | { | ||
385 | delete folder; | ||
386 | } | ||
387 | |||
315 | const QString& IMAPfolderItem::Delemiter()const | 388 | const QString& IMAPfolderItem::Delemiter()const |
316 | { | 389 | { |
317 | return folder->Separator(); | 390 | return folder->Separator(); |
@@ -342,6 +415,7 @@ QPopupMenu * IMAPfolderItem::getContextMenu() | |||
342 | if (m) { | 415 | if (m) { |
343 | if (folder->may_select()) { | 416 | if (folder->may_select()) { |
344 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 417 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
418 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | ||
345 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 419 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
346 | } | 420 | } |
347 | if (folder->no_inferior()==false) { | 421 | if (folder->no_inferior()==false) { |
@@ -389,6 +463,13 @@ void IMAPfolderItem::deleteFolder() | |||
389 | } | 463 | } |
390 | } | 464 | } |
391 | 465 | ||
466 | void IMAPfolderItem::downloadMails() | ||
467 | { | ||
468 | AccountView*bl = imap->accountView(); | ||
469 | if (!bl) return; | ||
470 | bl->downloadMails(folder,imap->getWrapper()); | ||
471 | } | ||
472 | |||
392 | void IMAPfolderItem::contextMenuSelected(int id) | 473 | void IMAPfolderItem::contextMenuSelected(int id) |
393 | { | 474 | { |
394 | qDebug("Selected id: %i",id); | 475 | qDebug("Selected id: %i",id); |
@@ -406,6 +487,9 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
406 | case 3: | 487 | case 3: |
407 | deleteFolder(); | 488 | deleteFolder(); |
408 | break; | 489 | break; |
490 | case 4: | ||
491 | downloadMails(); | ||
492 | break; | ||
409 | default: | 493 | default: |
410 | break; | 494 | break; |
411 | } | 495 | } |
@@ -417,6 +501,33 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
417 | 501 | ||
418 | const QString AccountViewItem::contextName="AccountViewItem"; | 502 | const QString AccountViewItem::contextName="AccountViewItem"; |
419 | 503 | ||
504 | AccountViewItem::AccountViewItem( AccountView *parent ) | ||
505 | : QListViewItem( parent ) | ||
506 | { | ||
507 | m_Backlink = parent; | ||
508 | } | ||
509 | |||
510 | AccountViewItem::AccountViewItem( QListViewItem *parent) | ||
511 | : QListViewItem( parent) | ||
512 | { | ||
513 | m_Backlink = 0; | ||
514 | } | ||
515 | |||
516 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | ||
517 | :QListViewItem( parent,after ) | ||
518 | { | ||
519 | m_Backlink = 0; | ||
520 | } | ||
521 | |||
522 | AccountViewItem::~AccountViewItem() | ||
523 | { | ||
524 | } | ||
525 | |||
526 | AccountView*AccountViewItem::accountView() | ||
527 | { | ||
528 | return m_Backlink; | ||
529 | } | ||
530 | |||
420 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | 531 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) |
421 | { | 532 | { |
422 | if (!wrapper) return; | 533 | if (!wrapper) return; |
@@ -447,6 +558,12 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
447 | setSorting(0); | 558 | setSorting(0); |
448 | } | 559 | } |
449 | 560 | ||
561 | AccountView::~AccountView() | ||
562 | { | ||
563 | imapAccounts.clear(); | ||
564 | mboxAccounts.clear(); | ||
565 | } | ||
566 | |||
450 | void AccountView::slotContextMenu(int id) | 567 | void AccountView::slotContextMenu(int id) |
451 | { | 568 | { |
452 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); | 569 | AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); |
@@ -471,17 +588,21 @@ void AccountView::populate( QList<Account> list ) | |||
471 | { | 588 | { |
472 | clear(); | 589 | clear(); |
473 | 590 | ||
474 | (void) new MBOXviewItem(AbstractMail::defaultLocalfolder(),this); | 591 | imapAccounts.clear(); |
592 | mboxAccounts.clear(); | ||
593 | |||
594 | mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this)); | ||
475 | 595 | ||
476 | Account *it; | 596 | Account *it; |
477 | for ( it = list.first(); it; it = list.next() ) { | 597 | for ( it = list.first(); it; it = list.next() ) { |
478 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 598 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
479 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 599 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
480 | qDebug( "added IMAP " + imap->getAccountName() ); | 600 | qDebug( "added IMAP " + imap->getAccountName() ); |
481 | (void) new IMAPviewItem( imap, this ); | 601 | imapAccounts.append(new IMAPviewItem( imap, this )); |
482 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 602 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
483 | POP3account *pop3 = static_cast<POP3account *>(it); | 603 | POP3account *pop3 = static_cast<POP3account *>(it); |
484 | qDebug( "added POP3 " + pop3->getAccountName() ); | 604 | qDebug( "added POP3 " + pop3->getAccountName() ); |
605 | /* must not be hold 'cause it isn't required */ | ||
485 | (void) new POP3viewItem( pop3, this ); | 606 | (void) new POP3viewItem( pop3, this ); |
486 | } | 607 | } |
487 | } | 608 | } |
@@ -503,12 +624,12 @@ void AccountView::refresh(QListViewItem *item) { | |||
503 | void AccountView::refreshCurrent() | 624 | void AccountView::refreshCurrent() |
504 | { | 625 | { |
505 | m_currentItem = currentItem(); | 626 | m_currentItem = currentItem(); |
506 | if ( !m_currentItem ) return; | 627 | if ( !m_currentItem ) return; |
507 | QList<RecMail> headerlist; | 628 | QList<RecMail> headerlist; |
508 | headerlist.setAutoDelete(true); | 629 | headerlist.setAutoDelete(true); |
509 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 630 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
510 | view->refresh(headerlist); | 631 | view->refresh(headerlist); |
511 | emit refreshMailview(&headerlist); | 632 | emit refreshMailview(&headerlist); |
512 | } | 633 | } |
513 | 634 | ||
514 | void AccountView::refreshAll() | 635 | void AccountView::refreshAll() |
@@ -524,15 +645,62 @@ RecBody AccountView::fetchBody(const RecMail&aMail) | |||
524 | return view->fetchBody(aMail); | 645 | return view->fetchBody(aMail); |
525 | } | 646 | } |
526 | 647 | ||
648 | void AccountView::setupFolderselect(Selectstore*sels) | ||
649 | { | ||
650 | sels->showMaximized(); | ||
651 | QStringList sFolders; | ||
652 | unsigned int i = 0; | ||
653 | for (i=0; i < mboxAccounts.count();++i) { | ||
654 | mboxAccounts[i]->refresh(false); | ||
655 | sFolders = mboxAccounts[i]->subFolders(); | ||
656 | sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); | ||
657 | } | ||
658 | for (i=0; i < imapAccounts.count();++i) { | ||
659 | if (imapAccounts[i]->offline()) | ||
660 | continue; | ||
661 | imapAccounts[i]->refreshFolders(false); | ||
662 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | ||
663 | } | ||
664 | } | ||
665 | |||
666 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | ||
667 | { | ||
668 | unsigned int i = 0; | ||
669 | AbstractMail*targetMail = 0; | ||
670 | QString targetFolder = ""; | ||
671 | Selectstore sels; | ||
672 | setupFolderselect(&sels); | ||
673 | if (!sels.exec()) return; | ||
674 | targetMail = sels.currentMail(); | ||
675 | targetFolder = sels.currentFolder(); | ||
676 | if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || | ||
677 | targetFolder.isEmpty()) { | ||
678 | return; | ||
679 | } | ||
680 | |||
681 | QList<RecMail> t; | ||
682 | fromWrapper->listMessages(fromFolder->getName(),t); | ||
683 | encodedString*st = 0; | ||
684 | for (i = 0; i < t.count();++i) { | ||
685 | RecMail*r = t.at(i); | ||
686 | st = fromWrapper->fetchRawBody(*r); | ||
687 | if (st) { | ||
688 | targetMail->storeMessage(st->Content(),st->Length(),targetFolder); | ||
689 | delete st; | ||
690 | } | ||
691 | } | ||
692 | } | ||
693 | |||
527 | /** | 694 | /** |
528 | * MBOX Account stuff | 695 | * MBOX Account stuff |
529 | */ | 696 | */ |
530 | 697 | ||
531 | MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) | 698 | MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) |
532 | : AccountViewItem( parent ) | 699 | : AccountViewItem( parent ) |
533 | { | 700 | { |
534 | m_Path = aPath; | 701 | m_Path = aPath; |
535 | wrapper = AbstractMail::getWrapper( m_Path ); | 702 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
703 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | ||
536 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 704 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
537 | setText( 0, " Local Folders" ); | 705 | setText( 0, " Local Folders" ); |
538 | setOpen( true ); | 706 | setOpen( true ); |
@@ -602,6 +770,19 @@ void MBOXviewItem::createFolder() | |||
602 | } | 770 | } |
603 | } | 771 | } |
604 | 772 | ||
773 | QStringList MBOXviewItem::subFolders() | ||
774 | { | ||
775 | QStringList result; | ||
776 | QListViewItem *child = firstChild(); | ||
777 | while ( child ) { | ||
778 | MBOXfolderItem *tmp = (MBOXfolderItem*)child; | ||
779 | child = child->nextSibling(); | ||
780 | result.append(tmp->getFolder()->getName()); | ||
781 | } | ||
782 | qDebug("Size of result: %i",result.count()); | ||
783 | return result; | ||
784 | } | ||
785 | |||
605 | void MBOXviewItem::contextMenuSelected(int which) | 786 | void MBOXviewItem::contextMenuSelected(int which) |
606 | { | 787 | { |
607 | switch (which) { | 788 | switch (which) { |
@@ -636,6 +817,11 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList | |||
636 | setText( 0, folder->getDisplayName() ); | 817 | setText( 0, folder->getDisplayName() ); |
637 | } | 818 | } |
638 | 819 | ||
820 | Folder*MBOXfolderItem::getFolder() | ||
821 | { | ||
822 | return folder; | ||
823 | } | ||
824 | |||
639 | void MBOXfolderItem::refresh(QList<RecMail>&target) | 825 | void MBOXfolderItem::refresh(QList<RecMail>&target) |
640 | { | 826 | { |
641 | if (folder->may_select()) | 827 | if (folder->may_select()) |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 7131192..48f52c7 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -12,36 +12,45 @@ class POP3wrapper; | |||
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | class QPopupMenu; | 14 | class QPopupMenu; |
15 | class Selectstore; | ||
16 | class AccountView; | ||
15 | 17 | ||
16 | class AccountViewItem : public QListViewItem | 18 | class AccountViewItem : public QListViewItem |
17 | { | 19 | { |
18 | 20 | ||
19 | public: | 21 | public: |
20 | AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} | 22 | AccountViewItem( AccountView *parent ); |
21 | AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} | 23 | AccountViewItem( QListViewItem *parent); |
22 | AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} | 24 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); |
25 | virtual ~AccountViewItem(); | ||
23 | virtual void refresh(QList<RecMail>&)=0; | 26 | virtual void refresh(QList<RecMail>&)=0; |
24 | virtual RecBody fetchBody(const RecMail&)=0; | 27 | virtual RecBody fetchBody(const RecMail&)=0; |
25 | virtual QPopupMenu * getContextMenu(){return 0;}; | 28 | virtual QPopupMenu * getContextMenu(){return 0;}; |
26 | virtual void contextMenuSelected(int){} | 29 | virtual void contextMenuSelected(int){} |
30 | virtual AccountView*accountView(); | ||
27 | protected: | 31 | protected: |
28 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | 32 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); |
29 | static const QString contextName; | 33 | static const QString contextName; |
34 | AccountView*m_Backlink; | ||
30 | }; | 35 | }; |
31 | 36 | ||
32 | class POP3viewItem : public AccountViewItem | 37 | class POP3viewItem : public AccountViewItem |
33 | { | 38 | { |
34 | 39 | ||
35 | public: | 40 | public: |
36 | POP3viewItem( POP3account *a, QListView *parent ); | 41 | POP3viewItem( POP3account *a, AccountView *parent ); |
37 | ~POP3viewItem(); | 42 | virtual ~POP3viewItem(); |
38 | virtual void refresh( QList<RecMail> &target ); | 43 | virtual void refresh( QList<RecMail> &target ); |
39 | virtual RecBody fetchBody( const RecMail &mail ); | 44 | virtual RecBody fetchBody( const RecMail &mail ); |
40 | AbstractMail *getWrapper(); | 45 | AbstractMail *getWrapper(); |
41 | private: | 46 | virtual QPopupMenu * getContextMenu(); |
47 | virtual void contextMenuSelected(int); | ||
48 | |||
49 | protected: | ||
42 | POP3account *account; | 50 | POP3account *account; |
43 | AbstractMail *wrapper; | 51 | AbstractMail *wrapper; |
44 | 52 | void disconnect(); | |
53 | void setOnOffline(); | ||
45 | }; | 54 | }; |
46 | 55 | ||
47 | class POP3folderItem : public AccountViewItem | 56 | class POP3folderItem : public AccountViewItem |
@@ -49,7 +58,7 @@ class POP3folderItem : public AccountViewItem | |||
49 | 58 | ||
50 | public: | 59 | public: |
51 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 60 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); |
52 | ~POP3folderItem(); | 61 | virtual ~POP3folderItem(); |
53 | virtual void refresh(QList<RecMail>&); | 62 | virtual void refresh(QList<RecMail>&); |
54 | virtual RecBody fetchBody(const RecMail&); | 63 | virtual RecBody fetchBody(const RecMail&); |
55 | virtual QPopupMenu * getContextMenu(); | 64 | virtual QPopupMenu * getContextMenu(); |
@@ -57,8 +66,6 @@ public: | |||
57 | 66 | ||
58 | protected: | 67 | protected: |
59 | void downloadMails(); | 68 | void downloadMails(); |
60 | |||
61 | private: | ||
62 | Folder *folder; | 69 | Folder *folder; |
63 | POP3viewItem *pop3; | 70 | POP3viewItem *pop3; |
64 | }; | 71 | }; |
@@ -69,23 +76,24 @@ class IMAPviewItem : public AccountViewItem | |||
69 | { | 76 | { |
70 | friend class IMAPfolderItem; | 77 | friend class IMAPfolderItem; |
71 | public: | 78 | public: |
72 | IMAPviewItem( IMAPaccount *a, QListView *parent ); | 79 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); |
73 | ~IMAPviewItem(); | 80 | virtual ~IMAPviewItem(); |
74 | virtual void refresh(QList<RecMail>&); | 81 | virtual void refresh(QList<RecMail>&); |
75 | virtual RecBody fetchBody(const RecMail&); | 82 | virtual RecBody fetchBody(const RecMail&); |
76 | AbstractMail *getWrapper(); | 83 | AbstractMail *getWrapper(); |
77 | virtual QPopupMenu * getContextMenu(); | 84 | virtual QPopupMenu * getContextMenu(); |
78 | virtual void contextMenuSelected(int); | 85 | virtual void contextMenuSelected(int); |
86 | const QStringList&subFolders(); | ||
87 | virtual void refreshFolders(bool force=false); | ||
88 | bool offline(); | ||
79 | 89 | ||
80 | protected: | 90 | protected: |
81 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | 91 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); |
82 | virtual void refreshFolders(bool force=false); | ||
83 | virtual void createNewFolder(); | 92 | virtual void createNewFolder(); |
84 | virtual void removeChilds(); | 93 | virtual void removeChilds(); |
85 | |||
86 | private: | ||
87 | IMAPaccount *account; | 94 | IMAPaccount *account; |
88 | AbstractMail *wrapper; | 95 | AbstractMail *wrapper; |
96 | QStringList currentFolders; | ||
89 | }; | 97 | }; |
90 | 98 | ||
91 | class IMAPfolderItem : public AccountViewItem | 99 | class IMAPfolderItem : public AccountViewItem |
@@ -94,7 +102,7 @@ class IMAPfolderItem : public AccountViewItem | |||
94 | public: | 102 | public: |
95 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 103 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); |
96 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 104 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
97 | ~IMAPfolderItem(); | 105 | virtual ~IMAPfolderItem(); |
98 | virtual void refresh(QList<RecMail>&); | 106 | virtual void refresh(QList<RecMail>&); |
99 | virtual RecBody fetchBody(const RecMail&); | 107 | virtual RecBody fetchBody(const RecMail&); |
100 | bool matchName(const QString&name)const; | 108 | bool matchName(const QString&name)const; |
@@ -104,8 +112,7 @@ public: | |||
104 | protected: | 112 | protected: |
105 | virtual void createNewFolder(); | 113 | virtual void createNewFolder(); |
106 | virtual void deleteFolder(); | 114 | virtual void deleteFolder(); |
107 | 115 | virtual void downloadMails(); | |
108 | private: | ||
109 | Folder *folder; | 116 | Folder *folder; |
110 | IMAPviewItem *imap; | 117 | IMAPviewItem *imap; |
111 | }; | 118 | }; |
@@ -115,21 +122,18 @@ class MBOXviewItem : public AccountViewItem | |||
115 | friend class MBOXfolderItem; | 122 | friend class MBOXfolderItem; |
116 | 123 | ||
117 | public: | 124 | public: |
118 | // MBOXviewItem( MBOXaccount *a, QListView *parent ); | 125 | MBOXviewItem( const QString&aMboxPath, AccountView *parent ); |
119 | MBOXviewItem( const QString&aMboxPath, QListView *parent ); | 126 | virtual ~MBOXviewItem(); |
120 | ~MBOXviewItem(); | ||
121 | virtual void refresh( QList<RecMail> &target ); | 127 | virtual void refresh( QList<RecMail> &target ); |
122 | virtual RecBody fetchBody( const RecMail &mail ); | 128 | virtual RecBody fetchBody( const RecMail &mail ); |
123 | AbstractMail *getWrapper(); | 129 | AbstractMail *getWrapper(); |
124 | virtual QPopupMenu * getContextMenu(); | 130 | virtual QPopupMenu * getContextMenu(); |
125 | virtual void contextMenuSelected(int); | 131 | virtual void contextMenuSelected(int); |
132 | QStringList subFolders(); | ||
133 | virtual void refresh(bool force=false); | ||
126 | 134 | ||
127 | protected: | 135 | protected: |
128 | virtual void refresh(bool force=false); | ||
129 | virtual void createFolder(); | 136 | virtual void createFolder(); |
130 | |||
131 | private: | ||
132 | // MBOXaccount *account; | ||
133 | QString m_Path; | 137 | QString m_Path; |
134 | AbstractMail *wrapper; | 138 | AbstractMail *wrapper; |
135 | 139 | ||
@@ -140,15 +144,15 @@ class MBOXfolderItem : public AccountViewItem | |||
140 | 144 | ||
141 | public: | 145 | public: |
142 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); | 146 | MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); |
143 | ~MBOXfolderItem(); | 147 | virtual ~MBOXfolderItem(); |
144 | virtual void refresh(QList<RecMail>&); | 148 | virtual void refresh(QList<RecMail>&); |
145 | virtual RecBody fetchBody(const RecMail&); | 149 | virtual RecBody fetchBody(const RecMail&); |
146 | virtual QPopupMenu * getContextMenu(); | 150 | virtual QPopupMenu * getContextMenu(); |
147 | virtual void contextMenuSelected(int); | 151 | virtual void contextMenuSelected(int); |
152 | virtual Folder*getFolder(); | ||
148 | 153 | ||
149 | protected: | 154 | protected: |
150 | virtual void deleteFolder(); | 155 | virtual void deleteFolder(); |
151 | private: | ||
152 | Folder *folder; | 156 | Folder *folder; |
153 | MBOXviewItem *mbox; | 157 | MBOXviewItem *mbox; |
154 | }; | 158 | }; |
@@ -159,8 +163,10 @@ class AccountView : public QListView | |||
159 | 163 | ||
160 | public: | 164 | public: |
161 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 165 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
162 | void populate( QList<Account> list ); | 166 | virtual ~AccountView(); |
163 | RecBody fetchBody(const RecMail&aMail); | 167 | virtual void populate( QList<Account> list ); |
168 | virtual RecBody fetchBody(const RecMail&aMail); | ||
169 | virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); | ||
164 | 170 | ||
165 | public slots: | 171 | public slots: |
166 | virtual void refreshAll(); | 172 | virtual void refreshAll(); |
@@ -168,12 +174,15 @@ public slots: | |||
168 | virtual void refreshCurrent(); | 174 | virtual void refreshCurrent(); |
169 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 175 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
170 | virtual void slotContextMenu(int id); | 176 | virtual void slotContextMenu(int id); |
177 | void setupFolderselect(Selectstore*sels); | ||
171 | 178 | ||
172 | signals: | 179 | signals: |
173 | void refreshMailview(QList<RecMail>*); | 180 | void refreshMailview(QList<RecMail>*); |
174 | 181 | ||
175 | private: | 182 | protected: |
176 | QListViewItem* m_currentItem; | 183 | QListViewItem* m_currentItem; |
184 | QValueList<IMAPviewItem*> imapAccounts; | ||
185 | QValueList<MBOXviewItem*> mboxAccounts; | ||
177 | }; | 186 | }; |
178 | 187 | ||
179 | #endif | 188 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 80d0b52..3dd2fce 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -21,9 +21,9 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) | |||
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(const QString&a) | 24 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
25 | { | 25 | { |
26 | return new MBOXwrapper(a); | 26 | return new MBOXwrapper(a,name); |
27 | } | 27 | } |
28 | 28 | ||
29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
@@ -99,3 +99,8 @@ QString AbstractMail::defaultLocalfolder() | |||
99 | f += "/Applications/opiemail/localmail"; | 99 | f += "/Applications/opiemail/localmail"; |
100 | return f; | 100 | return f; |
101 | } | 101 | } |
102 | |||
103 | /* temporary - will be removed when implemented in all classes */ | ||
104 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | ||
105 | { | ||
106 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 9770991..15d83cb 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -31,6 +31,7 @@ public: | |||
31 | virtual void deleteMail(const RecMail&mail)=0; | 31 | virtual void deleteMail(const RecMail&mail)=0; |
32 | virtual void answeredMail(const RecMail&mail)=0; | 32 | virtual void answeredMail(const RecMail&mail)=0; |
33 | virtual int deleteAllMail(const Folder*)=0; | 33 | virtual int deleteAllMail(const Folder*)=0; |
34 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | ||
34 | virtual int deleteMbox(const Folder*)=0; | 35 | virtual int deleteMbox(const Folder*)=0; |
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
36 | 37 | ||
@@ -46,11 +47,12 @@ public: | |||
46 | static AbstractMail* getWrapper(IMAPaccount *a); | 47 | static AbstractMail* getWrapper(IMAPaccount *a); |
47 | static AbstractMail* getWrapper(POP3account *a); | 48 | static AbstractMail* getWrapper(POP3account *a); |
48 | /* mbox only! */ | 49 | /* mbox only! */ |
49 | static AbstractMail* getWrapper(const QString&a); | 50 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
50 | 51 | ||
51 | static QString defaultLocalfolder(); | 52 | static QString defaultLocalfolder(); |
52 | 53 | ||
53 | virtual const QString&getType()const=0; | 54 | virtual const QString&getType()const=0; |
55 | virtual const QString&getName()const=0; | ||
54 | 56 | ||
55 | protected: | 57 | protected: |
56 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 58 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index d252159..bb74de9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -29,6 +29,7 @@ void IMAPwrapper::login() | |||
29 | uint16_t port; | 29 | uint16_t port; |
30 | int err = MAILIMAP_NO_ERROR; | 30 | int err = MAILIMAP_NO_ERROR; |
31 | 31 | ||
32 | if (account->getOffline()) return; | ||
32 | /* we are connected this moment */ | 33 | /* we are connected this moment */ |
33 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 34 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
34 | if (m_imap) { | 35 | if (m_imap) { |
@@ -1006,6 +1007,11 @@ const QString&IMAPwrapper::getType()const | |||
1006 | return account->getType(); | 1007 | return account->getType(); |
1007 | } | 1008 | } |
1008 | 1009 | ||
1010 | const QString&IMAPwrapper::getName()const | ||
1011 | { | ||
1012 | return account->getAccountName(); | ||
1013 | } | ||
1014 | |||
1009 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1015 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) |
1010 | { | 1016 | { |
1011 | // dummy | 1017 | // dummy |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b246f58..b2bd7e9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -45,6 +45,8 @@ public: | |||
45 | 45 | ||
46 | virtual void logout(); | 46 | virtual void logout(); |
47 | virtual const QString&getType()const; | 47 | virtual const QString&getType()const; |
48 | virtual const QString&getName()const; | ||
49 | |||
48 | protected: | 50 | protected: |
49 | RecMail*parse_list_result(mailimap_msg_att*); | 51 | RecMail*parse_list_result(mailimap_msg_att*); |
50 | void login(); | 52 | void login(); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index bc496f7..97f301e 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -8,8 +8,8 @@ | |||
8 | 8 | ||
9 | const QString MBOXwrapper::wrapperType="MBOX"; | 9 | const QString MBOXwrapper::wrapperType="MBOX"; |
10 | 10 | ||
11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
12 | : Genericwrapper(),MBOXPath(mbox_dir) | 12 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
13 | { | 13 | { |
14 | QDir dir(MBOXPath); | 14 | QDir dir(MBOXPath); |
15 | if (!dir.exists()) { | 15 | if (!dir.exists()) { |
@@ -330,3 +330,8 @@ const QString&MBOXwrapper::getType()const | |||
330 | { | 330 | { |
331 | return wrapperType; | 331 | return wrapperType; |
332 | } | 332 | } |
333 | |||
334 | const QString&MBOXwrapper::getName()const | ||
335 | { | ||
336 | return MBOXName; | ||
337 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 2794014..194ff86 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -13,7 +13,7 @@ class MBOXwrapper : public Genericwrapper | |||
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | MBOXwrapper(const QString & dir); | 16 | MBOXwrapper(const QString & dir,const QString&name); |
17 | virtual ~MBOXwrapper(); | 17 | virtual ~MBOXwrapper(); |
18 | 18 | ||
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
@@ -32,13 +32,15 @@ public: | |||
32 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 33 | ||
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
35 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 35 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
36 | virtual int deleteAllMail(const Folder*); | 36 | virtual int deleteAllMail(const Folder*); |
37 | virtual const QString&getType()const; | 37 | virtual const QString&getType()const; |
38 | virtual const QString&getName()const; | ||
38 | 39 | ||
39 | protected: | 40 | protected: |
40 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 41 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
41 | QString MBOXPath; | 42 | QString MBOXPath; |
43 | QString MBOXName; | ||
42 | static const QString wrapperType; | 44 | static const QString wrapperType; |
43 | }; | 45 | }; |
44 | 46 | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index cceb22e..67bde38 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -108,6 +108,7 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
108 | 108 | ||
109 | void POP3wrapper::login() | 109 | void POP3wrapper::login() |
110 | { | 110 | { |
111 | if (account->getOffline()) return; | ||
111 | /* we'll hold the line */ | 112 | /* we'll hold the line */ |
112 | if ( m_pop3 != NULL ) return; | 113 | if ( m_pop3 != NULL ) return; |
113 | 114 | ||
@@ -249,3 +250,8 @@ const QString&POP3wrapper::getType()const | |||
249 | { | 250 | { |
250 | return account->getType(); | 251 | return account->getType(); |
251 | } | 252 | } |
253 | |||
254 | const QString&POP3wrapper::getName()const | ||
255 | { | ||
256 | return account->getAccountName(); | ||
257 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index f0307b6..d2b708d 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -30,6 +30,7 @@ public: | |||
30 | virtual encodedString* fetchRawBody(const RecMail&mail); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual const QString&getType()const; | 32 | virtual const QString&getType()const; |
33 | virtual const QString&getName()const; | ||
33 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
34 | 35 | ||
35 | protected: | 36 | protected: |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index c5187f5..02a80a3 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -168,6 +168,8 @@ void IMAPaccount::read() | |||
168 | if (password.isNull()) password = ""; | 168 | if (password.isNull()) password = ""; |
169 | prefix = conf->readEntry("MailPrefix",""); | 169 | prefix = conf->readEntry("MailPrefix",""); |
170 | if (prefix.isNull()) prefix = ""; | 170 | if (prefix.isNull()) prefix = ""; |
171 | offline = conf->readBoolEntry("Offline",false); | ||
172 | delete conf; | ||
171 | } | 173 | } |
172 | 174 | ||
173 | void IMAPaccount::save() | 175 | void IMAPaccount::save() |
@@ -184,7 +186,9 @@ void IMAPaccount::save() | |||
184 | conf->writeEntry( "User", user ); | 186 | conf->writeEntry( "User", user ); |
185 | conf->writeEntryCrypt( "Password", password ); | 187 | conf->writeEntryCrypt( "Password", password ); |
186 | conf->writeEntry( "MailPrefix",prefix); | 188 | conf->writeEntry( "MailPrefix",prefix); |
189 | conf->writeEntry( "Offline",offline); | ||
187 | conf->write(); | 190 | conf->write(); |
191 | delete conf; | ||
188 | } | 192 | } |
189 | 193 | ||
190 | 194 | ||
@@ -238,6 +242,8 @@ void POP3account::read() | |||
238 | ssl = conf->readBoolEntry( "SSL" ); | 242 | ssl = conf->readBoolEntry( "SSL" ); |
239 | user = conf->readEntry( "User" ); | 243 | user = conf->readEntry( "User" ); |
240 | password = conf->readEntryCrypt( "Password" ); | 244 | password = conf->readEntryCrypt( "Password" ); |
245 | offline = conf->readBoolEntry("Offline",false); | ||
246 | delete conf; | ||
241 | } | 247 | } |
242 | 248 | ||
243 | void POP3account::save() | 249 | void POP3account::save() |
@@ -253,7 +259,9 @@ void POP3account::save() | |||
253 | conf->writeEntry( "SSL", ssl ); | 259 | conf->writeEntry( "SSL", ssl ); |
254 | conf->writeEntry( "User", user ); | 260 | conf->writeEntry( "User", user ); |
255 | conf->writeEntryCrypt( "Password", password ); | 261 | conf->writeEntryCrypt( "Password", password ); |
262 | conf->writeEntry( "Offline",offline); | ||
256 | conf->write(); | 263 | conf->write(); |
264 | delete conf; | ||
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
@@ -313,6 +321,7 @@ void SMTPaccount::read() | |||
313 | login = conf->readBoolEntry( "Login" ); | 321 | login = conf->readBoolEntry( "Login" ); |
314 | user = conf->readEntry( "User" ); | 322 | user = conf->readEntry( "User" ); |
315 | password = conf->readEntryCrypt( "Password" ); | 323 | password = conf->readEntryCrypt( "Password" ); |
324 | delete conf; | ||
316 | } | 325 | } |
317 | 326 | ||
318 | void SMTPaccount::save() | 327 | void SMTPaccount::save() |
@@ -330,6 +339,7 @@ void SMTPaccount::save() | |||
330 | conf->writeEntry( "User", user ); | 339 | conf->writeEntry( "User", user ); |
331 | conf->writeEntryCrypt( "Password", password ); | 340 | conf->writeEntryCrypt( "Password", password ); |
332 | conf->write(); | 341 | conf->write(); |
342 | delete conf; | ||
333 | } | 343 | } |
334 | 344 | ||
335 | 345 | ||
@@ -386,6 +396,7 @@ void NNTPaccount::read() | |||
386 | login = conf->readBoolEntry( "Login" ); | 396 | login = conf->readBoolEntry( "Login" ); |
387 | user = conf->readEntry( "User" ); | 397 | user = conf->readEntry( "User" ); |
388 | password = conf->readEntryCrypt( "Password" ); | 398 | password = conf->readEntryCrypt( "Password" ); |
399 | delete conf; | ||
389 | } | 400 | } |
390 | 401 | ||
391 | void NNTPaccount::save() | 402 | void NNTPaccount::save() |
@@ -403,6 +414,7 @@ void NNTPaccount::save() | |||
403 | conf->writeEntry( "User", user ); | 414 | conf->writeEntry( "User", user ); |
404 | conf->writeEntryCrypt( "Password", password ); | 415 | conf->writeEntryCrypt( "Password", password ); |
405 | conf->write(); | 416 | conf->write(); |
417 | delete conf; | ||
406 | } | 418 | } |
407 | 419 | ||
408 | 420 | ||
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index caa5dfc..2104997 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -30,6 +30,9 @@ public: | |||
30 | 30 | ||
31 | void setSSL( bool b ) { ssl = b; } | 31 | void setSSL( bool b ) { ssl = b; } |
32 | bool getSSL() { return ssl; } | 32 | bool getSSL() { return ssl; } |
33 | |||
34 | void setOffline(bool b) {offline = b;} | ||
35 | bool getOffline()const{return offline;} | ||
33 | 36 | ||
34 | virtual QString getFileName() { return accountName; } | 37 | virtual QString getFileName() { return accountName; } |
35 | virtual void read() { qDebug( "base reading..." ); } | 38 | virtual void read() { qDebug( "base reading..." ); } |
@@ -38,7 +41,7 @@ public: | |||
38 | protected: | 41 | protected: |
39 | QString accountName, type, server, port, user, password; | 42 | QString accountName, type, server, port, user, password; |
40 | bool ssl; | 43 | bool ssl; |
41 | 44 | bool offline; | |
42 | }; | 45 | }; |
43 | 46 | ||
44 | class IMAPaccount : public Account | 47 | class IMAPaccount : public Account |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 4764b77..281b88e 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -489,7 +489,7 @@ void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) | |||
489 | { | 489 | { |
490 | if (!mail) return; | 490 | if (!mail) return; |
491 | QString localfolders = AbstractMail::defaultLocalfolder(); | 491 | QString localfolders = AbstractMail::defaultLocalfolder(); |
492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 492 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
493 | wrap->storeMessage(mail,length,box); | 493 | wrap->storeMessage(mail,length,box); |
494 | delete wrap; | 494 | delete wrap; |
495 | } | 495 | } |
@@ -516,11 +516,9 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
516 | qDebug("Error fetching mime..."); | 516 | qDebug("Error fetching mime..."); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | QString tmp = data; | ||
520 | tmp.replace(QRegExp("\r+",true,false),""); | ||
521 | msg = 0; | 519 | msg = 0; |
522 | if (later) { | 520 | if (later) { |
523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); | 521 | storeMail(data,size,"Outgoing"); |
524 | if (data) free( data ); | 522 | if (data) free( data ); |
525 | Config cfg( "mail" ); | 523 | Config cfg( "mail" ); |
526 | cfg.setGroup( "Status" ); | 524 | cfg.setGroup( "Status" ); |
@@ -636,7 +634,7 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) | |||
636 | } | 634 | } |
637 | } | 635 | } |
638 | 636 | ||
639 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 637 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which) |
640 | { | 638 | { |
641 | size_t curTok = 0; | 639 | size_t curTok = 0; |
642 | mailimf_fields *fields = 0; | 640 | mailimf_fields *fields = 0; |
@@ -685,7 +683,7 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | |||
685 | if (!smtp) return false; | 683 | if (!smtp) return false; |
686 | 684 | ||
687 | QString localfolders = AbstractMail::defaultLocalfolder(); | 685 | QString localfolders = AbstractMail::defaultLocalfolder(); |
688 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 686 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
689 | if (!wrap) { | 687 | if (!wrap) { |
690 | qDebug("memory error"); | 688 | qDebug("memory error"); |
691 | return false; | 689 | return false; |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 04fc4b0..7dcdbfd 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -10,7 +10,7 @@ | |||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class MBOXwrapper; | 13 | class AbstractMail; |
14 | class RecMail; | 14 | class RecMail; |
15 | class Attachment; | 15 | class Attachment; |
16 | struct mailimf_fields; | 16 | struct mailimf_fields; |
@@ -59,7 +59,7 @@ protected: | |||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which); |
63 | 63 | ||
64 | int m_queuedMail; | 64 | int m_queuedMail; |
65 | static const char* USER_AGENT; | 65 | static const char* USER_AGENT; |
diff --git a/noncore/net/mail/selectstore.cpp b/noncore/net/mail/selectstore.cpp index 28ab5a8..0a07d51 100644 --- a/noncore/net/mail/selectstore.cpp +++ b/noncore/net/mail/selectstore.cpp | |||
@@ -1,9 +1,15 @@ | |||
1 | #include "selectstore.h" | 1 | #include "selectstore.h" |
2 | #include <qlineedit.h> | ||
3 | #include <qcheckbox.h> | ||
4 | #include <qcombobox.h> | ||
5 | #include <libmailwrapper/abstractmail.h> | ||
2 | 6 | ||
3 | Selectstore::Selectstore(QWidget* parent, const char* name) | 7 | Selectstore::Selectstore(QWidget* parent, const char* name) |
4 | :selectstoreui(parent,name,true) | 8 | :selectstoreui(parent,name,true) |
5 | { | 9 | { |
6 | 10 | folderMap.clear(); | |
11 | mailMap.clear(); | ||
12 | cMail = 0; | ||
7 | } | 13 | } |
8 | 14 | ||
9 | Selectstore::~Selectstore() | 15 | Selectstore::~Selectstore() |
@@ -12,8 +18,53 @@ Selectstore::~Selectstore() | |||
12 | 18 | ||
13 | void Selectstore::slotCreateNewFolder() | 19 | void Selectstore::slotCreateNewFolder() |
14 | { | 20 | { |
21 | bool how = newFoldersel->isChecked(); | ||
22 | folderSelection->setEnabled(!how); | ||
23 | newFolderedit->setEnabled(how); | ||
15 | } | 24 | } |
16 | 25 | ||
17 | void Selectstore::slotMoveMail() | 26 | void Selectstore::slotMoveMail() |
18 | { | 27 | { |
19 | } | 28 | } |
29 | |||
30 | void Selectstore::addAccounts(AbstractMail*mail,const QStringList&folders) | ||
31 | { | ||
32 | accountSelection->insertItem(mail->getName()); | ||
33 | mailMap[accountSelection->count()-1]=mail; | ||
34 | folderMap[accountSelection->count()-1]=folders; | ||
35 | if (accountSelection->count()==1) { | ||
36 | cMail = mail; | ||
37 | folderSelection->insertStringList(folders); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | void Selectstore::slotAccountselected(int i) | ||
42 | { | ||
43 | folderSelection->clear(); | ||
44 | folderSelection->insertStringList(folderMap[i]); | ||
45 | cMail = mailMap[i]; | ||
46 | } | ||
47 | |||
48 | QString Selectstore::currentFolder() | ||
49 | { | ||
50 | if (newFoldersel->isChecked()) { | ||
51 | return newFolderedit->text(); | ||
52 | } else { | ||
53 | return folderSelection->currentText(); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | AbstractMail*Selectstore::currentMail() | ||
58 | { | ||
59 | return cMail; | ||
60 | } | ||
61 | |||
62 | bool Selectstore::newFolder() | ||
63 | { | ||
64 | return newFoldersel->isChecked(); | ||
65 | } | ||
66 | |||
67 | bool Selectstore::moveMails() | ||
68 | { | ||
69 | return selMove->isChecked(); | ||
70 | } | ||
diff --git a/noncore/net/mail/selectstore.h b/noncore/net/mail/selectstore.h index 8b8e8ee..447a6ae 100644 --- a/noncore/net/mail/selectstore.h +++ b/noncore/net/mail/selectstore.h | |||
@@ -2,6 +2,11 @@ | |||
2 | #define _SELECTSTORE_H | 2 | #define _SELECTSTORE_H |
3 | 3 | ||
4 | #include "selectstoreui.h" | 4 | #include "selectstoreui.h" |
5 | #include <qvaluelist.h> | ||
6 | #include <qmap.h> | ||
7 | #include <qstringlist.h> | ||
8 | |||
9 | class AbstractMail; | ||
5 | 10 | ||
6 | class Selectstore:public selectstoreui | 11 | class Selectstore:public selectstoreui |
7 | { | 12 | { |
@@ -9,11 +14,20 @@ class Selectstore:public selectstoreui | |||
9 | public: | 14 | public: |
10 | Selectstore(QWidget* parent = 0, const char* name = 0); | 15 | Selectstore(QWidget* parent = 0, const char* name = 0); |
11 | virtual ~Selectstore(); | 16 | virtual ~Selectstore(); |
17 | virtual void addAccounts(AbstractMail*mail,const QStringList&folders); | ||
18 | virtual QString currentFolder(); | ||
19 | virtual AbstractMail*currentMail(); | ||
20 | bool newFolder(); | ||
21 | bool moveMails(); | ||
12 | 22 | ||
13 | protected: | 23 | protected slots: |
14 | virtual void slotCreateNewFolder(); | 24 | virtual void slotCreateNewFolder(); |
15 | virtual void slotMoveMail(); | 25 | virtual void slotMoveMail(); |
16 | protected slots: | 26 | virtual void slotAccountselected(int); |
17 | 27 | ||
28 | protected: | ||
29 | QMap<int,QStringList> folderMap; | ||
30 | QMap<int,AbstractMail*> mailMap; | ||
31 | AbstractMail*cMail; | ||
18 | }; | 32 | }; |
19 | #endif | 33 | #endif |
diff --git a/noncore/net/mail/selectstoreui.ui b/noncore/net/mail/selectstoreui.ui index 3741b71..5f0e507 100644 --- a/noncore/net/mail/selectstoreui.ui +++ b/noncore/net/mail/selectstoreui.ui | |||
@@ -11,7 +11,7 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>190</width> | 14 | <width>182</width> |
15 | <height>273</height> | 15 | <height>273</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
@@ -28,11 +28,11 @@ | |||
28 | <vbox> | 28 | <vbox> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>2</number> | 31 | <number>1</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>2</number> | 35 | <number>1</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
38 | <class>QLabel</class> | 38 | <class>QLabel</class> |
@@ -174,6 +174,27 @@ | |||
174 | </property> | 174 | </property> |
175 | </widget> | 175 | </widget> |
176 | <widget> | 176 | <widget> |
177 | <class>QLabel</class> | ||
178 | <property stdset="1"> | ||
179 | <name>name</name> | ||
180 | <cstring>newFolderLabel</cstring> | ||
181 | </property> | ||
182 | <property stdset="1"> | ||
183 | <name>text</name> | ||
184 | <string>Prefix will prepend, no need to enter it!</string> | ||
185 | </property> | ||
186 | <property stdset="1"> | ||
187 | <name>alignment</name> | ||
188 | <set>WordBreak|AlignCenter</set> | ||
189 | </property> | ||
190 | <property> | ||
191 | <name>hAlign</name> | ||
192 | </property> | ||
193 | <property> | ||
194 | <name>wordwrap</name> | ||
195 | </property> | ||
196 | </widget> | ||
197 | <widget> | ||
177 | <class>Line</class> | 198 | <class>Line</class> |
178 | <property stdset="1"> | 199 | <property stdset="1"> |
179 | <name>name</name> | 200 | <name>name</name> |
@@ -231,8 +252,22 @@ | |||
231 | <receiver>selectstoreui</receiver> | 252 | <receiver>selectstoreui</receiver> |
232 | <slot>slotCreateNewFolder()</slot> | 253 | <slot>slotCreateNewFolder()</slot> |
233 | </connection> | 254 | </connection> |
234 | <slot access="protected">slotMoveMail()</slot> | 255 | <connection> |
256 | <sender>accountSelection</sender> | ||
257 | <signal>activated(int)</signal> | ||
258 | <receiver>selectstoreui</receiver> | ||
259 | <slot>slotAccountselected(int)</slot> | ||
260 | </connection> | ||
261 | <connection> | ||
262 | <sender>folderSelection</sender> | ||
263 | <signal>activated(int)</signal> | ||
264 | <receiver>selectstoreui</receiver> | ||
265 | <slot>slotFolderSelected(int)</slot> | ||
266 | </connection> | ||
267 | <slot access="protected">slotFolderSelected(int)</slot> | ||
268 | <slot access="protected">slotAccountselected(int)</slot> | ||
235 | <slot access="protected">slotCreateNewFolder()</slot> | 269 | <slot access="protected">slotCreateNewFolder()</slot> |
270 | <slot access="protected">slotMoveMail()</slot> | ||
236 | </connections> | 271 | </connections> |
237 | <tabstops> | 272 | <tabstops> |
238 | <tabstop>accountSelection</tabstop> | 273 | <tabstop>accountSelection</tabstop> |