summaryrefslogtreecommitdiffabout
path: root/kmicromail/accountitem.cpp
Unidiff
Diffstat (limited to 'kmicromail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp
index 59c8abb..12d047a 100644
--- a/kmicromail/accountitem.cpp
+++ b/kmicromail/accountitem.cpp
@@ -1,1172 +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 19#define GET_NEW_MAILS 101
20 20
21using namespace Opie::Core; 21using namespace Opie::Core;
22#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 );}
23/** 23/**
24 * POP3 Account stuff 24 * POP3 Account stuff
25 */ 25 */
26POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 26POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
27 : AccountViewItem( parent ) 27 : AccountViewItem( parent )
28{ 28{
29 account = a; 29 account = a;
30 wrapper = AbstractMail::getWrapper( account ); 30 wrapper = AbstractMail::getWrapper( account );
31 SETPIX(PIXMAP_POP3FOLDER); 31 SETPIX(PIXMAP_POP3FOLDER);
32#if 0 32#if 0
33 if (!account->getOffline()) 33 if (!account->getOffline())
34 { 34 {
35 setPixmap( 0, ); 35 setPixmap( 0, );
36 } 36 }
37 else 37 else
38 { 38 {
39 setPixmap( 0, PIXMAP_OFFLINE ); 39 setPixmap( 0, PIXMAP_OFFLINE );
40 } 40 }
41#endif 41#endif
42 setText( 0, account->getAccountName() ); 42 setText( 0, account->getAccountName() );
43 setOpen( true ); 43 setOpen( true );
44} 44}
45 45
46POP3viewItem::~POP3viewItem() 46POP3viewItem::~POP3viewItem()
47{ 47{
48 delete wrapper; 48 delete wrapper;
49} 49}
50 50
51AbstractMail *POP3viewItem::getWrapper() 51AbstractMail *POP3viewItem::getWrapper()
52{ 52{
53 return wrapper; 53 return wrapper;
54} 54}
55 55
56void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) 56void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
57{ 57{
58 refresh(); 58 refresh();
59} 59}
60 60
61void POP3viewItem::refresh() 61void POP3viewItem::refresh()
62{ 62{
63 if (account->getOffline()) return; 63 if (account->getOffline()) return;
64 QValueList<FolderP> *folders = wrapper->listFolders(); 64 QValueList<FolderP> *folders = wrapper->listFolders();
65 QListViewItem *child = firstChild(); 65 QListViewItem *child = firstChild();
66 while ( child ) 66 while ( child )
67 { 67 {
68 QListViewItem *tmp = child; 68 QListViewItem *tmp = child;
69 child = child->nextSibling(); 69 child = child->nextSibling();
70 delete tmp; 70 delete tmp;
71 } 71 }
72 QValueList<FolderP>::ConstIterator it; 72 QValueList<FolderP>::ConstIterator it;
73 QListViewItem*item = 0; 73 QListViewItem*item = 0;
74 for ( it = folders->begin(); it!=folders->end(); ++it) 74 for ( it = folders->begin(); it!=folders->end(); ++it)
75 { 75 {
76 item = new POP3folderItem( (*it), this , item ); 76 item = new POP3folderItem( (*it), this , item );
77 item->setSelectable( (*it)->may_select()); 77 item->setSelectable( (*it)->may_select());
78 } 78 }
79 delete folders; 79 delete folders;
80} 80}
81 81
82RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) 82RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
83{ 83{
84 84
85 return wrapper->fetchBody( mail ); 85 return wrapper->fetchBody( mail );
86} 86}
87 87
88QPopupMenu * POP3viewItem::getContextMenu() 88QPopupMenu * POP3viewItem::getContextMenu()
89{ 89{
90 QPopupMenu *m = new QPopupMenu(0); 90 QPopupMenu *m = new QPopupMenu(0);
91 if (m) 91 if (m)
92 { 92 {
93 if (!account->getOffline()) 93 if (!account->getOffline())
94 { 94 {
95 m->insertItem(QObject::tr("Disconnect",contextName),0); 95 m->insertItem(QObject::tr("Disconnect",contextName),0);
96 m->insertItem(QObject::tr("Set offline",contextName),1); 96 m->insertItem(QObject::tr("Set offline",contextName),1);
97 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 97 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
98 } 98 }
99 else 99 else
100 { 100 {
101 m->insertItem(QObject::tr("Set online",contextName),1); 101 m->insertItem(QObject::tr("Set online",contextName),1);
102 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 102 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
103 } 103 }
104 } 104 }
105 return m; 105 return m;
106} 106}
107 107
108void POP3viewItem::disconnect() 108void POP3viewItem::disconnect()
109{ 109{
110 QListViewItem *child = firstChild(); 110 QListViewItem *child = firstChild();
111 while ( child ) 111 while ( child )
112 { 112 {
113 QListViewItem *tmp = child; 113 QListViewItem *tmp = child;
114 child = child->nextSibling(); 114 child = child->nextSibling();
115 delete tmp; 115 delete tmp;
116 } 116 }
117 wrapper->logout(); 117 wrapper->logout();
118} 118}
119 119
120void POP3viewItem::setOnOffline() 120void POP3viewItem::setOnOffline()
121{ 121{
122 if (!account->getOffline()) 122 if (!account->getOffline())
123 { 123 {
124 disconnect(); 124 disconnect();
125 } 125 }
126 account->setOffline(!account->getOffline()); 126 account->setOffline(!account->getOffline());
127 account->save(); 127 account->save();
128 SETPIX(PIXMAP_POP3FOLDER); 128 SETPIX(PIXMAP_POP3FOLDER);
129 refresh(); 129 refresh();
130} 130}
131 131
132void POP3viewItem::contextMenuSelected(int which) 132void POP3viewItem::contextMenuSelected(int which)
133{ 133{
134 switch (which) 134 switch (which)
135 { 135 {
136 case 0: 136 case 0:
137 disconnect(); 137 disconnect();
138 break; 138 break;
139 case 1: 139 case 1:
140 setOnOffline(); 140 setOnOffline();
141 break; 141 break;
142 case GET_NEW_MAILS: // daunlood 142 case GET_NEW_MAILS: // daunlood
143 if (account->getOffline()) 143 if (account->getOffline())
144 setOnOffline(); 144 setOnOffline();
145 AccountView*bl = accountView(); 145 AccountView*bl = accountView();
146 if (!bl) return; 146 if (!bl) return;
147 AccountViewItem* in = findSubItem( "inbox" , 0); 147 AccountViewItem* in = findSubItem( "inbox" , 0);
148 if ( ! in ) 148 if ( ! in )
149 return; 149 return;
150 bl->downloadMailsInbox(in->getFolder() ,getWrapper()); 150 bl->downloadMailsInbox(in->getFolder() ,getWrapper());
151 setOnOffline(); 151 setOnOffline();
152 break; 152 break;
153 } 153 }
154} 154}
155 155
156POP3folderItem::~POP3folderItem() 156POP3folderItem::~POP3folderItem()
157{} 157{}
158 158
159POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 159POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after )
160 : AccountViewItem(folderInit,parent,after ) 160 : AccountViewItem(folderInit,parent,after )
161{ 161{
162 pop3 = parent; 162 pop3 = parent;
163 if (folder->getDisplayName().lower()!="inbox") 163 if (folder->getDisplayName().lower()!="inbox")
164 { 164 {
165 setPixmap( 0, PIXMAP_POP3FOLDER ); 165 setPixmap( 0, PIXMAP_POP3FOLDER );
166 } 166 }
167 else 167 else
168 { 168 {
169 setPixmap( 0, PIXMAP_INBOXFOLDER); 169 setPixmap( 0, PIXMAP_INBOXFOLDER);
170 } 170 }
171 setText( 0, folder->getDisplayName() ); 171 setText( 0, folder->getDisplayName() );
172} 172}
173 173
174void POP3folderItem::refresh(QValueList<RecMailP>&target) 174void POP3folderItem::refresh(QValueList<RecMailP>&target)
175{ 175{
176 if (folder->may_select()) 176 if (folder->may_select())
177 pop3->getWrapper()->listMessages( folder->getName(),target ); 177 pop3->getWrapper()->listMessages( folder->getName(),target );
178} 178}
179 179
180RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 180RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
181{ 181{
182 return pop3->getWrapper()->fetchBody(aMail); 182 return pop3->getWrapper()->fetchBody(aMail);
183} 183}
184 184
185QPopupMenu * POP3folderItem::getContextMenu() 185QPopupMenu * POP3folderItem::getContextMenu()
186{ 186{
187 QPopupMenu *m = new QPopupMenu(0); 187 QPopupMenu *m = new QPopupMenu(0);
188 if (m) 188 if (m)
189 { 189 {
190 m->insertItem(QObject::tr("Refresh header list",contextName),0); 190 m->insertItem(QObject::tr("Refresh header list",contextName),0);
191 m->insertItem(QObject::tr("Delete all mails",contextName),1); 191 m->insertItem(QObject::tr("Delete all mails",contextName),1);
192 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 192 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
193 } 193 }
194 return m; 194 return m;
195} 195}
196 196
197void POP3folderItem::downloadMails() 197void POP3folderItem::downloadMails()
198{ 198{
199 AccountView*bl = pop3->accountView(); 199 AccountView*bl = pop3->accountView();
200 if (!bl) return; 200 if (!bl) return;
201 bl->downloadMails(folder,pop3->getWrapper()); 201 bl->downloadMails(folder,pop3->getWrapper());
202} 202}
203 203
204void POP3folderItem::contextMenuSelected(int which) 204void POP3folderItem::contextMenuSelected(int which)
205{ 205{
206 AccountView * view = (AccountView*)listView(); 206 AccountView * view = (AccountView*)listView();
207 switch (which) 207 switch (which)
208 { 208 {
209 case 0: 209 case 0:
210 /* must be 'cause pop3 lists are cached */ 210 /* must be 'cause pop3 lists are cached */
211 pop3->getWrapper()->logout(); 211 pop3->getWrapper()->logout();
212 view->refreshCurrent(); 212 view->refreshCurrent();
213 break; 213 break;
214 case 1: 214 case 1:
215 deleteAllMail(pop3->getWrapper(),folder); 215 deleteAllMail(pop3->getWrapper(),folder);
216 break; 216 break;
217 case 2: 217 case 2:
218 downloadMails(); 218 downloadMails();
219 break; 219 break;
220 default: 220 default:
221 break; 221 break;
222 } 222 }
223} 223}
224 224
225/** 225/**
226 * NNTP Account stuff 226 * NNTP Account stuff
227 */ 227 */
228NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 228NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
229 : AccountViewItem( parent ) 229 : AccountViewItem( parent )
230{ 230{
231 account = a; 231 account = a;
232 wrapper = AbstractMail::getWrapper( account ); 232 wrapper = AbstractMail::getWrapper( account );
233 //FIXME 233 //FIXME
234 SETPIX(PIXMAP_POP3FOLDER); 234 SETPIX(PIXMAP_POP3FOLDER);
235#if 0 235#if 0
236 if (!account->getOffline()) 236 if (!account->getOffline())
237 { 237 {
238 setPixmap( 0, ); 238 setPixmap( 0, );
239 } 239 }
240 else 240 else
241 { 241 {
242 setPixmap( 0, PIXMAP_OFFLINE ); 242 setPixmap( 0, PIXMAP_OFFLINE );
243 } 243 }
244#endif 244#endif
245 setText( 0, account->getAccountName() ); 245 setText( 0, account->getAccountName() );
246 setOpen( true ); 246 setOpen( true );
247} 247}
248 248
249NNTPviewItem::~NNTPviewItem() 249NNTPviewItem::~NNTPviewItem()
250{ 250{
251 delete wrapper; 251 delete wrapper;
252} 252}
253 253
254AbstractMail *NNTPviewItem::getWrapper() 254AbstractMail *NNTPviewItem::getWrapper()
255{ 255{
256 return wrapper; 256 return wrapper;
257} 257}
258 258
259void NNTPviewItem::refresh( QValueList<RecMailP> & ) 259void NNTPviewItem::refresh( QValueList<RecMailP> & )
260{ 260{
261 refresh(); 261 refresh();
262} 262}
263 263
264void NNTPviewItem::refresh() 264void NNTPviewItem::refresh()
265{ 265{
266 if (account->getOffline()) return; 266 if (account->getOffline()) return;
267 QValueList<FolderP> *folders = wrapper->listFolders(); 267 QValueList<FolderP> *folders = wrapper->listFolders();
268 268
269 QListViewItem *child = firstChild(); 269 QListViewItem *child = firstChild();
270 while ( child ) 270 while ( child )
271 { 271 {
272 QListViewItem *tmp = child; 272 QListViewItem *tmp = child;
273 child = child->nextSibling(); 273 child = child->nextSibling();
274 delete tmp; 274 delete tmp;
275 } 275 }
276 QValueList<FolderP>::ConstIterator it; 276 QValueList<FolderP>::ConstIterator it;
277 QListViewItem*item = 0; 277 QListViewItem*item = 0;
278 for ( it = folders->begin(); it!=folders->end(); ++it) 278 for ( it = folders->begin(); it!=folders->end(); ++it)
279 { 279 {
280 item = new NNTPfolderItem( (*it), this , item ); 280 item = new NNTPfolderItem( (*it), this , item );
281 item->setSelectable( (*it)->may_select()); 281 item->setSelectable( (*it)->may_select());
282 } 282 }
283 delete folders; 283 delete folders;
284} 284}
285 285
286RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) 286RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
287{ 287{
288 288
289 return wrapper->fetchBody( mail ); 289 return wrapper->fetchBody( mail );
290} 290}
291 291
292QPopupMenu * NNTPviewItem::getContextMenu() 292QPopupMenu * NNTPviewItem::getContextMenu()
293{ 293{
294 QPopupMenu *m = new QPopupMenu(0); 294 QPopupMenu *m = new QPopupMenu(0);
295 if (m) 295 if (m)
296 { 296 {
297 if (!account->getOffline()) 297 if (!account->getOffline())
298 { 298 {
299 m->insertItem(QObject::tr("Disconnect",contextName),0); 299 m->insertItem(QObject::tr("Disconnect",contextName),0);
300 m->insertItem(QObject::tr("Set offline",contextName),1); 300 m->insertItem(QObject::tr("Set offline",contextName),1);
301 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); 301 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2);
302 } 302 }
303 else 303 else
304 { 304 {
305 m->insertItem(QObject::tr("Set online",contextName),1); 305 m->insertItem(QObject::tr("Set online",contextName),1);
306 } 306 }
307 } 307 }
308 return m; 308 return m;
309} 309}
310 310
311void NNTPviewItem::subscribeGroups() 311void NNTPviewItem::subscribeGroups()
312{ 312{
313 NNTPGroupsDlg dlg(account); 313 NNTPGroupsDlg dlg(account);
314 dlg.showMaximized(); 314 dlg.showMaximized();
315 if ( dlg.exec()== QDialog::Accepted ){ 315 if ( dlg.exec()== QDialog::Accepted ){
316 refresh(); 316 refresh();
317 } 317 }
318} 318}
319 319
320void NNTPviewItem::disconnect() 320void NNTPviewItem::disconnect()
321{ 321{
322 QListViewItem *child = firstChild(); 322 QListViewItem *child = firstChild();
323 while ( child ) 323 while ( child )
324 { 324 {
325 QListViewItem *tmp = child; 325 QListViewItem *tmp = child;
326 child = child->nextSibling(); 326 child = child->nextSibling();
327 delete tmp; 327 delete tmp;
328 } 328 }
329 wrapper->logout(); 329 wrapper->logout();
330} 330}
331 331
332void NNTPviewItem::setOnOffline() 332void NNTPviewItem::setOnOffline()
333{ 333{
334 if (!account->getOffline()) 334 if (!account->getOffline())
335 { 335 {
336 disconnect(); 336 disconnect();
337 } 337 }
338 account->setOffline(!account->getOffline()); 338 account->setOffline(!account->getOffline());
339 account->save(); 339 account->save();
340 //FIXME 340 //FIXME
341 SETPIX(PIXMAP_POP3FOLDER); 341 SETPIX(PIXMAP_POP3FOLDER);
342 refresh(); 342 refresh();
343} 343}
344 344
345void NNTPviewItem::contextMenuSelected(int which) 345void NNTPviewItem::contextMenuSelected(int which)
346{ 346{
347 switch (which) 347 switch (which)
348 { 348 {
349 case 0: 349 case 0:
350 disconnect(); 350 disconnect();
351 break; 351 break;
352 case 1: 352 case 1:
353 setOnOffline(); 353 setOnOffline();
354 break; 354 break;
355 case 2: 355 case 2:
356 subscribeGroups(); 356 subscribeGroups();
357 break; 357 break;
358 } 358 }
359} 359}
360 360
361NNTPfolderItem::~NNTPfolderItem() 361NNTPfolderItem::~NNTPfolderItem()
362{} 362{}
363 363
364NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) 364NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after )
365 : AccountViewItem( folderInit, parent,after ) 365 : AccountViewItem( folderInit, parent,after )
366{ 366{
367 nntp = parent; 367 nntp = parent;
368 if (folder->getDisplayName().lower()!="inbox") 368 if (folder->getDisplayName().lower()!="inbox")
369 { 369 {
370 setPixmap( 0, PIXMAP_POP3FOLDER ); 370 setPixmap( 0, PIXMAP_POP3FOLDER );
371 } 371 }
372 else 372 else
373 { 373 {
374 setPixmap( 0, PIXMAP_INBOXFOLDER); 374 setPixmap( 0, PIXMAP_INBOXFOLDER);
375 } 375 }
376 setText( 0, folder->getDisplayName() ); 376 setText( 0, folder->getDisplayName() );
377} 377}
378 378
379void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 379void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
380{ 380{
381 if (folder->may_select()) 381 if (folder->may_select())
382 nntp->getWrapper()->listMessages( folder->getName(),target ); 382 nntp->getWrapper()->listMessages( folder->getName(),target );
383} 383}
384 384
385RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) 385RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
386{ 386{
387 return nntp->getWrapper()->fetchBody(aMail); 387 return nntp->getWrapper()->fetchBody(aMail);
388} 388}
389 389
390QPopupMenu * NNTPfolderItem::getContextMenu() 390QPopupMenu * NNTPfolderItem::getContextMenu()
391{ 391{
392 QPopupMenu *m = new QPopupMenu(0); 392 QPopupMenu *m = new QPopupMenu(0);
393 if (m) 393 if (m)
394 { 394 {
395 m->insertItem(QObject::tr("Refresh header list",contextName),0); 395 m->insertItem(QObject::tr("Refresh header list",contextName),0);
396 m->insertItem(QObject::tr("Copy all postings",contextName),1); 396 m->insertItem(QObject::tr("Copy all postings",contextName),1);
397 } 397 }
398 return m; 398 return m;
399} 399}
400 400
401void NNTPfolderItem::downloadMails() 401void NNTPfolderItem::downloadMails()
402{ 402{
403 AccountView*bl = nntp->accountView(); 403 AccountView*bl = nntp->accountView();
404 if (!bl) return; 404 if (!bl) return;
405 bl->downloadMails(folder,nntp->getWrapper()); 405 bl->downloadMails(folder,nntp->getWrapper());
406} 406}
407 407
408void NNTPfolderItem::contextMenuSelected(int which) 408void NNTPfolderItem::contextMenuSelected(int which)
409{ 409{
410 AccountView * view = (AccountView*)listView(); 410 AccountView * view = (AccountView*)listView();
411 switch (which) 411 switch (which)
412 { 412 {
413 case 0: 413 case 0:
414 /* must be 'cause pop3 lists are cached */ 414 /* must be 'cause pop3 lists are cached */
415 nntp->getWrapper()->logout(); 415 nntp->getWrapper()->logout();
416 view->refreshCurrent(); 416 view->refreshCurrent();
417 break; 417 break;
418 case 1: 418 case 1:
419 downloadMails(); 419 downloadMails();
420 break; 420 break;
421 default: 421 default:
422 break; 422 break;
423 } 423 }
424} 424}
425 425
426/** 426/**
427 * IMAP Account stuff 427 * IMAP Account stuff
428 */ 428 */
429IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 429IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
430 : AccountViewItem( parent ) 430 : AccountViewItem( parent )
431{ 431{
432 account = a; 432 account = a;
433 wrapper = AbstractMail::getWrapper( account ); 433 wrapper = AbstractMail::getWrapper( account );
434 SETPIX(PIXMAP_IMAPFOLDER); 434 SETPIX(PIXMAP_IMAPFOLDER);
435 setText( 0, account->getAccountName() ); 435 setText( 0, account->getAccountName() );
436 setOpen( true ); 436 setOpen( true );
437} 437}
438 438
439IMAPviewItem::~IMAPviewItem() 439IMAPviewItem::~IMAPviewItem()
440{ 440{
441 delete wrapper; 441 delete wrapper;
442} 442}
443 443
444AbstractMail *IMAPviewItem::getWrapper() 444AbstractMail *IMAPviewItem::getWrapper()
445{ 445{
446 return wrapper; 446 return wrapper;
447} 447}
448 448
449void IMAPviewItem::refresh(QValueList<RecMailP>&) 449void IMAPviewItem::refresh(QValueList<RecMailP>&)
450{ 450{
451 refreshFolders(false); 451 refreshFolders(false);
452} 452}
453 453
454const QStringList&IMAPviewItem::subFolders() 454const QStringList&IMAPviewItem::subFolders()
455{ 455{
456 return currentFolders; 456 return currentFolders;
457} 457}
458 458
459void IMAPviewItem::refreshFolders(bool force) 459void IMAPviewItem::refreshFolders(bool force)
460{ 460{
461 if (childCount()>0 && force==false) return; 461 if (childCount()>0 && force==false) return;
462 if (account->getOffline()) return; 462 if (account->getOffline()) return;
463 463
464 removeChilds(); 464 removeChilds();
465 currentFolders.clear(); 465 currentFolders.clear();
466 QValueList<FolderP> * folders = wrapper->listFolders(); 466 QValueList<FolderP> * folders = wrapper->listFolders();
467 467
468 QValueList<FolderP>::Iterator it; 468 QValueList<FolderP>::Iterator it;
469 QListViewItem*item = 0; 469 QListViewItem*item = 0;
470 QListViewItem*titem = 0; 470 QListViewItem*titem = 0;
471 QString fname,del,search; 471 QString fname,del,search;
472 int pos; 472 int pos;
473 473
474 for ( it = folders->begin(); it!=folders->end(); ++it) 474 for ( it = folders->begin(); it!=folders->end(); ++it)
475 { 475 {
476 if ((*it)->getDisplayName().lower()=="inbox") 476 if ((*it)->getDisplayName().lower()=="inbox")
477 { 477 {
478 item = new IMAPfolderItem( (*it), this , item ); 478 item = new IMAPfolderItem( (*it), this , item );
479 folders->remove(it); 479 folders->remove(it);
480 break; 480 break;
481 } 481 }
482 } 482 }
483 for ( it = folders->begin(); it!=folders->end(); ++it) 483 for ( it = folders->begin(); it!=folders->end(); ++it)
484 { 484 {
485 fname = (*it)->getDisplayName(); 485 fname = (*it)->getDisplayName();
486 currentFolders.append((*it)->getName()); 486 currentFolders.append((*it)->getName());
487 pos = fname.findRev((*it)->Separator()); 487 pos = fname.findRev((*it)->Separator());
488 if (pos != -1) 488 if (pos != -1)
489 { 489 {
490 fname = fname.left(pos); 490 fname = fname.left(pos);
491 } 491 }
492 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 492 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
493 if (pitem) 493 if (pitem)
494 { 494 {
495 titem = item; 495 titem = item;
496 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); 496 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
497 /* setup the short name */ 497 /* setup the short name */
498 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); 498 item->setText(0,(*it)->getDisplayName().mid(pos+1));
499 item = titem; 499 item = titem;
500 } 500 }
501 else 501 else
502 { 502 {
503 item = new IMAPfolderItem( (*it), this , item ); 503 item = new IMAPfolderItem( (*it), this , item );
504 } 504 }
505 } 505 }
506 delete folders; 506 delete folders;
507} 507}
508 508
509QPopupMenu * IMAPviewItem::getContextMenu() 509QPopupMenu * IMAPviewItem::getContextMenu()
510{ 510{
511 QPopupMenu *m = new QPopupMenu(0); 511 QPopupMenu *m = new QPopupMenu(0);
512 if (m) 512 if (m)
513 { 513 {
514 if (!account->getOffline()) 514 if (!account->getOffline())
515 { 515 {
516 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 516 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
517 m->insertItem(QObject::tr("Create new folder",contextName),1); 517 m->insertItem(QObject::tr("Create new folder",contextName),1);
518 m->insertSeparator(); 518 m->insertSeparator();
519 m->insertItem(QObject::tr("Disconnect",contextName),2); 519 m->insertItem(QObject::tr("Disconnect",contextName),2);
520 m->insertItem(QObject::tr("Set offline",contextName),3); 520 m->insertItem(QObject::tr("Set offline",contextName),3);
521 m->insertSeparator(); 521 m->insertSeparator();
522 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 522 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
523 } 523 }
524 else 524 else
525 { 525 {
526 m->insertItem(QObject::tr("Set online",contextName),3); 526 m->insertItem(QObject::tr("Set online",contextName),3);
527 m->insertSeparator(); 527 m->insertSeparator();
528 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 528 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
529 } 529 }
530 } 530 }
531 return m; 531 return m;
532} 532}
533 533
534void IMAPviewItem::createNewFolder() 534void IMAPviewItem::createNewFolder()
535{ 535{
536 Newmdirdlg ndirdlg; 536 Newmdirdlg ndirdlg;
537 537
538 ndirdlg.showMaximized(); 538 ndirdlg.showMaximized();
539 if ( ndirdlg.exec() ) 539 if ( ndirdlg.exec() )
540 { 540 {
541 QString ndir = ndirdlg.Newdir(); 541 QString ndir = ndirdlg.Newdir();
542 bool makesubs = ndirdlg.subpossible(); 542 bool makesubs = ndirdlg.subpossible();
543 QString delemiter = "/"; 543 QString delemiter = "/";
544 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 544 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
545 if (item) 545 if (item)
546 { 546 {
547 delemiter = item->Delemiter(); 547 delemiter = item->Delemiter();
548 } 548 }
549 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) 549 if (wrapper->createMbox(ndir,0,delemiter,makesubs))
550 { 550 {
551 refreshFolders(true); 551 refreshFolders(true);
552 } 552 }
553 } 553 }
554} 554}
555 555
556void IMAPviewItem::contextMenuSelected(int id) 556void IMAPviewItem::contextMenuSelected(int id)
557{ 557{
558 558
559 switch (id) 559 switch (id)
560 { 560 {
561 case 0: 561 case 0:
562 refreshFolders(true); 562 refreshFolders(true);
563 break; 563 break;
564 case 1: 564 case 1:
565 createNewFolder(); 565 createNewFolder();
566 break; 566 break;
567 case 2: 567 case 2:
568 removeChilds(); 568 removeChilds();
569 wrapper->logout(); 569 wrapper->logout();
570 break; 570 break;
571 case 3: 571 case 3:
572 if (account->getOffline()==false) 572 if (account->getOffline()==false)
573 { 573 {
574 removeChilds(); 574 removeChilds();
575 wrapper->logout(); 575 wrapper->logout();
576 } 576 }
577 account->setOffline(!account->getOffline()); 577 account->setOffline(!account->getOffline());
578 account->save(); 578 account->save();
579 SETPIX(PIXMAP_IMAPFOLDER); 579 SETPIX(PIXMAP_IMAPFOLDER);
580 refreshFolders(false); 580 refreshFolders(false);
581 break; 581 break;
582 case GET_NEW_MAILS: // daunlood 582 case GET_NEW_MAILS: // daunlood
583 { 583 {
584 if (account->getOffline()) { 584 if (account->getOffline()) {
585 contextMenuSelected( 3 ); 585 contextMenuSelected( 3 );
586 } 586 }
587 AccountView*bl = accountView(); 587 AccountView*bl = accountView();
588 if (!bl) return; 588 if (!bl) return;
589 AccountViewItem* in = findSubItem( "inbox" , 0); 589 AccountViewItem* in = findSubItem( "inbox" , 0);
590 if ( ! in ) 590 if ( ! in )
591 return; 591 return;
592 bl->downloadMailsInbox(in->getFolder(),getWrapper()); 592 bl->downloadMailsInbox(in->getFolder(),getWrapper());
593 } 593 }
594 break; 594 break;
595 default: 595 default:
596 break; 596 break;
597 } 597 }
598} 598}
599 599
600RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 600RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
601{ 601{
602 return new RecBody(); 602 return new RecBody();
603} 603}
604 604
605bool IMAPviewItem::offline() 605bool IMAPviewItem::offline()
606{ 606{
607 return account->getOffline(); 607 return account->getOffline();
608} 608}
609 609
610IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 610IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
611 : AccountViewItem( folderInit, parent , after ) 611 : AccountViewItem( folderInit, parent , after )
612{ 612{
613 imap = parent; 613 imap = parent;
614 if (folder->getDisplayName().lower()!="inbox") 614 if (folder->getDisplayName().lower()!="inbox")
615 { 615 {
616 setPixmap( 0, PIXMAP_IMAPFOLDER ); 616 setPixmap( 0, PIXMAP_IMAPFOLDER );
617 } 617 }
618 else 618 else
619 { 619 {
620 setPixmap( 0, PIXMAP_INBOXFOLDER); 620 setPixmap( 0, PIXMAP_INBOXFOLDER);
621 } 621 }
622 setText( 0, folder->getDisplayName() ); 622 setText( 0, folder->getDisplayName() );
623} 623}
624 624
625IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 625IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
626 : AccountViewItem(folderInit, parent,after ) 626 : AccountViewItem(folderInit, parent,after )
627{ 627{
628 imap = master; 628 imap = master;
629 if (folder->getDisplayName().lower()!="inbox") 629 if (folder->getDisplayName().lower()!="inbox")
630 { 630 {
631 setPixmap( 0, PIXMAP_IMAPFOLDER ); 631 setPixmap( 0, PIXMAP_IMAPFOLDER );
632 } 632 }
633 else 633 else
634 { 634 {
635 setPixmap( 0, PIXMAP_INBOXFOLDER); 635 setPixmap( 0, PIXMAP_INBOXFOLDER);
636 } 636 }
637 setText( 0, folder->getDisplayName() ); 637 setText( 0, folder->getDisplayName() );
638} 638}
639 639
640IMAPfolderItem::~IMAPfolderItem() 640IMAPfolderItem::~IMAPfolderItem()
641{} 641{}
642 642
643const QString& IMAPfolderItem::Delemiter()const 643const QString& IMAPfolderItem::Delemiter()const
644{ 644{
645 return folder->Separator(); 645 return folder->Separator();
646} 646}
647 647
648void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 648void IMAPfolderItem::refresh(QValueList<RecMailP>&target)
649{ 649{
650 if (folder->may_select()) 650 if (folder->may_select())
651 { 651 {
652 imap->getWrapper()->listMessages( folder->getName(),target ); 652 imap->getWrapper()->listMessages( folder->getName(),target );
653 } 653 }
654 else 654 else
655 { 655 {
656 target.clear(); 656 target.clear();
657 } 657 }
658} 658}
659 659
660RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 660RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
661{ 661{
662 return imap->getWrapper()->fetchBody(aMail); 662 return imap->getWrapper()->fetchBody(aMail);
663} 663}
664 664
665QPopupMenu * IMAPfolderItem::getContextMenu() 665QPopupMenu * IMAPfolderItem::getContextMenu()
666{ 666{
667 QPopupMenu *m = new QPopupMenu(0); 667 QPopupMenu *m = new QPopupMenu(0);
668 if (m) 668 if (m)
669 { 669 {
670 if (folder->may_select()) 670 if (folder->may_select())
671 { 671 {
672 m->insertItem(QObject::tr("Refresh header list",contextName),0); 672 m->insertItem(QObject::tr("Refresh header list",contextName),0);
673 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); 673 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
674 m->insertItem(QObject::tr("Delete all mails",contextName),1); 674 m->insertItem(QObject::tr("Delete all mails",contextName),1);
675 } 675 }
676 if (folder->no_inferior()==false) 676 if (folder->no_inferior()==false)
677 { 677 {
678 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 678 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
679 } 679 }
680 if (folder->getDisplayName().lower()!="inbox") 680 if (folder->getDisplayName().lower()!="inbox")
681 { 681 {
682 m->insertItem(QObject::tr("Delete folder",contextName),3); 682 m->insertItem(QObject::tr("Delete folder",contextName),3);
683 } 683 }
684 } 684 }
685 return m; 685 return m;
686} 686}
687 687
688void IMAPfolderItem::createNewFolder() 688void IMAPfolderItem::createNewFolder()
689{ 689{
690 Newmdirdlg ndirdlg; 690 Newmdirdlg ndirdlg;
691 ndirdlg.showMaximized(); 691 ndirdlg.showMaximized();
692 if ( ndirdlg.exec() ) 692 if ( ndirdlg.exec() )
693 { 693 {
694 QString ndir = ndirdlg.Newdir(); 694 QString ndir = ndirdlg.Newdir();
695 bool makesubs = ndirdlg.subpossible(); 695 bool makesubs = ndirdlg.subpossible();
696 QString delemiter = Delemiter(); 696 QString delemiter = Delemiter();
697 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) 697 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
698 { 698 {
699 imap->refreshFolders(true); 699 imap->refreshFolders(true);
700 } 700 }
701 } 701 }
702} 702}
703 703
704void IMAPfolderItem::deleteFolder() 704void IMAPfolderItem::deleteFolder()
705{ 705{
706 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 706 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
707 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()),
708 QObject::tr("Yes",contextName), 708 QObject::tr("Yes",contextName),
709 QObject::tr("No",contextName),QString::null,1,1); 709 QObject::tr("No",contextName),QString::null,1,1);
710 710
711 if (yesno == 0) 711 if (yesno == 0)
712 { 712 {
713 if (imap->getWrapper()->deleteMbox(folder)) 713 if (imap->getWrapper()->deleteMbox(folder))
714 { 714 {
715 QListView*v=listView(); 715 QListView*v=listView();
716 IMAPviewItem * box = imap; 716 IMAPviewItem * box = imap;
717 /* 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
718 * any member of it after that call!!*/ 718 * any member of it after that call!!*/
719 imap->refreshFolders(true); 719 imap->refreshFolders(true);
720 if (v) 720 if (v)
721 { 721 {
722 v->setSelected(box,true); 722 v->setSelected(box,true);
723 } 723 }
724 } 724 }
725 } 725 }
726} 726}
727 727
728void IMAPfolderItem::downloadMails() 728void IMAPfolderItem::downloadMails()
729{ 729{
730 AccountView*bl = imap->accountView(); 730 AccountView*bl = imap->accountView();
731 if (!bl) return; 731 if (!bl) return;
732 bl->downloadMails(folder,imap->getWrapper()); 732 bl->downloadMails(folder,imap->getWrapper());
733} 733}
734 734
735void IMAPfolderItem::contextMenuSelected(int id) 735void IMAPfolderItem::contextMenuSelected(int id)
736{ 736{
737 737
738 AccountView * view = (AccountView*)listView(); 738 AccountView * view = (AccountView*)listView();
739 switch(id) 739 switch(id)
740 { 740 {
741 case 0: 741 case 0:
742 view->refreshCurrent(); 742 view->refreshCurrent();
743 break; 743 break;
744 case 1: 744 case 1:
745 deleteAllMail(imap->getWrapper(),folder); 745 deleteAllMail(imap->getWrapper(),folder);
746 break; 746 break;
747 case 2: 747 case 2:
748 createNewFolder(); 748 createNewFolder();
749 break; 749 break;
750 case 3: 750 case 3:
751 deleteFolder(); 751 deleteFolder();
752 break; 752 break;
753 case 4: 753 case 4:
754 downloadMails(); 754 downloadMails();
755 break; 755 break;
756 default: 756 default:
757 break; 757 break;
758 } 758 }
759} 759}
760 760
761/** 761/**
762 * MH Account stuff 762 * MH Account stuff
763 */ 763 */
764/* 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
765 POP3 and MBOX */ 765 POP3 and MBOX */
766MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 766MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
767 : AccountViewItem( parent ) 767 : AccountViewItem( parent )
768{ 768{
769 m_Path = aPath; 769 m_Path = aPath;
770 /* 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 */
771 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 771 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
772 setPixmap( 0, PIXMAP_LOCALFOLDER ); 772 setPixmap( 0, PIXMAP_LOCALFOLDER );
773 setText( 0, " Local Folders" ); 773 setText( 0, " Local Folders" );
774 setOpen( true ); 774 setOpen( true );
775 folder = 0; 775 folder = 0;
776} 776}
777 777
778MHviewItem::~MHviewItem() 778MHviewItem::~MHviewItem()
779{ 779{
780 delete wrapper; 780 delete wrapper;
781} 781}
782 782
783AbstractMail *MHviewItem::getWrapper() 783AbstractMail *MHviewItem::getWrapper()
784{ 784{
785 return wrapper; 785 return wrapper;
786} 786}
787 787
788void MHviewItem::refresh( QValueList<RecMailP> & target) 788void MHviewItem::refresh( QValueList<RecMailP> & target)
789{ 789{
790 refresh(false); 790 refresh(false);
791 getWrapper()->listMessages( "",target ); 791 getWrapper()->listMessages( "",target );
792} 792}
793 793
794void MHviewItem::refresh(bool force) 794void MHviewItem::refresh(bool force)
795{ 795{
796 if (childCount()>0 && force==false) return; 796 if (childCount()>0 && force==false) return;
797 removeChilds(); 797 removeChilds();
798 currentFolders.clear(); 798 currentFolders.clear();
799 QValueList<FolderP> *folders = wrapper->listFolders(); 799 QValueList<FolderP> *folders = wrapper->listFolders();
800 QValueList<FolderP>::ConstIterator it; 800 QValueList<FolderP>::ConstIterator it;
801 MHfolderItem*item = 0; 801 MHfolderItem*item = 0;
802 MHfolderItem*pmaster = 0; 802 MHfolderItem*pmaster = 0;
803 QString fname = ""; 803 QString fname = "";
804 int pos; 804 int pos;
805 for ( it = folders->begin(); it!=folders->end(); ++it) 805 for ( it = folders->begin(); it!=folders->end(); ++it)
806 { 806 {
807 fname = (*it)->getDisplayName(); 807 fname = (*it)->getDisplayName();
808 /* this folder itself */ 808 /* this folder itself */
809 if (fname=="/") 809 if (fname=="/")
810 { 810 {
811 currentFolders.append(fname); 811 currentFolders.append(fname);
812 folder = (*it); 812 folder = (*it);
813 continue; 813 continue;
814 } 814 }
815 currentFolders.append(fname); 815 currentFolders.append(fname);
816 pos = fname.findRev("/"); 816 pos = fname.findRev("/");
817 if (pos > 0) 817 if (pos > 0)
818 { 818 {
819 fname = fname.left(pos); 819 fname = fname.left(pos);
820 pmaster = (MHfolderItem*)findSubItem(fname); 820 pmaster = (MHfolderItem*)findSubItem(fname);
821 } 821 }
822 else 822 else
823 { 823 {
824 pmaster = 0; 824 pmaster = 0;
825 } 825 }
826 if (pmaster) 826 if (pmaster)
827 { 827 {
828 item = new MHfolderItem( (*it), pmaster, item, this ); 828 item = new MHfolderItem( (*it), pmaster, item, this );
829 } 829 }
830 else 830 else
831 { 831 {
832 item = new MHfolderItem( (*it), this , item ); 832 item = new MHfolderItem( (*it), this , item );
833 } 833 }
834 item->setSelectable((*it)->may_select()); 834 item->setSelectable((*it)->may_select());
835 } 835 }
836 delete folders; 836 delete folders;
837} 837}
838 838
839RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) 839RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
840{ 840{
841 841
842 return wrapper->fetchBody( mail ); 842 return wrapper->fetchBody( mail );
843} 843}
844 844
845QPopupMenu * MHviewItem::getContextMenu() 845QPopupMenu * MHviewItem::getContextMenu()
846{ 846{
847 QPopupMenu *m = new QPopupMenu(0); 847 QPopupMenu *m = new QPopupMenu(0);
848 if (m) 848 if (m)
849 { 849 {
850 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 850 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
851 m->insertItem(QObject::tr("Create new folder",contextName),1); 851 m->insertItem(QObject::tr("Create new folder",contextName),1);
852 m->insertItem(QObject::tr("Delete all mails",contextName),2); 852 m->insertItem(QObject::tr("Delete all mails",contextName),2);
853 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); 853 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
854 } 854 }
855 return m; 855 return m;
856} 856}
857 857
858void MHviewItem::createFolder() 858void MHviewItem::createFolder()
859{ 859{
860 Newmdirdlg ndirdlg(0,0,true); 860 Newmdirdlg ndirdlg(0,0,true);
861 ndirdlg.showMaximized(); 861 ndirdlg.showMaximized();
862 if ( ndirdlg.exec() ) 862 if ( ndirdlg.exec() )
863 { 863 {
864 QString ndir = ndirdlg.Newdir(); 864 QString ndir = ndirdlg.Newdir();
865 if (wrapper->createMbox(ndir)) 865 if (wrapper->createMbox(ndir))
866 { 866 {
867 refresh(true); 867 refresh(true);
868 } 868 }
869 } 869 }
870} 870}
871 871
872void MHviewItem::downloadMails() 872void MHviewItem::downloadMails()
873{ 873{
874 AccountView*bl = accountView(); 874 AccountView*bl = accountView();
875 if (!bl) return; 875 if (!bl) return;
876 bl->downloadMails(folder,getWrapper()); 876 bl->downloadMails(folder,getWrapper());
877} 877}
878 878
879QStringList MHviewItem::subFolders() 879QStringList MHviewItem::subFolders()
880{ 880{
881 return currentFolders; 881 return currentFolders;
882} 882}
883 883
884void MHviewItem::contextMenuSelected(int which) 884void MHviewItem::contextMenuSelected(int which)
885{ 885{
886 switch (which) 886 switch (which)
887 { 887 {
888 case 0: 888 case 0:
889 refresh(true); 889 refresh(true);
890 break; 890 break;
891 case 1: 891 case 1:
892 createFolder(); 892 createFolder();
893 break; 893 break;
894 case 2: 894 case 2:
895 deleteAllMail(getWrapper(),folder); 895 deleteAllMail(getWrapper(),folder);
896 break; 896 break;
897 case 3: 897 case 3:
898 downloadMails(); 898 downloadMails();
899 break; 899 break;
900 default: 900 default:
901 break; 901 break;
902 } 902 }
903} 903}
904 904
905MHfolderItem::~MHfolderItem() 905MHfolderItem::~MHfolderItem()
906{} 906{}
907 907
908MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) 908MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
909 : AccountViewItem(folderInit, parent,after ) 909 : AccountViewItem(folderInit, parent,after )
910{ 910{
911 mbox = parent; 911 mbox = parent;
912 initName(); 912 initName();
913} 913}
914 914
915MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 915MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
916 : AccountViewItem(folderInit, parent,after ) 916 : AccountViewItem(folderInit, parent,after )
917{ 917{
918 folder = folderInit; 918 folder = folderInit;
919 mbox = master; 919 mbox = master;
920 initName(); 920 initName();
921} 921}
922 922
923void MHfolderItem::initName() 923void MHfolderItem::initName()
924{ 924{
925 QString bName = folder->getDisplayName(); 925 QString bName = folder->getDisplayName();
926 if (bName.startsWith("/")&&bName.length()>1) 926 if (bName.startsWith("/")&&bName.length()>1)
927 { 927 {
928 bName.replace(0,1,""); 928 bName.replace(0,1,"");
929 } 929 }
930 int pos = bName.findRev("/"); 930 int pos = bName.findRev("/");
931 if (pos > 0) 931 if (pos > 0)
932 { 932 {
933 bName.replace(0,pos+1,""); 933 bName.replace(0,pos+1,"");
934 } 934 }
935 if (bName.lower() == "outgoing") 935 if (bName.lower() == "outgoing")
936 { 936 {
937 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 937 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
938 } 938 }
939 else if (bName.lower() == "inbox") 939 else if (bName.lower() == "inbox")
940 { 940 {
941 setPixmap( 0, PIXMAP_INBOXFOLDER); 941 setPixmap( 0, PIXMAP_INBOXFOLDER);
942 } else if (bName.lower() == "drafts") { 942 } else if (bName.lower() == "drafts") {
943 setPixmap(0, SmallIcon ("edit")); 943 setPixmap(0, SmallIcon ("edit"));
944 } else { 944 } else {
945 setPixmap( 0, PIXMAP_MBOXFOLDER ); 945 setPixmap( 0, PIXMAP_MBOXFOLDER );
946 } 946 }
947 setText( 0, bName ); 947 setText( 0, bName );
948} 948}
949 949
950const FolderP&MHfolderItem::getFolder()const 950const FolderP&MHfolderItem::getFolder()const
951{ 951{
952 return folder; 952 return folder;
953} 953}
954 954
955void MHfolderItem::refresh(QValueList<RecMailP>&target) 955void MHfolderItem::refresh(QValueList<RecMailP>&target)
956{ 956{
957 if (folder->may_select()) 957 if (folder->may_select())
958 mbox->getWrapper()->listMessages( folder->getName(),target ); 958 mbox->getWrapper()->listMessages( folder->getName(),target );
959} 959}
960 960
961RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) 961RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
962{ 962{
963 return mbox->getWrapper()->fetchBody(aMail); 963 return mbox->getWrapper()->fetchBody(aMail);
964} 964}
965 965
966void MHfolderItem::deleteFolder() 966void MHfolderItem::deleteFolder()
967{ 967{
968 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 968 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
969 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()),
970 QObject::tr("Yes",contextName), 970 QObject::tr("Yes",contextName),
971 QObject::tr("No",contextName),QString::null,1,1); 971 QObject::tr("No",contextName),QString::null,1,1);
972 972
973 if (yesno == 0) 973 if (yesno == 0)
974 { 974 {
975 if (mbox->getWrapper()->deleteMbox(folder)) 975 if (mbox->getWrapper()->deleteMbox(folder))
976 { 976 {
977 QListView*v=listView(); 977 QListView*v=listView();
978 MHviewItem * box = mbox; 978 MHviewItem * box = mbox;
979 /* 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
980 * any member of it after that call!!*/ 980 * any member of it after that call!!*/
981 mbox->refresh(true); 981 mbox->refresh(true);
982 if (v) 982 if (v)
983 { 983 {
984 v->setSelected(box,true); 984 v->setSelected(box,true);
985 } 985 }
986 } 986 }
987 } 987 }
988} 988}
989 989
990QPopupMenu * MHfolderItem::getContextMenu() 990QPopupMenu * MHfolderItem::getContextMenu()
991{ 991{
992 QPopupMenu *m = new QPopupMenu(0); 992 QPopupMenu *m = new QPopupMenu(0);
993 if (m) 993 if (m)
994 { 994 {
995 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 995 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
996 m->insertItem(QObject::tr("Delete all mails",contextName),0); 996 m->insertItem(QObject::tr("Delete all mails",contextName),0);
997 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 997 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
998 m->insertItem(QObject::tr("Delete folder",contextName),1); 998 m->insertItem(QObject::tr("Delete folder",contextName),1);
999 } 999 }
1000 return m; 1000 return m;
1001} 1001}
1002 1002
1003void MHfolderItem::downloadMails() 1003void MHfolderItem::downloadMails()
1004{ 1004{
1005 AccountView*bl = mbox->accountView(); 1005 AccountView*bl = mbox->accountView();
1006 if (!bl) return; 1006 if (!bl) return;
1007 bl->downloadMails(folder,mbox->getWrapper()); 1007 bl->downloadMails(folder,mbox->getWrapper());
1008} 1008}
1009 1009
1010void MHfolderItem::createFolder() 1010void MHfolderItem::createFolder()
1011{ 1011{
1012 Newmdirdlg ndirdlg(0,0,true); 1012 Newmdirdlg ndirdlg(0,0,true);
1013 ndirdlg.showMaximized(); 1013 ndirdlg.showMaximized();
1014 if (ndirdlg.exec() ) 1014 if (ndirdlg.exec() )
1015 { 1015 {
1016 QString ndir = ndirdlg.Newdir(); 1016 QString ndir = ndirdlg.Newdir();
1017 if (mbox->getWrapper()->createMbox(ndir,folder)) 1017 if (mbox->getWrapper()->createMbox(ndir,folder))
1018 { 1018 {
1019 QListView*v=listView(); 1019 QListView*v=listView();
1020 MHviewItem * box = mbox; 1020 MHviewItem * box = mbox;
1021 /* 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
1022 * any member of it after that call!!*/ 1022 * any member of it after that call!!*/
1023 mbox->refresh(true); 1023 mbox->refresh(true);
1024 if (v) 1024 if (v)
1025 { 1025 {
1026 v->setSelected(box,true); 1026 v->setSelected(box,true);
1027 } 1027 }
1028 } 1028 }
1029 } 1029 }
1030} 1030}
1031 1031
1032void MHfolderItem::contextMenuSelected(int which) 1032void MHfolderItem::contextMenuSelected(int which)
1033{ 1033{
1034 switch(which) 1034 switch(which)
1035 { 1035 {
1036 case 0: 1036 case 0:
1037 deleteAllMail(mbox->getWrapper(),folder); 1037 deleteAllMail(mbox->getWrapper(),folder);
1038 break; 1038 break;
1039 case 1: 1039 case 1:
1040 deleteFolder(); 1040 deleteFolder();
1041 break; 1041 break;
1042 case 2: 1042 case 2:
1043 downloadMails(); 1043 downloadMails();
1044 break; 1044 break;
1045 case 3: 1045 case 3:
1046 createFolder(); 1046 createFolder();
1047 break; 1047 break;
1048 default: 1048 default:
1049 break; 1049 break;
1050 } 1050 }
1051} 1051}
1052 1052
1053bool MHfolderItem::isDraftfolder() 1053bool MHfolderItem::isDraftfolder()
1054{ 1054{
1055 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; 1055 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1056 return false; 1056 return false;
1057} 1057}
1058 1058
1059/** 1059/**
1060 * Generic stuff 1060 * Generic stuff
1061 */ 1061 */
1062 1062
1063const QString AccountViewItem::contextName="AccountViewItem"; 1063const QString AccountViewItem::contextName="AccountViewItem";
1064 1064
1065AccountViewItem::AccountViewItem( AccountView *parent ) 1065AccountViewItem::AccountViewItem( AccountView *parent )
1066 : QListViewItem( parent ) 1066 : QListViewItem( parent )
1067{ 1067{
1068 init(); 1068 init();
1069 m_Backlink = parent; 1069 m_Backlink = parent;
1070} 1070}
1071 1071
1072AccountViewItem::AccountViewItem( QListViewItem *parent) 1072AccountViewItem::AccountViewItem( QListViewItem *parent)
1073 : QListViewItem( parent),folder(0) 1073 : QListViewItem( parent),folder(0)
1074{ 1074{
1075 init(); 1075 init();
1076} 1076}
1077 1077
1078AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1078AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
1079 :QListViewItem( parent,after ),folder(0) 1079 :QListViewItem( parent,after ),folder(0)
1080{ 1080{
1081 init(); 1081 init();
1082} 1082}
1083 1083
1084AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) 1084AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
1085 :QListViewItem( parent,after ),folder(folderInit) 1085 :QListViewItem( parent,after ),folder(folderInit)
1086{ 1086{
1087 init(); 1087 init();
1088} 1088}
1089 1089
1090void AccountViewItem::init() 1090void AccountViewItem::init()
1091{ 1091{
1092 m_Backlink = 0; 1092 m_Backlink = 0;
1093} 1093}
1094 1094
1095AccountViewItem::~AccountViewItem() 1095AccountViewItem::~AccountViewItem()
1096{ 1096{
1097 folder = 0; 1097 folder = 0;
1098} 1098}
1099 1099
1100AccountView*AccountViewItem::accountView() 1100AccountView*AccountViewItem::accountView()
1101{ 1101{
1102 return m_Backlink; 1102 return m_Backlink;
1103} 1103}
1104 1104
1105void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) 1105void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder)
1106{ 1106{
1107 if (!wrapper) return; 1107 if (!wrapper) return;
1108 QString fname=""; 1108 QString fname="";
1109 if (folder) fname = folder->getDisplayName(); 1109 if (folder) fname = folder->getDisplayName();
1110 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 1110 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
1111 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).
1112 arg(fname), 1112 arg(fname),
1113 QObject::tr("Yes",contextName), 1113 QObject::tr("Yes",contextName),
1114 QObject::tr("No",contextName),QString::null,1,1); 1114 QObject::tr("No",contextName),QString::null,1,1);
1115 1115
1116 if (yesno == 0) 1116 if (yesno == 0)
1117 { 1117 {
1118 if (wrapper->deleteAllMail(folder)) 1118 if (wrapper->deleteAllMail(folder))
1119 { 1119 {
1120 AccountView * view = (AccountView*)listView(); 1120 AccountView * view = (AccountView*)listView();
1121 if (view) view->refreshCurrent(); 1121 if (view) view->refreshCurrent();
1122 } 1122 }
1123 } 1123 }
1124} 1124}
1125 1125
1126void AccountViewItem::removeChilds() 1126void AccountViewItem::removeChilds()
1127{ 1127{
1128 QListViewItem *child = firstChild(); 1128 QListViewItem *child = firstChild();
1129 while ( child ) 1129 while ( child )
1130 { 1130 {
1131 QListViewItem *tmp = child; 1131 QListViewItem *tmp = child;
1132 child = child->nextSibling(); 1132 child = child->nextSibling();
1133 delete tmp; 1133 delete tmp;
1134 } 1134 }
1135} 1135}
1136 1136
1137bool AccountViewItem::matchName(const QString&name)const 1137bool AccountViewItem::matchName(const QString&name)const
1138{ 1138{
1139 if (!folder) return false; 1139 if (!folder) return false;
1140 return folder->getDisplayName().lower()==name.lower(); 1140 return folder->getDisplayName().lower()==name.lower();
1141} 1141}
1142 1142
1143 1143
1144AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 1144AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
1145{ 1145{
1146 AccountViewItem*pitem,*sitem; 1146 AccountViewItem*pitem,*sitem;
1147 if (!start) pitem = (AccountViewItem*)firstChild(); 1147 if (!start) pitem = (AccountViewItem*)firstChild();
1148 else pitem = (AccountViewItem*)start->firstChild(); 1148 else pitem = (AccountViewItem*)start->firstChild();
1149 while (pitem) 1149 while (pitem)
1150 { 1150 {
1151 if (pitem->matchName(path)) 1151 if (pitem->matchName(path))
1152 { 1152 {
1153 break; 1153 break;
1154 } 1154 }
1155 if (pitem->childCount()>0) 1155 if (pitem->childCount()>0)
1156 { 1156 {
1157 sitem = findSubItem(path,pitem); 1157 sitem = findSubItem(path,pitem);
1158 if (sitem) 1158 if (sitem)
1159 { 1159 {
1160 pitem = sitem; 1160 pitem = sitem;
1161 break; 1161 break;
1162 } 1162 }
1163 } 1163 }
1164 pitem=(AccountViewItem*)pitem->nextSibling(); 1164 pitem=(AccountViewItem*)pitem->nextSibling();
1165 } 1165 }
1166 return pitem; 1166 return pitem;
1167} 1167}
1168 1168
1169bool AccountViewItem::isDraftfolder() 1169bool AccountViewItem::isDraftfolder()
1170{ 1170{
1171 return false; 1171 return false;
1172} 1172}