author | alwin <alwin> | 2004-03-12 14:12:00 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-12 14:12:00 (UTC) |
commit | d1929ef43f0eaaa17aa42196384d1ed925132873 (patch) (unidiff) | |
tree | eff911f93fe7919d7820e5a2e68b72f2f76143da /noncore/net | |
parent | d38384a6edb0110117e0297864f813b379d52789 (diff) | |
download | opie-d1929ef43f0eaaa17aa42196384d1ed925132873.zip opie-d1929ef43f0eaaa17aa42196384d1ed925132873.tar.gz opie-d1929ef43f0eaaa17aa42196384d1ed925132873.tar.bz2 |
some pointers embedded into osmart_pointer handling
21 files changed, 190 insertions, 172 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 396dcb7..3e12563 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -52,33 +52,31 @@ AbstractMail *POP3viewItem::getWrapper() | |||
52 | void POP3viewItem::refresh( QList<RecMail> & ) | 52 | void POP3viewItem::refresh( QList<RecMail> & ) |
53 | { | 53 | { |
54 | refresh(); | 54 | refresh(); |
55 | } | 55 | } |
56 | 56 | ||
57 | void POP3viewItem::refresh() | 57 | void POP3viewItem::refresh() |
58 | { | 58 | { |
59 | if (account->getOffline()) return; | 59 | if (account->getOffline()) return; |
60 | QList<Folder> *folders = wrapper->listFolders(); | 60 | QValueList<FolderP> *folders = wrapper->listFolders(); |
61 | QListViewItem *child = firstChild(); | 61 | QListViewItem *child = firstChild(); |
62 | while ( child ) | 62 | while ( child ) |
63 | { | 63 | { |
64 | QListViewItem *tmp = child; | 64 | QListViewItem *tmp = child; |
65 | child = child->nextSibling(); | 65 | child = child->nextSibling(); |
66 | delete tmp; | 66 | delete tmp; |
67 | } | 67 | } |
68 | Folder *it; | 68 | QValueList<FolderP>::ConstIterator it; |
69 | QListViewItem*item = 0; | 69 | QListViewItem*item = 0; |
70 | for ( it = folders->first(); it; it = folders->next() ) | 70 | for ( it = folders->begin(); it!=folders->end(); ++it) |
71 | { | 71 | { |
72 | item = new POP3folderItem( it, this , item ); | 72 | item = new POP3folderItem( (*it), this , item ); |
73 | item->setSelectable(it->may_select()); | 73 | item->setSelectable( (*it)->may_select()); |
74 | } | 74 | } |
75 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
76 | folders->setAutoDelete(false); | ||
77 | delete folders; | 75 | delete folders; |
78 | } | 76 | } |
79 | 77 | ||
80 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 78 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
81 | { | 79 | { |
82 | qDebug( "POP3 fetchBody" ); | 80 | qDebug( "POP3 fetchBody" ); |
83 | return wrapper->fetchBody( mail ); | 81 | return wrapper->fetchBody( mail ); |
84 | } | 82 | } |
@@ -136,20 +134,19 @@ void POP3viewItem::contextMenuSelected(int which) | |||
136 | setOnOffline(); | 134 | setOnOffline(); |
137 | break; | 135 | break; |
138 | } | 136 | } |
139 | } | 137 | } |
140 | 138 | ||
141 | POP3folderItem::~POP3folderItem() | 139 | POP3folderItem::~POP3folderItem() |
142 | {} | 140 | {} |
143 | 141 | ||
144 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 142 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
145 | : AccountViewItem( parent,after ) | 143 | : AccountViewItem(folderInit,parent,after ) |
146 | { | 144 | { |
147 | folder = folderInit; | ||
148 | pop3 = parent; | 145 | pop3 = parent; |
149 | if (folder->getDisplayName().lower()!="inbox") | 146 | if (folder->getDisplayName().lower()!="inbox") |
150 | { | 147 | { |
151 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 148 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
152 | } | 149 | } |
153 | else | 150 | else |
154 | { | 151 | { |
155 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 152 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
@@ -245,33 +242,32 @@ AbstractMail *NNTPviewItem::getWrapper() | |||
245 | void NNTPviewItem::refresh( QList<RecMail> & ) | 242 | void NNTPviewItem::refresh( QList<RecMail> & ) |
246 | { | 243 | { |
247 | refresh(); | 244 | refresh(); |
248 | } | 245 | } |
249 | 246 | ||
250 | void NNTPviewItem::refresh() | 247 | void NNTPviewItem::refresh() |
251 | { | 248 | { |
252 | if (account->getOffline()) return; | 249 | if (account->getOffline()) return; |
253 | QList<Folder> *folders = wrapper->listFolders(); | 250 | QValueList<FolderP> *folders = wrapper->listFolders(); |
251 | |||
254 | QListViewItem *child = firstChild(); | 252 | QListViewItem *child = firstChild(); |
255 | while ( child ) | 253 | while ( child ) |
256 | { | 254 | { |
257 | QListViewItem *tmp = child; | 255 | QListViewItem *tmp = child; |
258 | child = child->nextSibling(); | 256 | child = child->nextSibling(); |
259 | delete tmp; | 257 | delete tmp; |
260 | } | 258 | } |
261 | Folder *it; | 259 | QValueList<FolderP>::ConstIterator it; |
262 | QListViewItem*item = 0; | 260 | QListViewItem*item = 0; |
263 | for ( it = folders->first(); it; it = folders->next() ) | 261 | for ( it = folders->begin(); it!=folders->end(); ++it) |
264 | { | 262 | { |
265 | item = new NNTPfolderItem( it, this , item ); | 263 | item = new NNTPfolderItem( (*it), this , item ); |
266 | item->setSelectable(it->may_select()); | 264 | item->setSelectable( (*it)->may_select()); |
267 | } | 265 | } |
268 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
269 | folders->setAutoDelete(false); | ||
270 | delete folders; | 266 | delete folders; |
271 | } | 267 | } |
272 | 268 | ||
273 | RecBody NNTPviewItem::fetchBody( const RecMail &mail ) | 269 | RecBody NNTPviewItem::fetchBody( const RecMail &mail ) |
274 | { | 270 | { |
275 | qDebug( "NNTP fetchBody" ); | 271 | qDebug( "NNTP fetchBody" ); |
276 | return wrapper->fetchBody( mail ); | 272 | return wrapper->fetchBody( mail ); |
277 | } | 273 | } |
@@ -342,20 +338,19 @@ void NNTPviewItem::contextMenuSelected(int which) | |||
342 | subscribeGroups(); | 338 | subscribeGroups(); |
343 | break; | 339 | break; |
344 | } | 340 | } |
345 | } | 341 | } |
346 | 342 | ||
347 | NNTPfolderItem::~NNTPfolderItem() | 343 | NNTPfolderItem::~NNTPfolderItem() |
348 | {} | 344 | {} |
349 | 345 | ||
350 | NNTPfolderItem::NNTPfolderItem( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after ) | 346 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
351 | : AccountViewItem( parent,after ) | 347 | : AccountViewItem( folderInit, parent,after ) |
352 | { | 348 | { |
353 | folder = folderInit; | ||
354 | nntp = parent; | 349 | nntp = parent; |
355 | if (folder->getDisplayName().lower()!="inbox") | 350 | if (folder->getDisplayName().lower()!="inbox") |
356 | { | 351 | { |
357 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 352 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
358 | } | 353 | } |
359 | else | 354 | else |
360 | { | 355 | { |
361 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 356 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
@@ -445,57 +440,55 @@ const QStringList&IMAPviewItem::subFolders() | |||
445 | 440 | ||
446 | void IMAPviewItem::refreshFolders(bool force) | 441 | void IMAPviewItem::refreshFolders(bool force) |
447 | { | 442 | { |
448 | if (childCount()>0 && force==false) return; | 443 | if (childCount()>0 && force==false) return; |
449 | if (account->getOffline()) return; | 444 | if (account->getOffline()) return; |
450 | 445 | ||
451 | removeChilds(); | 446 | removeChilds(); |
452 | currentFolders.clear(); | 447 | currentFolders.clear(); |
453 | QList<Folder> *folders = wrapper->listFolders(); | 448 | QValueList<FolderP> * folders = wrapper->listFolders(); |
454 | 449 | ||
455 | Folder *it; | 450 | QValueList<FolderP>::Iterator it; |
456 | QListViewItem*item = 0; | 451 | QListViewItem*item = 0; |
457 | QListViewItem*titem = 0; | 452 | QListViewItem*titem = 0; |
458 | QString fname,del,search; | 453 | QString fname,del,search; |
459 | int pos; | 454 | int pos; |
460 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
461 | folders->setAutoDelete(false); | ||
462 | 455 | ||
463 | for ( it = folders->first(); it; it = folders->next() ) | 456 | for ( it = folders->begin(); it!=folders->end(); ++it) |
464 | { | 457 | { |
465 | if (it->getDisplayName().lower()=="inbox") | 458 | if ((*it)->getDisplayName().lower()=="inbox") |
466 | { | 459 | { |
467 | item = new IMAPfolderItem( it, this , item ); | 460 | item = new IMAPfolderItem( (*it), this , item ); |
468 | folders->remove(it); | 461 | folders->remove(it); |
469 | qDebug("inbox found"); | 462 | qDebug("inbox found"); |
470 | break; | 463 | break; |
471 | } | 464 | } |
472 | } | 465 | } |
473 | for ( it = folders->first(); it; it = folders->next() ) | 466 | for ( it = folders->begin(); it!=folders->end(); ++it) |
474 | { | 467 | { |
475 | fname = it->getDisplayName(); | 468 | fname = (*it)->getDisplayName(); |
476 | currentFolders.append(it->getName()); | 469 | currentFolders.append((*it)->getName()); |
477 | pos = fname.findRev(it->Separator()); | 470 | pos = fname.findRev((*it)->Separator()); |
478 | if (pos != -1) | 471 | if (pos != -1) |
479 | { | 472 | { |
480 | fname = fname.left(pos); | 473 | fname = fname.left(pos); |
481 | } | 474 | } |
482 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 475 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
483 | if (pitem) | 476 | if (pitem) |
484 | { | 477 | { |
485 | titem = item; | 478 | titem = item; |
486 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 479 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
487 | /* setup the short name */ | 480 | /* setup the short name */ |
488 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 481 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
489 | item = titem; | 482 | item = titem; |
490 | } | 483 | } |
491 | else | 484 | else |
492 | { | 485 | { |
493 | item = new IMAPfolderItem( it, this , item ); | 486 | item = new IMAPfolderItem( (*it), this , item ); |
494 | } | 487 | } |
495 | } | 488 | } |
496 | delete folders; | 489 | delete folders; |
497 | } | 490 | } |
498 | 491 | ||
499 | QPopupMenu * IMAPviewItem::getContextMenu() | 492 | QPopupMenu * IMAPviewItem::getContextMenu() |
500 | { | 493 | { |
501 | QPopupMenu *m = new QPopupMenu(0); | 494 | QPopupMenu *m = new QPopupMenu(0); |
@@ -573,36 +566,34 @@ RecBody IMAPviewItem::fetchBody(const RecMail&) | |||
573 | return RecBody(); | 566 | return RecBody(); |
574 | } | 567 | } |
575 | 568 | ||
576 | bool IMAPviewItem::offline() | 569 | bool IMAPviewItem::offline() |
577 | { | 570 | { |
578 | return account->getOffline(); | 571 | return account->getOffline(); |
579 | } | 572 | } |
580 | 573 | ||
581 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 574 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
582 | : AccountViewItem( parent , after ) | 575 | : AccountViewItem( folderInit, parent , after ) |
583 | { | 576 | { |
584 | folder = folderInit; | ||
585 | imap = parent; | 577 | imap = parent; |
586 | if (folder->getDisplayName().lower()!="inbox") | 578 | if (folder->getDisplayName().lower()!="inbox") |
587 | { | 579 | { |
588 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 580 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
589 | } | 581 | } |
590 | else | 582 | else |
591 | { | 583 | { |
592 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 584 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
593 | } | 585 | } |
594 | setText( 0, folder->getDisplayName() ); | 586 | setText( 0, folder->getDisplayName() ); |
595 | } | 587 | } |
596 | 588 | ||
597 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 589 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
598 | : AccountViewItem( parent,after ) | 590 | : AccountViewItem(folderInit, parent,after ) |
599 | { | 591 | { |
600 | folder = folderInit; | ||
601 | imap = master; | 592 | imap = master; |
602 | if (folder->getDisplayName().lower()!="inbox") | 593 | if (folder->getDisplayName().lower()!="inbox") |
603 | { | 594 | { |
604 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 595 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
605 | } | 596 | } |
606 | else | 597 | else |
607 | { | 598 | { |
608 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 599 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
@@ -763,55 +754,53 @@ void MHviewItem::refresh( QList<RecMail> & target) | |||
763 | getWrapper()->listMessages( "",target ); | 754 | getWrapper()->listMessages( "",target ); |
764 | } | 755 | } |
765 | 756 | ||
766 | void MHviewItem::refresh(bool force) | 757 | void MHviewItem::refresh(bool force) |
767 | { | 758 | { |
768 | if (childCount()>0 && force==false) return; | 759 | if (childCount()>0 && force==false) return; |
769 | removeChilds(); | 760 | removeChilds(); |
770 | currentFolders.clear(); | 761 | currentFolders.clear(); |
771 | QList<Folder> *folders = wrapper->listFolders(); | 762 | QValueList<FolderP> *folders = wrapper->listFolders(); |
772 | Folder *it; | 763 | QValueList<FolderP>::ConstIterator it; |
773 | MHfolderItem*item = 0; | 764 | MHfolderItem*item = 0; |
774 | MHfolderItem*pmaster = 0; | 765 | MHfolderItem*pmaster = 0; |
775 | QString fname = ""; | 766 | QString fname = ""; |
776 | int pos; | 767 | int pos; |
777 | for ( it = folders->first(); it; it = folders->next() ) | 768 | for ( it = folders->begin(); it!=folders->end(); ++it) |
778 | { | 769 | { |
779 | fname = it->getDisplayName(); | 770 | fname = (*it)->getDisplayName(); |
780 | /* this folder itself */ | 771 | /* this folder itself */ |
781 | if (fname=="/") | 772 | if (fname=="/") |
782 | { | 773 | { |
783 | currentFolders.append(fname); | 774 | currentFolders.append(fname); |
784 | folder = it; | 775 | folder = (*it); |
785 | continue; | 776 | continue; |
786 | } | 777 | } |
787 | currentFolders.append(fname); | 778 | currentFolders.append(fname); |
788 | pos = fname.findRev("/"); | 779 | pos = fname.findRev("/"); |
789 | if (pos > 0) | 780 | if (pos > 0) |
790 | { | 781 | { |
791 | fname = fname.left(pos); | 782 | fname = fname.left(pos); |
792 | pmaster = (MHfolderItem*)findSubItem(fname); | 783 | pmaster = (MHfolderItem*)findSubItem(fname); |
793 | } | 784 | } |
794 | else | 785 | else |
795 | { | 786 | { |
796 | pmaster = 0; | 787 | pmaster = 0; |
797 | } | 788 | } |
798 | if (pmaster) | 789 | if (pmaster) |
799 | { | 790 | { |
800 | item = new MHfolderItem( it, pmaster, item, this ); | 791 | item = new MHfolderItem( (*it), pmaster, item, this ); |
801 | } | 792 | } |
802 | else | 793 | else |
803 | { | 794 | { |
804 | item = new MHfolderItem( it, this , item ); | 795 | item = new MHfolderItem( (*it), this , item ); |
805 | } | 796 | } |
806 | item->setSelectable(it->may_select()); | 797 | item->setSelectable((*it)->may_select()); |
807 | } | 798 | } |
808 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
809 | folders->setAutoDelete(false); | ||
810 | delete folders; | 799 | delete folders; |
811 | } | 800 | } |
812 | 801 | ||
813 | RecBody MHviewItem::fetchBody( const RecMail &mail ) | 802 | RecBody MHviewItem::fetchBody( const RecMail &mail ) |
814 | { | 803 | { |
815 | qDebug( "MH fetchBody" ); | 804 | qDebug( "MH fetchBody" ); |
816 | return wrapper->fetchBody( mail ); | 805 | return wrapper->fetchBody( mail ); |
817 | } | 806 | } |
@@ -873,26 +862,25 @@ void MHviewItem::contextMenuSelected(int which) | |||
873 | default: | 862 | default: |
874 | break; | 863 | break; |
875 | } | 864 | } |
876 | } | 865 | } |
877 | 866 | ||
878 | MHfolderItem::~MHfolderItem() | 867 | MHfolderItem::~MHfolderItem() |
879 | {} | 868 | {} |
880 | 869 | ||
881 | MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) | 870 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
882 | : AccountViewItem( parent,after ) | 871 | : AccountViewItem(folderInit, parent,after ) |
883 | { | 872 | { |
884 | folder = folderInit; | ||
885 | mbox = parent; | 873 | mbox = parent; |
886 | initName(); | 874 | initName(); |
887 | } | 875 | } |
888 | 876 | ||
889 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 877 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
890 | : AccountViewItem( parent,after ) | 878 | : AccountViewItem(folderInit, parent,after ) |
891 | { | 879 | { |
892 | folder = folderInit; | 880 | folder = folderInit; |
893 | mbox = master; | 881 | mbox = master; |
894 | initName(); | 882 | initName(); |
895 | } | 883 | } |
896 | 884 | ||
897 | void MHfolderItem::initName() | 885 | void MHfolderItem::initName() |
898 | { | 886 | { |
@@ -916,17 +904,17 @@ void MHfolderItem::initName() | |||
916 | } else if (bName.lower() == "drafts") { | 904 | } else if (bName.lower() == "drafts") { |
917 | setPixmap(0, Resource::loadPixmap("inline/edit")); | 905 | setPixmap(0, Resource::loadPixmap("inline/edit")); |
918 | } else { | 906 | } else { |
919 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 907 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
920 | } | 908 | } |
921 | setText( 0, bName ); | 909 | setText( 0, bName ); |
922 | } | 910 | } |
923 | 911 | ||
924 | Folder*MHfolderItem::getFolder() | 912 | const FolderP&MHfolderItem::getFolder()const |
925 | { | 913 | { |
926 | return folder; | 914 | return folder; |
927 | } | 915 | } |
928 | 916 | ||
929 | void MHfolderItem::refresh(QList<RecMail>&target) | 917 | void MHfolderItem::refresh(QList<RecMail>&target) |
930 | { | 918 | { |
931 | if (folder->may_select()) | 919 | if (folder->may_select()) |
932 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 920 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
@@ -1038,44 +1026,49 @@ const QString AccountViewItem::contextName="AccountViewItem"; | |||
1038 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1026 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1039 | : QListViewItem( parent ) | 1027 | : QListViewItem( parent ) |
1040 | { | 1028 | { |
1041 | init(); | 1029 | init(); |
1042 | m_Backlink = parent; | 1030 | m_Backlink = parent; |
1043 | } | 1031 | } |
1044 | 1032 | ||
1045 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1033 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1046 | : QListViewItem( parent) | 1034 | : QListViewItem( parent),folder(0) |
1047 | { | 1035 | { |
1048 | init(); | 1036 | init(); |
1049 | } | 1037 | } |
1050 | 1038 | ||
1051 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1039 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1052 | :QListViewItem( parent,after ) | 1040 | :QListViewItem( parent,after ),folder(0) |
1041 | { | ||
1042 | init(); | ||
1043 | } | ||
1044 | |||
1045 | AccountViewItem::AccountViewItem( const Opie::osmart_pointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | ||
1046 | :QListViewItem( parent,after ),folder(folderInit) | ||
1053 | { | 1047 | { |
1054 | init(); | 1048 | init(); |
1055 | } | 1049 | } |
1056 | 1050 | ||
1057 | void AccountViewItem::init() | 1051 | void AccountViewItem::init() |
1058 | { | 1052 | { |
1059 | m_Backlink = 0; | 1053 | m_Backlink = 0; |
1060 | folder = 0; | ||
1061 | } | 1054 | } |
1062 | 1055 | ||
1063 | AccountViewItem::~AccountViewItem() | 1056 | AccountViewItem::~AccountViewItem() |
1064 | { | 1057 | { |
1065 | if (folder) delete folder; | 1058 | folder = 0; |
1066 | } | 1059 | } |
1067 | 1060 | ||
1068 | AccountView*AccountViewItem::accountView() | 1061 | AccountView*AccountViewItem::accountView() |
1069 | { | 1062 | { |
1070 | return m_Backlink; | 1063 | return m_Backlink; |
1071 | } | 1064 | } |
1072 | 1065 | ||
1073 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | 1066 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1074 | { | 1067 | { |
1075 | if (!wrapper) return; | 1068 | if (!wrapper) return; |
1076 | QString fname=""; | 1069 | QString fname=""; |
1077 | if (folder) fname = folder->getDisplayName(); | 1070 | if (folder) fname = folder->getDisplayName(); |
1078 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1071 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1079 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1072 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1080 | arg(fname), | 1073 | arg(fname), |
1081 | QObject::tr("Yes",contextName), | 1074 | QObject::tr("Yes",contextName), |
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index eb3baa3..8f712f5 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h | |||
@@ -1,50 +1,53 @@ | |||
1 | #ifndef __ACCOUNT_ITEM | 1 | #ifndef __ACCOUNT_ITEM |
2 | #define __ACCOUNT_ITEM | 2 | #define __ACCOUNT_ITEM |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmart_pointer.h> | ||
6 | 7 | ||
7 | class POP3wrapper; | 8 | class POP3wrapper; |
8 | class RecMail; | 9 | class RecMail; |
9 | class RecBody; | 10 | class RecBody; |
10 | class QPopupMenu; | 11 | class QPopupMenu; |
11 | class Selectstore; | 12 | class Selectstore; |
12 | class AccountView; | 13 | class AccountView; |
13 | class POP3account; | 14 | class POP3account; |
14 | class NNTPaccount; | 15 | class NNTPaccount; |
15 | class IMAPaccount; | 16 | class IMAPaccount; |
16 | class AbstractMail; | 17 | class AbstractMail; |
17 | class Folder; | 18 | class Folder; |
18 | 19 | ||
19 | class AccountViewItem : public QListViewItem | 20 | class AccountViewItem : public QListViewItem |
20 | { | 21 | { |
21 | 22 | ||
22 | public: | 23 | public: |
23 | AccountViewItem( AccountView *parent ); | 24 | AccountViewItem( AccountView *parent ); |
24 | AccountViewItem( QListViewItem *parent); | 25 | AccountViewItem( QListViewItem *parent); |
25 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); | 26 | AccountViewItem( QListViewItem *parent , QListViewItem*after ); |
27 | AccountViewItem( const Opie::osmart_pointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); | ||
28 | |||
26 | virtual ~AccountViewItem(); | 29 | virtual ~AccountViewItem(); |
27 | virtual void refresh(QList<RecMail>&)=0; | 30 | virtual void refresh(QList<RecMail>&)=0; |
28 | virtual RecBody fetchBody(const RecMail&)=0; | 31 | virtual RecBody fetchBody(const RecMail&)=0; |
29 | virtual QPopupMenu * getContextMenu(){return 0;}; | 32 | virtual QPopupMenu * getContextMenu(){return 0;}; |
30 | virtual void contextMenuSelected(int){} | 33 | virtual void contextMenuSelected(int){} |
31 | virtual AccountView*accountView(); | 34 | virtual AccountView*accountView(); |
32 | virtual bool matchName(const QString&name)const; | 35 | virtual bool matchName(const QString&name)const; |
33 | virtual bool isDraftfolder(); | 36 | virtual bool isDraftfolder(); |
34 | 37 | ||
35 | protected: | 38 | protected: |
36 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); | 39 | AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); |
37 | virtual void init(); | 40 | virtual void init(); |
38 | virtual void removeChilds(); | 41 | virtual void removeChilds(); |
39 | virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); | 42 | virtual void deleteAllMail(AbstractMail*wrapper,const Opie::osmart_pointer<Folder>&f); |
40 | static const QString contextName; | 43 | static const QString contextName; |
41 | AccountView*m_Backlink; | 44 | AccountView*m_Backlink; |
42 | Folder *folder; | 45 | Opie::osmart_pointer<Folder> folder; |
43 | }; | 46 | }; |
44 | 47 | ||
45 | class POP3viewItem : public AccountViewItem | 48 | class POP3viewItem : public AccountViewItem |
46 | { | 49 | { |
47 | 50 | ||
48 | public: | 51 | public: |
49 | POP3viewItem( POP3account *a, AccountView *parent ); | 52 | POP3viewItem( POP3account *a, AccountView *parent ); |
50 | virtual ~POP3viewItem(); | 53 | virtual ~POP3viewItem(); |
@@ -61,17 +64,17 @@ protected: | |||
61 | void disconnect(); | 64 | void disconnect(); |
62 | void setOnOffline(); | 65 | void setOnOffline(); |
63 | }; | 66 | }; |
64 | 67 | ||
65 | class POP3folderItem : public AccountViewItem | 68 | class POP3folderItem : public AccountViewItem |
66 | { | 69 | { |
67 | 70 | ||
68 | public: | 71 | public: |
69 | POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); | 72 | POP3folderItem( const Opie::osmart_pointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); |
70 | virtual ~POP3folderItem(); | 73 | virtual ~POP3folderItem(); |
71 | virtual void refresh(QList<RecMail>&); | 74 | virtual void refresh(QList<RecMail>&); |
72 | virtual RecBody fetchBody(const RecMail&); | 75 | virtual RecBody fetchBody(const RecMail&); |
73 | virtual QPopupMenu * getContextMenu(); | 76 | virtual QPopupMenu * getContextMenu(); |
74 | virtual void contextMenuSelected(int); | 77 | virtual void contextMenuSelected(int); |
75 | 78 | ||
76 | protected: | 79 | protected: |
77 | void downloadMails(); | 80 | void downloadMails(); |
@@ -99,17 +102,17 @@ protected: | |||
99 | void setOnOffline(); | 102 | void setOnOffline(); |
100 | void subscribeGroups(); | 103 | void subscribeGroups(); |
101 | }; | 104 | }; |
102 | 105 | ||
103 | class NNTPfolderItem : public AccountViewItem | 106 | class NNTPfolderItem : public AccountViewItem |
104 | { | 107 | { |
105 | 108 | ||
106 | public: | 109 | public: |
107 | NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after ); | 110 | NNTPfolderItem(const Opie::osmart_pointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); |
108 | virtual ~NNTPfolderItem(); | 111 | virtual ~NNTPfolderItem(); |
109 | virtual void refresh(QList<RecMail>&); | 112 | virtual void refresh(QList<RecMail>&); |
110 | virtual RecBody fetchBody(const RecMail&); | 113 | virtual RecBody fetchBody(const RecMail&); |
111 | virtual QPopupMenu * getContextMenu(); | 114 | virtual QPopupMenu * getContextMenu(); |
112 | virtual void contextMenuSelected(int); | 115 | virtual void contextMenuSelected(int); |
113 | 116 | ||
114 | protected: | 117 | protected: |
115 | void downloadMails(); | 118 | void downloadMails(); |
@@ -139,18 +142,18 @@ protected: | |||
139 | AbstractMail *wrapper; | 142 | AbstractMail *wrapper; |
140 | QStringList currentFolders; | 143 | QStringList currentFolders; |
141 | }; | 144 | }; |
142 | 145 | ||
143 | class IMAPfolderItem : public AccountViewItem | 146 | class IMAPfolderItem : public AccountViewItem |
144 | { | 147 | { |
145 | 148 | ||
146 | public: | 149 | public: |
147 | IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); | 150 | IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); |
148 | IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); | 151 | IMAPfolderItem( const Opie::osmart_pointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); |
149 | virtual ~IMAPfolderItem(); | 152 | virtual ~IMAPfolderItem(); |
150 | virtual void refresh(QList<RecMail>&); | 153 | virtual void refresh(QList<RecMail>&); |
151 | virtual RecBody fetchBody(const RecMail&); | 154 | virtual RecBody fetchBody(const RecMail&); |
152 | virtual QPopupMenu * getContextMenu(); | 155 | virtual QPopupMenu * getContextMenu(); |
153 | virtual void contextMenuSelected(int); | 156 | virtual void contextMenuSelected(int); |
154 | virtual const QString& Delemiter()const; | 157 | virtual const QString& Delemiter()const; |
155 | protected: | 158 | protected: |
156 | virtual void createNewFolder(); | 159 | virtual void createNewFolder(); |
@@ -181,24 +184,24 @@ protected: | |||
181 | AbstractMail *wrapper; | 184 | AbstractMail *wrapper; |
182 | QStringList currentFolders; | 185 | QStringList currentFolders; |
183 | }; | 186 | }; |
184 | 187 | ||
185 | class MHfolderItem : public AccountViewItem | 188 | class MHfolderItem : public AccountViewItem |
186 | { | 189 | { |
187 | 190 | ||
188 | public: | 191 | public: |
189 | MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); | 192 | MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); |
190 | MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); | 193 | MHfolderItem( const Opie::osmart_pointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); |
191 | virtual ~MHfolderItem(); | 194 | virtual ~MHfolderItem(); |
192 | virtual void refresh(QList<RecMail>&); | 195 | virtual void refresh(QList<RecMail>&); |
193 | virtual RecBody fetchBody(const RecMail&); | 196 | virtual RecBody fetchBody(const RecMail&); |
194 | virtual QPopupMenu * getContextMenu(); | 197 | virtual QPopupMenu * getContextMenu(); |
195 | virtual void contextMenuSelected(int); | 198 | virtual void contextMenuSelected(int); |
196 | virtual Folder*getFolder(); | 199 | virtual const Opie::osmart_pointer<Folder>&getFolder()const; |
197 | virtual bool isDraftfolder(); | 200 | virtual bool isDraftfolder(); |
198 | 201 | ||
199 | protected: | 202 | protected: |
200 | void downloadMails(); | 203 | void downloadMails(); |
201 | virtual void createFolder(); | 204 | virtual void createFolder(); |
202 | virtual void deleteFolder(); | 205 | virtual void deleteFolder(); |
203 | void initName(); | 206 | void initName(); |
204 | MHviewItem *mbox; | 207 | MHviewItem *mbox; |
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 7938d4f..297f553 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -138,17 +138,17 @@ void AccountView::setupFolderselect(Selectstore*sels) | |||
138 | { | 138 | { |
139 | if (imapAccounts[i]->offline()) | 139 | if (imapAccounts[i]->offline()) |
140 | continue; | 140 | continue; |
141 | imapAccounts[i]->refreshFolders(false); | 141 | imapAccounts[i]->refreshFolders(false); |
142 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); | 142 | sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) | 146 | void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) |
147 | { | 147 | { |
148 | AbstractMail*targetMail = 0; | 148 | AbstractMail*targetMail = 0; |
149 | QString targetFolder = ""; | 149 | QString targetFolder = ""; |
150 | Selectstore sels; | 150 | Selectstore sels; |
151 | setupFolderselect(&sels); | 151 | setupFolderselect(&sels); |
152 | if (!sels.exec()) return; | 152 | if (!sels.exec()) return; |
153 | targetMail = sels.currentMail(); | 153 | targetMail = sels.currentMail(); |
154 | targetFolder = sels.currentFolder(); | 154 | targetFolder = sels.currentFolder(); |
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 5000202..3478c0b 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h | |||
@@ -1,13 +1,14 @@ | |||
1 | #ifndef ACCOUNTVIEW_H | 1 | #ifndef ACCOUNTVIEW_H |
2 | #define ACCOUNTVIEW_H | 2 | #define ACCOUNTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <opie2/osmart_pointer.h> | ||
6 | 7 | ||
7 | class Selectstore; | 8 | class Selectstore; |
8 | class RecMail; | 9 | class RecMail; |
9 | class RecBody; | 10 | class RecBody; |
10 | class Folder; | 11 | class Folder; |
11 | class AbstractMail; | 12 | class AbstractMail; |
12 | class Account; | 13 | class Account; |
13 | class IMAPviewItem; | 14 | class IMAPviewItem; |
@@ -17,29 +18,29 @@ class AccountView : public QListView | |||
17 | { | 18 | { |
18 | Q_OBJECT | 19 | Q_OBJECT |
19 | 20 | ||
20 | public: | 21 | public: |
21 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 22 | AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
22 | virtual ~AccountView(); | 23 | virtual ~AccountView(); |
23 | virtual void populate( QList<Account> list ); | 24 | virtual void populate( QList<Account> list ); |
24 | virtual RecBody fetchBody(const RecMail&aMail); | 25 | virtual RecBody fetchBody(const RecMail&aMail); |
25 | virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); | 26 | virtual void downloadMails(const Opie::osmart_pointer<Folder>&fromFolder,AbstractMail*fromWrapper); |
26 | virtual bool currentisDraft(); | 27 | virtual bool currentisDraft(); |
27 | 28 | ||
28 | public slots: | 29 | public slots: |
29 | virtual void refreshAll(); | 30 | virtual void refreshAll(); |
30 | virtual void refresh(QListViewItem *item); | 31 | virtual void refresh(QListViewItem *item); |
31 | virtual void refreshCurrent(); | 32 | virtual void refreshCurrent(); |
32 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); | 33 | virtual void slotHold(int, QListViewItem *,const QPoint&,int); |
33 | virtual void slotContextMenu(int id); | 34 | virtual void slotContextMenu(int id); |
34 | void setupFolderselect(Selectstore*sels); | 35 | void setupFolderselect(Selectstore*sels); |
35 | 36 | ||
36 | signals: | 37 | signals: |
37 | void refreshMailview(QList<RecMail>*); | 38 | void refreshMailview(QList<RecMail>*); |
38 | 39 | ||
39 | protected: | 40 | protected: |
40 | QListViewItem* m_currentItem; | 41 | QListViewItem* m_currentItem; |
41 | QValueList<IMAPviewItem*> imapAccounts; | 42 | QValueList<IMAPviewItem*> imapAccounts; |
42 | QValueList<MHviewItem*> mhAccounts; | 43 | QValueList<MHviewItem*> mhAccounts; |
43 | }; | 44 | }; |
44 | 45 | ||
45 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index ac6f380..7e6d383 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -106,17 +106,17 @@ QString AbstractMail::gen_attachment_id() | |||
106 | if (!file.open(IO_ReadOnly ) ) | 106 | if (!file.open(IO_ReadOnly ) ) |
107 | return QString::null; | 107 | return QString::null; |
108 | 108 | ||
109 | QTextStream stream(&file); | 109 | QTextStream stream(&file); |
110 | 110 | ||
111 | return "{" + stream.read().stripWhiteSpace() + "}"; | 111 | return "{" + stream.read().stripWhiteSpace() + "}"; |
112 | } | 112 | } |
113 | 113 | ||
114 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 114 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& delemiter,bool) |
115 | { | 115 | { |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
119 | QString AbstractMail::defaultLocalfolder() | 119 | QString AbstractMail::defaultLocalfolder() |
120 | { | 120 | { |
121 | QString f = getenv( "HOME" ); | 121 | QString f = getenv( "HOME" ); |
122 | f += "/Applications/opiemail/localmail"; | 122 | f += "/Applications/opiemail/localmail"; |
@@ -128,17 +128,18 @@ QString AbstractMail::draftFolder() | |||
128 | return QString("Drafts"); | 128 | return QString("Drafts"); |
129 | } | 129 | } |
130 | 130 | ||
131 | /* temporary - will be removed when implemented in all classes */ | 131 | /* temporary - will be removed when implemented in all classes */ |
132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 132 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) |
133 | { | 133 | { |
134 | } | 134 | } |
135 | 135 | ||
136 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 136 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
137 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
137 | { | 138 | { |
138 | QList<RecMail> t; | 139 | QList<RecMail> t; |
139 | listMessages(fromFolder->getName(),t); | 140 | listMessages(fromFolder->getName(),t); |
140 | encodedString*st = 0; | 141 | encodedString*st = 0; |
141 | while (t.count()>0) { | 142 | while (t.count()>0) { |
142 | RecMail*r = t.at(0); | 143 | RecMail*r = t.at(0); |
143 | st = fetchRawBody(*r); | 144 | st = fetchRawBody(*r); |
144 | if (st) { | 145 | if (st) { |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index d377452..d911468 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,57 +1,61 @@ | |||
1 | #ifndef __abstract_mail_ | 1 | #ifndef __abstract_mail_ |
2 | #define __abstract_mail_ | 2 | #define __abstract_mail_ |
3 | 3 | ||
4 | #include "maildefines.h" | 4 | #include "maildefines.h" |
5 | 5 | ||
6 | #include <qobject.h> | ||
7 | #include "settings.h" | 6 | #include "settings.h" |
8 | 7 | ||
8 | #include <qobject.h> | ||
9 | #include <opie2/osmart_pointer.h> | ||
10 | |||
9 | class RecMail; | 11 | class RecMail; |
10 | class RecBody; | 12 | class RecBody; |
11 | class RecPart; | 13 | class RecPart; |
12 | class IMAPwrapper; | 14 | class IMAPwrapper; |
13 | class POP3wrapper; | 15 | class POP3wrapper; |
14 | class Folder; | 16 | class Folder; |
15 | class encodedString; | 17 | class encodedString; |
16 | struct folderStat; | 18 | struct folderStat; |
17 | 19 | ||
18 | class AbstractMail:public QObject | 20 | class AbstractMail:public QObject |
19 | { | 21 | { |
20 | Q_OBJECT | 22 | Q_OBJECT |
21 | public: | 23 | public: |
22 | AbstractMail(){}; | 24 | AbstractMail(){}; |
23 | virtual ~AbstractMail(){} | 25 | virtual ~AbstractMail(){} |
24 | virtual QList<Folder>* listFolders()=0; | 26 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders()=0; |
25 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
26 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
27 | virtual RecBody fetchBody(const RecMail&mail)=0; | 29 | virtual RecBody fetchBody(const RecMail&mail)=0; |
28 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 30 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 31 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
30 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 32 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
31 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | 33 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; |
32 | 34 | ||
33 | virtual void deleteMail(const RecMail&mail)=0; | 35 | virtual void deleteMail(const RecMail&mail)=0; |
34 | virtual void answeredMail(const RecMail&mail)=0; | 36 | virtual void answeredMail(const RecMail&mail)=0; |
35 | virtual int deleteAllMail(const Folder*)=0; | 37 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&)=0; |
36 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 38 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
37 | virtual int deleteMbox(const Folder*)=0; | 39 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&)=0; |
38 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 40 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
39 | 41 | ||
40 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 42 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, |
43 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
41 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 44 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
42 | 45 | ||
43 | virtual void cleanMimeCache(){}; | 46 | virtual void cleanMimeCache(){}; |
44 | /* mail box methods */ | 47 | /* mail box methods */ |
45 | /* parameter is the box to create. | 48 | /* parameter is the box to create. |
46 | * if the implementing subclass has prefixes, | 49 | * if the implementing subclass has prefixes, |
47 | * them has to be appended automatic. | 50 | * them has to be appended automatic. |
48 | */ | 51 | */ |
49 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 52 | virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0, |
53 | const QString& delemiter="/",bool getsubfolder=false); | ||
50 | virtual void logout()=0; | 54 | virtual void logout()=0; |
51 | 55 | ||
52 | static AbstractMail* getWrapper(IMAPaccount *a); | 56 | static AbstractMail* getWrapper(IMAPaccount *a); |
53 | static AbstractMail* getWrapper(POP3account *a); | 57 | static AbstractMail* getWrapper(POP3account *a); |
54 | static AbstractMail* getWrapper(NNTPaccount *a); | 58 | static AbstractMail* getWrapper(NNTPaccount *a); |
55 | /* mbox only! */ | 59 | /* mbox only! */ |
56 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 60 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
57 | static AbstractMail* getWrapper(Account*a); | 61 | static AbstractMail* getWrapper(Account*a); |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index b3cd4fe..d0db45a 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -33,17 +33,17 @@ class Genericwrapper : public AbstractMail | |||
33 | public: | 33 | public: |
34 | Genericwrapper(); | 34 | Genericwrapper(); |
35 | virtual ~Genericwrapper(); | 35 | virtual ~Genericwrapper(); |
36 | 36 | ||
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
39 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
40 | virtual void cleanMimeCache(); | 40 | virtual void cleanMimeCache(); |
41 | virtual int deleteMbox(const Folder*){return 1;} | 41 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&){return 1;} |
42 | virtual void logout(){}; | 42 | virtual void logout(){}; |
43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; | 43 | virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; |
44 | 44 | ||
45 | protected: | 45 | protected: |
46 | RecBody parseMail( mailmessage * msg ); | 46 | RecBody parseMail( mailmessage * msg ); |
47 | QString parseMailboxList( mailimf_mailbox_list *list ); | 47 | QString parseMailboxList( mailimf_mailbox_list *list ); |
48 | QString parseMailbox( mailimf_mailbox *box ); | 48 | QString parseMailbox( mailimf_mailbox *box ); |
49 | QString parseGroup( mailimf_group *group ); | 49 | QString parseGroup( mailimf_group *group ); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index e29a0a0..3b3be0f 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -261,27 +261,26 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
261 | } | 261 | } |
262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 262 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
263 | } else { | 263 | } else { |
264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
265 | } | 265 | } |
266 | if (result) mailimap_fetch_list_free(result); | 266 | if (result) mailimap_fetch_list_free(result); |
267 | } | 267 | } |
268 | 268 | ||
269 | QList<Folder>* IMAPwrapper::listFolders() | 269 | QValueList<Opie::osmart_pointer<Folder> >* IMAPwrapper::listFolders() |
270 | { | 270 | { |
271 | const char *path, *mask; | 271 | const char *path, *mask; |
272 | int err = MAILIMAP_NO_ERROR; | 272 | int err = MAILIMAP_NO_ERROR; |
273 | clist *result = 0; | 273 | clist *result = 0; |
274 | clistcell *current = 0; | 274 | clistcell *current = 0; |
275 | clistcell*cur_flag = 0; | 275 | clistcell*cur_flag = 0; |
276 | mailimap_mbx_list_flags*bflags = 0; | 276 | mailimap_mbx_list_flags*bflags = 0; |
277 | 277 | ||
278 | QList<Folder> * folders = new QList<Folder>(); | 278 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
279 | folders->setAutoDelete( false ); | ||
280 | login(); | 279 | login(); |
281 | if (!m_imap) { | 280 | if (!m_imap) { |
282 | return folders; | 281 | return folders; |
283 | } | 282 | } |
284 | 283 | ||
285 | /* | 284 | /* |
286 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 285 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
287 | * We must not forget to filter them out in next loop! | 286 | * We must not forget to filter them out in next loop! |
@@ -961,17 +960,17 @@ encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&pa | |||
961 | return r; | 960 | return r; |
962 | } | 961 | } |
963 | 962 | ||
964 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 963 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
965 | { | 964 | { |
966 | return fetchRawPart(mail,part.Positionlist(),false); | 965 | return fetchRawPart(mail,part.Positionlist(),false); |
967 | } | 966 | } |
968 | 967 | ||
969 | int IMAPwrapper::deleteAllMail(const Folder*folder) | 968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
970 | { | 969 | { |
971 | login(); | 970 | login(); |
972 | if (!m_imap) { | 971 | if (!m_imap) { |
973 | return 0; | 972 | return 0; |
974 | } | 973 | } |
975 | mailimap_flag_list*flist; | 974 | mailimap_flag_list*flist; |
976 | mailimap_set *set; | 975 | mailimap_set *set; |
977 | mailimap_store_att_flags * store_flags; | 976 | mailimap_store_att_flags * store_flags; |
@@ -1002,17 +1001,17 @@ int IMAPwrapper::deleteAllMail(const Folder*folder) | |||
1002 | if (err != MAILIMAP_NO_ERROR) { | 1001 | if (err != MAILIMAP_NO_ERROR) { |
1003 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1002 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1004 | return 0; | 1003 | return 0; |
1005 | } | 1004 | } |
1006 | qDebug("Delete successfull %s",m_imap->imap_response); | 1005 | qDebug("Delete successfull %s",m_imap->imap_response); |
1007 | return 1; | 1006 | return 1; |
1008 | } | 1007 | } |
1009 | 1008 | ||
1010 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 1009 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1011 | { | 1010 | { |
1012 | if (folder.length()==0) return 0; | 1011 | if (folder.length()==0) return 0; |
1013 | login(); | 1012 | login(); |
1014 | if (!m_imap) {return 0;} | 1013 | if (!m_imap) {return 0;} |
1015 | QString pre = account->getPrefix(); | 1014 | QString pre = account->getPrefix(); |
1016 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1015 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1017 | pre+=delemiter; | 1016 | pre+=delemiter; |
1018 | } | 1017 | } |
@@ -1032,17 +1031,17 @@ int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const | |||
1032 | int res = mailimap_create(m_imap,pre.latin1()); | 1031 | int res = mailimap_create(m_imap,pre.latin1()); |
1033 | if (res != MAILIMAP_NO_ERROR) { | 1032 | if (res != MAILIMAP_NO_ERROR) { |
1034 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1033 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1035 | return 0; | 1034 | return 0; |
1036 | } | 1035 | } |
1037 | return 1; | 1036 | return 1; |
1038 | } | 1037 | } |
1039 | 1038 | ||
1040 | int IMAPwrapper::deleteMbox(const Folder*folder) | 1039 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1041 | { | 1040 | { |
1042 | if (!folder) return 0; | 1041 | if (!folder) return 0; |
1043 | login(); | 1042 | login(); |
1044 | if (!m_imap) {return 0;} | 1043 | if (!m_imap) {return 0;} |
1045 | int res = mailimap_delete(m_imap,folder->getName()); | 1044 | int res = mailimap_delete(m_imap,folder->getName()); |
1046 | if (res != MAILIMAP_NO_ERROR) { | 1045 | if (res != MAILIMAP_NO_ERROR) { |
1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1046 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1048 | return 0; | 1047 | return 0; |
@@ -1118,17 +1117,18 @@ const QString&IMAPwrapper::getName()const | |||
1118 | 1117 | ||
1119 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1118 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) |
1120 | { | 1119 | { |
1121 | // dummy | 1120 | // dummy |
1122 | QValueList<int> path; | 1121 | QValueList<int> path; |
1123 | return fetchRawPart(mail,path,false); | 1122 | return fetchRawPart(mail,path,false); |
1124 | } | 1123 | } |
1125 | 1124 | ||
1126 | void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1125 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1126 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
1127 | { | 1127 | { |
1128 | if (targetWrapper != this) { | 1128 | if (targetWrapper != this) { |
1129 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1129 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1130 | qDebug("Using generic"); | 1130 | qDebug("Using generic"); |
1131 | return; | 1131 | return; |
1132 | } | 1132 | } |
1133 | mailimap_set *set = 0; | 1133 | mailimap_set *set = 0; |
1134 | login(); | 1134 | login(); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 2623725..15f049f 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -18,38 +18,40 @@ struct mailimap_msg_att; | |||
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
29 | 29 | ||
30 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
31 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
32 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&folder); |
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 34 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, |
35 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | ||
35 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 36 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
36 | 37 | ||
37 | virtual RecBody fetchBody(const RecMail&mail); | 38 | virtual RecBody fetchBody(const RecMail&mail); |
38 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 39 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 40 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
40 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 41 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
41 | virtual encodedString* fetchRawBody(const RecMail&mail); | 42 | virtual encodedString* fetchRawBody(const RecMail&mail); |
42 | 43 | ||
43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 44 | virtual int createMbox(const QString&,const Opie::osmart_pointer<Folder>&parentfolder=0, |
44 | virtual int deleteMbox(const Folder*folder); | 45 | const QString& delemiter="/",bool getsubfolder=false); |
45 | 46 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&folder); | |
47 | |||
46 | static void imap_progress( size_t current, size_t maximum ); | 48 | static void imap_progress( size_t current, size_t maximum ); |
47 | 49 | ||
48 | virtual void logout(); | 50 | virtual void logout(); |
49 | virtual MAILLIB::ATYPE getType()const; | 51 | virtual MAILLIB::ATYPE getType()const; |
50 | virtual const QString&getName()const; | 52 | virtual const QString&getName()const; |
51 | 53 | ||
52 | protected: | 54 | protected: |
53 | RecMail*parse_list_result(mailimap_msg_att*); | 55 | RecMail*parse_list_result(mailimap_msg_att*); |
54 | void login(); | 56 | void login(); |
55 | bool start_tls(bool force=true); | 57 | bool start_tls(bool force=true); |
@@ -59,17 +61,17 @@ protected: | |||
59 | int selectMbox(const QString&mbox); | 61 | int selectMbox(const QString&mbox); |
60 | 62 | ||
61 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 63 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
62 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 64 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
63 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 65 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
64 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 66 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
65 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 67 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
66 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 68 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
67 | 69 | ||
68 | /* just helpers */ | 70 | /* just helpers */ |
69 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 71 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
70 | static QStringList address_list_to_stringlist(clist*list); | 72 | static QStringList address_list_to_stringlist(clist*list); |
71 | 73 | ||
72 | 74 | ||
73 | IMAPaccount *account; | 75 | IMAPaccount *account; |
74 | mailimap *m_imap; | 76 | mailimap *m_imap; |
75 | QString m_Lastmbox; | 77 | QString m_Lastmbox; |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 17c6db9..10d367f 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -3,17 +3,16 @@ | |||
3 | 3 | ||
4 | #define FLAG_ANSWERED 0 | 4 | #define FLAG_ANSWERED 0 |
5 | #define FLAG_FLAGGED 1 | 5 | #define FLAG_FLAGGED 1 |
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | ||
12 | #include <qbitarray.h> | 11 | #include <qbitarray.h> |
13 | #include <qstring.h> | 12 | #include <qstring.h> |
14 | #include <qstringlist.h> | 13 | #include <qstringlist.h> |
15 | #include <qmap.h> | 14 | #include <qmap.h> |
16 | #include <qvaluelist.h> | 15 | #include <qvaluelist.h> |
17 | 16 | ||
18 | class AbstractMail; | 17 | class AbstractMail; |
19 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 6bd98f6..c71d69f 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -30,16 +30,20 @@ Attachment::Attachment( DocLnk lnk ) | |||
30 | Folder::Folder(const QString&tmp_name, const QString&sep ) | 30 | Folder::Folder(const QString&tmp_name, const QString&sep ) |
31 | { | 31 | { |
32 | name = tmp_name; | 32 | name = tmp_name; |
33 | nameDisplay = name; | 33 | nameDisplay = name; |
34 | separator = sep; | 34 | separator = sep; |
35 | prefix = ""; | 35 | prefix = ""; |
36 | } | 36 | } |
37 | 37 | ||
38 | Folder::~Folder() | ||
39 | { | ||
40 | } | ||
41 | |||
38 | const QString& Folder::Separator()const | 42 | const QString& Folder::Separator()const |
39 | { | 43 | { |
40 | return separator; | 44 | return separator; |
41 | } | 45 | } |
42 | 46 | ||
43 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) | 47 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) |
44 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) | 48 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) |
45 | { | 49 | { |
@@ -52,16 +56,20 @@ IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no | |||
52 | 56 | ||
53 | if (prefix.length()>0) { | 57 | if (prefix.length()>0) { |
54 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | 58 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { |
55 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | 59 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); |
56 | } | 60 | } |
57 | } | 61 | } |
58 | } | 62 | } |
59 | 63 | ||
64 | IMAPFolder::~IMAPFolder() | ||
65 | { | ||
66 | } | ||
67 | |||
60 | static unsigned char base64chars[] = | 68 | static unsigned char base64chars[] = |
61 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; | 69 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
62 | 70 | ||
63 | /** | 71 | /** |
64 | * Decodes base64 encoded parts of the imapfolder name | 72 | * Decodes base64 encoded parts of the imapfolder name |
65 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc | 73 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc |
66 | */ | 74 | */ |
67 | QString IMAPFolder::decodeFolderName( const QString &name ) | 75 | QString IMAPFolder::decodeFolderName( const QString &name ) |
@@ -159,8 +167,12 @@ MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | |||
159 | if (!disp_name.startsWith("/") && disp_name.length()>0) | 167 | if (!disp_name.startsWith("/") && disp_name.length()>0) |
160 | name+="/"; | 168 | name+="/"; |
161 | name+=disp_name; | 169 | name+=disp_name; |
162 | if (disp_name.length()==0) { | 170 | if (disp_name.length()==0) { |
163 | nameDisplay = separator; | 171 | nameDisplay = separator; |
164 | } | 172 | } |
165 | prefix = mbox; | 173 | prefix = mbox; |
166 | } | 174 | } |
175 | |||
176 | MHFolder::~MHFolder() | ||
177 | { | ||
178 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index c66572c..3b3bb32 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -8,25 +8,25 @@ | |||
8 | 8 | ||
9 | #include "settings.h" | 9 | #include "settings.h" |
10 | 10 | ||
11 | #include <opie2/osmart_pointer.h> | 11 | #include <opie2/osmart_pointer.h> |
12 | 12 | ||
13 | class Attachment | 13 | class Attachment |
14 | { | 14 | { |
15 | public: | 15 | public: |
16 | Attachment( DocLnk lnk ); | 16 | Attachment( DocLnk lnk ); |
17 | virtual ~Attachment(){} | 17 | virtual ~Attachment(){} |
18 | const QString getFileName()const{ return doc.file(); } | 18 | const QString getFileName()const{ return doc.file(); } |
19 | const QString getName()const{ return doc.name(); } | 19 | const QString getName()const{ return doc.name(); } |
20 | const QString getMimeType()const{ return doc.type(); } | 20 | const QString getMimeType()const{ return doc.type(); } |
21 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 21 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
22 | const int getSize()const { return size; } | 22 | const int getSize()const { return size; } |
23 | DocLnk getDocLnk() { return doc; } | 23 | DocLnk getDocLnk() { return doc; } |
24 | 24 | ||
25 | protected: | 25 | protected: |
26 | DocLnk doc; | 26 | DocLnk doc; |
27 | int size; | 27 | int size; |
28 | 28 | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | class Mail:public Opie::oref_count | 31 | class Mail:public Opie::oref_count |
32 | { | 32 | { |
@@ -35,17 +35,17 @@ public: | |||
35 | /* Possible that this destructor must not be declared virtual | 35 | /* Possible that this destructor must not be declared virtual |
36 | * 'cause it seems that it will never have some child classes. | 36 | * 'cause it seems that it will never have some child classes. |
37 | * in this case this object will not get a virtual table -> memory and | 37 | * in this case this object will not get a virtual table -> memory and |
38 | * speed will be a little bit better? | 38 | * speed will be a little bit better? |
39 | */ | 39 | */ |
40 | virtual ~Mail(){} | 40 | virtual ~Mail(){} |
41 | void addAttachment( Attachment *att ) { attList.append( att ); } | 41 | void addAttachment( Attachment *att ) { attList.append( att ); } |
42 | const QList<Attachment>& getAttachments()const { return attList; } | 42 | const QList<Attachment>& getAttachments()const { return attList; } |
43 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 43 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
44 | const QString&getName()const { return name; } | 44 | const QString&getName()const { return name; } |
45 | void setName( QString s ) { name = s; } | 45 | void setName( QString s ) { name = s; } |
46 | const QString&getMail()const{ return mail; } | 46 | const QString&getMail()const{ return mail; } |
47 | void setMail( const QString&s ) { mail = s; } | 47 | void setMail( const QString&s ) { mail = s; } |
48 | const QString&getTo()const{ return to; } | 48 | const QString&getTo()const{ return to; } |
49 | void setTo( const QString&s ) { to = s; } | 49 | void setTo( const QString&s ) { to = s; } |
50 | const QString&getCC()const{ return cc; } | 50 | const QString&getCC()const{ return cc; } |
51 | void setCC( const QString&s ) { cc = s; } | 51 | void setCC( const QString&s ) { cc = s; } |
@@ -61,44 +61,46 @@ public: | |||
61 | const QStringList&Inreply()const{return m_in_reply_to;} | 61 | const QStringList&Inreply()const{return m_in_reply_to;} |
62 | 62 | ||
63 | private: | 63 | private: |
64 | QList<Attachment> attList; | 64 | QList<Attachment> attList; |
65 | QString name, mail, to, cc, bcc, reply, subject, message; | 65 | QString name, mail, to, cc, bcc, reply, subject, message; |
66 | QStringList m_in_reply_to; | 66 | QStringList m_in_reply_to; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | class Folder : public QObject | 69 | class Folder:public Opie::oref_count |
70 | { | 70 | { |
71 | Q_OBJECT | ||
72 | |||
73 | public: | 71 | public: |
74 | Folder( const QString&init_name,const QString&sep ); | 72 | Folder( const QString&init_name,const QString&sep ); |
73 | virtual ~Folder(); | ||
75 | const QString&getDisplayName()const { return nameDisplay; } | 74 | const QString&getDisplayName()const { return nameDisplay; } |
76 | const QString&getName()const { return name; } | 75 | const QString&getName()const { return name; } |
77 | const QString&getPrefix()const{return prefix; } | 76 | const QString&getPrefix()const{return prefix; } |
78 | virtual bool may_select()const{return true;} | 77 | virtual bool may_select()const{return true;} |
79 | virtual bool no_inferior()const{return true;} | 78 | virtual bool no_inferior()const{return true;} |
80 | const QString&Separator()const; | 79 | const QString&Separator()const; |
81 | 80 | ||
82 | protected: | 81 | protected: |
83 | QString nameDisplay, name, separator,prefix; | 82 | QString nameDisplay, name, separator,prefix; |
84 | }; | 83 | }; |
85 | 84 | ||
85 | typedef Opie::osmart_pointer<Folder> FolderP; | ||
86 | |||
86 | class MHFolder : public Folder | 87 | class MHFolder : public Folder |
87 | { | 88 | { |
88 | Q_OBJECT | ||
89 | public: | 89 | public: |
90 | MHFolder(const QString&disp_name,const QString&mbox); | 90 | MHFolder(const QString&disp_name,const QString&mbox); |
91 | virtual ~MHFolder(); | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | class IMAPFolder : public Folder | 94 | class IMAPFolder : public Folder |
94 | { | 95 | { |
95 | public: | 96 | public: |
96 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); | 97 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); |
98 | virtual ~IMAPFolder(); | ||
97 | virtual bool may_select()const{return m_MaySelect;} | 99 | virtual bool may_select()const{return m_MaySelect;} |
98 | virtual bool no_inferior()const{return m_NoInferior;} | 100 | virtual bool no_inferior()const{return m_NoInferior;} |
99 | private: | 101 | private: |
100 | static QString decodeFolderName( const QString &name ); | 102 | static QString decodeFolderName( const QString &name ); |
101 | bool m_MaySelect,m_NoInferior; | 103 | bool m_MaySelect,m_NoInferior; |
102 | }; | 104 | }; |
103 | 105 | ||
104 | #endif | 106 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index abe4bb6..9ff3de2 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -9,70 +9,69 @@ | |||
9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) | 9 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
10 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) | 10 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
11 | { | 11 | { |
12 | QDir dir(MBOXPath); | 12 | QDir dir(MBOXPath); |
13 | if (!dir.exists()) { | 13 | if (!dir.exists()) { |
14 | dir.mkdir(MBOXPath); | 14 | dir.mkdir(MBOXPath); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 | ||
18 | MBOXwrapper::~MBOXwrapper() | 18 | MBOXwrapper::~MBOXwrapper() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 22 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
23 | { | 23 | { |
24 | mailstorage*storage = mailstorage_new(NULL); | 24 | mailstorage*storage = mailstorage_new(NULL); |
25 | QString p = MBOXPath+"/"; | 25 | QString p = MBOXPath+"/"; |
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | 27 | ||
28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
29 | mailfolder*folder; | 29 | mailfolder*folder; |
30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
31 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
32 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
33 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
34 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
35 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | 38 | ||
39 | parseList(target,folder->fld_session,mailbox); | 39 | parseList(target,folder->fld_session,mailbox); |
40 | 40 | ||
41 | mailfolder_disconnect(folder); | 41 | mailfolder_disconnect(folder); |
42 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
43 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
45 | } | 45 | } |
46 | 46 | ||
47 | QList<Folder>* MBOXwrapper::listFolders() | 47 | QValueList<Opie::osmart_pointer<Folder> >* MBOXwrapper::listFolders() |
48 | { | 48 | { |
49 | QList<Folder> * folders = new QList<Folder>(); | 49 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); |
50 | folders->setAutoDelete( false ); | ||
51 | QDir dir(MBOXPath); | 50 | QDir dir(MBOXPath); |
52 | if (!dir.exists()) return folders; | 51 | if (!dir.exists()) return folders; |
53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 52 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
54 | QStringList entries = dir.entryList(); | 53 | QStringList entries = dir.entryList(); |
55 | QStringList::ConstIterator it = entries.begin(); | 54 | QStringList::ConstIterator it = entries.begin(); |
56 | for (;it!=entries.end();++it) { | 55 | for (;it!=entries.end();++it) { |
57 | Folder*inb=new Folder(*it,"/"); | 56 | FolderP inb=new Folder(*it,"/"); |
58 | folders->append(inb); | 57 | folders->append(inb); |
59 | } | 58 | } |
60 | return folders; | 59 | return folders; |
61 | } | 60 | } |
62 | 61 | ||
63 | void MBOXwrapper::deleteMail(const RecMail&mail) | 62 | void MBOXwrapper::deleteMail(const RecMail&mail) |
64 | { | 63 | { |
65 | mailstorage*storage = mailstorage_new(NULL); | 64 | mailstorage*storage = mailstorage_new(NULL); |
66 | QString p = MBOXPath+"/"; | 65 | QString p = MBOXPath+"/"; |
67 | p+=mail.getMbox(); | 66 | p+=mail.getMbox(); |
68 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 67 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
69 | mailfolder*folder; | 68 | mailfolder*folder; |
70 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 69 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
71 | r = mailfolder_connect(folder); | 70 | r = mailfolder_connect(folder); |
72 | if (r != MAIL_NO_ERROR) { | 71 | if (r != MAIL_NO_ERROR) { |
73 | qDebug("Error initializing mbox"); | 72 | qDebug("Error initializing mbox"); |
74 | mailfolder_free(folder); | 73 | mailfolder_free(folder); |
75 | mailstorage_free(storage); | 74 | mailstorage_free(storage); |
76 | return; | 75 | return; |
77 | } | 76 | } |
78 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); | 77 | r = mailsession_remove_message(folder->fld_session,mail.getNumber()); |
@@ -94,17 +93,17 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | |||
94 | QString p = MBOXPath+"/"; | 93 | QString p = MBOXPath+"/"; |
95 | p+=mail.getMbox(); | 94 | p+=mail.getMbox(); |
96 | mailmessage * msg; | 95 | mailmessage * msg; |
97 | char*data=0; | 96 | char*data=0; |
98 | size_t size; | 97 | size_t size; |
99 | 98 | ||
100 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 99 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
101 | mailfolder*folder; | 100 | mailfolder*folder; |
102 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 101 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
103 | r = mailfolder_connect(folder); | 102 | r = mailfolder_connect(folder); |
104 | if (r != MAIL_NO_ERROR) { | 103 | if (r != MAIL_NO_ERROR) { |
105 | qDebug("Error initializing mbox"); | 104 | qDebug("Error initializing mbox"); |
106 | mailfolder_free(folder); | 105 | mailfolder_free(folder); |
107 | mailstorage_free(storage); | 106 | mailstorage_free(storage); |
108 | return body; | 107 | return body; |
109 | } | 108 | } |
110 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 109 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
@@ -117,30 +116,30 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail ) | |||
117 | r = mailmessage_fetch(msg,&data,&size); | 116 | r = mailmessage_fetch(msg,&data,&size); |
118 | if (r != MAIL_NO_ERROR) { | 117 | if (r != MAIL_NO_ERROR) { |
119 | qDebug("Error fetching mail %i",mail.getNumber()); | 118 | qDebug("Error fetching mail %i",mail.getNumber()); |
120 | mailfolder_free(folder); | 119 | mailfolder_free(folder); |
121 | mailstorage_free(storage); | 120 | mailstorage_free(storage); |
122 | mailmessage_free(msg); | 121 | mailmessage_free(msg); |
123 | return body; | 122 | return body; |
124 | } | 123 | } |
125 | body = parseMail(msg); | 124 | body = parseMail(msg); |
126 | mailmessage_fetch_result_free(msg,data); | 125 | mailmessage_fetch_result_free(msg,data); |
127 | mailfolder_free(folder); | 126 | mailfolder_free(folder); |
128 | mailstorage_free(storage); | 127 | mailstorage_free(storage); |
129 | 128 | ||
130 | return body; | 129 | return body; |
131 | } | 130 | } |
132 | 131 | ||
133 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 132 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) |
134 | { | 133 | { |
135 | qDebug("MBOX %i von %i",current,maximum); | 134 | qDebug("MBOX %i von %i",current,maximum); |
136 | } | 135 | } |
137 | 136 | ||
138 | int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool ) | 137 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
139 | { | 138 | { |
140 | QString p = MBOXPath+"/"; | 139 | QString p = MBOXPath+"/"; |
141 | p+=folder; | 140 | p+=folder; |
142 | QFileInfo fi(p); | 141 | QFileInfo fi(p); |
143 | if (fi.exists()) { | 142 | if (fi.exists()) { |
144 | Global::statusMessage(tr("Mailbox exists.")); | 143 | Global::statusMessage(tr("Mailbox exists.")); |
145 | return 0; | 144 | return 0; |
146 | } | 145 | } |
@@ -177,17 +176,17 @@ encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail) | |||
177 | QString p = MBOXPath+"/"; | 176 | QString p = MBOXPath+"/"; |
178 | p+=mail.getMbox(); | 177 | p+=mail.getMbox(); |
179 | mailmessage * msg; | 178 | mailmessage * msg; |
180 | char*data=0; | 179 | char*data=0; |
181 | size_t size; | 180 | size_t size; |
182 | 181 | ||
183 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 182 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
184 | mailfolder*folder; | 183 | mailfolder*folder; |
185 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 184 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
186 | r = mailfolder_connect(folder); | 185 | r = mailfolder_connect(folder); |
187 | if (r != MAIL_NO_ERROR) { | 186 | if (r != MAIL_NO_ERROR) { |
188 | Global::statusMessage(tr("Error initializing mbox")); | 187 | Global::statusMessage(tr("Error initializing mbox")); |
189 | mailfolder_free(folder); | 188 | mailfolder_free(folder); |
190 | mailstorage_free(storage); | 189 | mailstorage_free(storage); |
191 | return 0; | 190 | return 0; |
192 | } | 191 | } |
193 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); | 192 | r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); |
@@ -238,32 +237,32 @@ void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | |||
238 | } | 237 | } |
239 | } | 238 | } |
240 | r = mailmbox_expunge(f); | 239 | r = mailmbox_expunge(f); |
241 | if (r != MAILMBOX_NO_ERROR) { | 240 | if (r != MAILMBOX_NO_ERROR) { |
242 | qDebug("error expunge mailbox"); | 241 | qDebug("error expunge mailbox"); |
243 | } | 242 | } |
244 | } | 243 | } |
245 | 244 | ||
246 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 245 | int MBOXwrapper::deleteAllMail(const FolderP&tfolder) |
247 | { | 246 | { |
248 | if (!tfolder) return 0; | 247 | if (!tfolder) return 0; |
249 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 248 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
250 | int res = 1; | 249 | int res = 1; |
251 | 250 | ||
252 | mailfolder*folder = 0; | 251 | mailfolder*folder = 0; |
253 | mailmessage_list*l=0; | 252 | mailmessage_list*l=0; |
254 | mailstorage*storage = mailstorage_new(NULL); | 253 | mailstorage*storage = mailstorage_new(NULL); |
255 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 254 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
256 | if (r != MAIL_NO_ERROR) { | 255 | if (r != MAIL_NO_ERROR) { |
257 | Global::statusMessage(tr("Error initializing mbox")); | 256 | Global::statusMessage(tr("Error initializing mbox")); |
258 | res = 0; | 257 | res = 0; |
259 | } | 258 | } |
260 | if (res) { | 259 | if (res) { |
261 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 260 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
262 | r = mailfolder_connect(folder); | 261 | r = mailfolder_connect(folder); |
263 | if (r != MAIL_NO_ERROR) { | 262 | if (r != MAIL_NO_ERROR) { |
264 | Global::statusMessage(tr("Error initializing mbox")); | 263 | Global::statusMessage(tr("Error initializing mbox")); |
265 | res = 0; | 264 | res = 0; |
266 | } | 265 | } |
267 | } | 266 | } |
268 | if (res) { | 267 | if (res) { |
269 | r = mailsession_get_messages_list(folder->fld_session,&l); | 268 | r = mailsession_get_messages_list(folder->fld_session,&l); |
@@ -281,17 +280,17 @@ int MBOXwrapper::deleteAllMail(const Folder*tfolder) | |||
281 | } | 280 | } |
282 | } | 281 | } |
283 | if (l) mailmessage_list_free(l); | 282 | if (l) mailmessage_list_free(l); |
284 | if (folder) mailfolder_free(folder); | 283 | if (folder) mailfolder_free(folder); |
285 | if (storage) mailstorage_free(storage); | 284 | if (storage) mailstorage_free(storage); |
286 | return res; | 285 | return res; |
287 | } | 286 | } |
288 | 287 | ||
289 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | 288 | int MBOXwrapper::deleteMbox(const FolderP&tfolder) |
290 | { | 289 | { |
291 | if (!tfolder) return 0; | 290 | if (!tfolder) return 0; |
292 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); | 291 | QString p = MBOXPath+"/"+tfolder->getDisplayName(); |
293 | QFile fi(p); | 292 | QFile fi(p); |
294 | if (!fi.exists()) { | 293 | if (!fi.exists()) { |
295 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 294 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
296 | return 0; | 295 | return 0; |
297 | } | 296 | } |
@@ -311,17 +310,17 @@ void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
311 | target_stat.message_recent = 0; | 310 | target_stat.message_recent = 0; |
312 | QString p = MBOXPath+"/"+mailbox; | 311 | QString p = MBOXPath+"/"+mailbox; |
313 | QFile fi(p); | 312 | QFile fi(p); |
314 | if (!fi.exists()) { | 313 | if (!fi.exists()) { |
315 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 314 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
316 | return; | 315 | return; |
317 | } | 316 | } |
318 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 317 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
319 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 318 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
320 | r = mailfolder_connect(folder); | 319 | r = mailfolder_connect(folder); |
321 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 320 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
322 | &target_stat.message_recent,&target_stat.message_unseen); | 321 | &target_stat.message_recent,&target_stat.message_unseen); |
323 | if (folder) mailfolder_free(folder); | 322 | if (folder) mailfolder_free(folder); |
324 | if (storage) mailstorage_free(storage); | 323 | if (storage) mailstorage_free(storage); |
325 | } | 324 | } |
326 | 325 | ||
327 | MAILLIB::ATYPE MBOXwrapper::getType()const | 326 | MAILLIB::ATYPE MBOXwrapper::getType()const |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 7e7f359..c3d9b50 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -11,35 +11,36 @@ struct mailmbox_folder; | |||
11 | 11 | ||
12 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | MBOXwrapper(const QString & dir,const QString&name); | 17 | MBOXwrapper(const QString & dir,const QString&name); |
18 | virtual ~MBOXwrapper(); | 18 | virtual ~MBOXwrapper(); |
19 | 19 | ||
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
21 | virtual QList<Folder>* listFolders(); | 21 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); |
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
23 | 23 | ||
24 | virtual void deleteMail(const RecMail&mail); | 24 | virtual void deleteMail(const RecMail&mail); |
25 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMail&mail); |
26 | 26 | ||
27 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 27 | virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0, |
28 | virtual int deleteMbox(const Folder*); | 28 | const QString&d="",bool s=false); |
29 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&); | ||
29 | 30 | ||
30 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 31 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
31 | 32 | ||
32 | virtual RecBody fetchBody( const RecMail &mail ); | 33 | virtual RecBody fetchBody( const RecMail &mail ); |
33 | static void mbox_progress( size_t current, size_t maximum ); | 34 | static void mbox_progress( size_t current, size_t maximum ); |
34 | 35 | ||
35 | virtual encodedString* fetchRawBody(const RecMail&mail); | 36 | virtual encodedString* fetchRawBody(const RecMail&mail); |
36 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 37 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
37 | virtual int deleteAllMail(const Folder*); | 38 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); |
38 | virtual MAILLIB::ATYPE getType()const; | 39 | virtual MAILLIB::ATYPE getType()const; |
39 | virtual const QString&getName()const; | 40 | virtual const QString&getName()const; |
40 | 41 | ||
41 | protected: | 42 | protected: |
42 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 43 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
43 | QString MBOXPath; | 44 | QString MBOXPath; |
44 | QString MBOXName; | 45 | QString MBOXName; |
45 | }; | 46 | }; |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 560eab0..aaaa20a 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -71,20 +71,19 @@ void MHwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | |||
71 | if (r!=MAIL_NO_ERROR) { | 71 | if (r!=MAIL_NO_ERROR) { |
72 | qDebug("listMessages: error selecting folder!"); | 72 | qDebug("listMessages: error selecting folder!"); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | parseList(target,m_storage->sto_session,f); | 75 | parseList(target,m_storage->sto_session,f); |
76 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 76 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
77 | } | 77 | } |
78 | 78 | ||
79 | QList<Folder>* MHwrapper::listFolders() | 79 | QValueList<Opie::osmart_pointer<Folder> >* MHwrapper::listFolders() |
80 | { | 80 | { |
81 | QList<Folder> * folders = new QList<Folder>(); | 81 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); |
82 | folders->setAutoDelete( false ); | ||
83 | /* this is needed! */ | 82 | /* this is needed! */ |
84 | if (m_storage) mailstorage_disconnect(m_storage); | 83 | if (m_storage) mailstorage_disconnect(m_storage); |
85 | init_storage(); | 84 | init_storage(); |
86 | if (!m_storage) { | 85 | if (!m_storage) { |
87 | return folders; | 86 | return folders; |
88 | } | 87 | } |
89 | mail_list*flist = 0; | 88 | mail_list*flist = 0; |
90 | clistcell*current=0; | 89 | clistcell*current=0; |
@@ -139,17 +138,17 @@ RecBody MHwrapper::fetchBody( const RecMail &mail ) | |||
139 | if (r != MAIL_NO_ERROR) { | 138 | if (r != MAIL_NO_ERROR) { |
140 | return body; | 139 | return body; |
141 | } | 140 | } |
142 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); | 141 | r = mailsession_get_message(m_storage->sto_session, mail.getNumber(), &msg); |
143 | if (r != MAIL_NO_ERROR) { | 142 | if (r != MAIL_NO_ERROR) { |
144 | qDebug("Error fetching mail %i",mail.getNumber()); | 143 | qDebug("Error fetching mail %i",mail.getNumber()); |
145 | return body; | 144 | return body; |
146 | } | 145 | } |
147 | body = parseMail(msg); | 146 | body = parseMail(msg); |
148 | mailmessage_fetch_result_free(msg,data); | 147 | mailmessage_fetch_result_free(msg,data); |
149 | return body; | 148 | return body; |
150 | } | 149 | } |
151 | 150 | ||
152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 151 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
153 | { | 152 | { |
154 | qDebug("MH %i von %i",current,maximum); | 153 | qDebug("MH %i von %i",current,maximum); |
155 | } | 154 | } |
@@ -164,17 +163,17 @@ QString MHwrapper::buildPath(const QString&p) | |||
164 | } | 163 | } |
165 | if (!p.startsWith("/")) { | 164 | if (!p.startsWith("/")) { |
166 | f+="/"; | 165 | f+="/"; |
167 | } | 166 | } |
168 | f+=p; | 167 | f+=p; |
169 | return f; | 168 | return f; |
170 | } | 169 | } |
171 | 170 | ||
172 | int MHwrapper::createMbox(const QString&folder,const Folder*pfolder,const QString&,bool ) | 171 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
173 | { | 172 | { |
174 | init_storage(); | 173 | init_storage(); |
175 | if (!m_storage) { | 174 | if (!m_storage) { |
176 | return 0; | 175 | return 0; |
177 | } | 176 | } |
178 | QString f; | 177 | QString f; |
179 | if (!pfolder) { | 178 | if (!pfolder) { |
180 | // toplevel folder | 179 | // toplevel folder |
@@ -258,17 +257,17 @@ void MHwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | |||
258 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); | 257 | r = mailsession_remove_message(m_storage->sto_session,c->getNumber()); |
259 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
260 | qDebug("error deleting mail"); | 259 | qDebug("error deleting mail"); |
261 | break; | 260 | break; |
262 | } | 261 | } |
263 | } | 262 | } |
264 | } | 263 | } |
265 | 264 | ||
266 | int MHwrapper::deleteAllMail(const Folder*tfolder) | 265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
267 | { | 266 | { |
268 | init_storage(); | 267 | init_storage(); |
269 | if (!m_storage) { | 268 | if (!m_storage) { |
270 | return 0; | 269 | return 0; |
271 | } | 270 | } |
272 | int res = 1; | 271 | int res = 1; |
273 | if (!tfolder) return 0; | 272 | if (!tfolder) return 0; |
274 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
@@ -293,38 +292,38 @@ int MHwrapper::deleteAllMail(const Folder*tfolder) | |||
293 | res = 0; | 292 | res = 0; |
294 | break; | 293 | break; |
295 | } | 294 | } |
296 | } | 295 | } |
297 | if (l) mailmessage_list_free(l); | 296 | if (l) mailmessage_list_free(l); |
298 | return res; | 297 | return res; |
299 | } | 298 | } |
300 | 299 | ||
301 | int MHwrapper::deleteMbox(const Folder*tfolder) | 300 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
302 | { | 301 | { |
303 | init_storage(); | 302 | init_storage(); |
304 | if (!m_storage) { | 303 | if (!m_storage) { |
305 | return 0; | 304 | return 0; |
306 | } | 305 | } |
307 | if (!tfolder) return 0; | 306 | if (!tfolder) return 0; |
308 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
309 | 308 | ||
310 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
311 | 310 | ||
312 | if (r != MAIL_NO_ERROR) { | 311 | if (r != MAIL_NO_ERROR) { |
313 | qDebug("error deleting mail box"); | 312 | qDebug("error deleting mail box"); |
314 | return 0; | 313 | return 0; |
315 | } | 314 | } |
316 | QString cmd = "rm -rf "+tfolder->getName(); | 315 | QString cmd = "rm -rf "+tfolder->getName(); |
317 | QStringList command; | 316 | QStringList command; |
318 | command << "/bin/sh"; | 317 | command << "/bin/sh"; |
319 | command << "-c"; | 318 | command << "-c"; |
320 | command << cmd.latin1(); | 319 | command << cmd.latin1(); |
321 | OProcess *process = new OProcess(); | 320 | OProcess *process = new OProcess(); |
322 | 321 | ||
323 | connect(process, SIGNAL(processExited(OProcess*)), | 322 | connect(process, SIGNAL(processExited(OProcess*)), |
324 | this, SLOT( processEnded(OProcess*))); | 323 | this, SLOT( processEnded(OProcess*))); |
325 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), | 324 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), |
326 | this, SLOT( oprocessStderr(OProcess*,char*,int))); | 325 | this, SLOT( oprocessStderr(OProcess*,char*,int))); |
327 | 326 | ||
328 | *process << command; | 327 | *process << command; |
329 | removeMboxfailed = false; | 328 | removeMboxfailed = false; |
330 | if(!process->start(OProcess::Block, OProcess::All) ) { | 329 | if(!process->start(OProcess::Block, OProcess::All) ) { |
@@ -381,32 +380,33 @@ void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractM | |||
381 | } | 380 | } |
382 | if (targetWrapper != this) { | 381 | if (targetWrapper != this) { |
383 | qDebug("Using generic"); | 382 | qDebug("Using generic"); |
384 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
385 | return; | 384 | return; |
386 | } | 385 | } |
387 | qDebug("Using internal routines for move/copy"); | 386 | qDebug("Using internal routines for move/copy"); |
388 | QString tf = buildPath(targetFolder); | 387 | QString tf = buildPath(targetFolder); |
389 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); | 388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); |
390 | if (r != MAIL_NO_ERROR) { | 389 | if (r != MAIL_NO_ERROR) { |
391 | qDebug("Error selecting source mailbox"); | 390 | qDebug("Error selecting source mailbox"); |
392 | return; | 391 | return; |
393 | } | 392 | } |
394 | if (moveit) { | 393 | if (moveit) { |
395 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 394 | r = mailsession_move_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
396 | } else { | 395 | } else { |
397 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); | 396 | r = mailsession_copy_message(m_storage->sto_session,mail.getNumber(),(char*)tf.latin1()); |
398 | } | 397 | } |
399 | if (r != MAIL_NO_ERROR) { | 398 | if (r != MAIL_NO_ERROR) { |
400 | qDebug("Error copy/moving mail internal (%i)",r); | 399 | qDebug("Error copy/moving mail internal (%i)",r); |
401 | } | 400 | } |
402 | } | 401 | } |
403 | 402 | ||
404 | void MHwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
405 | { | 405 | { |
406 | init_storage(); | 406 | init_storage(); |
407 | if (!m_storage) { | 407 | if (!m_storage) { |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (targetWrapper != this) { | 410 | if (targetWrapper != this) { |
411 | qDebug("Using generic"); | 411 | qDebug("Using generic"); |
412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index b7c23af..c7c8183 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h | |||
@@ -13,48 +13,50 @@ struct mailmbox_folder; | |||
13 | class OProcess; | 13 | class OProcess; |
14 | 14 | ||
15 | class MHwrapper : public Genericwrapper | 15 | class MHwrapper : public Genericwrapper |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | public: | 18 | public: |
19 | MHwrapper(const QString & dir,const QString&name); | 19 | MHwrapper(const QString & dir,const QString&name); |
20 | virtual ~MHwrapper(); | 20 | virtual ~MHwrapper(); |
21 | 21 | ||
22 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 22 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
23 | virtual QList<Folder>* listFolders(); | 23 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
25 | 25 | ||
26 | virtual void deleteMail(const RecMail&mail); | 26 | virtual void deleteMail(const RecMail&mail); |
27 | virtual void answeredMail(const RecMail&mail); | 27 | virtual void answeredMail(const RecMail&mail); |
28 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 28 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
29 | virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 29 | virtual void mvcpAllMails(const Opie::osmart_pointer<Folder>&fromFolder, |
30 | 30 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | |
31 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 31 | |
32 | virtual int deleteMbox(const Folder*); | 32 | virtual int createMbox(const QString&folder,const Opie::osmart_pointer<Folder>&f=0, |
33 | const QString&d="",bool s=false); | ||
34 | virtual int deleteMbox(const Opie::osmart_pointer<Folder>&); | ||
33 | 35 | ||
34 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
35 | 37 | ||
36 | virtual RecBody fetchBody( const RecMail &mail ); | 38 | virtual RecBody fetchBody( const RecMail &mail ); |
37 | static void mbox_progress( size_t current, size_t maximum ); | 39 | static void mbox_progress( size_t current, size_t maximum ); |
38 | 40 | ||
39 | virtual encodedString* fetchRawBody(const RecMail&mail); | 41 | virtual encodedString* fetchRawBody(const RecMail&mail); |
40 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | 42 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
41 | virtual int deleteAllMail(const Folder*); | 43 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); |
42 | virtual MAILLIB::ATYPE getType()const; | 44 | virtual MAILLIB::ATYPE getType()const; |
43 | virtual const QString&getName()const; | 45 | virtual const QString&getName()const; |
44 | 46 | ||
45 | public slots: | 47 | public slots: |
46 | /* for deleting maildirs we are using a system call */ | 48 | /* for deleting maildirs we are using a system call */ |
47 | virtual void oprocessStderr(OProcess*, char *buffer, int ); | 49 | virtual void oprocessStderr(OProcess*, char *buffer, int ); |
48 | virtual void processEnded(OProcess *); | 50 | virtual void processEnded(OProcess *); |
49 | protected: | 51 | protected: |
50 | QString buildPath(const QString&p); | 52 | QString buildPath(const QString&p); |
51 | QString MHPath; | 53 | QString MHPath; |
52 | QString MHName; | 54 | QString MHName; |
53 | 55 | ||
54 | void init_storage(); | 56 | void init_storage(); |
55 | void clean_storage(); | 57 | void clean_storage(); |
56 | 58 | ||
57 | bool removeMboxfailed; | 59 | bool removeMboxfailed; |
58 | }; | 60 | }; |
59 | 61 | ||
60 | #endif | 62 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 1956c61..2ec052c 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -183,33 +183,32 @@ void NNTPwrapper::logout() | |||
183 | { | 183 | { |
184 | int err = NEWSNNTP_NO_ERROR; | 184 | int err = NEWSNNTP_NO_ERROR; |
185 | if ( m_nntp == NULL ) | 185 | if ( m_nntp == NULL ) |
186 | return; | 186 | return; |
187 | mailstorage_free(m_nntp); | 187 | mailstorage_free(m_nntp); |
188 | m_nntp = 0; | 188 | m_nntp = 0; |
189 | } | 189 | } |
190 | 190 | ||
191 | QList<Folder>* NNTPwrapper::listFolders() { | 191 | QValueList<Opie::osmart_pointer<Folder> >* NNTPwrapper::listFolders() { |
192 | 192 | ||
193 | QList<Folder> * folders = new QList<Folder>(); | 193 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<Opie::osmart_pointer<Folder> >(); |
194 | folders->setAutoDelete( false ); | ||
195 | QStringList groups; | 194 | QStringList groups; |
196 | if (account) { | 195 | if (account) { |
197 | groups = account->getGroups(); | 196 | groups = account->getGroups(); |
198 | } | 197 | } |
199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 198 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
200 | folders->append(new Folder((*it),".")); | 199 | folders->append(new Folder((*it),".")); |
201 | } | 200 | } |
202 | return folders; | 201 | return folders; |
203 | } | 202 | } |
204 | 203 | ||
205 | /* we made this method in raw nntp access of etpan and not via generic interface | 204 | /* we made this method in raw nntp access of etpan and not via generic interface |
206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 205 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
207 | * copy that stuff into its own structures and we must copy it into useable c++ | 206 | * copy that stuff into its own structures and we must copy it into useable c++ |
208 | * structures for our frontend. this would not make sense, so it is better to reimplement | 207 | * structures for our frontend. this would not make sense, so it is better to reimplement |
209 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 208 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
210 | */ | 209 | */ |
211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 210 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
212 | login(); | 211 | login(); |
213 | QStringList res; | 212 | QStringList res; |
214 | clist *result = 0; | 213 | clist *result = 0; |
215 | clistcell *current = 0; | 214 | clistcell *current = 0; |
@@ -275,10 +274,10 @@ MAILLIB::ATYPE NNTPwrapper::getType()const { | |||
275 | 274 | ||
276 | const QString&NNTPwrapper::getName()const{ | 275 | const QString&NNTPwrapper::getName()const{ |
277 | return account->getAccountName(); | 276 | return account->getAccountName(); |
278 | } | 277 | } |
279 | 278 | ||
280 | void NNTPwrapper::deleteMail(const RecMail&) { | 279 | void NNTPwrapper::deleteMail(const RecMail&) { |
281 | } | 280 | } |
282 | 281 | ||
283 | int NNTPwrapper::deleteAllMail(const Folder*) { | 282 | int NNTPwrapper::deleteAllMail(const FolderP&) { |
284 | } | 283 | } |
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index 955b9f1..d3a384a 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h | |||
@@ -17,23 +17,23 @@ class NNTPwrapper : public Genericwrapper | |||
17 | 17 | ||
18 | public: | 18 | public: |
19 | NNTPwrapper( NNTPaccount *a ); | 19 | NNTPwrapper( NNTPaccount *a ); |
20 | virtual ~NNTPwrapper(); | 20 | virtual ~NNTPwrapper(); |
21 | 21 | ||
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 23 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
24 | /* should only get the subscribed one */ | 24 | /* should only get the subscribed one */ |
25 | virtual QList<Folder>* listFolders(); | 25 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); |
26 | /* mailbox will be ignored */ | 26 | /* mailbox will be ignored */ |
27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 27 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
28 | QStringList listAllNewsgroups(const QString&mask = QString::null); | 28 | QStringList listAllNewsgroups(const QString&mask = QString::null); |
29 | virtual void deleteMail(const RecMail&mail); | 29 | virtual void deleteMail(const RecMail&mail); |
30 | virtual void answeredMail(const RecMail&mail); | 30 | virtual void answeredMail(const RecMail&mail); |
31 | virtual int deleteAllMail(const Folder*); | 31 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); |
32 | 32 | ||
33 | virtual RecBody fetchBody( const RecMail &mail ); | 33 | virtual RecBody fetchBody( const RecMail &mail ); |
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
35 | virtual void logout(); | 35 | virtual void logout(); |
36 | virtual MAILLIB::ATYPE getType()const; | 36 | virtual MAILLIB::ATYPE getType()const; |
37 | virtual const QString&getName()const; | 37 | virtual const QString&getName()const; |
38 | static void nntp_progress( size_t current, size_t maximum ); | 38 | static void nntp_progress( size_t current, size_t maximum ); |
39 | 39 | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 0939b22..7bf7ed2 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -172,37 +172,36 @@ void POP3wrapper::logout() | |||
172 | int err = MAILPOP3_NO_ERROR; | 172 | int err = MAILPOP3_NO_ERROR; |
173 | if ( m_pop3 == NULL ) | 173 | if ( m_pop3 == NULL ) |
174 | return; | 174 | return; |
175 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
176 | m_pop3 = 0; | 176 | m_pop3 = 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | QList<Folder>* POP3wrapper::listFolders() { | 180 | QValueList<Opie::osmart_pointer<Folder> >* POP3wrapper::listFolders() { |
181 | QList<Folder> * folders = new QList<Folder>(); | 181 | QValueList<Opie::osmart_pointer<Folder> >* folders = new QValueList<FolderP>(); |
182 | folders->setAutoDelete( false ); | 182 | FolderP inb=new Folder("INBOX","/"); |
183 | Folder*inb=new Folder("INBOX","/"); | ||
184 | folders->append(inb); | 183 | folders->append(inb); |
185 | return folders; | 184 | return folders; |
186 | } | 185 | } |
187 | 186 | ||
188 | void POP3wrapper::deleteMail(const RecMail&mail) { | 187 | void POP3wrapper::deleteMail(const RecMail&mail) { |
189 | login(); | 188 | login(); |
190 | if (!m_pop3) | 189 | if (!m_pop3) |
191 | return; | 190 | return; |
192 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); | 191 | int err = mailsession_remove_message(m_pop3->sto_session,mail.getNumber()); |
193 | if (err != MAIL_NO_ERROR) { | 192 | if (err != MAIL_NO_ERROR) { |
194 | Global::statusMessage(tr("error deleting mail")); | 193 | Global::statusMessage(tr("error deleting mail")); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | 196 | ||
198 | void POP3wrapper::answeredMail(const RecMail&) {} | 197 | void POP3wrapper::answeredMail(const RecMail&) {} |
199 | 198 | ||
200 | int POP3wrapper::deleteAllMail(const Folder*) { | 199 | int POP3wrapper::deleteAllMail(const FolderP&) { |
201 | login(); | 200 | login(); |
202 | if (!m_pop3) | 201 | if (!m_pop3) |
203 | return 0; | 202 | return 0; |
204 | int res = 1; | 203 | int res = 1; |
205 | 204 | ||
206 | uint32_t result = 0; | 205 | uint32_t result = 0; |
207 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 206 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
208 | if (err != MAIL_NO_ERROR) { | 207 | if (err != MAIL_NO_ERROR) { |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 391c841..e4afb94 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -13,23 +13,23 @@ class POP3wrapper : public Genericwrapper | |||
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | POP3wrapper( POP3account *a ); | 17 | POP3wrapper( POP3account *a ); |
18 | virtual ~POP3wrapper(); | 18 | virtual ~POP3wrapper(); |
19 | /* mailbox will be ignored */ | 19 | /* mailbox will be ignored */ |
20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
21 | virtual QList<Folder>* listFolders(); | 21 | virtual QValueList<Opie::osmart_pointer<Folder> >* listFolders(); |
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMail&mail); |
26 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMail&mail); |
27 | virtual int deleteAllMail(const Folder*); | 27 | virtual int deleteAllMail(const Opie::osmart_pointer<Folder>&); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMail&mail); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual MAILLIB::ATYPE getType()const; | 32 | virtual MAILLIB::ATYPE getType()const; |
33 | virtual const QString&getName()const; | 33 | virtual const QString&getName()const; |
34 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
35 | 35 | ||
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index aa8f37a..78652d7 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -128,16 +128,17 @@ void ViewMail::setBody( RecBody body ) | |||
128 | o << s << " " << q << "Byte"; | 128 | o << s << " " << q << "Byte"; |
129 | } | 129 | } |
130 | 130 | ||
131 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 131 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); |
132 | QString filename = ""; | 132 | QString filename = ""; |
133 | 133 | ||
134 | for (unsigned int i = 0; i < body.Parts().count();++i) | 134 | for (unsigned int i = 0; i < body.Parts().count();++i) |
135 | { | 135 | { |
136 | filename = ""; | ||
136 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 137 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
137 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 138 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
138 | for (;it!=body.Parts()[i].Parameters().end();++it) | 139 | for (;it!=body.Parts()[i].Parameters().end();++it) |
139 | { | 140 | { |
140 | qDebug(it.key()); | 141 | qDebug(it.key()); |
141 | if (it.key().lower()=="name") | 142 | if (it.key().lower()=="name") |
142 | { | 143 | { |
143 | filename=it.data(); | 144 | filename=it.data(); |
@@ -390,44 +391,44 @@ void ViewMail::slotReply() | |||
390 | { | 391 | { |
391 | if (!m_gotBody) | 392 | if (!m_gotBody) |
392 | { | 393 | { |
393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 394 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
394 | return; | 395 | return; |
395 | } | 396 | } |
396 | 397 | ||
397 | QString rtext; | 398 | QString rtext; |
398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 399 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
399 | .arg( m_mail[0] ) | 400 | .arg( m_mail[0] ) |
400 | .arg( m_mail[3] ); | 401 | .arg( m_mail[3] ); |
401 | 402 | ||
402 | QString text = m_mail[2]; | 403 | QString text = m_mail[2]; |
403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 404 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
404 | QStringList::Iterator it; | 405 | QStringList::Iterator it; |
405 | for (it = lines.begin(); it != lines.end(); it++) | 406 | for (it = lines.begin(); it != lines.end(); it++) |
406 | { | 407 | { |
407 | rtext += "> " + *it + "\n"; | 408 | rtext += "> " + *it + "\n"; |
408 | } | 409 | } |
409 | rtext += "\n"; | 410 | rtext += "\n"; |
410 | 411 | ||
411 | QString prefix; | 412 | QString prefix; |
412 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 413 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
413 | else prefix = "Re: "; // no i18n on purpose | 414 | else prefix = "Re: "; // no i18n on purpose |
414 | 415 | ||
415 | Settings *settings = new Settings(); | 416 | Settings *settings = new Settings(); |
416 | ComposeMail composer( settings ,this, 0, true); | 417 | ComposeMail composer( settings ,this, 0, true); |
417 | if (m_recMail.Replyto().isEmpty()) { | 418 | if (m_recMail.Replyto().isEmpty()) { |
418 | composer.setTo( m_recMail.getFrom()); | 419 | composer.setTo( m_recMail.getFrom()); |
419 | } else { | 420 | } else { |
420 | composer.setTo( m_recMail.Replyto()); | 421 | composer.setTo( m_recMail.Replyto()); |
421 | } | 422 | } |
422 | composer.setSubject( prefix + m_mail[1] ); | 423 | composer.setSubject( prefix + m_mail[1] ); |
423 | composer.setMessage( rtext ); | 424 | composer.setMessage( rtext ); |
424 | composer.setInReplyTo(m_recMail.Msgid()); | 425 | composer.setInReplyTo(m_recMail.Msgid()); |
425 | 426 | ||
426 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) | 427 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
427 | { | 428 | { |
428 | m_recMail.Wrapper()->answeredMail(m_recMail); | 429 | m_recMail.Wrapper()->answeredMail(m_recMail); |
429 | } | 430 | } |
430 | } | 431 | } |
431 | 432 | ||
432 | void ViewMail::slotForward() | 433 | void ViewMail::slotForward() |
433 | { | 434 | { |