-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,268 +1,270 @@ | |||
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 | { |
51 | return wrapper; | 53 | return wrapper; |
52 | } | 54 | } |
53 | 55 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 56 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 57 | { |
56 | refresh(); | 58 | refresh(); |
57 | } | 59 | } |
58 | 60 | ||
59 | void POP3viewItem::refresh() | 61 | void POP3viewItem::refresh() |
60 | { | 62 | { |
61 | if (account->getOffline()) return; | 63 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 64 | QValueList<FolderP> *folders = wrapper->listFolders(); |
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) |
173 | { | 175 | { |
174 | if (folder->may_select()) | 176 | if (folder->may_select()) |
175 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 177 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
176 | } | 178 | } |
177 | 179 | ||
178 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 180 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
179 | { | 181 | { |
180 | return pop3->getWrapper()->fetchBody(aMail); | 182 | return pop3->getWrapper()->fetchBody(aMail); |
181 | } | 183 | } |
182 | 184 | ||
183 | QPopupMenu * POP3folderItem::getContextMenu() | 185 | QPopupMenu * POP3folderItem::getContextMenu() |
184 | { | 186 | { |
185 | QPopupMenu *m = new QPopupMenu(0); | 187 | QPopupMenu *m = new QPopupMenu(0); |
186 | if (m) | 188 | if (m) |
187 | { | 189 | { |
188 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 190 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
189 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 191 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
190 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 192 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
191 | } | 193 | } |
192 | return m; | 194 | return m; |
193 | } | 195 | } |
194 | 196 | ||
195 | void POP3folderItem::downloadMails() | 197 | void POP3folderItem::downloadMails() |
196 | { | 198 | { |
197 | AccountView*bl = pop3->accountView(); | 199 | AccountView*bl = pop3->accountView(); |
198 | if (!bl) return; | 200 | if (!bl) return; |
199 | bl->downloadMails(folder,pop3->getWrapper()); | 201 | bl->downloadMails(folder,pop3->getWrapper()); |
200 | } | 202 | } |
201 | 203 | ||
202 | void POP3folderItem::contextMenuSelected(int which) | 204 | void POP3folderItem::contextMenuSelected(int which) |
203 | { | 205 | { |
204 | AccountView * view = (AccountView*)listView(); | 206 | AccountView * view = (AccountView*)listView(); |
205 | switch (which) | 207 | switch (which) |
206 | { | 208 | { |
207 | case 0: | 209 | case 0: |
208 | /* must be 'cause pop3 lists are cached */ | 210 | /* must be 'cause pop3 lists are cached */ |
209 | pop3->getWrapper()->logout(); | 211 | pop3->getWrapper()->logout(); |
210 | view->refreshCurrent(); | 212 | view->refreshCurrent(); |
211 | break; | 213 | break; |
212 | case 1: | 214 | case 1: |
213 | deleteAllMail(pop3->getWrapper(),folder); | 215 | deleteAllMail(pop3->getWrapper(),folder); |
214 | break; | 216 | break; |
215 | case 2: | 217 | case 2: |
216 | downloadMails(); | 218 | downloadMails(); |
217 | break; | 219 | break; |
218 | default: | 220 | default: |
219 | break; | 221 | break; |
220 | } | 222 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | /** | 225 | /** |
224 | * NNTP Account stuff | 226 | * NNTP Account stuff |
225 | */ | 227 | */ |
226 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 228 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
227 | : AccountViewItem( parent ) | 229 | : AccountViewItem( parent ) |
228 | { | 230 | { |
229 | account = a; | 231 | account = a; |
230 | wrapper = AbstractMail::getWrapper( account ); | 232 | wrapper = AbstractMail::getWrapper( account ); |
231 | //FIXME | 233 | //FIXME |
232 | SETPIX(PIXMAP_POP3FOLDER); | 234 | SETPIX(PIXMAP_POP3FOLDER); |
233 | #if 0 | 235 | #if 0 |
234 | if (!account->getOffline()) | 236 | if (!account->getOffline()) |
235 | { | 237 | { |
236 | setPixmap( 0, ); | 238 | setPixmap( 0, ); |
237 | } | 239 | } |
238 | else | 240 | else |
239 | { | 241 | { |
240 | setPixmap( 0, PIXMAP_OFFLINE ); | 242 | setPixmap( 0, PIXMAP_OFFLINE ); |
241 | } | 243 | } |
242 | #endif | 244 | #endif |
243 | setText( 0, account->getAccountName() ); | 245 | setText( 0, account->getAccountName() ); |
244 | setOpen( true ); | 246 | setOpen( true ); |
245 | } | 247 | } |
246 | 248 | ||
247 | NNTPviewItem::~NNTPviewItem() | 249 | NNTPviewItem::~NNTPviewItem() |
248 | { | 250 | { |
249 | delete wrapper; | 251 | delete wrapper; |
250 | } | 252 | } |
251 | 253 | ||
252 | AbstractMail *NNTPviewItem::getWrapper() | 254 | AbstractMail *NNTPviewItem::getWrapper() |
253 | { | 255 | { |
254 | return wrapper; | 256 | return wrapper; |
255 | } | 257 | } |
256 | 258 | ||
257 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 259 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
258 | { | 260 | { |
259 | refresh(); | 261 | refresh(); |
260 | } | 262 | } |
261 | 263 | ||
262 | void NNTPviewItem::refresh() | 264 | void NNTPviewItem::refresh() |
263 | { | 265 | { |
264 | if (account->getOffline()) return; | 266 | if (account->getOffline()) return; |
265 | QValueList<FolderP> *folders = wrapper->listFolders(); | 267 | QValueList<FolderP> *folders = wrapper->listFolders(); |
266 | 268 | ||
267 | QListViewItem *child = firstChild(); | 269 | QListViewItem *child = firstChild(); |
268 | while ( child ) | 270 | while ( child ) |
@@ -392,317 +394,317 @@ QPopupMenu * NNTPfolderItem::getContextMenu() | |||
392 | { | 394 | { |
393 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 395 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
394 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 396 | m->insertItem(QObject::tr("Copy all postings",contextName),1); |
395 | } | 397 | } |
396 | return m; | 398 | return m; |
397 | } | 399 | } |
398 | 400 | ||
399 | void NNTPfolderItem::downloadMails() | 401 | void NNTPfolderItem::downloadMails() |
400 | { | 402 | { |
401 | AccountView*bl = nntp->accountView(); | 403 | AccountView*bl = nntp->accountView(); |
402 | if (!bl) return; | 404 | if (!bl) return; |
403 | bl->downloadMails(folder,nntp->getWrapper()); | 405 | bl->downloadMails(folder,nntp->getWrapper()); |
404 | } | 406 | } |
405 | 407 | ||
406 | void NNTPfolderItem::contextMenuSelected(int which) | 408 | void NNTPfolderItem::contextMenuSelected(int which) |
407 | { | 409 | { |
408 | AccountView * view = (AccountView*)listView(); | 410 | AccountView * view = (AccountView*)listView(); |
409 | switch (which) | 411 | switch (which) |
410 | { | 412 | { |
411 | case 0: | 413 | case 0: |
412 | /* must be 'cause pop3 lists are cached */ | 414 | /* must be 'cause pop3 lists are cached */ |
413 | nntp->getWrapper()->logout(); | 415 | nntp->getWrapper()->logout(); |
414 | view->refreshCurrent(); | 416 | view->refreshCurrent(); |
415 | break; | 417 | break; |
416 | case 1: | 418 | case 1: |
417 | downloadMails(); | 419 | downloadMails(); |
418 | break; | 420 | break; |
419 | default: | 421 | default: |
420 | break; | 422 | break; |
421 | } | 423 | } |
422 | } | 424 | } |
423 | 425 | ||
424 | /** | 426 | /** |
425 | * IMAP Account stuff | 427 | * IMAP Account stuff |
426 | */ | 428 | */ |
427 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 429 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
428 | : AccountViewItem( parent ) | 430 | : AccountViewItem( parent ) |
429 | { | 431 | { |
430 | account = a; | 432 | account = a; |
431 | wrapper = AbstractMail::getWrapper( account ); | 433 | wrapper = AbstractMail::getWrapper( account ); |
432 | SETPIX(PIXMAP_IMAPFOLDER); | 434 | SETPIX(PIXMAP_IMAPFOLDER); |
433 | setText( 0, account->getAccountName() ); | 435 | setText( 0, account->getAccountName() ); |
434 | setOpen( true ); | 436 | setOpen( true ); |
435 | } | 437 | } |
436 | 438 | ||
437 | IMAPviewItem::~IMAPviewItem() | 439 | IMAPviewItem::~IMAPviewItem() |
438 | { | 440 | { |
439 | delete wrapper; | 441 | delete wrapper; |
440 | } | 442 | } |
441 | 443 | ||
442 | AbstractMail *IMAPviewItem::getWrapper() | 444 | AbstractMail *IMAPviewItem::getWrapper() |
443 | { | 445 | { |
444 | return wrapper; | 446 | return wrapper; |
445 | } | 447 | } |
446 | 448 | ||
447 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 449 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
448 | { | 450 | { |
449 | refreshFolders(false); | 451 | refreshFolders(false); |
450 | } | 452 | } |
451 | 453 | ||
452 | const QStringList&IMAPviewItem::subFolders() | 454 | const QStringList&IMAPviewItem::subFolders() |
453 | { | 455 | { |
454 | return currentFolders; | 456 | return currentFolders; |
455 | } | 457 | } |
456 | 458 | ||
457 | void IMAPviewItem::refreshFolders(bool force) | 459 | void IMAPviewItem::refreshFolders(bool force) |
458 | { | 460 | { |
459 | if (childCount()>0 && force==false) return; | 461 | if (childCount()>0 && force==false) return; |
460 | if (account->getOffline()) return; | 462 | if (account->getOffline()) return; |
461 | 463 | ||
462 | removeChilds(); | 464 | removeChilds(); |
463 | currentFolders.clear(); | 465 | currentFolders.clear(); |
464 | QValueList<FolderP> * folders = wrapper->listFolders(); | 466 | QValueList<FolderP> * folders = wrapper->listFolders(); |
465 | 467 | ||
466 | QValueList<FolderP>::Iterator it; | 468 | QValueList<FolderP>::Iterator it; |
467 | QListViewItem*item = 0; | 469 | QListViewItem*item = 0; |
468 | QListViewItem*titem = 0; | 470 | QListViewItem*titem = 0; |
469 | QString fname,del,search; | 471 | QString fname,del,search; |
470 | int pos; | 472 | int pos; |
471 | 473 | ||
472 | for ( it = folders->begin(); it!=folders->end(); ++it) | 474 | for ( it = folders->begin(); it!=folders->end(); ++it) |
473 | { | 475 | { |
474 | if ((*it)->getDisplayName().lower()=="inbox") | 476 | if ((*it)->getDisplayName().lower()=="inbox") |
475 | { | 477 | { |
476 | item = new IMAPfolderItem( (*it), this , item ); | 478 | item = new IMAPfolderItem( (*it), this , item ); |
477 | folders->remove(it); | 479 | folders->remove(it); |
478 | break; | 480 | break; |
479 | } | 481 | } |
480 | } | 482 | } |
481 | for ( it = folders->begin(); it!=folders->end(); ++it) | 483 | for ( it = folders->begin(); it!=folders->end(); ++it) |
482 | { | 484 | { |
483 | fname = (*it)->getDisplayName(); | 485 | fname = (*it)->getDisplayName(); |
484 | currentFolders.append((*it)->getName()); | 486 | currentFolders.append((*it)->getName()); |
485 | pos = fname.findRev((*it)->Separator()); | 487 | pos = fname.findRev((*it)->Separator()); |
486 | if (pos != -1) | 488 | if (pos != -1) |
487 | { | 489 | { |
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") |
613 | { | 615 | { |
614 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 616 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
615 | } | 617 | } |
616 | else | 618 | else |
617 | { | 619 | { |
618 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 620 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
619 | } | 621 | } |
620 | setText( 0, folder->getDisplayName() ); | 622 | setText( 0, folder->getDisplayName() ); |
621 | } | 623 | } |
622 | 624 | ||
623 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 625 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
624 | : AccountViewItem(folderInit, parent,after ) | 626 | : AccountViewItem(folderInit, parent,after ) |
625 | { | 627 | { |
626 | imap = master; | 628 | imap = master; |
627 | if (folder->getDisplayName().lower()!="inbox") | 629 | if (folder->getDisplayName().lower()!="inbox") |
628 | { | 630 | { |
629 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 631 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
630 | } | 632 | } |
631 | else | 633 | else |
632 | { | 634 | { |
633 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 635 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
634 | } | 636 | } |
635 | setText( 0, folder->getDisplayName() ); | 637 | setText( 0, folder->getDisplayName() ); |
636 | } | 638 | } |
637 | 639 | ||
638 | IMAPfolderItem::~IMAPfolderItem() | 640 | IMAPfolderItem::~IMAPfolderItem() |
639 | {} | 641 | {} |
640 | 642 | ||
641 | const QString& IMAPfolderItem::Delemiter()const | 643 | const QString& IMAPfolderItem::Delemiter()const |
642 | { | 644 | { |
643 | return folder->Separator(); | 645 | return folder->Separator(); |
644 | } | 646 | } |
645 | 647 | ||
646 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 648 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
647 | { | 649 | { |
648 | if (folder->may_select()) | 650 | if (folder->may_select()) |
649 | { | 651 | { |
650 | imap->getWrapper()->listMessages( folder->getName(),target ); | 652 | imap->getWrapper()->listMessages( folder->getName(),target ); |
651 | } | 653 | } |
652 | else | 654 | else |
653 | { | 655 | { |
654 | target.clear(); | 656 | target.clear(); |
655 | } | 657 | } |
656 | } | 658 | } |
657 | 659 | ||
658 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 660 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
659 | { | 661 | { |
660 | return imap->getWrapper()->fetchBody(aMail); | 662 | return imap->getWrapper()->fetchBody(aMail); |
661 | } | 663 | } |
662 | 664 | ||
663 | QPopupMenu * IMAPfolderItem::getContextMenu() | 665 | QPopupMenu * IMAPfolderItem::getContextMenu() |
664 | { | 666 | { |
665 | QPopupMenu *m = new QPopupMenu(0); | 667 | QPopupMenu *m = new QPopupMenu(0); |
666 | if (m) | 668 | if (m) |
667 | { | 669 | { |
668 | if (folder->may_select()) | 670 | if (folder->may_select()) |
669 | { | 671 | { |
670 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 672 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
671 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 673 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
672 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 674 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
673 | } | 675 | } |
674 | if (folder->no_inferior()==false) | 676 | if (folder->no_inferior()==false) |
675 | { | 677 | { |
676 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 678 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
677 | } | 679 | } |
678 | if (folder->getDisplayName().lower()!="inbox") | 680 | if (folder->getDisplayName().lower()!="inbox") |
679 | { | 681 | { |
680 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 682 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
681 | } | 683 | } |
682 | } | 684 | } |
683 | return m; | 685 | return m; |
684 | } | 686 | } |
685 | 687 | ||
686 | void IMAPfolderItem::createNewFolder() | 688 | void IMAPfolderItem::createNewFolder() |
687 | { | 689 | { |
688 | Newmdirdlg ndirdlg; | 690 | Newmdirdlg ndirdlg; |
689 | ndirdlg.showMaximized(); | 691 | ndirdlg.showMaximized(); |
690 | if ( ndirdlg.exec() ) | 692 | if ( ndirdlg.exec() ) |
691 | { | 693 | { |
692 | QString ndir = ndirdlg.Newdir(); | 694 | QString ndir = ndirdlg.Newdir(); |
693 | bool makesubs = ndirdlg.subpossible(); | 695 | bool makesubs = ndirdlg.subpossible(); |
694 | QString delemiter = Delemiter(); | 696 | QString delemiter = Delemiter(); |
695 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 697 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
696 | { | 698 | { |
697 | imap->refreshFolders(true); | 699 | imap->refreshFolders(true); |
698 | } | 700 | } |
699 | } | 701 | } |
700 | } | 702 | } |
701 | 703 | ||
702 | void IMAPfolderItem::deleteFolder() | 704 | void IMAPfolderItem::deleteFolder() |
703 | { | 705 | { |
704 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 706 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
705 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 707 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
706 | QObject::tr("Yes",contextName), | 708 | QObject::tr("Yes",contextName), |
707 | QObject::tr("No",contextName),QString::null,1,1); | 709 | QObject::tr("No",contextName),QString::null,1,1); |
708 | 710 | ||