summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountitem.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp14
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,1170 +1,1172 @@
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
19using namespace Opie::Core; 21using 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 */
24POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 26POP3viewItem::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
44POP3viewItem::~POP3viewItem() 46POP3viewItem::~POP3viewItem()
45{ 47{
46 delete wrapper; 48 delete wrapper;
47} 49}
48 50
49AbstractMail *POP3viewItem::getWrapper() 51AbstractMail *POP3viewItem::getWrapper()
50{ 52{
51 return wrapper; 53 return wrapper;
52} 54}
53 55
54void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) 56void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
55{ 57{
56 refresh(); 58 refresh();
57} 59}
58 60
59void POP3viewItem::refresh() 61void 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
80RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 82RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
81{ 83{
82 84
83 return wrapper->fetchBody( mail ); 85 return wrapper->fetchBody( mail );
84} 86}
85 87
86QPopupMenu * POP3viewItem::getContextMenu() 88QPopupMenu * 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
106void POP3viewItem::disconnect() 108void 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
118void POP3viewItem::setOnOffline() 120void 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
130void POP3viewItem::contextMenuSelected(int which) 132void 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
154POP3folderItem::~POP3folderItem() 156POP3folderItem::~POP3folderItem()
155{} 157{}
156 158
157POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 159POP3folderItem::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
172void POP3folderItem::refresh(QValueList<RecMailP>&target) 174void 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
178RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 180RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
179{ 181{
180 return pop3->getWrapper()->fetchBody(aMail); 182 return pop3->getWrapper()->fetchBody(aMail);
181} 183}
182 184
183QPopupMenu * POP3folderItem::getContextMenu() 185QPopupMenu * 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
195void POP3folderItem::downloadMails() 197void 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
202void POP3folderItem::contextMenuSelected(int which) 204void 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 */
226NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 228NNTPviewItem::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
247NNTPviewItem::~NNTPviewItem() 249NNTPviewItem::~NNTPviewItem()
248{ 250{
249 delete wrapper; 251 delete wrapper;
250} 252}
251 253
252AbstractMail *NNTPviewItem::getWrapper() 254AbstractMail *NNTPviewItem::getWrapper()
253{ 255{
254 return wrapper; 256 return wrapper;
255} 257}
256 258
257void NNTPviewItem::refresh( QValueList<RecMailP> & ) 259void NNTPviewItem::refresh( QValueList<RecMailP> & )
258{ 260{
259 refresh(); 261 refresh();
260} 262}
261 263
262void NNTPviewItem::refresh() 264void 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 )
269 { 271 {
270 QListViewItem *tmp = child; 272 QListViewItem *tmp = child;
271 child = child->nextSibling(); 273 child = child->nextSibling();
272 delete tmp; 274 delete tmp;
273 } 275 }
274 QValueList<FolderP>::ConstIterator it; 276 QValueList<FolderP>::ConstIterator it;
275 QListViewItem*item = 0; 277 QListViewItem*item = 0;
276 for ( it = folders->begin(); it!=folders->end(); ++it) 278 for ( it = folders->begin(); it!=folders->end(); ++it)
277 { 279 {
278 item = new NNTPfolderItem( (*it), this , item ); 280 item = new NNTPfolderItem( (*it), this , item );
279 item->setSelectable( (*it)->may_select()); 281 item->setSelectable( (*it)->may_select());
280 } 282 }
281 delete folders; 283 delete folders;
282} 284}
283 285
284RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) 286RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
285{ 287{
286 288
287 return wrapper->fetchBody( mail ); 289 return wrapper->fetchBody( mail );
288} 290}
289 291
290QPopupMenu * NNTPviewItem::getContextMenu() 292QPopupMenu * NNTPviewItem::getContextMenu()
291{ 293{
292 QPopupMenu *m = new QPopupMenu(0); 294 QPopupMenu *m = new QPopupMenu(0);
293 if (m) 295 if (m)
294 { 296 {
295 if (!account->getOffline()) 297 if (!account->getOffline())
296 { 298 {
297 m->insertItem(QObject::tr("Disconnect",contextName),0); 299 m->insertItem(QObject::tr("Disconnect",contextName),0);
298 m->insertItem(QObject::tr("Set offline",contextName),1); 300 m->insertItem(QObject::tr("Set offline",contextName),1);
299 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); 301 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2);
300 } 302 }
301 else 303 else
302 { 304 {
303 m->insertItem(QObject::tr("Set online",contextName),1); 305 m->insertItem(QObject::tr("Set online",contextName),1);
304 } 306 }
305 } 307 }
306 return m; 308 return m;
307} 309}
308 310
309void NNTPviewItem::subscribeGroups() 311void NNTPviewItem::subscribeGroups()
310{ 312{
311 NNTPGroupsDlg dlg(account); 313 NNTPGroupsDlg dlg(account);
312 dlg.showMaximized(); 314 dlg.showMaximized();
313 if ( dlg.exec()== QDialog::Accepted ){ 315 if ( dlg.exec()== QDialog::Accepted ){
314 refresh(); 316 refresh();
315 } 317 }
316} 318}
317 319
318void NNTPviewItem::disconnect() 320void NNTPviewItem::disconnect()
319{ 321{
320 QListViewItem *child = firstChild(); 322 QListViewItem *child = firstChild();
321 while ( child ) 323 while ( child )
322 { 324 {
323 QListViewItem *tmp = child; 325 QListViewItem *tmp = child;
324 child = child->nextSibling(); 326 child = child->nextSibling();
325 delete tmp; 327 delete tmp;
326 } 328 }
327 wrapper->logout(); 329 wrapper->logout();
328} 330}
329 331
330void NNTPviewItem::setOnOffline() 332void NNTPviewItem::setOnOffline()
331{ 333{
332 if (!account->getOffline()) 334 if (!account->getOffline())
333 { 335 {
334 disconnect(); 336 disconnect();
335 } 337 }
336 account->setOffline(!account->getOffline()); 338 account->setOffline(!account->getOffline());
337 account->save(); 339 account->save();
338 //FIXME 340 //FIXME
339 SETPIX(PIXMAP_POP3FOLDER); 341 SETPIX(PIXMAP_POP3FOLDER);
340 refresh(); 342 refresh();
341} 343}
342 344
343void NNTPviewItem::contextMenuSelected(int which) 345void NNTPviewItem::contextMenuSelected(int which)
344{ 346{
345 switch (which) 347 switch (which)
346 { 348 {
347 case 0: 349 case 0:
348 disconnect(); 350 disconnect();
349 break; 351 break;
350 case 1: 352 case 1:
351 setOnOffline(); 353 setOnOffline();
352 break; 354 break;
353 case 2: 355 case 2:
354 subscribeGroups(); 356 subscribeGroups();
355 break; 357 break;
356 } 358 }
357} 359}
358 360
359NNTPfolderItem::~NNTPfolderItem() 361NNTPfolderItem::~NNTPfolderItem()
360{} 362{}
361 363
362NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) 364NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after )
363 : AccountViewItem( folderInit, parent,after ) 365 : AccountViewItem( folderInit, parent,after )
364{ 366{
365 nntp = parent; 367 nntp = parent;
366 if (folder->getDisplayName().lower()!="inbox") 368 if (folder->getDisplayName().lower()!="inbox")
367 { 369 {
368 setPixmap( 0, PIXMAP_POP3FOLDER ); 370 setPixmap( 0, PIXMAP_POP3FOLDER );
369 } 371 }
370 else 372 else
371 { 373 {
372 setPixmap( 0, PIXMAP_INBOXFOLDER); 374 setPixmap( 0, PIXMAP_INBOXFOLDER);
373 } 375 }
374 setText( 0, folder->getDisplayName() ); 376 setText( 0, folder->getDisplayName() );
375} 377}
376 378
377void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 379void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
378{ 380{
379 if (folder->may_select()) 381 if (folder->may_select())
380 nntp->getWrapper()->listMessages( folder->getName(),target ); 382 nntp->getWrapper()->listMessages( folder->getName(),target );
381} 383}
382 384
383RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) 385RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
384{ 386{
385 return nntp->getWrapper()->fetchBody(aMail); 387 return nntp->getWrapper()->fetchBody(aMail);
386} 388}
387 389
388QPopupMenu * NNTPfolderItem::getContextMenu() 390QPopupMenu * NNTPfolderItem::getContextMenu()
389{ 391{
390 QPopupMenu *m = new QPopupMenu(0); 392 QPopupMenu *m = new QPopupMenu(0);
391 if (m) 393 if (m)
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
399void NNTPfolderItem::downloadMails() 401void 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
406void NNTPfolderItem::contextMenuSelected(int which) 408void 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 */
427IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 429IMAPviewItem::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
437IMAPviewItem::~IMAPviewItem() 439IMAPviewItem::~IMAPviewItem()
438{ 440{
439 delete wrapper; 441 delete wrapper;
440} 442}
441 443
442AbstractMail *IMAPviewItem::getWrapper() 444AbstractMail *IMAPviewItem::getWrapper()
443{ 445{
444 return wrapper; 446 return wrapper;
445} 447}
446 448
447void IMAPviewItem::refresh(QValueList<RecMailP>&) 449void IMAPviewItem::refresh(QValueList<RecMailP>&)
448{ 450{
449 refreshFolders(false); 451 refreshFolders(false);
450} 452}
451 453
452const QStringList&IMAPviewItem::subFolders() 454const QStringList&IMAPviewItem::subFolders()
453{ 455{
454 return currentFolders; 456 return currentFolders;
455} 457}
456 458
457void IMAPviewItem::refreshFolders(bool force) 459void 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
507QPopupMenu * IMAPviewItem::getContextMenu() 509QPopupMenu * 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
532void IMAPviewItem::createNewFolder() 534void 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
554void IMAPviewItem::contextMenuSelected(int id) 556void 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
598RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 600RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
599{ 601{
600 return new RecBody(); 602 return new RecBody();
601} 603}
602 604
603bool IMAPviewItem::offline() 605bool IMAPviewItem::offline()
604{ 606{
605 return account->getOffline(); 607 return account->getOffline();
606} 608}
607 609
608IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 610IMAPfolderItem::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
623IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 625IMAPfolderItem::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
638IMAPfolderItem::~IMAPfolderItem() 640IMAPfolderItem::~IMAPfolderItem()
639{} 641{}
640 642
641const QString& IMAPfolderItem::Delemiter()const 643const QString& IMAPfolderItem::Delemiter()const
642{ 644{
643 return folder->Separator(); 645 return folder->Separator();
644} 646}
645 647
646void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 648void 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
658RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 660RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
659{ 661{
660 return imap->getWrapper()->fetchBody(aMail); 662 return imap->getWrapper()->fetchBody(aMail);
661} 663}
662 664
663QPopupMenu * IMAPfolderItem::getContextMenu() 665QPopupMenu * 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
686void IMAPfolderItem::createNewFolder() 688void 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
702void IMAPfolderItem::deleteFolder() 704void 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
709 if (yesno == 0) 711 if (yesno == 0)
710 { 712 {
711 if (imap->getWrapper()->deleteMbox(folder)) 713 if (imap->getWrapper()->deleteMbox(folder))
712 { 714 {
713 QListView*v=listView(); 715 QListView*v=listView();
714 IMAPviewItem * box = imap; 716 IMAPviewItem * box = imap;
715 /* be carefull - after that this object is destroyd so don't use 717 /* be carefull - after that this object is destroyd so don't use
716 * any member of it after that call!!*/ 718 * any member of it after that call!!*/
717 imap->refreshFolders(true); 719 imap->refreshFolders(true);
718 if (v) 720 if (v)
719 { 721 {
720 v->setSelected(box,true); 722 v->setSelected(box,true);
721 } 723 }
722 } 724 }
723 } 725 }
724} 726}
725 727
726void IMAPfolderItem::downloadMails() 728void IMAPfolderItem::downloadMails()
727{ 729{
728 AccountView*bl = imap->accountView(); 730 AccountView*bl = imap->accountView();
729 if (!bl) return; 731 if (!bl) return;
730 bl->downloadMails(folder,imap->getWrapper()); 732 bl->downloadMails(folder,imap->getWrapper());
731} 733}
732 734
733void IMAPfolderItem::contextMenuSelected(int id) 735void IMAPfolderItem::contextMenuSelected(int id)
734{ 736{
735 737
736 AccountView * view = (AccountView*)listView(); 738 AccountView * view = (AccountView*)listView();
737 switch(id) 739 switch(id)
738 { 740 {
739 case 0: 741 case 0:
740 view->refreshCurrent(); 742 view->refreshCurrent();
741 break; 743 break;
742 case 1: 744 case 1:
743 deleteAllMail(imap->getWrapper(),folder); 745 deleteAllMail(imap->getWrapper(),folder);
744 break; 746 break;
745 case 2: 747 case 2:
746 createNewFolder(); 748 createNewFolder();
747 break; 749 break;
748 case 3: 750 case 3:
749 deleteFolder(); 751 deleteFolder();
750 break; 752 break;
751 case 4: 753 case 4:
752 downloadMails(); 754 downloadMails();
753 break; 755 break;
754 default: 756 default:
755 break; 757 break;
756 } 758 }
757} 759}
758 760
759/** 761/**
760 * MH Account stuff 762 * MH Account stuff
761 */ 763 */
762/* MH is a little bit different - the top folder can contains messages other than in IMAP and 764/* MH is a little bit different - the top folder can contains messages other than in IMAP and
763 POP3 and MBOX */ 765 POP3 and MBOX */
764MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 766MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
765 : AccountViewItem( parent ) 767 : AccountViewItem( parent )
766{ 768{
767 m_Path = aPath; 769 m_Path = aPath;
768 /* be carefull - the space within settext is wanted - thats why the string twice */ 770 /* be carefull - the space within settext is wanted - thats why the string twice */
769 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 771 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
770 setPixmap( 0, PIXMAP_LOCALFOLDER ); 772 setPixmap( 0, PIXMAP_LOCALFOLDER );
771 setText( 0, " Local Folders" ); 773 setText( 0, " Local Folders" );
772 setOpen( true ); 774 setOpen( true );
773 folder = 0; 775 folder = 0;
774} 776}
775 777
776MHviewItem::~MHviewItem() 778MHviewItem::~MHviewItem()
777{ 779{
778 delete wrapper; 780 delete wrapper;
779} 781}
780 782
781AbstractMail *MHviewItem::getWrapper() 783AbstractMail *MHviewItem::getWrapper()
782{ 784{
783 return wrapper; 785 return wrapper;
784} 786}
785 787
786void MHviewItem::refresh( QValueList<RecMailP> & target) 788void MHviewItem::refresh( QValueList<RecMailP> & target)
787{ 789{
788 refresh(false); 790 refresh(false);
789 getWrapper()->listMessages( "",target ); 791 getWrapper()->listMessages( "",target );
790} 792}
791 793
792void MHviewItem::refresh(bool force) 794void MHviewItem::refresh(bool force)
793{ 795{
794 if (childCount()>0 && force==false) return; 796 if (childCount()>0 && force==false) return;
795 removeChilds(); 797 removeChilds();
796 currentFolders.clear(); 798 currentFolders.clear();
797 QValueList<FolderP> *folders = wrapper->listFolders(); 799 QValueList<FolderP> *folders = wrapper->listFolders();
798 QValueList<FolderP>::ConstIterator it; 800 QValueList<FolderP>::ConstIterator it;
799 MHfolderItem*item = 0; 801 MHfolderItem*item = 0;
800 MHfolderItem*pmaster = 0; 802 MHfolderItem*pmaster = 0;
801 QString fname = ""; 803 QString fname = "";
802 int pos; 804 int pos;
803 for ( it = folders->begin(); it!=folders->end(); ++it) 805 for ( it = folders->begin(); it!=folders->end(); ++it)
804 { 806 {
805 fname = (*it)->getDisplayName(); 807 fname = (*it)->getDisplayName();
806 /* this folder itself */ 808 /* this folder itself */
807 if (fname=="/") 809 if (fname=="/")
808 { 810 {
809 currentFolders.append(fname); 811 currentFolders.append(fname);
810 folder = (*it); 812 folder = (*it);
811 continue; 813 continue;
812 } 814 }
813 currentFolders.append(fname); 815 currentFolders.append(fname);
814 pos = fname.findRev("/"); 816 pos = fname.findRev("/");
815 if (pos > 0) 817 if (pos > 0)
816 { 818 {
817 fname = fname.left(pos); 819 fname = fname.left(pos);
818 pmaster = (MHfolderItem*)findSubItem(fname); 820 pmaster = (MHfolderItem*)findSubItem(fname);
819 } 821 }
820 else 822 else
821 { 823 {
822 pmaster = 0; 824 pmaster = 0;
823 } 825 }
824 if (pmaster) 826 if (pmaster)
825 { 827 {
826 item = new MHfolderItem( (*it), pmaster, item, this ); 828 item = new MHfolderItem( (*it), pmaster, item, this );
827 } 829 }
828 else 830 else
829 { 831 {
830 item = new MHfolderItem( (*it), this , item ); 832 item = new MHfolderItem( (*it), this , item );
831 } 833 }
832 item->setSelectable((*it)->may_select()); 834 item->setSelectable((*it)->may_select());
833 } 835 }
834 delete folders; 836 delete folders;
835} 837}
836 838
837RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) 839RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
838{ 840{
839 841
840 return wrapper->fetchBody( mail ); 842 return wrapper->fetchBody( mail );
841} 843}
842 844
843QPopupMenu * MHviewItem::getContextMenu() 845QPopupMenu * MHviewItem::getContextMenu()
844{ 846{
845 QPopupMenu *m = new QPopupMenu(0); 847 QPopupMenu *m = new QPopupMenu(0);
846 if (m) 848 if (m)
847 { 849 {
848 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 850 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
849 m->insertItem(QObject::tr("Create new folder",contextName),1); 851 m->insertItem(QObject::tr("Create new folder",contextName),1);
850 m->insertItem(QObject::tr("Delete all mails",contextName),2); 852 m->insertItem(QObject::tr("Delete all mails",contextName),2);
851 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); 853 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
852 } 854 }
853 return m; 855 return m;
854} 856}
855 857
856void MHviewItem::createFolder() 858void MHviewItem::createFolder()
857{ 859{
858 Newmdirdlg ndirdlg(0,0,true); 860 Newmdirdlg ndirdlg(0,0,true);
859 ndirdlg.showMaximized(); 861 ndirdlg.showMaximized();
860 if ( ndirdlg.exec() ) 862 if ( ndirdlg.exec() )
861 { 863 {
862 QString ndir = ndirdlg.Newdir(); 864 QString ndir = ndirdlg.Newdir();
863 if (wrapper->createMbox(ndir)) 865 if (wrapper->createMbox(ndir))
864 { 866 {
865 refresh(true); 867 refresh(true);
866 } 868 }
867 } 869 }
868} 870}
869 871
870void MHviewItem::downloadMails() 872void MHviewItem::downloadMails()
871{ 873{
872 AccountView*bl = accountView(); 874 AccountView*bl = accountView();
873 if (!bl) return; 875 if (!bl) return;
874 bl->downloadMails(folder,getWrapper()); 876 bl->downloadMails(folder,getWrapper());
875} 877}
876 878
877QStringList MHviewItem::subFolders() 879QStringList MHviewItem::subFolders()
878{ 880{
879 return currentFolders; 881 return currentFolders;
880} 882}
881 883
882void MHviewItem::contextMenuSelected(int which) 884void MHviewItem::contextMenuSelected(int which)
883{ 885{
884 switch (which) 886 switch (which)
885 { 887 {
886 case 0: 888 case 0:
887 refresh(true); 889 refresh(true);
888 break; 890 break;
889 case 1: 891 case 1:
890 createFolder(); 892 createFolder();
891 break; 893 break;
892 case 2: 894 case 2:
893 deleteAllMail(getWrapper(),folder); 895 deleteAllMail(getWrapper(),folder);
894 break; 896 break;
895 case 3: 897 case 3:
896 downloadMails(); 898 downloadMails();
897 break; 899 break;
898 default: 900 default:
899 break; 901 break;
900 } 902 }
901} 903}
902 904
903MHfolderItem::~MHfolderItem() 905MHfolderItem::~MHfolderItem()
904{} 906{}
905 907
906MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) 908MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
907 : AccountViewItem(folderInit, parent,after ) 909 : AccountViewItem(folderInit, parent,after )
908{ 910{
909 mbox = parent; 911 mbox = parent;
910 initName(); 912 initName();
911} 913}
912 914
913MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 915MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
914 : AccountViewItem(folderInit, parent,after ) 916 : AccountViewItem(folderInit, parent,after )
915{ 917{
916 folder = folderInit; 918 folder = folderInit;
917 mbox = master; 919 mbox = master;
918 initName(); 920 initName();
919} 921}
920 922
921void MHfolderItem::initName() 923void MHfolderItem::initName()
922{ 924{
923 QString bName = folder->getDisplayName(); 925 QString bName = folder->getDisplayName();
924 if (bName.startsWith("/")&&bName.length()>1) 926 if (bName.startsWith("/")&&bName.length()>1)
925 { 927 {
926 bName.replace(0,1,""); 928 bName.replace(0,1,"");
927 } 929 }
928 int pos = bName.findRev("/"); 930 int pos = bName.findRev("/");
929 if (pos > 0) 931 if (pos > 0)
930 { 932 {
931 bName.replace(0,pos+1,""); 933 bName.replace(0,pos+1,"");
932 } 934 }
933 if (bName.lower() == "outgoing") 935 if (bName.lower() == "outgoing")
934 { 936 {
935 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 937 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
936 } 938 }
937 else if (bName.lower() == "inbox") 939 else if (bName.lower() == "inbox")
938 { 940 {
939 setPixmap( 0, PIXMAP_INBOXFOLDER); 941 setPixmap( 0, PIXMAP_INBOXFOLDER);
940 } else if (bName.lower() == "drafts") { 942 } else if (bName.lower() == "drafts") {
941 setPixmap(0, SmallIcon ("edit")); 943 setPixmap(0, SmallIcon ("edit"));
942 } else { 944 } else {
943 setPixmap( 0, PIXMAP_MBOXFOLDER ); 945 setPixmap( 0, PIXMAP_MBOXFOLDER );
944 } 946 }
945 setText( 0, bName ); 947 setText( 0, bName );
946} 948}
947 949
948const FolderP&MHfolderItem::getFolder()const 950const FolderP&MHfolderItem::getFolder()const
949{ 951{
950 return folder; 952 return folder;
951} 953}
952 954
953void MHfolderItem::refresh(QValueList<RecMailP>&target) 955void MHfolderItem::refresh(QValueList<RecMailP>&target)
954{ 956{
955 if (folder->may_select()) 957 if (folder->may_select())
956 mbox->getWrapper()->listMessages( folder->getName(),target ); 958 mbox->getWrapper()->listMessages( folder->getName(),target );
957} 959}
958 960
959RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) 961RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
960{ 962{
961 return mbox->getWrapper()->fetchBody(aMail); 963 return mbox->getWrapper()->fetchBody(aMail);
962} 964}
963 965
964void MHfolderItem::deleteFolder() 966void MHfolderItem::deleteFolder()
965{ 967{
966 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 968 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
967 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 969 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
968 QObject::tr("Yes",contextName), 970 QObject::tr("Yes",contextName),
969 QObject::tr("No",contextName),QString::null,1,1); 971 QObject::tr("No",contextName),QString::null,1,1);
970 972
971 if (yesno == 0) 973 if (yesno == 0)
972 { 974 {
973 if (mbox->getWrapper()->deleteMbox(folder)) 975 if (mbox->getWrapper()->deleteMbox(folder))
974 { 976 {
975 QListView*v=listView(); 977 QListView*v=listView();
976 MHviewItem * box = mbox; 978 MHviewItem * box = mbox;
977 /* be carefull - after that this object is destroyd so don't use 979 /* be carefull - after that this object is destroyd so don't use
978 * any member of it after that call!!*/ 980 * any member of it after that call!!*/
979 mbox->refresh(true); 981 mbox->refresh(true);
980 if (v) 982 if (v)
981 { 983 {
982 v->setSelected(box,true); 984 v->setSelected(box,true);
983 } 985 }
984 } 986 }
985 } 987 }
986} 988}
987 989
988QPopupMenu * MHfolderItem::getContextMenu() 990QPopupMenu * MHfolderItem::getContextMenu()
989{ 991{
990 QPopupMenu *m = new QPopupMenu(0); 992 QPopupMenu *m = new QPopupMenu(0);
991 if (m) 993 if (m)
992 { 994 {
993 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 995 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
994 m->insertItem(QObject::tr("Delete all mails",contextName),0); 996 m->insertItem(QObject::tr("Delete all mails",contextName),0);
995 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 997 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
996 m->insertItem(QObject::tr("Delete folder",contextName),1); 998 m->insertItem(QObject::tr("Delete folder",contextName),1);
997 } 999 }
998 return m; 1000 return m;
999} 1001}
1000 1002
1001void MHfolderItem::downloadMails() 1003void MHfolderItem::downloadMails()
1002{ 1004{
1003 AccountView*bl = mbox->accountView(); 1005 AccountView*bl = mbox->accountView();
1004 if (!bl) return; 1006 if (!bl) return;
1005 bl->downloadMails(folder,mbox->getWrapper()); 1007 bl->downloadMails(folder,mbox->getWrapper());
1006} 1008}
1007 1009
1008void MHfolderItem::createFolder() 1010void MHfolderItem::createFolder()
1009{ 1011{
1010 Newmdirdlg ndirdlg(0,0,true); 1012 Newmdirdlg ndirdlg(0,0,true);
1011 ndirdlg.showMaximized(); 1013 ndirdlg.showMaximized();
1012 if (ndirdlg.exec() ) 1014 if (ndirdlg.exec() )
1013 { 1015 {
1014 QString ndir = ndirdlg.Newdir(); 1016 QString ndir = ndirdlg.Newdir();
1015 if (mbox->getWrapper()->createMbox(ndir,folder)) 1017 if (mbox->getWrapper()->createMbox(ndir,folder))
1016 { 1018 {
1017 QListView*v=listView(); 1019 QListView*v=listView();
1018 MHviewItem * box = mbox; 1020 MHviewItem * box = mbox;
1019 /* be carefull - after that this object is destroyd so don't use 1021 /* be carefull - after that this object is destroyd so don't use
1020 * any member of it after that call!!*/ 1022 * any member of it after that call!!*/
1021 mbox->refresh(true); 1023 mbox->refresh(true);
1022 if (v) 1024 if (v)
1023 { 1025 {
1024 v->setSelected(box,true); 1026 v->setSelected(box,true);
1025 } 1027 }
1026 } 1028 }
1027 } 1029 }
1028} 1030}
1029 1031
1030void MHfolderItem::contextMenuSelected(int which) 1032void MHfolderItem::contextMenuSelected(int which)
1031{ 1033{
1032 switch(which) 1034 switch(which)
1033 { 1035 {
1034 case 0: 1036 case 0:
1035 deleteAllMail(mbox->getWrapper(),folder); 1037 deleteAllMail(mbox->getWrapper(),folder);
1036 break; 1038 break;
1037 case 1: 1039 case 1:
1038 deleteFolder(); 1040 deleteFolder();
1039 break; 1041 break;
1040 case 2: 1042 case 2:
1041 downloadMails(); 1043 downloadMails();
1042 break; 1044 break;
1043 case 3: 1045 case 3:
1044 createFolder(); 1046 createFolder();
1045 break; 1047 break;
1046 default: 1048 default:
1047 break; 1049 break;
1048 } 1050 }
1049} 1051}
1050 1052
1051bool MHfolderItem::isDraftfolder() 1053bool MHfolderItem::isDraftfolder()
1052{ 1054{
1053 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; 1055 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1054 return false; 1056 return false;
1055} 1057}
1056 1058
1057/** 1059/**
1058 * Generic stuff 1060 * Generic stuff
1059 */ 1061 */
1060 1062
1061const QString AccountViewItem::contextName="AccountViewItem"; 1063const QString AccountViewItem::contextName="AccountViewItem";
1062 1064
1063AccountViewItem::AccountViewItem( AccountView *parent ) 1065AccountViewItem::AccountViewItem( AccountView *parent )
1064 : QListViewItem( parent ) 1066 : QListViewItem( parent )
1065{ 1067{
1066 init(); 1068 init();
1067 m_Backlink = parent; 1069 m_Backlink = parent;
1068} 1070}
1069 1071
1070AccountViewItem::AccountViewItem( QListViewItem *parent) 1072AccountViewItem::AccountViewItem( QListViewItem *parent)
1071 : QListViewItem( parent),folder(0) 1073 : QListViewItem( parent),folder(0)
1072{ 1074{
1073 init(); 1075 init();
1074} 1076}
1075 1077
1076AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1078AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
1077 :QListViewItem( parent,after ),folder(0) 1079 :QListViewItem( parent,after ),folder(0)
1078{ 1080{
1079 init(); 1081 init();
1080} 1082}
1081 1083
1082AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) 1084AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
1083 :QListViewItem( parent,after ),folder(folderInit) 1085 :QListViewItem( parent,after ),folder(folderInit)
1084{ 1086{
1085 init(); 1087 init();
1086} 1088}
1087 1089
1088void AccountViewItem::init() 1090void AccountViewItem::init()
1089{ 1091{
1090 m_Backlink = 0; 1092 m_Backlink = 0;
1091} 1093}
1092 1094
1093AccountViewItem::~AccountViewItem() 1095AccountViewItem::~AccountViewItem()
1094{ 1096{
1095 folder = 0; 1097 folder = 0;
1096} 1098}
1097 1099
1098AccountView*AccountViewItem::accountView() 1100AccountView*AccountViewItem::accountView()
1099{ 1101{
1100 return m_Backlink; 1102 return m_Backlink;
1101} 1103}
1102 1104
1103void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) 1105void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder)
1104{ 1106{
1105 if (!wrapper) return; 1107 if (!wrapper) return;
1106 QString fname=""; 1108 QString fname="";
1107 if (folder) fname = folder->getDisplayName(); 1109 if (folder) fname = folder->getDisplayName();
1108 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 1110 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
1109 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 1111 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
1110 arg(fname), 1112 arg(fname),
1111 QObject::tr("Yes",contextName), 1113 QObject::tr("Yes",contextName),
1112 QObject::tr("No",contextName),QString::null,1,1); 1114 QObject::tr("No",contextName),QString::null,1,1);
1113 1115
1114 if (yesno == 0) 1116 if (yesno == 0)
1115 { 1117 {
1116 if (wrapper->deleteAllMail(folder)) 1118 if (wrapper->deleteAllMail(folder))
1117 { 1119 {
1118 AccountView * view = (AccountView*)listView(); 1120 AccountView * view = (AccountView*)listView();
1119 if (view) view->refreshCurrent(); 1121 if (view) view->refreshCurrent();
1120 } 1122 }
1121 } 1123 }
1122} 1124}
1123 1125
1124void AccountViewItem::removeChilds() 1126void AccountViewItem::removeChilds()
1125{ 1127{
1126 QListViewItem *child = firstChild(); 1128 QListViewItem *child = firstChild();
1127 while ( child ) 1129 while ( child )
1128 { 1130 {
1129 QListViewItem *tmp = child; 1131 QListViewItem *tmp = child;
1130 child = child->nextSibling(); 1132 child = child->nextSibling();
1131 delete tmp; 1133 delete tmp;
1132 } 1134 }
1133} 1135}
1134 1136
1135bool AccountViewItem::matchName(const QString&name)const 1137bool AccountViewItem::matchName(const QString&name)const
1136{ 1138{
1137 if (!folder) return false; 1139 if (!folder) return false;
1138 return folder->getDisplayName().lower()==name.lower(); 1140 return folder->getDisplayName().lower()==name.lower();
1139} 1141}
1140 1142
1141 1143
1142AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 1144AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
1143{ 1145{
1144 AccountViewItem*pitem,*sitem; 1146 AccountViewItem*pitem,*sitem;
1145 if (!start) pitem = (AccountViewItem*)firstChild(); 1147 if (!start) pitem = (AccountViewItem*)firstChild();
1146 else pitem = (AccountViewItem*)start->firstChild(); 1148 else pitem = (AccountViewItem*)start->firstChild();
1147 while (pitem) 1149 while (pitem)
1148 { 1150 {
1149 if (pitem->matchName(path)) 1151 if (pitem->matchName(path))
1150 { 1152 {
1151 break; 1153 break;
1152 } 1154 }
1153 if (pitem->childCount()>0) 1155 if (pitem->childCount()>0)
1154 { 1156 {
1155 sitem = findSubItem(path,pitem); 1157 sitem = findSubItem(path,pitem);
1156 if (sitem) 1158 if (sitem)
1157 { 1159 {
1158 pitem = sitem; 1160 pitem = sitem;
1159 break; 1161 break;
1160 } 1162 }
1161 } 1163 }
1162 pitem=(AccountViewItem*)pitem->nextSibling(); 1164 pitem=(AccountViewItem*)pitem->nextSibling();
1163 } 1165 }
1164 return pitem; 1166 return pitem;
1165} 1167}
1166 1168
1167bool AccountViewItem::isDraftfolder() 1169bool AccountViewItem::isDraftfolder()
1168{ 1170{
1169 return false; 1171 return false;
1170} 1172}