author | zautrix <zautrix> | 2004-09-11 16:44:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 16:44:49 (UTC) |
commit | 06be094df4e34cc41db113d8c0e78eccde5365b5 (patch) (unidiff) | |
tree | b99317f9c83886d05b83cdb49e066f414e0fde25 /kmicromail/accountitem.cpp | |
parent | 53e10fa5e66620ff1eba1c9d17738103ad511c91 (diff) | |
download | kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.zip kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.tar.gz kdepimpi-06be094df4e34cc41db113d8c0e78eccde5365b5.tar.bz2 |
Mail more useful
-rw-r--r-- | kmicromail/accountitem.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 7b9b881..59c8abb 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,50 +1,52 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | 18 | ||
19 | #define GET_NEW_MAILS 101 | ||
20 | |||
19 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 22 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 23 | /** |
22 | * POP3 Account stuff | 24 | * POP3 Account stuff |
23 | */ | 25 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 26 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 27 | : AccountViewItem( parent ) |
26 | { | 28 | { |
27 | account = a; | 29 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 30 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 31 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 32 | #if 0 |
31 | if (!account->getOffline()) | 33 | if (!account->getOffline()) |
32 | { | 34 | { |
33 | setPixmap( 0, ); | 35 | setPixmap( 0, ); |
34 | } | 36 | } |
35 | else | 37 | else |
36 | { | 38 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 39 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 40 | } |
39 | #endif | 41 | #endif |
40 | setText( 0, account->getAccountName() ); | 42 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 43 | setOpen( true ); |
42 | } | 44 | } |
43 | 45 | ||
44 | POP3viewItem::~POP3viewItem() | 46 | POP3viewItem::~POP3viewItem() |
45 | { | 47 | { |
46 | delete wrapper; | 48 | delete wrapper; |
47 | } | 49 | } |
48 | 50 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 51 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 52 | { |
@@ -63,110 +65,110 @@ void POP3viewItem::refresh() | |||
63 | QListViewItem *child = firstChild(); | 65 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 66 | while ( child ) |
65 | { | 67 | { |
66 | QListViewItem *tmp = child; | 68 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 69 | child = child->nextSibling(); |
68 | delete tmp; | 70 | delete tmp; |
69 | } | 71 | } |
70 | QValueList<FolderP>::ConstIterator it; | 72 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 73 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 74 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 75 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 76 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 77 | item->setSelectable( (*it)->may_select()); |
76 | } | 78 | } |
77 | delete folders; | 79 | delete folders; |
78 | } | 80 | } |
79 | 81 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 82 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 83 | { |
82 | 84 | ||
83 | return wrapper->fetchBody( mail ); | 85 | return wrapper->fetchBody( mail ); |
84 | } | 86 | } |
85 | 87 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 88 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 89 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 90 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 91 | if (m) |
90 | { | 92 | { |
91 | if (!account->getOffline()) | 93 | if (!account->getOffline()) |
92 | { | 94 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 95 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 96 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | 97 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
96 | } | 98 | } |
97 | else | 99 | else |
98 | { | 100 | { |
99 | m->insertItem(QObject::tr("Set online",contextName),1); | 101 | m->insertItem(QObject::tr("Set online",contextName),1); |
100 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | 102 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
101 | } | 103 | } |
102 | } | 104 | } |
103 | return m; | 105 | return m; |
104 | } | 106 | } |
105 | 107 | ||
106 | void POP3viewItem::disconnect() | 108 | void POP3viewItem::disconnect() |
107 | { | 109 | { |
108 | QListViewItem *child = firstChild(); | 110 | QListViewItem *child = firstChild(); |
109 | while ( child ) | 111 | while ( child ) |
110 | { | 112 | { |
111 | QListViewItem *tmp = child; | 113 | QListViewItem *tmp = child; |
112 | child = child->nextSibling(); | 114 | child = child->nextSibling(); |
113 | delete tmp; | 115 | delete tmp; |
114 | } | 116 | } |
115 | wrapper->logout(); | 117 | wrapper->logout(); |
116 | } | 118 | } |
117 | 119 | ||
118 | void POP3viewItem::setOnOffline() | 120 | void POP3viewItem::setOnOffline() |
119 | { | 121 | { |
120 | if (!account->getOffline()) | 122 | if (!account->getOffline()) |
121 | { | 123 | { |
122 | disconnect(); | 124 | disconnect(); |
123 | } | 125 | } |
124 | account->setOffline(!account->getOffline()); | 126 | account->setOffline(!account->getOffline()); |
125 | account->save(); | 127 | account->save(); |
126 | SETPIX(PIXMAP_POP3FOLDER); | 128 | SETPIX(PIXMAP_POP3FOLDER); |
127 | refresh(); | 129 | refresh(); |
128 | } | 130 | } |
129 | 131 | ||
130 | void POP3viewItem::contextMenuSelected(int which) | 132 | void POP3viewItem::contextMenuSelected(int which) |
131 | { | 133 | { |
132 | switch (which) | 134 | switch (which) |
133 | { | 135 | { |
134 | case 0: | 136 | case 0: |
135 | disconnect(); | 137 | disconnect(); |
136 | break; | 138 | break; |
137 | case 1: | 139 | case 1: |
138 | setOnOffline(); | 140 | setOnOffline(); |
139 | break; | 141 | break; |
140 | case 2: // daunlood | 142 | case GET_NEW_MAILS: // daunlood |
141 | if (account->getOffline()) | 143 | if (account->getOffline()) |
142 | setOnOffline(); | 144 | setOnOffline(); |
143 | AccountView*bl = accountView(); | 145 | AccountView*bl = accountView(); |
144 | if (!bl) return; | 146 | if (!bl) return; |
145 | AccountViewItem* in = findSubItem( "inbox" , 0); | 147 | AccountViewItem* in = findSubItem( "inbox" , 0); |
146 | if ( ! in ) | 148 | if ( ! in ) |
147 | return; | 149 | return; |
148 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 150 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
149 | setOnOffline(); | 151 | setOnOffline(); |
150 | break; | 152 | break; |
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
154 | POP3folderItem::~POP3folderItem() | 156 | POP3folderItem::~POP3folderItem() |
155 | {} | 157 | {} |
156 | 158 | ||
157 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 159 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
158 | : AccountViewItem(folderInit,parent,after ) | 160 | : AccountViewItem(folderInit,parent,after ) |
159 | { | 161 | { |
160 | pop3 = parent; | 162 | pop3 = parent; |
161 | if (folder->getDisplayName().lower()!="inbox") | 163 | if (folder->getDisplayName().lower()!="inbox") |
162 | { | 164 | { |
163 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 165 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
164 | } | 166 | } |
165 | else | 167 | else |
166 | { | 168 | { |
167 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 169 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
168 | } | 170 | } |
169 | setText( 0, folder->getDisplayName() ); | 171 | setText( 0, folder->getDisplayName() ); |
170 | } | 172 | } |
171 | 173 | ||
172 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 174 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
@@ -488,125 +490,125 @@ void IMAPviewItem::refreshFolders(bool force) | |||
488 | fname = fname.left(pos); | 490 | fname = fname.left(pos); |
489 | } | 491 | } |
490 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 492 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
491 | if (pitem) | 493 | if (pitem) |
492 | { | 494 | { |
493 | titem = item; | 495 | titem = item; |
494 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 496 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
495 | /* setup the short name */ | 497 | /* setup the short name */ |
496 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 498 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
497 | item = titem; | 499 | item = titem; |
498 | } | 500 | } |
499 | else | 501 | else |
500 | { | 502 | { |
501 | item = new IMAPfolderItem( (*it), this , item ); | 503 | item = new IMAPfolderItem( (*it), this , item ); |
502 | } | 504 | } |
503 | } | 505 | } |
504 | delete folders; | 506 | delete folders; |
505 | } | 507 | } |
506 | 508 | ||
507 | QPopupMenu * IMAPviewItem::getContextMenu() | 509 | QPopupMenu * IMAPviewItem::getContextMenu() |
508 | { | 510 | { |
509 | QPopupMenu *m = new QPopupMenu(0); | 511 | QPopupMenu *m = new QPopupMenu(0); |
510 | if (m) | 512 | if (m) |
511 | { | 513 | { |
512 | if (!account->getOffline()) | 514 | if (!account->getOffline()) |
513 | { | 515 | { |
514 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 516 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
515 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 517 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
516 | m->insertSeparator(); | 518 | m->insertSeparator(); |
517 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 519 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
518 | m->insertItem(QObject::tr("Set offline",contextName),3); | 520 | m->insertItem(QObject::tr("Set offline",contextName),3); |
519 | m->insertSeparator(); | 521 | m->insertSeparator(); |
520 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | 522 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
521 | } | 523 | } |
522 | else | 524 | else |
523 | { | 525 | { |
524 | m->insertItem(QObject::tr("Set online",contextName),3); | 526 | m->insertItem(QObject::tr("Set online",contextName),3); |
525 | m->insertSeparator(); | 527 | m->insertSeparator(); |
526 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | 528 | m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); |
527 | } | 529 | } |
528 | } | 530 | } |
529 | return m; | 531 | return m; |
530 | } | 532 | } |
531 | 533 | ||
532 | void IMAPviewItem::createNewFolder() | 534 | void IMAPviewItem::createNewFolder() |
533 | { | 535 | { |
534 | Newmdirdlg ndirdlg; | 536 | Newmdirdlg ndirdlg; |
535 | 537 | ||
536 | ndirdlg.showMaximized(); | 538 | ndirdlg.showMaximized(); |
537 | if ( ndirdlg.exec() ) | 539 | if ( ndirdlg.exec() ) |
538 | { | 540 | { |
539 | QString ndir = ndirdlg.Newdir(); | 541 | QString ndir = ndirdlg.Newdir(); |
540 | bool makesubs = ndirdlg.subpossible(); | 542 | bool makesubs = ndirdlg.subpossible(); |
541 | QString delemiter = "/"; | 543 | QString delemiter = "/"; |
542 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 544 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
543 | if (item) | 545 | if (item) |
544 | { | 546 | { |
545 | delemiter = item->Delemiter(); | 547 | delemiter = item->Delemiter(); |
546 | } | 548 | } |
547 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 549 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
548 | { | 550 | { |
549 | refreshFolders(true); | 551 | refreshFolders(true); |
550 | } | 552 | } |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
554 | void IMAPviewItem::contextMenuSelected(int id) | 556 | void IMAPviewItem::contextMenuSelected(int id) |
555 | { | 557 | { |
556 | 558 | ||
557 | switch (id) | 559 | switch (id) |
558 | { | 560 | { |
559 | case 0: | 561 | case 0: |
560 | refreshFolders(true); | 562 | refreshFolders(true); |
561 | break; | 563 | break; |
562 | case 1: | 564 | case 1: |
563 | createNewFolder(); | 565 | createNewFolder(); |
564 | break; | 566 | break; |
565 | case 2: | 567 | case 2: |
566 | removeChilds(); | 568 | removeChilds(); |
567 | wrapper->logout(); | 569 | wrapper->logout(); |
568 | break; | 570 | break; |
569 | case 3: | 571 | case 3: |
570 | if (account->getOffline()==false) | 572 | if (account->getOffline()==false) |
571 | { | 573 | { |
572 | removeChilds(); | 574 | removeChilds(); |
573 | wrapper->logout(); | 575 | wrapper->logout(); |
574 | } | 576 | } |
575 | account->setOffline(!account->getOffline()); | 577 | account->setOffline(!account->getOffline()); |
576 | account->save(); | 578 | account->save(); |
577 | SETPIX(PIXMAP_IMAPFOLDER); | 579 | SETPIX(PIXMAP_IMAPFOLDER); |
578 | refreshFolders(false); | 580 | refreshFolders(false); |
579 | break; | 581 | break; |
580 | case 4: // daunlood | 582 | case GET_NEW_MAILS: // daunlood |
581 | { | 583 | { |
582 | if (account->getOffline()) { | 584 | if (account->getOffline()) { |
583 | contextMenuSelected( 3 ); | 585 | contextMenuSelected( 3 ); |
584 | } | 586 | } |
585 | AccountView*bl = accountView(); | 587 | AccountView*bl = accountView(); |
586 | if (!bl) return; | 588 | if (!bl) return; |
587 | AccountViewItem* in = findSubItem( "inbox" , 0); | 589 | AccountViewItem* in = findSubItem( "inbox" , 0); |
588 | if ( ! in ) | 590 | if ( ! in ) |
589 | return; | 591 | return; |
590 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | 592 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); |
591 | } | 593 | } |
592 | break; | 594 | break; |
593 | default: | 595 | default: |
594 | break; | 596 | break; |
595 | } | 597 | } |
596 | } | 598 | } |
597 | 599 | ||
598 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 600 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
599 | { | 601 | { |
600 | return new RecBody(); | 602 | return new RecBody(); |
601 | } | 603 | } |
602 | 604 | ||
603 | bool IMAPviewItem::offline() | 605 | bool IMAPviewItem::offline() |
604 | { | 606 | { |
605 | return account->getOffline(); | 607 | return account->getOffline(); |
606 | } | 608 | } |
607 | 609 | ||
608 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 610 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
609 | : AccountViewItem( folderInit, parent , after ) | 611 | : AccountViewItem( folderInit, parent , after ) |
610 | { | 612 | { |
611 | imap = parent; | 613 | imap = parent; |
612 | if (folder->getDisplayName().lower()!="inbox") | 614 | if (folder->getDisplayName().lower()!="inbox") |