author | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 15:41:30 (UTC) |
commit | 32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff) | |
tree | 8856a90d505df8dc3afa0d72541f27cb68913a0d /kmicromail/accountitem.cpp | |
parent | d7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff) | |
download | kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2 |
Mail enhancements
-rw-r--r-- | kmicromail/accountitem.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index 1698b40..7b9b881 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,235 +1,238 @@ | |||
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 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 21 | /** |
22 | * POP3 Account stuff | 22 | * POP3 Account stuff |
23 | */ | 23 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 25 | : AccountViewItem( parent ) |
26 | { | 26 | { |
27 | account = a; | 27 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 28 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 29 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 30 | #if 0 |
31 | if (!account->getOffline()) | 31 | if (!account->getOffline()) |
32 | { | 32 | { |
33 | setPixmap( 0, ); | 33 | setPixmap( 0, ); |
34 | } | 34 | } |
35 | else | 35 | else |
36 | { | 36 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 37 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | setText( 0, account->getAccountName() ); | 40 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 41 | setOpen( true ); |
42 | } | 42 | } |
43 | 43 | ||
44 | POP3viewItem::~POP3viewItem() | 44 | POP3viewItem::~POP3viewItem() |
45 | { | 45 | { |
46 | delete wrapper; | 46 | delete wrapper; |
47 | } | 47 | } |
48 | 48 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 50 | { |
51 | return wrapper; | 51 | return wrapper; |
52 | } | 52 | } |
53 | 53 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 55 | { |
56 | refresh(); | 56 | refresh(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
60 | { | 60 | { |
61 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 64 | while ( child ) |
65 | { | 65 | { |
66 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
68 | delete tmp; | 68 | delete tmp; |
69 | } | 69 | } |
70 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 73 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
76 | } | 76 | } |
77 | delete folders; | 77 | delete folders; |
78 | } | 78 | } |
79 | 79 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 81 | { |
82 | 82 | ||
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download messages",contextName),2); | 95 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); |
96 | } | 96 | } |
97 | else | 97 | else |
98 | { | 98 | { |
99 | m->insertItem(QObject::tr("Set online",contextName),1); | 99 | m->insertItem(QObject::tr("Set online",contextName),1); |
100 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),2); | ||
100 | } | 101 | } |
101 | } | 102 | } |
102 | return m; | 103 | return m; |
103 | } | 104 | } |
104 | 105 | ||
105 | void POP3viewItem::disconnect() | 106 | void POP3viewItem::disconnect() |
106 | { | 107 | { |
107 | QListViewItem *child = firstChild(); | 108 | QListViewItem *child = firstChild(); |
108 | while ( child ) | 109 | while ( child ) |
109 | { | 110 | { |
110 | QListViewItem *tmp = child; | 111 | QListViewItem *tmp = child; |
111 | child = child->nextSibling(); | 112 | child = child->nextSibling(); |
112 | delete tmp; | 113 | delete tmp; |
113 | } | 114 | } |
114 | wrapper->logout(); | 115 | wrapper->logout(); |
115 | } | 116 | } |
116 | 117 | ||
117 | void POP3viewItem::setOnOffline() | 118 | void POP3viewItem::setOnOffline() |
118 | { | 119 | { |
119 | if (!account->getOffline()) | 120 | if (!account->getOffline()) |
120 | { | 121 | { |
121 | disconnect(); | 122 | disconnect(); |
122 | } | 123 | } |
123 | account->setOffline(!account->getOffline()); | 124 | account->setOffline(!account->getOffline()); |
124 | account->save(); | 125 | account->save(); |
125 | SETPIX(PIXMAP_POP3FOLDER); | 126 | SETPIX(PIXMAP_POP3FOLDER); |
126 | refresh(); | 127 | refresh(); |
127 | } | 128 | } |
128 | 129 | ||
129 | void POP3viewItem::contextMenuSelected(int which) | 130 | void POP3viewItem::contextMenuSelected(int which) |
130 | { | 131 | { |
131 | switch (which) | 132 | switch (which) |
132 | { | 133 | { |
133 | case 0: | 134 | case 0: |
134 | disconnect(); | 135 | disconnect(); |
135 | break; | 136 | break; |
136 | case 1: | 137 | case 1: |
137 | setOnOffline(); | 138 | setOnOffline(); |
138 | break; | 139 | break; |
139 | case 2: // daunlood | 140 | case 2: // daunlood |
141 | if (account->getOffline()) | ||
142 | setOnOffline(); | ||
140 | AccountView*bl = accountView(); | 143 | AccountView*bl = accountView(); |
141 | if (!bl) return; | 144 | if (!bl) return; |
142 | AccountViewItem* in = findSubItem( "inbox" , 0); | 145 | AccountViewItem* in = findSubItem( "inbox" , 0); |
143 | if ( ! in ) | 146 | if ( ! in ) |
144 | return; | 147 | return; |
145 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | 148 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); |
146 | setOnOffline(); | 149 | setOnOffline(); |
147 | break; | 150 | break; |
148 | } | 151 | } |
149 | } | 152 | } |
150 | 153 | ||
151 | POP3folderItem::~POP3folderItem() | 154 | POP3folderItem::~POP3folderItem() |
152 | {} | 155 | {} |
153 | 156 | ||
154 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 157 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
155 | : AccountViewItem(folderInit,parent,after ) | 158 | : AccountViewItem(folderInit,parent,after ) |
156 | { | 159 | { |
157 | pop3 = parent; | 160 | pop3 = parent; |
158 | if (folder->getDisplayName().lower()!="inbox") | 161 | if (folder->getDisplayName().lower()!="inbox") |
159 | { | 162 | { |
160 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 163 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
161 | } | 164 | } |
162 | else | 165 | else |
163 | { | 166 | { |
164 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 167 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
165 | } | 168 | } |
166 | setText( 0, folder->getDisplayName() ); | 169 | setText( 0, folder->getDisplayName() ); |
167 | } | 170 | } |
168 | 171 | ||
169 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 172 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
170 | { | 173 | { |
171 | if (folder->may_select()) | 174 | if (folder->may_select()) |
172 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 175 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
173 | } | 176 | } |
174 | 177 | ||
175 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 178 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
176 | { | 179 | { |
177 | return pop3->getWrapper()->fetchBody(aMail); | 180 | return pop3->getWrapper()->fetchBody(aMail); |
178 | } | 181 | } |
179 | 182 | ||
180 | QPopupMenu * POP3folderItem::getContextMenu() | 183 | QPopupMenu * POP3folderItem::getContextMenu() |
181 | { | 184 | { |
182 | QPopupMenu *m = new QPopupMenu(0); | 185 | QPopupMenu *m = new QPopupMenu(0); |
183 | if (m) | 186 | if (m) |
184 | { | 187 | { |
185 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 188 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
186 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 189 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
187 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 190 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
188 | } | 191 | } |
189 | return m; | 192 | return m; |
190 | } | 193 | } |
191 | 194 | ||
192 | void POP3folderItem::downloadMails() | 195 | void POP3folderItem::downloadMails() |
193 | { | 196 | { |
194 | AccountView*bl = pop3->accountView(); | 197 | AccountView*bl = pop3->accountView(); |
195 | if (!bl) return; | 198 | if (!bl) return; |
196 | bl->downloadMails(folder,pop3->getWrapper()); | 199 | bl->downloadMails(folder,pop3->getWrapper()); |
197 | } | 200 | } |
198 | 201 | ||
199 | void POP3folderItem::contextMenuSelected(int which) | 202 | void POP3folderItem::contextMenuSelected(int which) |
200 | { | 203 | { |
201 | AccountView * view = (AccountView*)listView(); | 204 | AccountView * view = (AccountView*)listView(); |
202 | switch (which) | 205 | switch (which) |
203 | { | 206 | { |
204 | case 0: | 207 | case 0: |
205 | /* must be 'cause pop3 lists are cached */ | 208 | /* must be 'cause pop3 lists are cached */ |
206 | pop3->getWrapper()->logout(); | 209 | pop3->getWrapper()->logout(); |
207 | view->refreshCurrent(); | 210 | view->refreshCurrent(); |
208 | break; | 211 | break; |
209 | case 1: | 212 | case 1: |
210 | deleteAllMail(pop3->getWrapper(),folder); | 213 | deleteAllMail(pop3->getWrapper(),folder); |
211 | break; | 214 | break; |
212 | case 2: | 215 | case 2: |
213 | downloadMails(); | 216 | downloadMails(); |
214 | break; | 217 | break; |
215 | default: | 218 | default: |
216 | break; | 219 | break; |
217 | } | 220 | } |
218 | } | 221 | } |
219 | 222 | ||
220 | /** | 223 | /** |
221 | * NNTP Account stuff | 224 | * NNTP Account stuff |
222 | */ | 225 | */ |
223 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 226 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
224 | : AccountViewItem( parent ) | 227 | : AccountViewItem( parent ) |
225 | { | 228 | { |
226 | account = a; | 229 | account = a; |
227 | wrapper = AbstractMail::getWrapper( account ); | 230 | wrapper = AbstractMail::getWrapper( account ); |
228 | //FIXME | 231 | //FIXME |
229 | SETPIX(PIXMAP_POP3FOLDER); | 232 | SETPIX(PIXMAP_POP3FOLDER); |
230 | #if 0 | 233 | #if 0 |
231 | if (!account->getOffline()) | 234 | if (!account->getOffline()) |
232 | { | 235 | { |
233 | setPixmap( 0, ); | 236 | setPixmap( 0, ); |
234 | } | 237 | } |
235 | else | 238 | else |
@@ -420,249 +423,266 @@ void NNTPfolderItem::contextMenuSelected(int which) | |||
420 | 423 | ||
421 | /** | 424 | /** |
422 | * IMAP Account stuff | 425 | * IMAP Account stuff |
423 | */ | 426 | */ |
424 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 427 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
425 | : AccountViewItem( parent ) | 428 | : AccountViewItem( parent ) |
426 | { | 429 | { |
427 | account = a; | 430 | account = a; |
428 | wrapper = AbstractMail::getWrapper( account ); | 431 | wrapper = AbstractMail::getWrapper( account ); |
429 | SETPIX(PIXMAP_IMAPFOLDER); | 432 | SETPIX(PIXMAP_IMAPFOLDER); |
430 | setText( 0, account->getAccountName() ); | 433 | setText( 0, account->getAccountName() ); |
431 | setOpen( true ); | 434 | setOpen( true ); |
432 | } | 435 | } |
433 | 436 | ||
434 | IMAPviewItem::~IMAPviewItem() | 437 | IMAPviewItem::~IMAPviewItem() |
435 | { | 438 | { |
436 | delete wrapper; | 439 | delete wrapper; |
437 | } | 440 | } |
438 | 441 | ||
439 | AbstractMail *IMAPviewItem::getWrapper() | 442 | AbstractMail *IMAPviewItem::getWrapper() |
440 | { | 443 | { |
441 | return wrapper; | 444 | return wrapper; |
442 | } | 445 | } |
443 | 446 | ||
444 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 447 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
445 | { | 448 | { |
446 | refreshFolders(false); | 449 | refreshFolders(false); |
447 | } | 450 | } |
448 | 451 | ||
449 | const QStringList&IMAPviewItem::subFolders() | 452 | const QStringList&IMAPviewItem::subFolders() |
450 | { | 453 | { |
451 | return currentFolders; | 454 | return currentFolders; |
452 | } | 455 | } |
453 | 456 | ||
454 | void IMAPviewItem::refreshFolders(bool force) | 457 | void IMAPviewItem::refreshFolders(bool force) |
455 | { | 458 | { |
456 | if (childCount()>0 && force==false) return; | 459 | if (childCount()>0 && force==false) return; |
457 | if (account->getOffline()) return; | 460 | if (account->getOffline()) return; |
458 | 461 | ||
459 | removeChilds(); | 462 | removeChilds(); |
460 | currentFolders.clear(); | 463 | currentFolders.clear(); |
461 | QValueList<FolderP> * folders = wrapper->listFolders(); | 464 | QValueList<FolderP> * folders = wrapper->listFolders(); |
462 | 465 | ||
463 | QValueList<FolderP>::Iterator it; | 466 | QValueList<FolderP>::Iterator it; |
464 | QListViewItem*item = 0; | 467 | QListViewItem*item = 0; |
465 | QListViewItem*titem = 0; | 468 | QListViewItem*titem = 0; |
466 | QString fname,del,search; | 469 | QString fname,del,search; |
467 | int pos; | 470 | int pos; |
468 | 471 | ||
469 | for ( it = folders->begin(); it!=folders->end(); ++it) | 472 | for ( it = folders->begin(); it!=folders->end(); ++it) |
470 | { | 473 | { |
471 | if ((*it)->getDisplayName().lower()=="inbox") | 474 | if ((*it)->getDisplayName().lower()=="inbox") |
472 | { | 475 | { |
473 | item = new IMAPfolderItem( (*it), this , item ); | 476 | item = new IMAPfolderItem( (*it), this , item ); |
474 | folders->remove(it); | 477 | folders->remove(it); |
475 | break; | 478 | break; |
476 | } | 479 | } |
477 | } | 480 | } |
478 | for ( it = folders->begin(); it!=folders->end(); ++it) | 481 | for ( it = folders->begin(); it!=folders->end(); ++it) |
479 | { | 482 | { |
480 | fname = (*it)->getDisplayName(); | 483 | fname = (*it)->getDisplayName(); |
481 | currentFolders.append((*it)->getName()); | 484 | currentFolders.append((*it)->getName()); |
482 | pos = fname.findRev((*it)->Separator()); | 485 | pos = fname.findRev((*it)->Separator()); |
483 | if (pos != -1) | 486 | if (pos != -1) |
484 | { | 487 | { |
485 | fname = fname.left(pos); | 488 | fname = fname.left(pos); |
486 | } | 489 | } |
487 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 490 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
488 | if (pitem) | 491 | if (pitem) |
489 | { | 492 | { |
490 | titem = item; | 493 | titem = item; |
491 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 494 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
492 | /* setup the short name */ | 495 | /* setup the short name */ |
493 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 496 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
494 | item = titem; | 497 | item = titem; |
495 | } | 498 | } |
496 | else | 499 | else |
497 | { | 500 | { |
498 | item = new IMAPfolderItem( (*it), this , item ); | 501 | item = new IMAPfolderItem( (*it), this , item ); |
499 | } | 502 | } |
500 | } | 503 | } |
501 | delete folders; | 504 | delete folders; |
502 | } | 505 | } |
503 | 506 | ||
504 | QPopupMenu * IMAPviewItem::getContextMenu() | 507 | QPopupMenu * IMAPviewItem::getContextMenu() |
505 | { | 508 | { |
506 | QPopupMenu *m = new QPopupMenu(0); | 509 | QPopupMenu *m = new QPopupMenu(0); |
507 | if (m) | 510 | if (m) |
508 | { | 511 | { |
509 | if (!account->getOffline()) | 512 | if (!account->getOffline()) |
510 | { | 513 | { |
511 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 514 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
512 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 515 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
513 | m->insertSeparator(); | 516 | m->insertSeparator(); |
514 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 517 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
515 | m->insertItem(QObject::tr("Set offline",contextName),3); | 518 | m->insertItem(QObject::tr("Set offline",contextName),3); |
519 | m->insertSeparator(); | ||
520 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
516 | } | 521 | } |
517 | else | 522 | else |
518 | { | 523 | { |
519 | m->insertItem(QObject::tr("Set online",contextName),3); | 524 | m->insertItem(QObject::tr("Set online",contextName),3); |
525 | m->insertSeparator(); | ||
526 | m->insertItem(QObject::tr("Download new INBOX messages",contextName),4); | ||
520 | } | 527 | } |
521 | } | 528 | } |
522 | return m; | 529 | return m; |
523 | } | 530 | } |
524 | 531 | ||
525 | void IMAPviewItem::createNewFolder() | 532 | void IMAPviewItem::createNewFolder() |
526 | { | 533 | { |
527 | Newmdirdlg ndirdlg; | 534 | Newmdirdlg ndirdlg; |
528 | 535 | ||
529 | ndirdlg.showMaximized(); | 536 | ndirdlg.showMaximized(); |
530 | if ( ndirdlg.exec() ) | 537 | if ( ndirdlg.exec() ) |
531 | { | 538 | { |
532 | QString ndir = ndirdlg.Newdir(); | 539 | QString ndir = ndirdlg.Newdir(); |
533 | bool makesubs = ndirdlg.subpossible(); | 540 | bool makesubs = ndirdlg.subpossible(); |
534 | QString delemiter = "/"; | 541 | QString delemiter = "/"; |
535 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 542 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
536 | if (item) | 543 | if (item) |
537 | { | 544 | { |
538 | delemiter = item->Delemiter(); | 545 | delemiter = item->Delemiter(); |
539 | } | 546 | } |
540 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 547 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
541 | { | 548 | { |
542 | refreshFolders(true); | 549 | refreshFolders(true); |
543 | } | 550 | } |
544 | } | 551 | } |
545 | } | 552 | } |
546 | 553 | ||
547 | void IMAPviewItem::contextMenuSelected(int id) | 554 | void IMAPviewItem::contextMenuSelected(int id) |
548 | { | 555 | { |
549 | 556 | ||
550 | switch (id) | 557 | switch (id) |
551 | { | 558 | { |
552 | case 0: | 559 | case 0: |
553 | refreshFolders(true); | 560 | refreshFolders(true); |
554 | break; | 561 | break; |
555 | case 1: | 562 | case 1: |
556 | createNewFolder(); | 563 | createNewFolder(); |
557 | break; | 564 | break; |
558 | case 2: | 565 | case 2: |
559 | removeChilds(); | 566 | removeChilds(); |
560 | wrapper->logout(); | 567 | wrapper->logout(); |
561 | break; | 568 | break; |
562 | case 3: | 569 | case 3: |
563 | if (account->getOffline()==false) | 570 | if (account->getOffline()==false) |
564 | { | 571 | { |
565 | removeChilds(); | 572 | removeChilds(); |
566 | wrapper->logout(); | 573 | wrapper->logout(); |
567 | } | 574 | } |
568 | account->setOffline(!account->getOffline()); | 575 | account->setOffline(!account->getOffline()); |
569 | account->save(); | 576 | account->save(); |
570 | SETPIX(PIXMAP_IMAPFOLDER); | 577 | SETPIX(PIXMAP_IMAPFOLDER); |
571 | refreshFolders(false); | 578 | refreshFolders(false); |
572 | break; | 579 | break; |
580 | case 4: // daunlood | ||
581 | { | ||
582 | if (account->getOffline()) { | ||
583 | contextMenuSelected( 3 ); | ||
584 | } | ||
585 | AccountView*bl = accountView(); | ||
586 | if (!bl) return; | ||
587 | AccountViewItem* in = findSubItem( "inbox" , 0); | ||
588 | if ( ! in ) | ||
589 | return; | ||
590 | bl->downloadMailsInbox(in->getFolder(),getWrapper()); | ||
591 | } | ||
592 | break; | ||
573 | default: | 593 | default: |
574 | break; | 594 | break; |
575 | } | 595 | } |
576 | } | 596 | } |
577 | 597 | ||
578 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 598 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
579 | { | 599 | { |
580 | return new RecBody(); | 600 | return new RecBody(); |
581 | } | 601 | } |
582 | 602 | ||
583 | bool IMAPviewItem::offline() | 603 | bool IMAPviewItem::offline() |
584 | { | 604 | { |
585 | return account->getOffline(); | 605 | return account->getOffline(); |
586 | } | 606 | } |
587 | 607 | ||
588 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 608 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
589 | : AccountViewItem( folderInit, parent , after ) | 609 | : AccountViewItem( folderInit, parent , after ) |
590 | { | 610 | { |
591 | imap = parent; | 611 | imap = parent; |
592 | if (folder->getDisplayName().lower()!="inbox") | 612 | if (folder->getDisplayName().lower()!="inbox") |
593 | { | 613 | { |
594 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 614 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
595 | } | 615 | } |
596 | else | 616 | else |
597 | { | 617 | { |
598 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 618 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
599 | } | 619 | } |
600 | setText( 0, folder->getDisplayName() ); | 620 | setText( 0, folder->getDisplayName() ); |
601 | } | 621 | } |
602 | 622 | ||
603 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 623 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
604 | : AccountViewItem(folderInit, parent,after ) | 624 | : AccountViewItem(folderInit, parent,after ) |
605 | { | 625 | { |
606 | imap = master; | 626 | imap = master; |
607 | if (folder->getDisplayName().lower()!="inbox") | 627 | if (folder->getDisplayName().lower()!="inbox") |
608 | { | 628 | { |
609 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 629 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
610 | } | 630 | } |
611 | else | 631 | else |
612 | { | 632 | { |
613 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 633 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
614 | } | 634 | } |
615 | setText( 0, folder->getDisplayName() ); | 635 | setText( 0, folder->getDisplayName() ); |
616 | } | 636 | } |
617 | 637 | ||
618 | IMAPfolderItem::~IMAPfolderItem() | 638 | IMAPfolderItem::~IMAPfolderItem() |
619 | {} | 639 | {} |
620 | 640 | ||
621 | const QString& IMAPfolderItem::Delemiter()const | 641 | const QString& IMAPfolderItem::Delemiter()const |
622 | { | 642 | { |
623 | return folder->Separator(); | 643 | return folder->Separator(); |
624 | } | 644 | } |
625 | 645 | ||
626 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 646 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
627 | { | 647 | { |
628 | if (folder->may_select()) | 648 | if (folder->may_select()) |
629 | { | 649 | { |
630 | imap->getWrapper()->listMessages( folder->getName(),target ); | 650 | imap->getWrapper()->listMessages( folder->getName(),target ); |
631 | } | 651 | } |
632 | else | 652 | else |
633 | { | 653 | { |
634 | target.clear(); | 654 | target.clear(); |
635 | } | 655 | } |
636 | } | 656 | } |
637 | 657 | ||
638 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 658 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
639 | { | 659 | { |
640 | return imap->getWrapper()->fetchBody(aMail); | 660 | return imap->getWrapper()->fetchBody(aMail); |
641 | } | 661 | } |
642 | 662 | ||
643 | QPopupMenu * IMAPfolderItem::getContextMenu() | 663 | QPopupMenu * IMAPfolderItem::getContextMenu() |
644 | { | 664 | { |
645 | QPopupMenu *m = new QPopupMenu(0); | 665 | QPopupMenu *m = new QPopupMenu(0); |
646 | if (m) | 666 | if (m) |
647 | { | 667 | { |
648 | if (folder->may_select()) | 668 | if (folder->may_select()) |
649 | { | 669 | { |
650 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 670 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
651 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 671 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
652 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 672 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
653 | } | 673 | } |
654 | if (folder->no_inferior()==false) | 674 | if (folder->no_inferior()==false) |
655 | { | 675 | { |
656 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 676 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
657 | } | 677 | } |
658 | if (folder->getDisplayName().lower()!="inbox") | 678 | if (folder->getDisplayName().lower()!="inbox") |
659 | { | 679 | { |
660 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 680 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
661 | } | 681 | } |
662 | } | 682 | } |
663 | return m; | 683 | return m; |
664 | } | 684 | } |
665 | 685 | ||
666 | void IMAPfolderItem::createNewFolder() | 686 | void IMAPfolderItem::createNewFolder() |
667 | { | 687 | { |
668 | Newmdirdlg ndirdlg; | 688 | Newmdirdlg ndirdlg; |