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