-rw-r--r-- | noncore/net/mail/accountitem.cpp | 842 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 164 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 818 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 162 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 2 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 1 |
6 files changed, 1020 insertions, 969 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp new file mode 100644 index 0000000..2d3cd4b --- a/dev/null +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -0,0 +1,842 @@ | |||
1 | #include "accountitem.h" | ||
2 | #include "accountview.h" | ||
3 | #include <qpopupmenu.h> | ||
4 | #include <qmessagebox.h> | ||
5 | #include "selectstore.h" | ||
6 | #include "newmaildir.h" | ||
7 | #include <libmailwrapper/mailtypes.h> | ||
8 | #include <libmailwrapper/abstractmail.h> | ||
9 | #include <libmailwrapper/mailwrapper.h> | ||
10 | #include "defines.h" | ||
11 | |||
12 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | ||
13 | /** | ||
14 | * POP3 Account stuff | ||
15 | */ | ||
16 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | ||
17 | : AccountViewItem( parent ) | ||
18 | { | ||
19 | account = a; | ||
20 | wrapper = AbstractMail::getWrapper( account ); | ||
21 | SETPIX(PIXMAP_POP3FOLDER); | ||
22 | #if 0 | ||
23 | if (!account->getOffline()) { | ||
24 | setPixmap( 0, ); | ||
25 | } else { | ||
26 | setPixmap( 0, PIXMAP_OFFLINE ); | ||
27 | } | ||
28 | #endif | ||
29 | setText( 0, account->getAccountName() ); | ||
30 | setOpen( true ); | ||
31 | } | ||
32 | |||
33 | POP3viewItem::~POP3viewItem() | ||
34 | { | ||
35 | delete wrapper; | ||
36 | } | ||
37 | |||
38 | AbstractMail *POP3viewItem::getWrapper() | ||
39 | { | ||
40 | return wrapper; | ||
41 | } | ||
42 | |||
43 | void POP3viewItem::refresh( QList<RecMail> & ) | ||
44 | { | ||
45 | refresh(); | ||
46 | } | ||
47 | |||
48 | void POP3viewItem::refresh() | ||
49 | { | ||
50 | if (account->getOffline()) return; | ||
51 | QList<Folder> *folders = wrapper->listFolders(); | ||
52 | QListViewItem *child = firstChild(); | ||
53 | while ( child ) { | ||
54 | QListViewItem *tmp = child; | ||
55 | child = child->nextSibling(); | ||
56 | delete tmp; | ||
57 | } | ||
58 | Folder *it; | ||
59 | QListViewItem*item = 0; | ||
60 | for ( it = folders->first(); it; it = folders->next() ) { | ||
61 | item = new POP3folderItem( it, this , item ); | ||
62 | item->setSelectable(it->may_select()); | ||
63 | } | ||
64 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
65 | folders->setAutoDelete(false); | ||
66 | delete folders; | ||
67 | } | ||
68 | |||
69 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | ||
70 | { | ||
71 | qDebug( "POP3 fetchBody" ); | ||
72 | return wrapper->fetchBody( mail ); | ||
73 | } | ||
74 | |||
75 | QPopupMenu * POP3viewItem::getContextMenu() | ||
76 | { | ||
77 | QPopupMenu *m = new QPopupMenu(0); | ||
78 | if (m) { | ||
79 | if (!account->getOffline()) { | ||
80 | m->insertItem(QObject::tr("Disconnect",contextName),0); | ||
81 | m->insertItem(QObject::tr("Set offline",contextName),1); | ||
82 | } else { | ||
83 | m->insertItem(QObject::tr("Set online",contextName),1); | ||
84 | } | ||
85 | } | ||
86 | return m; | ||
87 | } | ||
88 | |||
89 | void POP3viewItem::disconnect() | ||
90 | { | ||
91 | QListViewItem *child = firstChild(); | ||
92 | while ( child ) { | ||
93 | QListViewItem *tmp = child; | ||
94 | child = child->nextSibling(); | ||
95 | delete tmp; | ||
96 | } | ||
97 | wrapper->logout(); | ||
98 | } | ||
99 | |||
100 | void POP3viewItem::setOnOffline() | ||
101 | { | ||
102 | if (!account->getOffline()) { | ||
103 | disconnect(); | ||
104 | } | ||
105 | account->setOffline(!account->getOffline()); | ||
106 | account->save(); | ||
107 | SETPIX(PIXMAP_POP3FOLDER); | ||
108 | refresh(); | ||
109 | } | ||
110 | |||
111 | void POP3viewItem::contextMenuSelected(int which) | ||
112 | { | ||
113 | switch (which) { | ||
114 | case 0: | ||
115 | disconnect(); | ||
116 | break; | ||
117 | case 1: | ||
118 | setOnOffline(); | ||
119 | break; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | POP3folderItem::~POP3folderItem() | ||
124 | { | ||
125 | } | ||
126 | |||
127 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | ||
128 | : AccountViewItem( parent,after ) | ||
129 | { | ||
130 | folder = folderInit; | ||
131 | pop3 = parent; | ||
132 | if (folder->getDisplayName().lower()!="inbox") { | ||
133 | setPixmap( 0, PIXMAP_POP3FOLDER ); | ||
134 | } else { | ||
135 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
136 | } | ||
137 | setText( 0, folder->getDisplayName() ); | ||
138 | } | ||
139 | |||
140 | void POP3folderItem::refresh(QList<RecMail>&target) | ||
141 | { | ||
142 | if (folder->may_select()) | ||
143 | pop3->getWrapper()->listMessages( folder->getName(),target ); | ||
144 | } | ||
145 | |||
146 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | ||
147 | { | ||
148 | return pop3->getWrapper()->fetchBody(aMail); | ||
149 | } | ||
150 | |||
151 | QPopupMenu * POP3folderItem::getContextMenu() | ||
152 | { | ||
153 | QPopupMenu *m = new QPopupMenu(0); | ||
154 | if (m) { | ||
155 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
156 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | ||
157 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
158 | } | ||
159 | return m; | ||
160 | } | ||
161 | |||
162 | void POP3folderItem::downloadMails() | ||
163 | { | ||
164 | AccountView*bl = pop3->accountView(); | ||
165 | if (!bl) return; | ||
166 | bl->downloadMails(folder,pop3->getWrapper()); | ||
167 | } | ||
168 | |||
169 | void POP3folderItem::contextMenuSelected(int which) | ||
170 | { | ||
171 | AccountView * view = (AccountView*)listView(); | ||
172 | switch (which) { | ||
173 | case 0: | ||
174 | /* must be 'cause pop3 lists are cached */ | ||
175 | pop3->getWrapper()->logout(); | ||
176 | view->refreshCurrent(); | ||
177 | break; | ||
178 | case 1: | ||
179 | deleteAllMail(pop3->getWrapper(),folder); | ||
180 | break; | ||
181 | case 2: | ||
182 | downloadMails(); | ||
183 | break; | ||
184 | default: | ||
185 | break; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * IMAP Account stuff | ||
191 | */ | ||
192 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | ||
193 | : AccountViewItem( parent ) | ||
194 | { | ||
195 | account = a; | ||
196 | wrapper = AbstractMail::getWrapper( account ); | ||
197 | SETPIX(PIXMAP_IMAPFOLDER); | ||
198 | setText( 0, account->getAccountName() ); | ||
199 | setOpen( true ); | ||
200 | } | ||
201 | |||
202 | IMAPviewItem::~IMAPviewItem() | ||
203 | { | ||
204 | delete wrapper; | ||
205 | } | ||
206 | |||
207 | AbstractMail *IMAPviewItem::getWrapper() | ||
208 | { | ||
209 | return wrapper; | ||
210 | } | ||
211 | |||
212 | void IMAPviewItem::refresh(QList<RecMail>&) | ||
213 | { | ||
214 | refreshFolders(false); | ||
215 | } | ||
216 | |||
217 | const QStringList&IMAPviewItem::subFolders() | ||
218 | { | ||
219 | return currentFolders; | ||
220 | } | ||
221 | |||
222 | void IMAPviewItem::refreshFolders(bool force) | ||
223 | { | ||
224 | if (childCount()>0 && force==false) return; | ||
225 | if (account->getOffline()) return; | ||
226 | |||
227 | removeChilds(); | ||
228 | currentFolders.clear(); | ||
229 | QList<Folder> *folders = wrapper->listFolders(); | ||
230 | |||
231 | Folder *it; | ||
232 | QListViewItem*item = 0; | ||
233 | QListViewItem*titem = 0; | ||
234 | QString fname,del,search; | ||
235 | int pos; | ||
236 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
237 | folders->setAutoDelete(false); | ||
238 | |||
239 | for ( it = folders->first(); it; it = folders->next() ) { | ||
240 | if (it->getDisplayName().lower()=="inbox") { | ||
241 | item = new IMAPfolderItem( it, this , item ); | ||
242 | folders->remove(it); | ||
243 | qDebug("inbox found"); | ||
244 | break; | ||
245 | } | ||
246 | } | ||
247 | for ( it = folders->first(); it; it = folders->next() ) { | ||
248 | fname = it->getDisplayName(); | ||
249 | currentFolders.append(it->getName()); | ||
250 | pos = fname.findRev(it->Separator()); | ||
251 | if (pos != -1) { | ||
252 | fname = fname.left(pos); | ||
253 | } | ||
254 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | ||
255 | if (pitem) { | ||
256 | titem = item; | ||
257 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | ||
258 | /* setup the short name */ | ||
259 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | ||
260 | item = titem; | ||
261 | } else { | ||
262 | item = new IMAPfolderItem( it, this , item ); | ||
263 | } | ||
264 | } | ||
265 | delete folders; | ||
266 | } | ||
267 | |||
268 | QPopupMenu * IMAPviewItem::getContextMenu() | ||
269 | { | ||
270 | QPopupMenu *m = new QPopupMenu(0); | ||
271 | if (m) { | ||
272 | if (!account->getOffline()) { | ||
273 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
274 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
275 | m->insertSeparator(); | ||
276 | m->insertItem(QObject::tr("Disconnect",contextName),2); | ||
277 | m->insertItem(QObject::tr("Set offline",contextName),3); | ||
278 | } else { | ||
279 | m->insertItem(QObject::tr("Set online",contextName),3); | ||
280 | } | ||
281 | } | ||
282 | return m; | ||
283 | } | ||
284 | |||
285 | void IMAPviewItem::createNewFolder() | ||
286 | { | ||
287 | Newmdirdlg ndirdlg; | ||
288 | ndirdlg.showMaximized(); | ||
289 | if (ndirdlg.exec()) { | ||
290 | QString ndir = ndirdlg.Newdir(); | ||
291 | bool makesubs = ndirdlg.subpossible(); | ||
292 | QString delemiter = "/"; | ||
293 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | ||
294 | if (item) { | ||
295 | delemiter = item->Delemiter(); | ||
296 | } | ||
297 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | ||
298 | refreshFolders(true); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | |||
303 | void IMAPviewItem::contextMenuSelected(int id) | ||
304 | { | ||
305 | qDebug("Id selected: %i",id); | ||
306 | switch (id) { | ||
307 | case 0: | ||
308 | refreshFolders(true); | ||
309 | break; | ||
310 | case 1: | ||
311 | createNewFolder(); | ||
312 | break; | ||
313 | case 2: | ||
314 | removeChilds(); | ||
315 | wrapper->logout(); | ||
316 | break; | ||
317 | case 3: | ||
318 | if (account->getOffline()==false) { | ||
319 | removeChilds(); | ||
320 | wrapper->logout(); | ||
321 | } | ||
322 | account->setOffline(!account->getOffline()); | ||
323 | account->save(); | ||
324 | SETPIX(PIXMAP_IMAPFOLDER); | ||
325 | refreshFolders(false); | ||
326 | break; | ||
327 | default: | ||
328 | break; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | RecBody IMAPviewItem::fetchBody(const RecMail&) | ||
333 | { | ||
334 | return RecBody(); | ||
335 | } | ||
336 | |||
337 | bool IMAPviewItem::offline() | ||
338 | { | ||
339 | return account->getOffline(); | ||
340 | } | ||
341 | |||
342 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | ||
343 | : AccountViewItem( parent , after ) | ||
344 | { | ||
345 | folder = folderInit; | ||
346 | imap = parent; | ||
347 | if (folder->getDisplayName().lower()!="inbox") { | ||
348 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | ||
349 | } else { | ||
350 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
351 | } | ||
352 | setText( 0, folder->getDisplayName() ); | ||
353 | } | ||
354 | |||
355 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | ||
356 | : AccountViewItem( parent,after ) | ||
357 | { | ||
358 | folder = folderInit; | ||
359 | imap = master; | ||
360 | if (folder->getDisplayName().lower()!="inbox") { | ||
361 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | ||
362 | } else { | ||
363 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
364 | } | ||
365 | setText( 0, folder->getDisplayName() ); | ||
366 | } | ||
367 | |||
368 | IMAPfolderItem::~IMAPfolderItem() | ||
369 | { | ||
370 | } | ||
371 | |||
372 | const QString& IMAPfolderItem::Delemiter()const | ||
373 | { | ||
374 | return folder->Separator(); | ||
375 | } | ||
376 | |||
377 | void IMAPfolderItem::refresh(QList<RecMail>&target) | ||
378 | { | ||
379 | if (folder->may_select()) { | ||
380 | imap->getWrapper()->listMessages( folder->getName(),target ); | ||
381 | } else { | ||
382 | target.clear(); | ||
383 | } | ||
384 | } | ||
385 | |||
386 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | ||
387 | { | ||
388 | return imap->getWrapper()->fetchBody(aMail); | ||
389 | } | ||
390 | |||
391 | QPopupMenu * IMAPfolderItem::getContextMenu() | ||
392 | { | ||
393 | QPopupMenu *m = new QPopupMenu(0); | ||
394 | if (m) { | ||
395 | if (folder->may_select()) { | ||
396 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
397 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | ||
398 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | ||
399 | } | ||
400 | if (folder->no_inferior()==false) { | ||
401 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | ||
402 | } | ||
403 | if (folder->getDisplayName().lower()!="inbox") { | ||
404 | m->insertItem(QObject::tr("Delete folder",contextName),3); | ||
405 | } | ||
406 | } | ||
407 | return m; | ||
408 | } | ||
409 | |||
410 | void IMAPfolderItem::createNewFolder() | ||
411 | { | ||
412 | Newmdirdlg ndirdlg; | ||
413 | ndirdlg.showMaximized(); | ||
414 | if (ndirdlg.exec()) { | ||
415 | QString ndir = ndirdlg.Newdir(); | ||
416 | bool makesubs = ndirdlg.subpossible(); | ||
417 | QString delemiter = Delemiter(); | ||
418 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | ||
419 | imap->refreshFolders(true); | ||
420 | } | ||
421 | } | ||
422 | } | ||
423 | |||
424 | void IMAPfolderItem::deleteFolder() | ||
425 | { | ||
426 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
427 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
428 | QObject::tr("Yes",contextName), | ||
429 | QObject::tr("No",contextName),QString::null,1,1); | ||
430 | qDebug("Auswahl: %i",yesno); | ||
431 | if (yesno == 0) { | ||
432 | if (imap->getWrapper()->deleteMbox(folder)) { | ||
433 | QListView*v=listView(); | ||
434 | IMAPviewItem * box = imap; | ||
435 | /* be carefull - after that this object is destroyd so don't use | ||
436 | * any member of it after that call!!*/ | ||
437 | imap->refreshFolders(true); | ||
438 | if (v) { | ||
439 | v->setSelected(box,true); | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | |||
445 | void IMAPfolderItem::downloadMails() | ||
446 | { | ||
447 | AccountView*bl = imap->accountView(); | ||
448 | if (!bl) return; | ||
449 | bl->downloadMails(folder,imap->getWrapper()); | ||
450 | } | ||
451 | |||
452 | void IMAPfolderItem::contextMenuSelected(int id) | ||
453 | { | ||
454 | qDebug("Selected id: %i",id); | ||
455 | AccountView * view = (AccountView*)listView(); | ||
456 | switch(id) { | ||
457 | case 0: | ||
458 | view->refreshCurrent(); | ||
459 | break; | ||
460 | case 1: | ||
461 | deleteAllMail(imap->getWrapper(),folder); | ||
462 | break; | ||
463 | case 2: | ||
464 | createNewFolder(); | ||
465 | break; | ||
466 | case 3: | ||
467 | deleteFolder(); | ||
468 | break; | ||
469 | case 4: | ||
470 | downloadMails(); | ||
471 | break; | ||
472 | default: | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * MH Account stuff | ||
479 | */ | ||
480 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | ||
481 | POP3 and MBOX */ | ||
482 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | ||
483 | : AccountViewItem( parent ) | ||
484 | { | ||
485 | m_Path = aPath; | ||
486 | /* be carefull - the space within settext is wanted - thats why the string twice */ | ||
487 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | ||
488 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | ||
489 | setText( 0, " Local Folders" ); | ||
490 | setOpen( true ); | ||
491 | folder = 0; | ||
492 | } | ||
493 | |||
494 | MHviewItem::~MHviewItem() | ||
495 | { | ||
496 | delete wrapper; | ||
497 | } | ||
498 | |||
499 | AbstractMail *MHviewItem::getWrapper() | ||
500 | { | ||
501 | return wrapper; | ||
502 | } | ||
503 | |||
504 | void MHviewItem::refresh( QList<RecMail> & target) | ||
505 | { | ||
506 | refresh(false); | ||
507 | getWrapper()->listMessages( "",target ); | ||
508 | } | ||
509 | |||
510 | void MHviewItem::refresh(bool force) | ||
511 | { | ||
512 | if (childCount()>0 && force==false) return; | ||
513 | removeChilds(); | ||
514 | currentFolders.clear(); | ||
515 | QList<Folder> *folders = wrapper->listFolders(); | ||
516 | Folder *it; | ||
517 | MHfolderItem*item = 0; | ||
518 | MHfolderItem*pmaster = 0; | ||
519 | QString fname = ""; | ||
520 | int pos; | ||
521 | for ( it = folders->first(); it; it = folders->next() ) { | ||
522 | fname = it->getDisplayName(); | ||
523 | /* this folder itself */ | ||
524 | if (fname=="/") { | ||
525 | currentFolders.append(fname); | ||
526 | folder = it; | ||
527 | continue; | ||
528 | } | ||
529 | currentFolders.append(fname); | ||
530 | pos = fname.findRev("/"); | ||
531 | if (pos > 0) { | ||
532 | fname = fname.left(pos); | ||
533 | pmaster = (MHfolderItem*)findSubItem(fname); | ||
534 | } else { | ||
535 | pmaster = 0; | ||
536 | } | ||
537 | if (pmaster) { | ||
538 | item = new MHfolderItem( it, pmaster, item, this ); | ||
539 | } else { | ||
540 | item = new MHfolderItem( it, this , item ); | ||
541 | } | ||
542 | item->setSelectable(it->may_select()); | ||
543 | } | ||
544 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
545 | folders->setAutoDelete(false); | ||
546 | delete folders; | ||
547 | } | ||
548 | |||
549 | RecBody MHviewItem::fetchBody( const RecMail &mail ) | ||
550 | { | ||
551 | qDebug( "MH fetchBody" ); | ||
552 | return wrapper->fetchBody( mail ); | ||
553 | } | ||
554 | |||
555 | QPopupMenu * MHviewItem::getContextMenu() | ||
556 | { | ||
557 | QPopupMenu *m = new QPopupMenu(0); | ||
558 | if (m) { | ||
559 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
560 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
561 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | ||
562 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | ||
563 | } | ||
564 | return m; | ||
565 | } | ||
566 | |||
567 | void MHviewItem::createFolder() | ||
568 | { | ||
569 | Newmdirdlg ndirdlg(0,0,true); | ||
570 | ndirdlg.showMaximized(); | ||
571 | if (ndirdlg.exec()) { | ||
572 | QString ndir = ndirdlg.Newdir(); | ||
573 | if (wrapper->createMbox(ndir)) { | ||
574 | refresh(true); | ||
575 | } | ||
576 | } | ||
577 | } | ||
578 | |||
579 | void MHviewItem::downloadMails() | ||
580 | { | ||
581 | AccountView*bl = accountView(); | ||
582 | if (!bl) return; | ||
583 | bl->downloadMails(folder,getWrapper()); | ||
584 | } | ||
585 | |||
586 | QStringList MHviewItem::subFolders() | ||
587 | { | ||
588 | return currentFolders; | ||
589 | } | ||
590 | |||
591 | void MHviewItem::contextMenuSelected(int which) | ||
592 | { | ||
593 | switch (which) { | ||
594 | case 0: | ||
595 | refresh(true); | ||
596 | break; | ||
597 | case 1: | ||
598 | createFolder(); | ||
599 | break; | ||
600 | case 2: | ||
601 | deleteAllMail(getWrapper(),folder); | ||
602 | break; | ||
603 | case 3: | ||
604 | downloadMails(); | ||
605 | break; | ||
606 | default: | ||
607 | break; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | MHfolderItem::~MHfolderItem() | ||
612 | { | ||
613 | } | ||
614 | |||
615 | MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) | ||
616 | : AccountViewItem( parent,after ) | ||
617 | { | ||
618 | folder = folderInit; | ||
619 | mbox = parent; | ||
620 | initName(); | ||
621 | } | ||
622 | |||
623 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | ||
624 | : AccountViewItem( parent,after ) | ||
625 | { | ||
626 | folder = folderInit; | ||
627 | mbox = master; | ||
628 | initName(); | ||
629 | } | ||
630 | |||
631 | void MHfolderItem::initName() | ||
632 | { | ||
633 | QString bName = folder->getDisplayName(); | ||
634 | if (bName.startsWith("/")&&bName.length()>1) { | ||
635 | bName.replace(0,1,""); | ||
636 | } | ||
637 | int pos = bName.findRev("/"); | ||
638 | if (pos > 0) { | ||
639 | bName.replace(0,pos+1,""); | ||
640 | } | ||
641 | if (bName.lower() == "outgoing") { | ||
642 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | ||
643 | } else if (bName.lower() == "inbox") { | ||
644 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
645 | } else { | ||
646 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | ||
647 | } | ||
648 | setText( 0, bName ); | ||
649 | } | ||
650 | |||
651 | Folder*MHfolderItem::getFolder() | ||
652 | { | ||
653 | return folder; | ||
654 | } | ||
655 | |||
656 | void MHfolderItem::refresh(QList<RecMail>&target) | ||
657 | { | ||
658 | if (folder->may_select()) | ||
659 | mbox->getWrapper()->listMessages( folder->getName(),target ); | ||
660 | } | ||
661 | |||
662 | RecBody MHfolderItem::fetchBody(const RecMail&aMail) | ||
663 | { | ||
664 | return mbox->getWrapper()->fetchBody(aMail); | ||
665 | } | ||
666 | |||
667 | void MHfolderItem::deleteFolder() | ||
668 | { | ||
669 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
670 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
671 | QObject::tr("Yes",contextName), | ||
672 | QObject::tr("No",contextName),QString::null,1,1); | ||
673 | qDebug("Auswahl: %i",yesno); | ||
674 | if (yesno == 0) { | ||
675 | if (mbox->getWrapper()->deleteMbox(folder)) { | ||
676 | QListView*v=listView(); | ||
677 | MHviewItem * box = mbox; | ||
678 | /* be carefull - after that this object is destroyd so don't use | ||
679 | * any member of it after that call!!*/ | ||
680 | mbox->refresh(true); | ||
681 | if (v) { | ||
682 | v->setSelected(box,true); | ||
683 | } | ||
684 | } | ||
685 | } | ||
686 | } | ||
687 | |||
688 | QPopupMenu * MHfolderItem::getContextMenu() | ||
689 | { | ||
690 | QPopupMenu *m = new QPopupMenu(0); | ||
691 | if (m) { | ||
692 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
693 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | ||
694 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | ||
695 | m->insertItem(QObject::tr("Delete folder",contextName),1); | ||
696 | } | ||
697 | return m; | ||
698 | } | ||
699 | |||
700 | void MHfolderItem::downloadMails() | ||
701 | { | ||
702 | AccountView*bl = mbox->accountView(); | ||
703 | if (!bl) return; | ||
704 | bl->downloadMails(folder,mbox->getWrapper()); | ||
705 | } | ||
706 | |||
707 | void MHfolderItem::createFolder() | ||
708 | { | ||
709 | Newmdirdlg ndirdlg(0,0,true); | ||
710 | ndirdlg.showMaximized(); | ||
711 | if (ndirdlg.exec()) { | ||
712 | QString ndir = ndirdlg.Newdir(); | ||
713 | if (mbox->getWrapper()->createMbox(ndir,folder)) { | ||
714 | QListView*v=listView(); | ||
715 | MHviewItem * box = mbox; | ||
716 | /* be carefull - after that this object is destroyd so don't use | ||
717 | * any member of it after that call!!*/ | ||
718 | mbox->refresh(true); | ||
719 | if (v) { | ||
720 | v->setSelected(box,true); | ||
721 | } | ||
722 | } | ||
723 | } | ||
724 | } | ||
725 | |||
726 | void MHfolderItem::contextMenuSelected(int which) | ||
727 | { | ||
728 | switch(which) { | ||
729 | case 0: | ||
730 | deleteAllMail(mbox->getWrapper(),folder); | ||
731 | break; | ||
732 | case 1: | ||
733 | deleteFolder(); | ||
734 | break; | ||
735 | case 2: | ||
736 | downloadMails(); | ||
737 | break; | ||
738 | case 3: | ||
739 | createFolder(); | ||
740 | break; | ||
741 | default: | ||
742 | break; | ||
743 | } | ||
744 | } | ||
745 | |||
746 | /** | ||
747 | * Generic stuff | ||
748 | */ | ||
749 | |||
750 | const QString AccountViewItem::contextName="AccountViewItem"; | ||
751 | |||
752 | AccountViewItem::AccountViewItem( AccountView *parent ) | ||
753 | : QListViewItem( parent ) | ||
754 | { | ||
755 | init(); | ||
756 | m_Backlink = parent; | ||
757 | } | ||
758 | |||
759 | AccountViewItem::AccountViewItem( QListViewItem *parent) | ||
760 | : QListViewItem( parent) | ||
761 | { | ||
762 | init(); | ||
763 | } | ||
764 | |||
765 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | ||
766 | :QListViewItem( parent,after ) | ||
767 | { | ||
768 | init(); | ||
769 | } | ||
770 | |||
771 | void AccountViewItem::init() | ||
772 | { | ||
773 | m_Backlink = 0; | ||
774 | folder = 0; | ||
775 | } | ||
776 | |||
777 | AccountViewItem::~AccountViewItem() | ||
778 | { | ||
779 | if (folder) delete folder; | ||
780 | } | ||
781 | |||
782 | AccountView*AccountViewItem::accountView() | ||
783 | { | ||
784 | return m_Backlink; | ||
785 | } | ||
786 | |||
787 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | ||
788 | { | ||
789 | if (!wrapper) return; | ||
790 | QString fname=""; | ||
791 | if (folder) fname = folder->getDisplayName(); | ||
792 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
793 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | ||
794 | arg(fname), | ||
795 | QObject::tr("Yes",contextName), | ||
796 | QObject::tr("No",contextName),QString::null,1,1); | ||
797 | qDebug("Auswahl: %i",yesno); | ||
798 | if (yesno == 0) { | ||
799 | if (wrapper->deleteAllMail(folder)) { | ||
800 | AccountView * view = (AccountView*)listView(); | ||
801 | if (view) view->refreshCurrent(); | ||
802 | } | ||
803 | } | ||
804 | } | ||
805 | |||
806 | void AccountViewItem::removeChilds() | ||
807 | { | ||
808 | QListViewItem *child = firstChild(); | ||
809 | while ( child ) { | ||
810 | QListViewItem *tmp = child; | ||
811 | child = child->nextSibling(); | ||
812 | delete tmp; | ||
813 | } | ||
814 | } | ||
815 | |||
816 | bool AccountViewItem::matchName(const QString&name)const | ||
817 | { | ||
818 | if (!folder) return false; | ||
819 | return folder->getDisplayName()==name; | ||
820 | } | ||
821 | |||
822 | |||
823 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | ||
824 | { | ||
825 | AccountViewItem*pitem,*sitem; | ||
826 | if (!start) pitem = (AccountViewItem*)firstChild(); | ||
827 | else pitem = (AccountViewItem*)start->firstChild(); | ||
828 | while (pitem) { | ||
829 | if (pitem->matchName(path)) { | ||
830 | break; | ||
831 | } | ||
832 | if (pitem->childCount()>0) { | ||
833 | sitem = findSubItem(path,pitem); | ||
834 | if (sitem) { | ||
835 | pitem = sitem; | ||
836 | break; | ||
837 | } | ||
838 | } | ||
839 | pitem=(AccountViewItem*)pitem->nextSibling(); | ||
840 | } | ||
841 | return pitem; | ||
842 | } | ||
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h new file mode 100644 index 0000000..99208b6 --- a/dev/null +++ b/noncore/net/mail/accountitem.h | |||
@@ -0,0 +1,164 @@ | |||
1 | #ifndef __ACCOUNT_ITEM | ||
2 | #define __ACCOUNT_ITEM | ||
3 | |||
4 | #include <qlistview.h> | ||
5 | #include <qlist.h> | ||
6 | |||
7 | class POP3wrapper; | ||
8 | class RecMail; | ||
9 | class RecBody; | ||
10 | class QPopupMenu; | ||
11 | class Selectstore; | ||
12 | class AccountView; | ||
13 | class POP3account; | ||
14 | class IMAPaccount; | ||
15 | class AbstractMail; | ||
16 | class Folder; | ||
17 | |||
18 | class AccountViewItem : public QListViewItem | ||
19 | { | ||
20 | |||
21 | public: | ||
22 | AccountViewItem( AccountView *parent ); | ||
23 | AccountViewItem( QListViewItem *parent); | ||
24 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | ||
25 | virtual ~AccountViewItem(); | ||
26 | virtual void refresh(QList<RecMail>&)=0; | ||
27 | virtual RecBody fetchBody(const RecMail&)=0; | ||
28 | virtual QPopupMenu * getContextMenu(){return 0;}; | ||
29 | virtual void contextMenuSelected(int){} | ||
30 | virtual AccountView*accountView(); | ||
31 | virtual bool matchName(const QString&name)const; | ||
32 | |||
33 | protected: | ||
34 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); | ||
35 | virtual void init(); | ||
36 | virtual void removeChilds(); | ||
37 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | ||
38 | static const QString contextName; | ||
39 | AccountView*m_Backlink; | ||
40 | Folder *folder; | ||
41 | }; | ||
42 | |||
43 | class POP3viewItem : public AccountViewItem | ||
44 | { | ||
45 | |||
46 | public: | ||
47 | POP3viewItem( POP3account *a, AccountView *parent ); | ||
48 | virtual ~POP3viewItem(); | ||
49 | virtual void refresh( QList<RecMail> &target ); | ||
50 | virtual RecBody fetchBody( const RecMail &mail ); | ||
51 | AbstractMail *getWrapper(); | ||
52 | virtual QPopupMenu * getContextMenu(); | ||
53 | virtual void contextMenuSelected(int); | ||
54 | |||
55 | protected: | ||
56 | POP3account *account; | ||
57 | virtual void refresh(); | ||
58 | AbstractMail *wrapper; | ||
59 | void disconnect(); | ||
60 | void setOnOffline(); | ||
61 | }; | ||
62 | |||
63 | class POP3folderItem : public AccountViewItem | ||
64 | { | ||
65 | |||
66 | public: | ||
67 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | ||
68 | virtual ~POP3folderItem(); | ||
69 | virtual void refresh(QList<RecMail>&); | ||
70 | virtual RecBody fetchBody(const RecMail&); | ||
71 | virtual QPopupMenu * getContextMenu(); | ||
72 | virtual void contextMenuSelected(int); | ||
73 | |||
74 | protected: | ||
75 | void downloadMails(); | ||
76 | POP3viewItem *pop3; | ||
77 | }; | ||
78 | |||
79 | class IMAPviewItem : public AccountViewItem | ||
80 | { | ||
81 | friend class IMAPfolderItem; | ||
82 | public: | ||
83 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); | ||
84 | virtual ~IMAPviewItem(); | ||
85 | virtual void refresh(QList<RecMail>&); | ||
86 | virtual RecBody fetchBody(const RecMail&); | ||
87 | AbstractMail *getWrapper(); | ||
88 | virtual QPopupMenu * getContextMenu(); | ||
89 | virtual void contextMenuSelected(int); | ||
90 | const QStringList&subFolders(); | ||
91 | virtual void refreshFolders(bool force=false); | ||
92 | bool offline(); | ||
93 | |||
94 | protected: | ||
95 | virtual void createNewFolder(); | ||
96 | IMAPaccount *account; | ||
97 | AbstractMail *wrapper; | ||
98 | QStringList currentFolders; | ||
99 | }; | ||
100 | |||
101 | class IMAPfolderItem : public AccountViewItem | ||
102 | { | ||
103 | |||
104 | public: | ||
105 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | ||
106 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | ||
107 | virtual ~IMAPfolderItem(); | ||
108 | virtual void refresh(QList<RecMail>&); | ||
109 | virtual RecBody fetchBody(const RecMail&); | ||
110 | virtual QPopupMenu * getContextMenu(); | ||
111 | virtual void contextMenuSelected(int); | ||
112 | virtual const QString& Delemiter()const; | ||
113 | protected: | ||
114 | virtual void createNewFolder(); | ||
115 | virtual void deleteFolder(); | ||
116 | virtual void downloadMails(); | ||
117 | IMAPviewItem *imap; | ||
118 | }; | ||
119 | |||
120 | class MHviewItem : public AccountViewItem | ||
121 | { | ||
122 | friend class MHfolderItem; | ||
123 | |||
124 | public: | ||
125 | MHviewItem( const QString&aMboxPath, AccountView *parent ); | ||
126 | virtual ~MHviewItem(); | ||
127 | virtual void refresh( QList<RecMail> &target ); | ||
128 | virtual RecBody fetchBody( const RecMail &mail ); | ||
129 | AbstractMail *getWrapper(); | ||
130 | virtual QPopupMenu * getContextMenu(); | ||
131 | virtual void contextMenuSelected(int); | ||
132 | QStringList subFolders(); | ||
133 | virtual void refresh(bool force=false); | ||
134 | |||
135 | protected: | ||
136 | void downloadMails(); | ||
137 | virtual void createFolder(); | ||
138 | QString m_Path; | ||
139 | AbstractMail *wrapper; | ||
140 | QStringList currentFolders; | ||
141 | }; | ||
142 | |||
143 | class MHfolderItem : public AccountViewItem | ||
144 | { | ||
145 | |||
146 | public: | ||
147 | MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); | ||
148 | MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | ||
149 | virtual ~MHfolderItem(); | ||
150 | virtual void refresh(QList<RecMail>&); | ||
151 | virtual RecBody fetchBody(const RecMail&); | ||
152 | virtual QPopupMenu * getContextMenu(); | ||
153 | virtual void contextMenuSelected(int); | ||
154 | virtual Folder*getFolder(); | ||
155 | |||
156 | protected: | ||
157 | void downloadMails(); | ||
158 | virtual void createFolder(); | ||
159 | virtual void deleteFolder(); | ||
160 | void initName(); | ||
161 | MHviewItem *mbox; | ||
162 | }; | ||
163 | |||
164 | #endif | ||
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 3048e49..d9792d4 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,565 +1,12 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include <libmailwrapper/mailtypes.h> | 2 | #include "accountitem.h" |
3 | #include <libmailwrapper/abstractmail.h> | ||
4 | #include "defines.h" | ||
5 | #include "newmaildir.h" | ||
6 | #include "selectstore.h" | 3 | #include "selectstore.h" |
7 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
8 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <libmailwrapper/settings.h> | ||
7 | #include <libmailwrapper/mailwrapper.h> | ||
8 | #include <libmailwrapper/mailtypes.h> | ||
9 | #include <libmailwrapper/abstractmail.h> | ||
9 | 10 | ||
10 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | ||
11 | /** | ||
12 | * POP3 Account stuff | ||
13 | */ | ||
14 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | ||
15 | : AccountViewItem( parent ) | ||
16 | { | ||
17 | account = a; | ||
18 | wrapper = AbstractMail::getWrapper( account ); | ||
19 | SETPIX(PIXMAP_POP3FOLDER); | ||
20 | #if 0 | ||
21 | if (!account->getOffline()) { | ||
22 | setPixmap( 0, ); | ||
23 | } else { | ||
24 | setPixmap( 0, PIXMAP_OFFLINE ); | ||
25 | } | ||
26 | #endif | ||
27 | setText( 0, account->getAccountName() ); | ||
28 | setOpen( true ); | ||
29 | } | ||
30 | |||
31 | POP3viewItem::~POP3viewItem() | ||
32 | { | ||
33 | delete wrapper; | ||
34 | } | ||
35 | |||
36 | AbstractMail *POP3viewItem::getWrapper() | ||
37 | { | ||
38 | return wrapper; | ||
39 | } | ||
40 | |||
41 | void POP3viewItem::refresh( QList<RecMail> & ) | ||
42 | { | ||
43 | refresh(); | ||
44 | } | ||
45 | |||
46 | void POP3viewItem::refresh() | ||
47 | { | ||
48 | if (account->getOffline()) return; | ||
49 | QList<Folder> *folders = wrapper->listFolders(); | ||
50 | QListViewItem *child = firstChild(); | ||
51 | while ( child ) { | ||
52 | QListViewItem *tmp = child; | ||
53 | child = child->nextSibling(); | ||
54 | delete tmp; | ||
55 | } | ||
56 | Folder *it; | ||
57 | QListViewItem*item = 0; | ||
58 | for ( it = folders->first(); it; it = folders->next() ) { | ||
59 | item = new POP3folderItem( it, this , item ); | ||
60 | item->setSelectable(it->may_select()); | ||
61 | } | ||
62 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
63 | folders->setAutoDelete(false); | ||
64 | delete folders; | ||
65 | } | ||
66 | |||
67 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | ||
68 | { | ||
69 | qDebug( "POP3 fetchBody" ); | ||
70 | return wrapper->fetchBody( mail ); | ||
71 | } | ||
72 | |||
73 | QPopupMenu * POP3viewItem::getContextMenu() | ||
74 | { | ||
75 | QPopupMenu *m = new QPopupMenu(0); | ||
76 | if (m) { | ||
77 | if (!account->getOffline()) { | ||
78 | m->insertItem(QObject::tr("Disconnect",contextName),0); | ||
79 | m->insertItem(QObject::tr("Set offline",contextName),1); | ||
80 | } else { | ||
81 | m->insertItem(QObject::tr("Set online",contextName),1); | ||
82 | } | ||
83 | } | ||
84 | return m; | ||
85 | } | ||
86 | |||
87 | void POP3viewItem::disconnect() | ||
88 | { | ||
89 | QListViewItem *child = firstChild(); | ||
90 | while ( child ) { | ||
91 | QListViewItem *tmp = child; | ||
92 | child = child->nextSibling(); | ||
93 | delete tmp; | ||
94 | } | ||
95 | wrapper->logout(); | ||
96 | } | ||
97 | |||
98 | void POP3viewItem::setOnOffline() | ||
99 | { | ||
100 | if (!account->getOffline()) { | ||
101 | disconnect(); | ||
102 | } | ||
103 | account->setOffline(!account->getOffline()); | ||
104 | account->save(); | ||
105 | SETPIX(PIXMAP_POP3FOLDER); | ||
106 | refresh(); | ||
107 | } | ||
108 | |||
109 | void POP3viewItem::contextMenuSelected(int which) | ||
110 | { | ||
111 | switch (which) { | ||
112 | case 0: | ||
113 | disconnect(); | ||
114 | break; | ||
115 | case 1: | ||
116 | setOnOffline(); | ||
117 | break; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | POP3folderItem::~POP3folderItem() | ||
122 | { | ||
123 | delete folder; | ||
124 | } | ||
125 | |||
126 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | ||
127 | : AccountViewItem( parent,after ) | ||
128 | { | ||
129 | folder = folderInit; | ||
130 | pop3 = parent; | ||
131 | if (folder->getDisplayName().lower()!="inbox") { | ||
132 | setPixmap( 0, PIXMAP_POP3FOLDER ); | ||
133 | } else { | ||
134 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
135 | } | ||
136 | setText( 0, folder->getDisplayName() ); | ||
137 | } | ||
138 | |||
139 | void POP3folderItem::refresh(QList<RecMail>&target) | ||
140 | { | ||
141 | if (folder->may_select()) | ||
142 | pop3->getWrapper()->listMessages( folder->getName(),target ); | ||
143 | } | ||
144 | |||
145 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | ||
146 | { | ||
147 | return pop3->getWrapper()->fetchBody(aMail); | ||
148 | } | ||
149 | |||
150 | QPopupMenu * POP3folderItem::getContextMenu() | ||
151 | { | ||
152 | QPopupMenu *m = new QPopupMenu(0); | ||
153 | if (m) { | ||
154 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
155 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | ||
156 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
157 | } | ||
158 | return m; | ||
159 | } | ||
160 | |||
161 | void POP3folderItem::downloadMails() | ||
162 | { | ||
163 | AccountView*bl = pop3->accountView(); | ||
164 | if (!bl) return; | ||
165 | bl->downloadMails(folder,pop3->getWrapper()); | ||
166 | } | ||
167 | |||
168 | void POP3folderItem::contextMenuSelected(int which) | ||
169 | { | ||
170 | AccountView * view = (AccountView*)listView(); | ||
171 | switch (which) { | ||
172 | case 0: | ||
173 | /* must be 'cause pop3 lists are cached */ | ||
174 | pop3->getWrapper()->logout(); | ||
175 | view->refreshCurrent(); | ||
176 | break; | ||
177 | case 1: | ||
178 | deleteAllMail(pop3->getWrapper(),folder); | ||
179 | break; | ||
180 | case 2: | ||
181 | downloadMails(); | ||
182 | break; | ||
183 | default: | ||
184 | break; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * IMAP Account stuff | ||
190 | */ | ||
191 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | ||
192 | : AccountViewItem( parent ) | ||
193 | { | ||
194 | account = a; | ||
195 | wrapper = AbstractMail::getWrapper( account ); | ||
196 | SETPIX(PIXMAP_IMAPFOLDER); | ||
197 | setText( 0, account->getAccountName() ); | ||
198 | setOpen( true ); | ||
199 | } | ||
200 | |||
201 | IMAPviewItem::~IMAPviewItem() | ||
202 | { | ||
203 | delete wrapper; | ||
204 | } | ||
205 | |||
206 | AbstractMail *IMAPviewItem::getWrapper() | ||
207 | { | ||
208 | return wrapper; | ||
209 | } | ||
210 | |||
211 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | ||
212 | { | ||
213 | IMAPfolderItem*pitem,*sitem; | ||
214 | if (!start) pitem = (IMAPfolderItem*)firstChild(); | ||
215 | else pitem = (IMAPfolderItem*)start->firstChild(); | ||
216 | while (pitem) { | ||
217 | if (pitem->matchName(path)) { | ||
218 | break; | ||
219 | } | ||
220 | if (pitem->childCount()>0) { | ||
221 | sitem = findSubItem(path,pitem); | ||
222 | if (sitem) { | ||
223 | pitem = sitem; | ||
224 | break; | ||
225 | } | ||
226 | } | ||
227 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | ||
228 | } | ||
229 | return pitem; | ||
230 | } | ||
231 | |||
232 | void IMAPviewItem::refresh(QList<RecMail>&) | ||
233 | { | ||
234 | refreshFolders(false); | ||
235 | } | ||
236 | |||
237 | void IMAPviewItem::removeChilds() | ||
238 | { | ||
239 | QListViewItem *child = firstChild(); | ||
240 | while ( child ) { | ||
241 | QListViewItem *tmp = child; | ||
242 | child = child->nextSibling(); | ||
243 | delete tmp; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | const QStringList&IMAPviewItem::subFolders() | ||
248 | { | ||
249 | return currentFolders; | ||
250 | } | ||
251 | |||
252 | void IMAPviewItem::refreshFolders(bool force) | ||
253 | { | ||
254 | if (childCount()>0 && force==false) return; | ||
255 | if (account->getOffline()) return; | ||
256 | |||
257 | removeChilds(); | ||
258 | currentFolders.clear(); | ||
259 | QList<Folder> *folders = wrapper->listFolders(); | ||
260 | |||
261 | Folder *it; | ||
262 | QListViewItem*item = 0; | ||
263 | QListViewItem*titem = 0; | ||
264 | QString fname,del,search; | ||
265 | int pos; | ||
266 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
267 | folders->setAutoDelete(false); | ||
268 | |||
269 | for ( it = folders->first(); it; it = folders->next() ) { | ||
270 | if (it->getDisplayName().lower()=="inbox") { | ||
271 | item = new IMAPfolderItem( it, this , item ); | ||
272 | folders->remove(it); | ||
273 | qDebug("inbox found"); | ||
274 | break; | ||
275 | } | ||
276 | } | ||
277 | for ( it = folders->first(); it; it = folders->next() ) { | ||
278 | fname = it->getDisplayName(); | ||
279 | currentFolders.append(it->getName()); | ||
280 | pos = fname.findRev(it->Separator()); | ||
281 | if (pos != -1) { | ||
282 | fname = fname.left(pos); | ||
283 | } | ||
284 | IMAPfolderItem*pitem = findSubItem(fname); | ||
285 | if (pitem) { | ||
286 | titem = item; | ||
287 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | ||
288 | /* setup the short name */ | ||
289 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | ||
290 | item = titem; | ||
291 | } else { | ||
292 | item = new IMAPfolderItem( it, this , item ); | ||
293 | } | ||
294 | } | ||
295 | delete folders; | ||
296 | } | ||
297 | |||
298 | QPopupMenu * IMAPviewItem::getContextMenu() | ||
299 | { | ||
300 | QPopupMenu *m = new QPopupMenu(0); | ||
301 | if (m) { | ||
302 | if (!account->getOffline()) { | ||
303 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
304 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
305 | m->insertSeparator(); | ||
306 | m->insertItem(QObject::tr("Disconnect",contextName),2); | ||
307 | m->insertItem(QObject::tr("Set offline",contextName),3); | ||
308 | } else { | ||
309 | m->insertItem(QObject::tr("Set online",contextName),3); | ||
310 | } | ||
311 | } | ||
312 | return m; | ||
313 | } | ||
314 | |||
315 | void IMAPviewItem::createNewFolder() | ||
316 | { | ||
317 | Newmdirdlg ndirdlg; | ||
318 | ndirdlg.showMaximized(); | ||
319 | if (ndirdlg.exec()) { | ||
320 | QString ndir = ndirdlg.Newdir(); | ||
321 | bool makesubs = ndirdlg.subpossible(); | ||
322 | QString delemiter = "/"; | ||
323 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | ||
324 | if (item) { | ||
325 | delemiter = item->Delemiter(); | ||
326 | } | ||
327 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { | ||
328 | refreshFolders(true); | ||
329 | } | ||
330 | } | ||
331 | } | ||
332 | |||
333 | void IMAPviewItem::contextMenuSelected(int id) | ||
334 | { | ||
335 | qDebug("Id selected: %i",id); | ||
336 | switch (id) { | ||
337 | case 0: | ||
338 | refreshFolders(true); | ||
339 | break; | ||
340 | case 1: | ||
341 | createNewFolder(); | ||
342 | break; | ||
343 | case 2: | ||
344 | removeChilds(); | ||
345 | wrapper->logout(); | ||
346 | break; | ||
347 | case 3: | ||
348 | if (account->getOffline()==false) { | ||
349 | removeChilds(); | ||
350 | wrapper->logout(); | ||
351 | } | ||
352 | account->setOffline(!account->getOffline()); | ||
353 | account->save(); | ||
354 | SETPIX(PIXMAP_IMAPFOLDER); | ||
355 | refreshFolders(false); | ||
356 | break; | ||
357 | default: | ||
358 | break; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | RecBody IMAPviewItem::fetchBody(const RecMail&) | ||
363 | { | ||
364 | return RecBody(); | ||
365 | } | ||
366 | |||
367 | bool IMAPviewItem::offline() | ||
368 | { | ||
369 | return account->getOffline(); | ||
370 | } | ||
371 | |||
372 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | ||
373 | : AccountViewItem( parent , after ) | ||
374 | { | ||
375 | folder = folderInit; | ||
376 | imap = parent; | ||
377 | if (folder->getDisplayName().lower()!="inbox") { | ||
378 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | ||
379 | } else { | ||
380 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
381 | } | ||
382 | setText( 0, folder->getDisplayName() ); | ||
383 | } | ||
384 | |||
385 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | ||
386 | : AccountViewItem( parent,after ) | ||
387 | { | ||
388 | folder = folderInit; | ||
389 | imap = master; | ||
390 | if (folder->getDisplayName().lower()!="inbox") { | ||
391 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | ||
392 | } else { | ||
393 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
394 | } | ||
395 | setText( 0, folder->getDisplayName() ); | ||
396 | } | ||
397 | |||
398 | IMAPfolderItem::~IMAPfolderItem() | ||
399 | { | ||
400 | delete folder; | ||
401 | } | ||
402 | |||
403 | const QString& IMAPfolderItem::Delemiter()const | ||
404 | { | ||
405 | return folder->Separator(); | ||
406 | } | ||
407 | |||
408 | bool IMAPfolderItem::matchName(const QString&name)const | ||
409 | { | ||
410 | return folder->getDisplayName()==name; | ||
411 | } | ||
412 | |||
413 | void IMAPfolderItem::refresh(QList<RecMail>&target) | ||
414 | { | ||
415 | if (folder->may_select()) { | ||
416 | imap->getWrapper()->listMessages( folder->getName(),target ); | ||
417 | } else { | ||
418 | target.clear(); | ||
419 | } | ||
420 | } | ||
421 | |||
422 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | ||
423 | { | ||
424 | return imap->getWrapper()->fetchBody(aMail); | ||
425 | } | ||
426 | |||
427 | QPopupMenu * IMAPfolderItem::getContextMenu() | ||
428 | { | ||
429 | QPopupMenu *m = new QPopupMenu(0); | ||
430 | if (m) { | ||
431 | if (folder->may_select()) { | ||
432 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | ||
433 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | ||
434 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | ||
435 | } | ||
436 | if (folder->no_inferior()==false) { | ||
437 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | ||
438 | } | ||
439 | if (folder->getDisplayName().lower()!="inbox") { | ||
440 | m->insertItem(QObject::tr("Delete folder",contextName),3); | ||
441 | } | ||
442 | } | ||
443 | return m; | ||
444 | } | ||
445 | |||
446 | void IMAPfolderItem::createNewFolder() | ||
447 | { | ||
448 | Newmdirdlg ndirdlg; | ||
449 | ndirdlg.showMaximized(); | ||
450 | if (ndirdlg.exec()) { | ||
451 | QString ndir = ndirdlg.Newdir(); | ||
452 | bool makesubs = ndirdlg.subpossible(); | ||
453 | QString delemiter = Delemiter(); | ||
454 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { | ||
455 | imap->refreshFolders(true); | ||
456 | } | ||
457 | } | ||
458 | } | ||
459 | |||
460 | void IMAPfolderItem::deleteFolder() | ||
461 | { | ||
462 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
463 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
464 | QObject::tr("Yes",contextName), | ||
465 | QObject::tr("No",contextName),QString::null,1,1); | ||
466 | qDebug("Auswahl: %i",yesno); | ||
467 | if (yesno == 0) { | ||
468 | if (imap->getWrapper()->deleteMbox(folder)) { | ||
469 | QListView*v=listView(); | ||
470 | IMAPviewItem * box = imap; | ||
471 | /* be carefull - after that this object is destroyd so don't use | ||
472 | * any member of it after that call!!*/ | ||
473 | imap->refreshFolders(true); | ||
474 | if (v) { | ||
475 | v->setSelected(box,true); | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | } | ||
480 | |||
481 | void IMAPfolderItem::downloadMails() | ||
482 | { | ||
483 | AccountView*bl = imap->accountView(); | ||
484 | if (!bl) return; | ||
485 | bl->downloadMails(folder,imap->getWrapper()); | ||
486 | } | ||
487 | |||
488 | void IMAPfolderItem::contextMenuSelected(int id) | ||
489 | { | ||
490 | qDebug("Selected id: %i",id); | ||
491 | AccountView * view = (AccountView*)listView(); | ||
492 | switch(id) { | ||
493 | case 0: | ||
494 | view->refreshCurrent(); | ||
495 | break; | ||
496 | case 1: | ||
497 | deleteAllMail(imap->getWrapper(),folder); | ||
498 | break; | ||
499 | case 2: | ||
500 | createNewFolder(); | ||
501 | break; | ||
502 | case 3: | ||
503 | deleteFolder(); | ||
504 | break; | ||
505 | case 4: | ||
506 | downloadMails(); | ||
507 | break; | ||
508 | default: | ||
509 | break; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Generic stuff | ||
515 | */ | ||
516 | |||
517 | const QString AccountViewItem::contextName="AccountViewItem"; | ||
518 | |||
519 | AccountViewItem::AccountViewItem( AccountView *parent ) | ||
520 | : QListViewItem( parent ) | ||
521 | { | ||
522 | m_Backlink = parent; | ||
523 | } | ||
524 | |||
525 | AccountViewItem::AccountViewItem( QListViewItem *parent) | ||
526 | : QListViewItem( parent) | ||
527 | { | ||
528 | m_Backlink = 0; | ||
529 | } | ||
530 | |||
531 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | ||
532 | :QListViewItem( parent,after ) | ||
533 | { | ||
534 | m_Backlink = 0; | ||
535 | } | ||
536 | |||
537 | AccountViewItem::~AccountViewItem() | ||
538 | { | ||
539 | } | ||
540 | |||
541 | AccountView*AccountViewItem::accountView() | ||
542 | { | ||
543 | return m_Backlink; | ||
544 | } | ||
545 | |||
546 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | ||
547 | { | ||
548 | if (!wrapper) return; | ||
549 | QString fname=""; | ||
550 | if (folder) fname = folder->getDisplayName(); | ||
551 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
552 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | ||
553 | arg(fname), | ||
554 | QObject::tr("Yes",contextName), | ||
555 | QObject::tr("No",contextName),QString::null,1,1); | ||
556 | qDebug("Auswahl: %i",yesno); | ||
557 | if (yesno == 0) { | ||
558 | if (wrapper->deleteAllMail(folder)) { | ||
559 | AccountView * view = (AccountView*)listView(); | ||
560 | if (view) view->refreshCurrent(); | ||
561 | } | ||
562 | } | ||
563 | } | ||
564 | 11 | ||
565 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 12 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
@@ -570,5 +17,4 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | |||
570 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, | 17 | connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, |
571 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); | 18 | SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); |
572 | |||
573 | setSorting(0); | 19 | setSorting(0); |
574 | } | 20 | } |
@@ -702,256 +148,2 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | |||
702 | refreshCurrent(); | 148 | refreshCurrent(); |
703 | } | 149 | } |
704 | |||
705 | /** | ||
706 | * MH Account stuff | ||
707 | */ | ||
708 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | ||
709 | POP3 and MBOX */ | ||
710 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | ||
711 | : AccountViewItem( parent ) | ||
712 | { | ||
713 | m_Path = aPath; | ||
714 | /* be carefull - the space within settext is wanted - thats why the string twice */ | ||
715 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | ||
716 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | ||
717 | setText( 0, " Local Folders" ); | ||
718 | setOpen( true ); | ||
719 | folder = 0; | ||
720 | } | ||
721 | |||
722 | MHviewItem::~MHviewItem() | ||
723 | { | ||
724 | delete wrapper; | ||
725 | if (folder) delete folder; | ||
726 | } | ||
727 | |||
728 | AbstractMail *MHviewItem::getWrapper() | ||
729 | { | ||
730 | return wrapper; | ||
731 | } | ||
732 | |||
733 | void MHviewItem::refresh( QList<RecMail> & target) | ||
734 | { | ||
735 | refresh(false); | ||
736 | getWrapper()->listMessages( "",target ); | ||
737 | } | ||
738 | |||
739 | void MHviewItem::removeChilds() | ||
740 | { | ||
741 | QListViewItem *child = firstChild(); | ||
742 | while ( child ) { | ||
743 | QListViewItem *tmp = child; | ||
744 | child = child->nextSibling(); | ||
745 | delete tmp; | ||
746 | } | ||
747 | } | ||
748 | |||
749 | void MHviewItem::refresh(bool force) | ||
750 | { | ||
751 | if (childCount()>0 && force==false) return; | ||
752 | removeChilds(); | ||
753 | QList<Folder> *folders = wrapper->listFolders(); | ||
754 | Folder *it; | ||
755 | MHfolderItem*item = 0; | ||
756 | MHfolderItem*pmaster = 0; | ||
757 | QString fname = ""; | ||
758 | for ( it = folders->first(); it; it = folders->next() ) { | ||
759 | fname = it->getDisplayName(); | ||
760 | /* this folder itself */ | ||
761 | if (fname=="/") { | ||
762 | folder = it; | ||
763 | continue; | ||
764 | } | ||
765 | if (pmaster) { | ||
766 | item = new MHfolderItem( it, pmaster, item, this ); | ||
767 | } else { | ||
768 | item = new MHfolderItem( it, this , item ); | ||
769 | } | ||
770 | item->setSelectable(it->may_select()); | ||
771 | } | ||
772 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
773 | folders->setAutoDelete(false); | ||
774 | delete folders; | ||
775 | } | ||
776 | |||
777 | RecBody MHviewItem::fetchBody( const RecMail &mail ) | ||
778 | { | ||
779 | qDebug( "MH fetchBody" ); | ||
780 | return wrapper->fetchBody( mail ); | ||
781 | } | ||
782 | |||
783 | QPopupMenu * MHviewItem::getContextMenu() | ||
784 | { | ||
785 | QPopupMenu *m = new QPopupMenu(0); | ||
786 | if (m) { | ||
787 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
788 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
789 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | ||
790 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | ||
791 | } | ||
792 | return m; | ||
793 | } | ||
794 | |||
795 | void MHviewItem::createFolder() | ||
796 | { | ||
797 | Newmdirdlg ndirdlg(0,0,true); | ||
798 | ndirdlg.showMaximized(); | ||
799 | if (ndirdlg.exec()) { | ||
800 | QString ndir = ndirdlg.Newdir(); | ||
801 | if (wrapper->createMbox(ndir)) { | ||
802 | refresh(true); | ||
803 | } | ||
804 | } | ||
805 | } | ||
806 | |||
807 | void MHviewItem::downloadMails() | ||
808 | { | ||
809 | AccountView*bl = accountView(); | ||
810 | if (!bl) return; | ||
811 | bl->downloadMails(folder,getWrapper()); | ||
812 | } | ||
813 | |||
814 | QStringList MHviewItem::subFolders() | ||
815 | { | ||
816 | QStringList result; | ||
817 | QListViewItem *child = firstChild(); | ||
818 | result.append("/"); | ||
819 | while ( child ) { | ||
820 | MHfolderItem *tmp = (MHfolderItem*)child; | ||
821 | child = child->nextSibling(); | ||
822 | result.append(tmp->getFolder()->getDisplayName()); | ||
823 | } | ||
824 | qDebug("Size of result: %i",result.count()); | ||
825 | return result; | ||
826 | } | ||
827 | |||
828 | void MHviewItem::contextMenuSelected(int which) | ||
829 | { | ||
830 | switch (which) { | ||
831 | case 0: | ||
832 | refresh(true); | ||
833 | break; | ||
834 | case 1: | ||
835 | createFolder(); | ||
836 | break; | ||
837 | case 2: | ||
838 | deleteAllMail(getWrapper(),folder); | ||
839 | break; | ||
840 | case 3: | ||
841 | downloadMails(); | ||
842 | break; | ||
843 | default: | ||
844 | break; | ||
845 | } | ||
846 | } | ||
847 | |||
848 | MHfolderItem::~MHfolderItem() | ||
849 | { | ||
850 | delete folder; | ||
851 | } | ||
852 | |||
853 | MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) | ||
854 | : AccountViewItem( parent,after ) | ||
855 | { | ||
856 | folder = folderInit; | ||
857 | mbox = parent; | ||
858 | initName(); | ||
859 | } | ||
860 | |||
861 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | ||
862 | : AccountViewItem( parent,after ) | ||
863 | { | ||
864 | folder = folderInit; | ||
865 | mbox = master; | ||
866 | initName(); | ||
867 | } | ||
868 | |||
869 | void MHfolderItem::initName() | ||
870 | { | ||
871 | QString bName = folder->getDisplayName(); | ||
872 | if (bName.startsWith("/")&&bName.length()>1) { | ||
873 | bName.replace(0,1,""); | ||
874 | } | ||
875 | if (bName.lower() == "outgoing") { | ||
876 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | ||
877 | } else if (bName.lower() == "inbox") { | ||
878 | setPixmap( 0, PIXMAP_INBOXFOLDER); | ||
879 | } else { | ||
880 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | ||
881 | } | ||
882 | setText( 0, bName ); | ||
883 | } | ||
884 | |||
885 | Folder*MHfolderItem::getFolder() | ||
886 | { | ||
887 | return folder; | ||
888 | } | ||
889 | |||
890 | void MHfolderItem::refresh(QList<RecMail>&target) | ||
891 | { | ||
892 | if (folder->may_select()) | ||
893 | mbox->getWrapper()->listMessages( folder->getName(),target ); | ||
894 | } | ||
895 | |||
896 | RecBody MHfolderItem::fetchBody(const RecMail&aMail) | ||
897 | { | ||
898 | return mbox->getWrapper()->fetchBody(aMail); | ||
899 | } | ||
900 | |||
901 | void MHfolderItem::deleteFolder() | ||
902 | { | ||
903 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
904 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
905 | QObject::tr("Yes",contextName), | ||
906 | QObject::tr("No",contextName),QString::null,1,1); | ||
907 | qDebug("Auswahl: %i",yesno); | ||
908 | if (yesno == 0) { | ||
909 | if (mbox->getWrapper()->deleteMbox(folder)) { | ||
910 | QListView*v=listView(); | ||
911 | MHviewItem * box = mbox; | ||
912 | /* be carefull - after that this object is destroyd so don't use | ||
913 | * any member of it after that call!!*/ | ||
914 | mbox->refresh(true); | ||
915 | if (v) { | ||
916 | v->setSelected(box,true); | ||
917 | } | ||
918 | } | ||
919 | } | ||
920 | } | ||
921 | |||
922 | QPopupMenu * MHfolderItem::getContextMenu() | ||
923 | { | ||
924 | QPopupMenu *m = new QPopupMenu(0); | ||
925 | if (m) { | ||
926 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | ||
927 | m->insertItem(QObject::tr("Delete folder",contextName),1); | ||
928 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | ||
929 | m->insertItem(QObject::tr("Create new folder",contextName),3); | ||
930 | } | ||
931 | return m; | ||
932 | } | ||
933 | |||
934 | void MHfolderItem::downloadMails() | ||
935 | { | ||
936 | AccountView*bl = mbox->accountView(); | ||
937 | if (!bl) return; | ||
938 | bl->downloadMails(folder,mbox->getWrapper()); | ||
939 | } | ||
940 | |||
941 | void MHfolderItem::contextMenuSelected(int which) | ||
942 | { | ||
943 | switch(which) { | ||
944 | case 0: | ||
945 | deleteAllMail(mbox->getWrapper(),folder); | ||
946 | break; | ||
947 | case 1: | ||
948 | deleteFolder(); | ||
949 | break; | ||
950 | case 2: | ||
951 | downloadMails(); | ||
952 | break; | ||
953 | default: | ||
954 | break; | ||
955 | } | ||
956 | } | ||
957 | |||
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 60e2b4b..9f92090 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -5,162 +5,12 @@ | |||
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include <libmailwrapper/settings.h> | 7 | class Selectstore; |
8 | #include <libmailwrapper/mailwrapper.h> | ||
9 | #include <libmailwrapper/abstractmail.h> | ||
10 | |||
11 | class POP3wrapper; | ||
12 | class RecMail; | 8 | class RecMail; |
13 | class RecBody; | 9 | class RecBody; |
14 | class QPopupMenu; | 10 | class Folder; |
15 | class Selectstore; | 11 | class AbstractMail; |
16 | class AccountView; | 12 | class Account; |
17 | 13 | class IMAPviewItem; | |
18 | class AccountViewItem : public QListViewItem | 14 | class MHviewItem; |
19 | { | ||
20 | |||
21 | public: | ||
22 | AccountViewItem( AccountView *parent ); | ||
23 | AccountViewItem( QListViewItem *parent); | ||
24 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | ||
25 | virtual ~AccountViewItem(); | ||
26 | virtual void refresh(QList<RecMail>&)=0; | ||
27 | virtual RecBody fetchBody(const RecMail&)=0; | ||
28 | virtual QPopupMenu * getContextMenu(){return 0;}; | ||
29 | virtual void contextMenuSelected(int){} | ||
30 | virtual AccountView*accountView(); | ||
31 | protected: | ||
32 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | ||
33 | static const QString contextName; | ||
34 | AccountView*m_Backlink; | ||
35 | }; | ||
36 | |||
37 | class POP3viewItem : public AccountViewItem | ||
38 | { | ||
39 | |||
40 | public: | ||
41 | POP3viewItem( POP3account *a, AccountView *parent ); | ||
42 | virtual ~POP3viewItem(); | ||
43 | virtual void refresh( QList<RecMail> &target ); | ||
44 | virtual RecBody fetchBody( const RecMail &mail ); | ||
45 | AbstractMail *getWrapper(); | ||
46 | virtual QPopupMenu * getContextMenu(); | ||
47 | virtual void contextMenuSelected(int); | ||
48 | |||
49 | protected: | ||
50 | POP3account *account; | ||
51 | virtual void refresh(); | ||
52 | AbstractMail *wrapper; | ||
53 | void disconnect(); | ||
54 | void setOnOffline(); | ||
55 | }; | ||
56 | |||
57 | class POP3folderItem : public AccountViewItem | ||
58 | { | ||
59 | |||
60 | public: | ||
61 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | ||
62 | virtual ~POP3folderItem(); | ||
63 | virtual void refresh(QList<RecMail>&); | ||
64 | virtual RecBody fetchBody(const RecMail&); | ||
65 | virtual QPopupMenu * getContextMenu(); | ||
66 | virtual void contextMenuSelected(int); | ||
67 | |||
68 | protected: | ||
69 | void downloadMails(); | ||
70 | Folder *folder; | ||
71 | POP3viewItem *pop3; | ||
72 | }; | ||
73 | |||
74 | class IMAPfolderItem; | ||
75 | |||
76 | class IMAPviewItem : public AccountViewItem | ||
77 | { | ||
78 | friend class IMAPfolderItem; | ||
79 | public: | ||
80 | IMAPviewItem( IMAPaccount *a, AccountView *parent ); | ||
81 | virtual ~IMAPviewItem(); | ||
82 | virtual void refresh(QList<RecMail>&); | ||
83 | virtual RecBody fetchBody(const RecMail&); | ||
84 | AbstractMail *getWrapper(); | ||
85 | virtual QPopupMenu * getContextMenu(); | ||
86 | virtual void contextMenuSelected(int); | ||
87 | const QStringList&subFolders(); | ||
88 | virtual void refreshFolders(bool force=false); | ||
89 | bool offline(); | ||
90 | |||
91 | protected: | ||
92 | IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); | ||
93 | virtual void createNewFolder(); | ||
94 | virtual void removeChilds(); | ||
95 | IMAPaccount *account; | ||
96 | AbstractMail *wrapper; | ||
97 | QStringList currentFolders; | ||
98 | }; | ||
99 | |||
100 | class IMAPfolderItem : public AccountViewItem | ||
101 | { | ||
102 | |||
103 | public: | ||
104 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | ||
105 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | ||
106 | virtual ~IMAPfolderItem(); | ||
107 | virtual void refresh(QList<RecMail>&); | ||
108 | virtual RecBody fetchBody(const RecMail&); | ||
109 | bool matchName(const QString&name)const; | ||
110 | virtual QPopupMenu * getContextMenu(); | ||
111 | virtual void contextMenuSelected(int); | ||
112 | virtual const QString& Delemiter()const; | ||
113 | protected: | ||
114 | virtual void createNewFolder(); | ||
115 | virtual void deleteFolder(); | ||
116 | virtual void downloadMails(); | ||
117 | Folder *folder; | ||
118 | IMAPviewItem *imap; | ||
119 | }; | ||
120 | |||
121 | class MHviewItem : public AccountViewItem | ||
122 | { | ||
123 | friend class MHfolderItem; | ||
124 | |||
125 | public: | ||
126 | MHviewItem( const QString&aMboxPath, AccountView *parent ); | ||
127 | virtual ~MHviewItem(); | ||
128 | virtual void refresh( QList<RecMail> &target ); | ||
129 | virtual RecBody fetchBody( const RecMail &mail ); | ||
130 | AbstractMail *getWrapper(); | ||
131 | virtual QPopupMenu * getContextMenu(); | ||
132 | virtual void contextMenuSelected(int); | ||
133 | QStringList subFolders(); | ||
134 | virtual void refresh(bool force=false); | ||
135 | |||
136 | protected: | ||
137 | void downloadMails(); | ||
138 | void removeChilds(); | ||
139 | virtual void createFolder(); | ||
140 | QString m_Path; | ||
141 | AbstractMail *wrapper; | ||
142 | Folder *folder; | ||
143 | }; | ||
144 | |||
145 | class MHfolderItem : public AccountViewItem | ||
146 | { | ||
147 | |||
148 | public: | ||
149 | MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); | ||
150 | MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | ||
151 | virtual ~MHfolderItem(); | ||
152 | virtual void refresh(QList<RecMail>&); | ||
153 | virtual RecBody fetchBody(const RecMail&); | ||
154 | virtual QPopupMenu * getContextMenu(); | ||
155 | virtual void contextMenuSelected(int); | ||
156 | virtual Folder*getFolder(); | ||
157 | |||
158 | protected: | ||
159 | void downloadMails(); | ||
160 | virtual void deleteFolder(); | ||
161 | void initName(); | ||
162 | Folder *folder; | ||
163 | MHviewItem *mbox; | ||
164 | }; | ||
165 | 15 | ||
166 | class AccountView : public QListView | 16 | class AccountView : public QListView |
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 90e1e46..552f0e5 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro | |||
@@ -5,4 +5,5 @@ HEADERS = defines.h \ | |||
5 | composemail.h \ | 5 | composemail.h \ |
6 | accountview.h \ | 6 | accountview.h \ |
7 | accountitem.h \ | ||
7 | mainwindow.h \ | 8 | mainwindow.h \ |
8 | viewmail.h \ | 9 | viewmail.h \ |
@@ -19,4 +20,5 @@ SOURCES = main.cpp \ | |||
19 | mainwindow.cpp \ | 20 | mainwindow.cpp \ |
20 | accountview.cpp \ | 21 | accountview.cpp \ |
22 | accountitem.cpp \ | ||
21 | composemail.cpp \ | 23 | composemail.cpp \ |
22 | addresspicker.cpp \ | 24 | addresspicker.cpp \ |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 39e3a64..d3d3cdb 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -10,4 +10,5 @@ | |||
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <libmailwrapper/mailtypes.h> | 11 | #include <libmailwrapper/mailtypes.h> |
12 | #include <libmailwrapper/abstractmail.h> | ||
12 | #include "mailistviewitem.h" | 13 | #include "mailistviewitem.h" |
13 | #include "viewmail.h" | 14 | #include "viewmail.h" |