summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountitem.cpp
authorzautrix <zautrix>2004-09-11 15:41:30 (UTC)
committer zautrix <zautrix>2004-09-11 15:41:30 (UTC)
commit32f9963a39236d08718a36d5adad2a0c5c4e2602 (patch) (unidiff)
tree8856a90d505df8dc3afa0d72541f27cb68913a0d /kmicromail/accountitem.cpp
parentd7a273f40838f56205c1377ed0bcc5457bd46ea3 (diff)
downloadkdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.zip
kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.gz
kdepimpi-32f9963a39236d08718a36d5adad2a0c5c4e2602.tar.bz2
Mail enhancements
Diffstat (limited to 'kmicromail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp22
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,764 +1,784 @@
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
19using namespace Opie::Core; 19using 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 */
24POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 24POP3viewItem::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
44POP3viewItem::~POP3viewItem() 44POP3viewItem::~POP3viewItem()
45{ 45{
46 delete wrapper; 46 delete wrapper;
47} 47}
48 48
49AbstractMail *POP3viewItem::getWrapper() 49AbstractMail *POP3viewItem::getWrapper()
50{ 50{
51 return wrapper; 51 return wrapper;
52} 52}
53 53
54void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) 54void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
55{ 55{
56 refresh(); 56 refresh();
57} 57}
58 58
59void POP3viewItem::refresh() 59void 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
80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
81{ 81{
82 82
83 return wrapper->fetchBody( mail ); 83 return wrapper->fetchBody( mail );
84} 84}
85 85
86QPopupMenu * POP3viewItem::getContextMenu() 86QPopupMenu * 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
105void POP3viewItem::disconnect() 106void 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
117void POP3viewItem::setOnOffline() 118void 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
129void POP3viewItem::contextMenuSelected(int which) 130void 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
151POP3folderItem::~POP3folderItem() 154POP3folderItem::~POP3folderItem()
152{} 155{}
153 156
154POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 157POP3folderItem::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
169void POP3folderItem::refresh(QValueList<RecMailP>&target) 172void 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
175RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 178RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
176{ 179{
177 return pop3->getWrapper()->fetchBody(aMail); 180 return pop3->getWrapper()->fetchBody(aMail);
178} 181}
179 182
180QPopupMenu * POP3folderItem::getContextMenu() 183QPopupMenu * 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
192void POP3folderItem::downloadMails() 195void 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
199void POP3folderItem::contextMenuSelected(int which) 202void 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 */
223NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 226NNTPviewItem::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
236 { 239 {
237 setPixmap( 0, PIXMAP_OFFLINE ); 240 setPixmap( 0, PIXMAP_OFFLINE );
238 } 241 }
239#endif 242#endif
240 setText( 0, account->getAccountName() ); 243 setText( 0, account->getAccountName() );
241 setOpen( true ); 244 setOpen( true );
242} 245}
243 246
244NNTPviewItem::~NNTPviewItem() 247NNTPviewItem::~NNTPviewItem()
245{ 248{
246 delete wrapper; 249 delete wrapper;
247} 250}
248 251
249AbstractMail *NNTPviewItem::getWrapper() 252AbstractMail *NNTPviewItem::getWrapper()
250{ 253{
251 return wrapper; 254 return wrapper;
252} 255}
253 256
254void NNTPviewItem::refresh( QValueList<RecMailP> & ) 257void NNTPviewItem::refresh( QValueList<RecMailP> & )
255{ 258{
256 refresh(); 259 refresh();
257} 260}
258 261
259void NNTPviewItem::refresh() 262void NNTPviewItem::refresh()
260{ 263{
261 if (account->getOffline()) return; 264 if (account->getOffline()) return;
262 QValueList<FolderP> *folders = wrapper->listFolders(); 265 QValueList<FolderP> *folders = wrapper->listFolders();
263 266
264 QListViewItem *child = firstChild(); 267 QListViewItem *child = firstChild();
265 while ( child ) 268 while ( child )
266 { 269 {
267 QListViewItem *tmp = child; 270 QListViewItem *tmp = child;
268 child = child->nextSibling(); 271 child = child->nextSibling();
269 delete tmp; 272 delete tmp;
270 } 273 }
271 QValueList<FolderP>::ConstIterator it; 274 QValueList<FolderP>::ConstIterator it;
272 QListViewItem*item = 0; 275 QListViewItem*item = 0;
273 for ( it = folders->begin(); it!=folders->end(); ++it) 276 for ( it = folders->begin(); it!=folders->end(); ++it)
274 { 277 {
275 item = new NNTPfolderItem( (*it), this , item ); 278 item = new NNTPfolderItem( (*it), this , item );
276 item->setSelectable( (*it)->may_select()); 279 item->setSelectable( (*it)->may_select());
277 } 280 }
278 delete folders; 281 delete folders;
279} 282}
280 283
281RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) 284RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
282{ 285{
283 286
284 return wrapper->fetchBody( mail ); 287 return wrapper->fetchBody( mail );
285} 288}
286 289
287QPopupMenu * NNTPviewItem::getContextMenu() 290QPopupMenu * NNTPviewItem::getContextMenu()
288{ 291{
289 QPopupMenu *m = new QPopupMenu(0); 292 QPopupMenu *m = new QPopupMenu(0);
290 if (m) 293 if (m)
291 { 294 {
292 if (!account->getOffline()) 295 if (!account->getOffline())
293 { 296 {
294 m->insertItem(QObject::tr("Disconnect",contextName),0); 297 m->insertItem(QObject::tr("Disconnect",contextName),0);
295 m->insertItem(QObject::tr("Set offline",contextName),1); 298 m->insertItem(QObject::tr("Set offline",contextName),1);
296 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); 299 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2);
297 } 300 }
298 else 301 else
299 { 302 {
300 m->insertItem(QObject::tr("Set online",contextName),1); 303 m->insertItem(QObject::tr("Set online",contextName),1);
301 } 304 }
302 } 305 }
303 return m; 306 return m;
304} 307}
305 308
306void NNTPviewItem::subscribeGroups() 309void NNTPviewItem::subscribeGroups()
307{ 310{
308 NNTPGroupsDlg dlg(account); 311 NNTPGroupsDlg dlg(account);
309 dlg.showMaximized(); 312 dlg.showMaximized();
310 if ( dlg.exec()== QDialog::Accepted ){ 313 if ( dlg.exec()== QDialog::Accepted ){
311 refresh(); 314 refresh();
312 } 315 }
313} 316}
314 317
315void NNTPviewItem::disconnect() 318void NNTPviewItem::disconnect()
316{ 319{
317 QListViewItem *child = firstChild(); 320 QListViewItem *child = firstChild();
318 while ( child ) 321 while ( child )
319 { 322 {
320 QListViewItem *tmp = child; 323 QListViewItem *tmp = child;
321 child = child->nextSibling(); 324 child = child->nextSibling();
322 delete tmp; 325 delete tmp;
323 } 326 }
324 wrapper->logout(); 327 wrapper->logout();
325} 328}
326 329
327void NNTPviewItem::setOnOffline() 330void NNTPviewItem::setOnOffline()
328{ 331{
329 if (!account->getOffline()) 332 if (!account->getOffline())
330 { 333 {
331 disconnect(); 334 disconnect();
332 } 335 }
333 account->setOffline(!account->getOffline()); 336 account->setOffline(!account->getOffline());
334 account->save(); 337 account->save();
335 //FIXME 338 //FIXME
336 SETPIX(PIXMAP_POP3FOLDER); 339 SETPIX(PIXMAP_POP3FOLDER);
337 refresh(); 340 refresh();
338} 341}
339 342
340void NNTPviewItem::contextMenuSelected(int which) 343void NNTPviewItem::contextMenuSelected(int which)
341{ 344{
342 switch (which) 345 switch (which)
343 { 346 {
344 case 0: 347 case 0:
345 disconnect(); 348 disconnect();
346 break; 349 break;
347 case 1: 350 case 1:
348 setOnOffline(); 351 setOnOffline();
349 break; 352 break;
350 case 2: 353 case 2:
351 subscribeGroups(); 354 subscribeGroups();
352 break; 355 break;
353 } 356 }
354} 357}
355 358
356NNTPfolderItem::~NNTPfolderItem() 359NNTPfolderItem::~NNTPfolderItem()
357{} 360{}
358 361
359NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) 362NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after )
360 : AccountViewItem( folderInit, parent,after ) 363 : AccountViewItem( folderInit, parent,after )
361{ 364{
362 nntp = parent; 365 nntp = parent;
363 if (folder->getDisplayName().lower()!="inbox") 366 if (folder->getDisplayName().lower()!="inbox")
364 { 367 {
365 setPixmap( 0, PIXMAP_POP3FOLDER ); 368 setPixmap( 0, PIXMAP_POP3FOLDER );
366 } 369 }
367 else 370 else
368 { 371 {
369 setPixmap( 0, PIXMAP_INBOXFOLDER); 372 setPixmap( 0, PIXMAP_INBOXFOLDER);
370 } 373 }
371 setText( 0, folder->getDisplayName() ); 374 setText( 0, folder->getDisplayName() );
372} 375}
373 376
374void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 377void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
375{ 378{
376 if (folder->may_select()) 379 if (folder->may_select())
377 nntp->getWrapper()->listMessages( folder->getName(),target ); 380 nntp->getWrapper()->listMessages( folder->getName(),target );
378} 381}
379 382
380RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) 383RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
381{ 384{
382 return nntp->getWrapper()->fetchBody(aMail); 385 return nntp->getWrapper()->fetchBody(aMail);
383} 386}
384 387
385QPopupMenu * NNTPfolderItem::getContextMenu() 388QPopupMenu * NNTPfolderItem::getContextMenu()
386{ 389{
387 QPopupMenu *m = new QPopupMenu(0); 390 QPopupMenu *m = new QPopupMenu(0);
388 if (m) 391 if (m)
389 { 392 {
390 m->insertItem(QObject::tr("Refresh header list",contextName),0); 393 m->insertItem(QObject::tr("Refresh header list",contextName),0);
391 m->insertItem(QObject::tr("Copy all postings",contextName),1); 394 m->insertItem(QObject::tr("Copy all postings",contextName),1);
392 } 395 }
393 return m; 396 return m;
394} 397}
395 398
396void NNTPfolderItem::downloadMails() 399void NNTPfolderItem::downloadMails()
397{ 400{
398 AccountView*bl = nntp->accountView(); 401 AccountView*bl = nntp->accountView();
399 if (!bl) return; 402 if (!bl) return;
400 bl->downloadMails(folder,nntp->getWrapper()); 403 bl->downloadMails(folder,nntp->getWrapper());
401} 404}
402 405
403void NNTPfolderItem::contextMenuSelected(int which) 406void NNTPfolderItem::contextMenuSelected(int which)
404{ 407{
405 AccountView * view = (AccountView*)listView(); 408 AccountView * view = (AccountView*)listView();
406 switch (which) 409 switch (which)
407 { 410 {
408 case 0: 411 case 0:
409 /* must be 'cause pop3 lists are cached */ 412 /* must be 'cause pop3 lists are cached */
410 nntp->getWrapper()->logout(); 413 nntp->getWrapper()->logout();
411 view->refreshCurrent(); 414 view->refreshCurrent();
412 break; 415 break;
413 case 1: 416 case 1:
414 downloadMails(); 417 downloadMails();
415 break; 418 break;
416 default: 419 default:
417 break; 420 break;
418 } 421 }
419} 422}
420 423
421/** 424/**
422 * IMAP Account stuff 425 * IMAP Account stuff
423 */ 426 */
424IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 427IMAPviewItem::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
434IMAPviewItem::~IMAPviewItem() 437IMAPviewItem::~IMAPviewItem()
435{ 438{
436 delete wrapper; 439 delete wrapper;
437} 440}
438 441
439AbstractMail *IMAPviewItem::getWrapper() 442AbstractMail *IMAPviewItem::getWrapper()
440{ 443{
441 return wrapper; 444 return wrapper;
442} 445}
443 446
444void IMAPviewItem::refresh(QValueList<RecMailP>&) 447void IMAPviewItem::refresh(QValueList<RecMailP>&)
445{ 448{
446 refreshFolders(false); 449 refreshFolders(false);
447} 450}
448 451
449const QStringList&IMAPviewItem::subFolders() 452const QStringList&IMAPviewItem::subFolders()
450{ 453{
451 return currentFolders; 454 return currentFolders;
452} 455}
453 456
454void IMAPviewItem::refreshFolders(bool force) 457void 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
504QPopupMenu * IMAPviewItem::getContextMenu() 507QPopupMenu * 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
525void IMAPviewItem::createNewFolder() 532void 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
547void IMAPviewItem::contextMenuSelected(int id) 554void 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
578RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 598RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
579{ 599{
580 return new RecBody(); 600 return new RecBody();
581} 601}
582 602
583bool IMAPviewItem::offline() 603bool IMAPviewItem::offline()
584{ 604{
585 return account->getOffline(); 605 return account->getOffline();
586} 606}
587 607
588IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 608IMAPfolderItem::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
603IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 623IMAPfolderItem::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
618IMAPfolderItem::~IMAPfolderItem() 638IMAPfolderItem::~IMAPfolderItem()
619{} 639{}
620 640
621const QString& IMAPfolderItem::Delemiter()const 641const QString& IMAPfolderItem::Delemiter()const
622{ 642{
623 return folder->Separator(); 643 return folder->Separator();
624} 644}
625 645
626void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 646void 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
638RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 658RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
639{ 659{
640 return imap->getWrapper()->fetchBody(aMail); 660 return imap->getWrapper()->fetchBody(aMail);
641} 661}
642 662
643QPopupMenu * IMAPfolderItem::getContextMenu() 663QPopupMenu * 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
666void IMAPfolderItem::createNewFolder() 686void IMAPfolderItem::createNewFolder()
667{ 687{
668 Newmdirdlg ndirdlg; 688 Newmdirdlg ndirdlg;
669 ndirdlg.showMaximized(); 689 ndirdlg.showMaximized();
670 if ( ndirdlg.exec() ) 690 if ( ndirdlg.exec() )
671 { 691 {
672 QString ndir = ndirdlg.Newdir(); 692 QString ndir = ndirdlg.Newdir();
673 bool makesubs = ndirdlg.subpossible(); 693 bool makesubs = ndirdlg.subpossible();
674 QString delemiter = Delemiter(); 694 QString delemiter = Delemiter();
675 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) 695 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
676 { 696 {
677 imap->refreshFolders(true); 697 imap->refreshFolders(true);
678 } 698 }
679 } 699 }
680} 700}
681 701
682void IMAPfolderItem::deleteFolder() 702void IMAPfolderItem::deleteFolder()
683{ 703{
684 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 704 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
685 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 705 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
686 QObject::tr("Yes",contextName), 706 QObject::tr("Yes",contextName),
687 QObject::tr("No",contextName),QString::null,1,1); 707 QObject::tr("No",contextName),QString::null,1,1);
688 708
689 if (yesno == 0) 709 if (yesno == 0)
690 { 710 {
691 if (imap->getWrapper()->deleteMbox(folder)) 711 if (imap->getWrapper()->deleteMbox(folder))
692 { 712 {
693 QListView*v=listView(); 713 QListView*v=listView();
694 IMAPviewItem * box = imap; 714 IMAPviewItem * box = imap;
695 /* be carefull - after that this object is destroyd so don't use 715 /* be carefull - after that this object is destroyd so don't use
696 * any member of it after that call!!*/ 716 * any member of it after that call!!*/
697 imap->refreshFolders(true); 717 imap->refreshFolders(true);
698 if (v) 718 if (v)
699 { 719 {
700 v->setSelected(box,true); 720 v->setSelected(box,true);
701 } 721 }
702 } 722 }
703 } 723 }
704} 724}
705 725
706void IMAPfolderItem::downloadMails() 726void IMAPfolderItem::downloadMails()
707{ 727{
708 AccountView*bl = imap->accountView(); 728 AccountView*bl = imap->accountView();
709 if (!bl) return; 729 if (!bl) return;
710 bl->downloadMails(folder,imap->getWrapper()); 730 bl->downloadMails(folder,imap->getWrapper());
711} 731}
712 732
713void IMAPfolderItem::contextMenuSelected(int id) 733void IMAPfolderItem::contextMenuSelected(int id)
714{ 734{
715 735
716 AccountView * view = (AccountView*)listView(); 736 AccountView * view = (AccountView*)listView();
717 switch(id) 737 switch(id)
718 { 738 {
719 case 0: 739 case 0:
720 view->refreshCurrent(); 740 view->refreshCurrent();
721 break; 741 break;
722 case 1: 742 case 1:
723 deleteAllMail(imap->getWrapper(),folder); 743 deleteAllMail(imap->getWrapper(),folder);
724 break; 744 break;
725 case 2: 745 case 2:
726 createNewFolder(); 746 createNewFolder();
727 break; 747 break;
728 case 3: 748 case 3:
729 deleteFolder(); 749 deleteFolder();
730 break; 750 break;
731 case 4: 751 case 4:
732 downloadMails(); 752 downloadMails();
733 break; 753 break;
734 default: 754 default:
735 break; 755 break;
736 } 756 }
737} 757}
738 758
739/** 759/**
740 * MH Account stuff 760 * MH Account stuff
741 */ 761 */
742/* MH is a little bit different - the top folder can contains messages other than in IMAP and 762/* MH is a little bit different - the top folder can contains messages other than in IMAP and
743 POP3 and MBOX */ 763 POP3 and MBOX */
744MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 764MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
745 : AccountViewItem( parent ) 765 : AccountViewItem( parent )
746{ 766{
747 m_Path = aPath; 767 m_Path = aPath;
748 /* be carefull - the space within settext is wanted - thats why the string twice */ 768 /* be carefull - the space within settext is wanted - thats why the string twice */
749 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 769 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
750 setPixmap( 0, PIXMAP_LOCALFOLDER ); 770 setPixmap( 0, PIXMAP_LOCALFOLDER );
751 setText( 0, " Local Folders" ); 771 setText( 0, " Local Folders" );
752 setOpen( true ); 772 setOpen( true );
753 folder = 0; 773 folder = 0;
754} 774}
755 775
756MHviewItem::~MHviewItem() 776MHviewItem::~MHviewItem()
757{ 777{
758 delete wrapper; 778 delete wrapper;
759} 779}
760 780
761AbstractMail *MHviewItem::getWrapper() 781AbstractMail *MHviewItem::getWrapper()
762{ 782{
763 return wrapper; 783 return wrapper;
764} 784}