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