summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp17
-rw-r--r--noncore/net/mail/accountitem.h2
-rw-r--r--noncore/net/mail/accountview.cpp7
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/composemail.cpp90
-rw-r--r--noncore/net/mail/composemail.h25
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h10
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp8
-rw-r--r--noncore/net/mail/libmailwrapper/libmailwrapper.pro6
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.cpp90
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.h29
-rw-r--r--noncore/net/mail/mailistviewitem.cpp7
-rw-r--r--noncore/net/mail/mailistviewitem.h6
-rw-r--r--noncore/net/mail/nntpgroupsdlg.cpp2
-rw-r--r--noncore/net/mail/opiemail.cpp23
-rw-r--r--noncore/net/mail/opiemail.h1
18 files changed, 309 insertions, 39 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 0d636a4..396dcb7 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -532,598 +532,609 @@ void IMAPviewItem::createNewFolder()
532 } 532 }
533 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) 533 if (wrapper->createMbox(ndir,0,delemiter,makesubs))
534 { 534 {
535 refreshFolders(true); 535 refreshFolders(true);
536 } 536 }
537 } 537 }
538} 538}
539 539
540void IMAPviewItem::contextMenuSelected(int id) 540void IMAPviewItem::contextMenuSelected(int id)
541{ 541{
542 qDebug("Id selected: %i",id); 542 qDebug("Id selected: %i",id);
543 switch (id) 543 switch (id)
544 { 544 {
545 case 0: 545 case 0:
546 refreshFolders(true); 546 refreshFolders(true);
547 break; 547 break;
548 case 1: 548 case 1:
549 createNewFolder(); 549 createNewFolder();
550 break; 550 break;
551 case 2: 551 case 2:
552 removeChilds(); 552 removeChilds();
553 wrapper->logout(); 553 wrapper->logout();
554 break; 554 break;
555 case 3: 555 case 3:
556 if (account->getOffline()==false) 556 if (account->getOffline()==false)
557 { 557 {
558 removeChilds(); 558 removeChilds();
559 wrapper->logout(); 559 wrapper->logout();
560 } 560 }
561 account->setOffline(!account->getOffline()); 561 account->setOffline(!account->getOffline());
562 account->save(); 562 account->save();
563 SETPIX(PIXMAP_IMAPFOLDER); 563 SETPIX(PIXMAP_IMAPFOLDER);
564 refreshFolders(false); 564 refreshFolders(false);
565 break; 565 break;
566 default: 566 default:
567 break; 567 break;
568 } 568 }
569} 569}
570 570
571RecBody IMAPviewItem::fetchBody(const RecMail&) 571RecBody IMAPviewItem::fetchBody(const RecMail&)
572{ 572{
573 return RecBody(); 573 return RecBody();
574} 574}
575 575
576bool IMAPviewItem::offline() 576bool IMAPviewItem::offline()
577{ 577{
578 return account->getOffline(); 578 return account->getOffline();
579} 579}
580 580
581IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 581IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
582 : AccountViewItem( parent , after ) 582 : AccountViewItem( parent , after )
583{ 583{
584 folder = folderInit; 584 folder = folderInit;
585 imap = parent; 585 imap = parent;
586 if (folder->getDisplayName().lower()!="inbox") 586 if (folder->getDisplayName().lower()!="inbox")
587 { 587 {
588 setPixmap( 0, PIXMAP_IMAPFOLDER ); 588 setPixmap( 0, PIXMAP_IMAPFOLDER );
589 } 589 }
590 else 590 else
591 { 591 {
592 setPixmap( 0, PIXMAP_INBOXFOLDER); 592 setPixmap( 0, PIXMAP_INBOXFOLDER);
593 } 593 }
594 setText( 0, folder->getDisplayName() ); 594 setText( 0, folder->getDisplayName() );
595} 595}
596 596
597IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 597IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
598 : AccountViewItem( parent,after ) 598 : AccountViewItem( parent,after )
599{ 599{
600 folder = folderInit; 600 folder = folderInit;
601 imap = master; 601 imap = master;
602 if (folder->getDisplayName().lower()!="inbox") 602 if (folder->getDisplayName().lower()!="inbox")
603 { 603 {
604 setPixmap( 0, PIXMAP_IMAPFOLDER ); 604 setPixmap( 0, PIXMAP_IMAPFOLDER );
605 } 605 }
606 else 606 else
607 { 607 {
608 setPixmap( 0, PIXMAP_INBOXFOLDER); 608 setPixmap( 0, PIXMAP_INBOXFOLDER);
609 } 609 }
610 setText( 0, folder->getDisplayName() ); 610 setText( 0, folder->getDisplayName() );
611} 611}
612 612
613IMAPfolderItem::~IMAPfolderItem() 613IMAPfolderItem::~IMAPfolderItem()
614{} 614{}
615 615
616const QString& IMAPfolderItem::Delemiter()const 616const QString& IMAPfolderItem::Delemiter()const
617{ 617{
618 return folder->Separator(); 618 return folder->Separator();
619} 619}
620 620
621void IMAPfolderItem::refresh(QList<RecMail>&target) 621void IMAPfolderItem::refresh(QList<RecMail>&target)
622{ 622{
623 if (folder->may_select()) 623 if (folder->may_select())
624 { 624 {
625 imap->getWrapper()->listMessages( folder->getName(),target ); 625 imap->getWrapper()->listMessages( folder->getName(),target );
626 } 626 }
627 else 627 else
628 { 628 {
629 target.clear(); 629 target.clear();
630 } 630 }
631} 631}
632 632
633RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 633RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
634{ 634{
635 return imap->getWrapper()->fetchBody(aMail); 635 return imap->getWrapper()->fetchBody(aMail);
636} 636}
637 637
638QPopupMenu * IMAPfolderItem::getContextMenu() 638QPopupMenu * IMAPfolderItem::getContextMenu()
639{ 639{
640 QPopupMenu *m = new QPopupMenu(0); 640 QPopupMenu *m = new QPopupMenu(0);
641 if (m) 641 if (m)
642 { 642 {
643 if (folder->may_select()) 643 if (folder->may_select())
644 { 644 {
645 m->insertItem(QObject::tr("Refresh header list",contextName),0); 645 m->insertItem(QObject::tr("Refresh header list",contextName),0);
646 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); 646 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
647 m->insertItem(QObject::tr("Delete all mails",contextName),1); 647 m->insertItem(QObject::tr("Delete all mails",contextName),1);
648 } 648 }
649 if (folder->no_inferior()==false) 649 if (folder->no_inferior()==false)
650 { 650 {
651 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 651 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
652 } 652 }
653 if (folder->getDisplayName().lower()!="inbox") 653 if (folder->getDisplayName().lower()!="inbox")
654 { 654 {
655 m->insertItem(QObject::tr("Delete folder",contextName),3); 655 m->insertItem(QObject::tr("Delete folder",contextName),3);
656 } 656 }
657 } 657 }
658 return m; 658 return m;
659} 659}
660 660
661void IMAPfolderItem::createNewFolder() 661void IMAPfolderItem::createNewFolder()
662{ 662{
663 Newmdirdlg ndirdlg; 663 Newmdirdlg ndirdlg;
664 if ( QPEApplication::execDialog( &ndirdlg ) ) 664 if ( QPEApplication::execDialog( &ndirdlg ) )
665 { 665 {
666 QString ndir = ndirdlg.Newdir(); 666 QString ndir = ndirdlg.Newdir();
667 bool makesubs = ndirdlg.subpossible(); 667 bool makesubs = ndirdlg.subpossible();
668 QString delemiter = Delemiter(); 668 QString delemiter = Delemiter();
669 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) 669 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
670 { 670 {
671 imap->refreshFolders(true); 671 imap->refreshFolders(true);
672 } 672 }
673 } 673 }
674} 674}
675 675
676void IMAPfolderItem::deleteFolder() 676void IMAPfolderItem::deleteFolder()
677{ 677{
678 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 678 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
679 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 679 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
680 QObject::tr("Yes",contextName), 680 QObject::tr("Yes",contextName),
681 QObject::tr("No",contextName),QString::null,1,1); 681 QObject::tr("No",contextName),QString::null,1,1);
682 qDebug("Auswahl: %i",yesno); 682 qDebug("Auswahl: %i",yesno);
683 if (yesno == 0) 683 if (yesno == 0)
684 { 684 {
685 if (imap->getWrapper()->deleteMbox(folder)) 685 if (imap->getWrapper()->deleteMbox(folder))
686 { 686 {
687 QListView*v=listView(); 687 QListView*v=listView();
688 IMAPviewItem * box = imap; 688 IMAPviewItem * box = imap;
689 /* be carefull - after that this object is destroyd so don't use 689 /* be carefull - after that this object is destroyd so don't use
690 * any member of it after that call!!*/ 690 * any member of it after that call!!*/
691 imap->refreshFolders(true); 691 imap->refreshFolders(true);
692 if (v) 692 if (v)
693 { 693 {
694 v->setSelected(box,true); 694 v->setSelected(box,true);
695 } 695 }
696 } 696 }
697 } 697 }
698} 698}
699 699
700void IMAPfolderItem::downloadMails() 700void IMAPfolderItem::downloadMails()
701{ 701{
702 AccountView*bl = imap->accountView(); 702 AccountView*bl = imap->accountView();
703 if (!bl) return; 703 if (!bl) return;
704 bl->downloadMails(folder,imap->getWrapper()); 704 bl->downloadMails(folder,imap->getWrapper());
705} 705}
706 706
707void IMAPfolderItem::contextMenuSelected(int id) 707void IMAPfolderItem::contextMenuSelected(int id)
708{ 708{
709 qDebug("Selected id: %i",id); 709 qDebug("Selected id: %i",id);
710 AccountView * view = (AccountView*)listView(); 710 AccountView * view = (AccountView*)listView();
711 switch(id) 711 switch(id)
712 { 712 {
713 case 0: 713 case 0:
714 view->refreshCurrent(); 714 view->refreshCurrent();
715 break; 715 break;
716 case 1: 716 case 1:
717 deleteAllMail(imap->getWrapper(),folder); 717 deleteAllMail(imap->getWrapper(),folder);
718 break; 718 break;
719 case 2: 719 case 2:
720 createNewFolder(); 720 createNewFolder();
721 break; 721 break;
722 case 3: 722 case 3:
723 deleteFolder(); 723 deleteFolder();
724 break; 724 break;
725 case 4: 725 case 4:
726 downloadMails(); 726 downloadMails();
727 break; 727 break;
728 default: 728 default:
729 break; 729 break;
730 } 730 }
731} 731}
732 732
733/** 733/**
734 * MH Account stuff 734 * MH Account stuff
735 */ 735 */
736/* MH is a little bit different - the top folder can contains messages other than in IMAP and 736/* MH is a little bit different - the top folder can contains messages other than in IMAP and
737 POP3 and MBOX */ 737 POP3 and MBOX */
738MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 738MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
739 : AccountViewItem( parent ) 739 : AccountViewItem( parent )
740{ 740{
741 m_Path = aPath; 741 m_Path = aPath;
742 /* be carefull - the space within settext is wanted - thats why the string twice */ 742 /* be carefull - the space within settext is wanted - thats why the string twice */
743 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 743 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
744 setPixmap( 0, PIXMAP_LOCALFOLDER ); 744 setPixmap( 0, PIXMAP_LOCALFOLDER );
745 setText( 0, " Local Folders" ); 745 setText( 0, " Local Folders" );
746 setOpen( true ); 746 setOpen( true );
747 folder = 0; 747 folder = 0;
748} 748}
749 749
750MHviewItem::~MHviewItem() 750MHviewItem::~MHviewItem()
751{ 751{
752 delete wrapper; 752 delete wrapper;
753} 753}
754 754
755AbstractMail *MHviewItem::getWrapper() 755AbstractMail *MHviewItem::getWrapper()
756{ 756{
757 return wrapper; 757 return wrapper;
758} 758}
759 759
760void MHviewItem::refresh( QList<RecMail> & target) 760void MHviewItem::refresh( QList<RecMail> & target)
761{ 761{
762 refresh(false); 762 refresh(false);
763 getWrapper()->listMessages( "",target ); 763 getWrapper()->listMessages( "",target );
764} 764}
765 765
766void MHviewItem::refresh(bool force) 766void MHviewItem::refresh(bool force)
767{ 767{
768 if (childCount()>0 && force==false) return; 768 if (childCount()>0 && force==false) return;
769 removeChilds(); 769 removeChilds();
770 currentFolders.clear(); 770 currentFolders.clear();
771 QList<Folder> *folders = wrapper->listFolders(); 771 QList<Folder> *folders = wrapper->listFolders();
772 Folder *it; 772 Folder *it;
773 MHfolderItem*item = 0; 773 MHfolderItem*item = 0;
774 MHfolderItem*pmaster = 0; 774 MHfolderItem*pmaster = 0;
775 QString fname = ""; 775 QString fname = "";
776 int pos; 776 int pos;
777 for ( it = folders->first(); it; it = folders->next() ) 777 for ( it = folders->first(); it; it = folders->next() )
778 { 778 {
779 fname = it->getDisplayName(); 779 fname = it->getDisplayName();
780 /* this folder itself */ 780 /* this folder itself */
781 if (fname=="/") 781 if (fname=="/")
782 { 782 {
783 currentFolders.append(fname); 783 currentFolders.append(fname);
784 folder = it; 784 folder = it;
785 continue; 785 continue;
786 } 786 }
787 currentFolders.append(fname); 787 currentFolders.append(fname);
788 pos = fname.findRev("/"); 788 pos = fname.findRev("/");
789 if (pos > 0) 789 if (pos > 0)
790 { 790 {
791 fname = fname.left(pos); 791 fname = fname.left(pos);
792 pmaster = (MHfolderItem*)findSubItem(fname); 792 pmaster = (MHfolderItem*)findSubItem(fname);
793 } 793 }
794 else 794 else
795 { 795 {
796 pmaster = 0; 796 pmaster = 0;
797 } 797 }
798 if (pmaster) 798 if (pmaster)
799 { 799 {
800 item = new MHfolderItem( it, pmaster, item, this ); 800 item = new MHfolderItem( it, pmaster, item, this );
801 } 801 }
802 else 802 else
803 { 803 {
804 item = new MHfolderItem( it, this , item ); 804 item = new MHfolderItem( it, this , item );
805 } 805 }
806 item->setSelectable(it->may_select()); 806 item->setSelectable(it->may_select());
807 } 807 }
808 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 808 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
809 folders->setAutoDelete(false); 809 folders->setAutoDelete(false);
810 delete folders; 810 delete folders;
811} 811}
812 812
813RecBody MHviewItem::fetchBody( const RecMail &mail ) 813RecBody MHviewItem::fetchBody( const RecMail &mail )
814{ 814{
815 qDebug( "MH fetchBody" ); 815 qDebug( "MH fetchBody" );
816 return wrapper->fetchBody( mail ); 816 return wrapper->fetchBody( mail );
817} 817}
818 818
819QPopupMenu * MHviewItem::getContextMenu() 819QPopupMenu * MHviewItem::getContextMenu()
820{ 820{
821 QPopupMenu *m = new QPopupMenu(0); 821 QPopupMenu *m = new QPopupMenu(0);
822 if (m) 822 if (m)
823 { 823 {
824 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 824 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
825 m->insertItem(QObject::tr("Create new folder",contextName),1); 825 m->insertItem(QObject::tr("Create new folder",contextName),1);
826 m->insertItem(QObject::tr("Delete all mails",contextName),2); 826 m->insertItem(QObject::tr("Delete all mails",contextName),2);
827 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); 827 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
828 } 828 }
829 return m; 829 return m;
830} 830}
831 831
832void MHviewItem::createFolder() 832void MHviewItem::createFolder()
833{ 833{
834 Newmdirdlg ndirdlg(0,0,true); 834 Newmdirdlg ndirdlg(0,0,true);
835 if ( QPEApplication::execDialog( &ndirdlg ) ) 835 if ( QPEApplication::execDialog( &ndirdlg ) )
836 { 836 {
837 QString ndir = ndirdlg.Newdir(); 837 QString ndir = ndirdlg.Newdir();
838 if (wrapper->createMbox(ndir)) 838 if (wrapper->createMbox(ndir))
839 { 839 {
840 refresh(true); 840 refresh(true);
841 } 841 }
842 } 842 }
843} 843}
844 844
845void MHviewItem::downloadMails() 845void MHviewItem::downloadMails()
846{ 846{
847 AccountView*bl = accountView(); 847 AccountView*bl = accountView();
848 if (!bl) return; 848 if (!bl) return;
849 bl->downloadMails(folder,getWrapper()); 849 bl->downloadMails(folder,getWrapper());
850} 850}
851 851
852QStringList MHviewItem::subFolders() 852QStringList MHviewItem::subFolders()
853{ 853{
854 return currentFolders; 854 return currentFolders;
855} 855}
856 856
857void MHviewItem::contextMenuSelected(int which) 857void MHviewItem::contextMenuSelected(int which)
858{ 858{
859 switch (which) 859 switch (which)
860 { 860 {
861 case 0: 861 case 0:
862 refresh(true); 862 refresh(true);
863 break; 863 break;
864 case 1: 864 case 1:
865 createFolder(); 865 createFolder();
866 break; 866 break;
867 case 2: 867 case 2:
868 deleteAllMail(getWrapper(),folder); 868 deleteAllMail(getWrapper(),folder);
869 break; 869 break;
870 case 3: 870 case 3:
871 downloadMails(); 871 downloadMails();
872 break; 872 break;
873 default: 873 default:
874 break; 874 break;
875 } 875 }
876} 876}
877 877
878MHfolderItem::~MHfolderItem() 878MHfolderItem::~MHfolderItem()
879{} 879{}
880 880
881MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) 881MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
882 : AccountViewItem( parent,after ) 882 : AccountViewItem( parent,after )
883{ 883{
884 folder = folderInit; 884 folder = folderInit;
885 mbox = parent; 885 mbox = parent;
886 initName(); 886 initName();
887} 887}
888 888
889MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 889MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
890 : AccountViewItem( parent,after ) 890 : AccountViewItem( parent,after )
891{ 891{
892 folder = folderInit; 892 folder = folderInit;
893 mbox = master; 893 mbox = master;
894 initName(); 894 initName();
895} 895}
896 896
897void MHfolderItem::initName() 897void MHfolderItem::initName()
898{ 898{
899 QString bName = folder->getDisplayName(); 899 QString bName = folder->getDisplayName();
900 if (bName.startsWith("/")&&bName.length()>1) 900 if (bName.startsWith("/")&&bName.length()>1)
901 { 901 {
902 bName.replace(0,1,""); 902 bName.replace(0,1,"");
903 } 903 }
904 int pos = bName.findRev("/"); 904 int pos = bName.findRev("/");
905 if (pos > 0) 905 if (pos > 0)
906 { 906 {
907 bName.replace(0,pos+1,""); 907 bName.replace(0,pos+1,"");
908 } 908 }
909 if (bName.lower() == "outgoing") 909 if (bName.lower() == "outgoing")
910 { 910 {
911 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 911 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
912 } 912 }
913 else if (bName.lower() == "inbox") 913 else if (bName.lower() == "inbox")
914 { 914 {
915 setPixmap( 0, PIXMAP_INBOXFOLDER); 915 setPixmap( 0, PIXMAP_INBOXFOLDER);
916 } 916 } else if (bName.lower() == "drafts") {
917 else 917 setPixmap(0, Resource::loadPixmap("inline/edit"));
918 { 918 } else {
919 setPixmap( 0, PIXMAP_MBOXFOLDER ); 919 setPixmap( 0, PIXMAP_MBOXFOLDER );
920 } 920 }
921 setText( 0, bName ); 921 setText( 0, bName );
922} 922}
923 923
924Folder*MHfolderItem::getFolder() 924Folder*MHfolderItem::getFolder()
925{ 925{
926 return folder; 926 return folder;
927} 927}
928 928
929void MHfolderItem::refresh(QList<RecMail>&target) 929void MHfolderItem::refresh(QList<RecMail>&target)
930{ 930{
931 if (folder->may_select()) 931 if (folder->may_select())
932 mbox->getWrapper()->listMessages( folder->getName(),target ); 932 mbox->getWrapper()->listMessages( folder->getName(),target );
933} 933}
934 934
935RecBody MHfolderItem::fetchBody(const RecMail&aMail) 935RecBody MHfolderItem::fetchBody(const RecMail&aMail)
936{ 936{
937 return mbox->getWrapper()->fetchBody(aMail); 937 return mbox->getWrapper()->fetchBody(aMail);
938} 938}
939 939
940void MHfolderItem::deleteFolder() 940void MHfolderItem::deleteFolder()
941{ 941{
942 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 942 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
943 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 943 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
944 QObject::tr("Yes",contextName), 944 QObject::tr("Yes",contextName),
945 QObject::tr("No",contextName),QString::null,1,1); 945 QObject::tr("No",contextName),QString::null,1,1);
946 qDebug("Auswahl: %i",yesno); 946 qDebug("Auswahl: %i",yesno);
947 if (yesno == 0) 947 if (yesno == 0)
948 { 948 {
949 if (mbox->getWrapper()->deleteMbox(folder)) 949 if (mbox->getWrapper()->deleteMbox(folder))
950 { 950 {
951 QListView*v=listView(); 951 QListView*v=listView();
952 MHviewItem * box = mbox; 952 MHviewItem * box = mbox;
953 /* be carefull - after that this object is destroyd so don't use 953 /* be carefull - after that this object is destroyd so don't use
954 * any member of it after that call!!*/ 954 * any member of it after that call!!*/
955 mbox->refresh(true); 955 mbox->refresh(true);
956 if (v) 956 if (v)
957 { 957 {
958 v->setSelected(box,true); 958 v->setSelected(box,true);
959 } 959 }
960 } 960 }
961 } 961 }
962} 962}
963 963
964QPopupMenu * MHfolderItem::getContextMenu() 964QPopupMenu * MHfolderItem::getContextMenu()
965{ 965{
966 QPopupMenu *m = new QPopupMenu(0); 966 QPopupMenu *m = new QPopupMenu(0);
967 if (m) 967 if (m)
968 { 968 {
969 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 969 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
970 m->insertItem(QObject::tr("Delete all mails",contextName),0); 970 m->insertItem(QObject::tr("Delete all mails",contextName),0);
971 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 971 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
972 m->insertItem(QObject::tr("Delete folder",contextName),1); 972 m->insertItem(QObject::tr("Delete folder",contextName),1);
973 } 973 }
974 return m; 974 return m;
975} 975}
976 976
977void MHfolderItem::downloadMails() 977void MHfolderItem::downloadMails()
978{ 978{
979 AccountView*bl = mbox->accountView(); 979 AccountView*bl = mbox->accountView();
980 if (!bl) return; 980 if (!bl) return;
981 bl->downloadMails(folder,mbox->getWrapper()); 981 bl->downloadMails(folder,mbox->getWrapper());
982} 982}
983 983
984void MHfolderItem::createFolder() 984void MHfolderItem::createFolder()
985{ 985{
986 Newmdirdlg ndirdlg(0,0,true); 986 Newmdirdlg ndirdlg(0,0,true);
987 if ( QPEApplication::execDialog( &ndirdlg ) ) 987 if ( QPEApplication::execDialog( &ndirdlg ) )
988 { 988 {
989 QString ndir = ndirdlg.Newdir(); 989 QString ndir = ndirdlg.Newdir();
990 if (mbox->getWrapper()->createMbox(ndir,folder)) 990 if (mbox->getWrapper()->createMbox(ndir,folder))
991 { 991 {
992 QListView*v=listView(); 992 QListView*v=listView();
993 MHviewItem * box = mbox; 993 MHviewItem * box = mbox;
994 /* be carefull - after that this object is destroyd so don't use 994 /* be carefull - after that this object is destroyd so don't use
995 * any member of it after that call!!*/ 995 * any member of it after that call!!*/
996 mbox->refresh(true); 996 mbox->refresh(true);
997 if (v) 997 if (v)
998 { 998 {
999 v->setSelected(box,true); 999 v->setSelected(box,true);
1000 } 1000 }
1001 } 1001 }
1002 } 1002 }
1003} 1003}
1004 1004
1005void MHfolderItem::contextMenuSelected(int which) 1005void MHfolderItem::contextMenuSelected(int which)
1006{ 1006{
1007 switch(which) 1007 switch(which)
1008 { 1008 {
1009 case 0: 1009 case 0:
1010 deleteAllMail(mbox->getWrapper(),folder); 1010 deleteAllMail(mbox->getWrapper(),folder);
1011 break; 1011 break;
1012 case 1: 1012 case 1:
1013 deleteFolder(); 1013 deleteFolder();
1014 break; 1014 break;
1015 case 2: 1015 case 2:
1016 downloadMails(); 1016 downloadMails();
1017 break; 1017 break;
1018 case 3: 1018 case 3:
1019 createFolder(); 1019 createFolder();
1020 break; 1020 break;
1021 default: 1021 default:
1022 break; 1022 break;
1023 } 1023 }
1024} 1024}
1025 1025
1026bool MHfolderItem::isDraftfolder()
1027{
1028 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1029 return false;
1030}
1031
1026/** 1032/**
1027 * Generic stuff 1033 * Generic stuff
1028 */ 1034 */
1029 1035
1030const QString AccountViewItem::contextName="AccountViewItem"; 1036const QString AccountViewItem::contextName="AccountViewItem";
1031 1037
1032AccountViewItem::AccountViewItem( AccountView *parent ) 1038AccountViewItem::AccountViewItem( AccountView *parent )
1033 : QListViewItem( parent ) 1039 : QListViewItem( parent )
1034{ 1040{
1035 init(); 1041 init();
1036 m_Backlink = parent; 1042 m_Backlink = parent;
1037} 1043}
1038 1044
1039AccountViewItem::AccountViewItem( QListViewItem *parent) 1045AccountViewItem::AccountViewItem( QListViewItem *parent)
1040 : QListViewItem( parent) 1046 : QListViewItem( parent)
1041{ 1047{
1042 init(); 1048 init();
1043} 1049}
1044 1050
1045AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1051AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
1046 :QListViewItem( parent,after ) 1052 :QListViewItem( parent,after )
1047{ 1053{
1048 init(); 1054 init();
1049} 1055}
1050 1056
1051void AccountViewItem::init() 1057void AccountViewItem::init()
1052{ 1058{
1053 m_Backlink = 0; 1059 m_Backlink = 0;
1054 folder = 0; 1060 folder = 0;
1055} 1061}
1056 1062
1057AccountViewItem::~AccountViewItem() 1063AccountViewItem::~AccountViewItem()
1058{ 1064{
1059 if (folder) delete folder; 1065 if (folder) delete folder;
1060} 1066}
1061 1067
1062AccountView*AccountViewItem::accountView() 1068AccountView*AccountViewItem::accountView()
1063{ 1069{
1064 return m_Backlink; 1070 return m_Backlink;
1065} 1071}
1066 1072
1067void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) 1073void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
1068{ 1074{
1069 if (!wrapper) return; 1075 if (!wrapper) return;
1070 QString fname=""; 1076 QString fname="";
1071 if (folder) fname = folder->getDisplayName(); 1077 if (folder) fname = folder->getDisplayName();
1072 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 1078 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
1073 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 1079 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
1074 arg(fname), 1080 arg(fname),
1075 QObject::tr("Yes",contextName), 1081 QObject::tr("Yes",contextName),
1076 QObject::tr("No",contextName),QString::null,1,1); 1082 QObject::tr("No",contextName),QString::null,1,1);
1077 qDebug("Auswahl: %i",yesno); 1083 qDebug("Auswahl: %i",yesno);
1078 if (yesno == 0) 1084 if (yesno == 0)
1079 { 1085 {
1080 if (wrapper->deleteAllMail(folder)) 1086 if (wrapper->deleteAllMail(folder))
1081 { 1087 {
1082 AccountView * view = (AccountView*)listView(); 1088 AccountView * view = (AccountView*)listView();
1083 if (view) view->refreshCurrent(); 1089 if (view) view->refreshCurrent();
1084 } 1090 }
1085 } 1091 }
1086} 1092}
1087 1093
1088void AccountViewItem::removeChilds() 1094void AccountViewItem::removeChilds()
1089{ 1095{
1090 QListViewItem *child = firstChild(); 1096 QListViewItem *child = firstChild();
1091 while ( child ) 1097 while ( child )
1092 { 1098 {
1093 QListViewItem *tmp = child; 1099 QListViewItem *tmp = child;
1094 child = child->nextSibling(); 1100 child = child->nextSibling();
1095 delete tmp; 1101 delete tmp;
1096 } 1102 }
1097} 1103}
1098 1104
1099bool AccountViewItem::matchName(const QString&name)const 1105bool AccountViewItem::matchName(const QString&name)const
1100{ 1106{
1101 if (!folder) return false; 1107 if (!folder) return false;
1102 return folder->getDisplayName()==name; 1108 return folder->getDisplayName()==name;
1103} 1109}
1104 1110
1105 1111
1106AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 1112AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
1107{ 1113{
1108 AccountViewItem*pitem,*sitem; 1114 AccountViewItem*pitem,*sitem;
1109 if (!start) pitem = (AccountViewItem*)firstChild(); 1115 if (!start) pitem = (AccountViewItem*)firstChild();
1110 else pitem = (AccountViewItem*)start->firstChild(); 1116 else pitem = (AccountViewItem*)start->firstChild();
1111 while (pitem) 1117 while (pitem)
1112 { 1118 {
1113 if (pitem->matchName(path)) 1119 if (pitem->matchName(path))
1114 { 1120 {
1115 break; 1121 break;
1116 } 1122 }
1117 if (pitem->childCount()>0) 1123 if (pitem->childCount()>0)
1118 { 1124 {
1119 sitem = findSubItem(path,pitem); 1125 sitem = findSubItem(path,pitem);
1120 if (sitem) 1126 if (sitem)
1121 { 1127 {
1122 pitem = sitem; 1128 pitem = sitem;
1123 break; 1129 break;
1124 } 1130 }
1125 } 1131 }
1126 pitem=(AccountViewItem*)pitem->nextSibling(); 1132 pitem=(AccountViewItem*)pitem->nextSibling();
1127 } 1133 }
1128 return pitem; 1134 return pitem;
1129} 1135}
1136
1137bool AccountViewItem::isDraftfolder()
1138{
1139 return false;
1140}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index f3c0f5d..eb3baa3 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -1,205 +1,207 @@
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 6
7class POP3wrapper; 7class POP3wrapper;
8class RecMail; 8class RecMail;
9class RecBody; 9class RecBody;
10class QPopupMenu; 10class QPopupMenu;
11class Selectstore; 11class Selectstore;
12class AccountView; 12class AccountView;
13class POP3account; 13class POP3account;
14class NNTPaccount; 14class NNTPaccount;
15class IMAPaccount; 15class IMAPaccount;
16class AbstractMail; 16class AbstractMail;
17class Folder; 17class Folder;
18 18
19class AccountViewItem : public QListViewItem 19class AccountViewItem : public QListViewItem
20{ 20{
21 21
22public: 22public:
23 AccountViewItem( AccountView *parent ); 23 AccountViewItem( AccountView *parent );
24 AccountViewItem( QListViewItem *parent); 24 AccountViewItem( QListViewItem *parent);
25 AccountViewItem( QListViewItem *parent , QListViewItem*after ); 25 AccountViewItem( QListViewItem *parent , QListViewItem*after );
26 virtual ~AccountViewItem(); 26 virtual ~AccountViewItem();
27 virtual void refresh(QList<RecMail>&)=0; 27 virtual void refresh(QList<RecMail>&)=0;
28 virtual RecBody fetchBody(const RecMail&)=0; 28 virtual RecBody fetchBody(const RecMail&)=0;
29 virtual QPopupMenu * getContextMenu(){return 0;}; 29 virtual QPopupMenu * getContextMenu(){return 0;};
30 virtual void contextMenuSelected(int){} 30 virtual void contextMenuSelected(int){}
31 virtual AccountView*accountView(); 31 virtual AccountView*accountView();
32 virtual bool matchName(const QString&name)const; 32 virtual bool matchName(const QString&name)const;
33 virtual bool isDraftfolder();
33 34
34protected: 35protected:
35 AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); 36 AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
36 virtual void init(); 37 virtual void init();
37 virtual void removeChilds(); 38 virtual void removeChilds();
38 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); 39 virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
39 static const QString contextName; 40 static const QString contextName;
40 AccountView*m_Backlink; 41 AccountView*m_Backlink;
41 Folder *folder; 42 Folder *folder;
42}; 43};
43 44
44class POP3viewItem : public AccountViewItem 45class POP3viewItem : public AccountViewItem
45{ 46{
46 47
47public: 48public:
48 POP3viewItem( POP3account *a, AccountView *parent ); 49 POP3viewItem( POP3account *a, AccountView *parent );
49 virtual ~POP3viewItem(); 50 virtual ~POP3viewItem();
50 virtual void refresh( QList<RecMail> &target ); 51 virtual void refresh( QList<RecMail> &target );
51 virtual RecBody fetchBody( const RecMail &mail ); 52 virtual RecBody fetchBody( const RecMail &mail );
52 AbstractMail *getWrapper(); 53 AbstractMail *getWrapper();
53 virtual QPopupMenu * getContextMenu(); 54 virtual QPopupMenu * getContextMenu();
54 virtual void contextMenuSelected(int); 55 virtual void contextMenuSelected(int);
55 56
56protected: 57protected:
57 POP3account *account; 58 POP3account *account;
58 virtual void refresh(); 59 virtual void refresh();
59 AbstractMail *wrapper; 60 AbstractMail *wrapper;
60 void disconnect(); 61 void disconnect();
61 void setOnOffline(); 62 void setOnOffline();
62}; 63};
63 64
64class POP3folderItem : public AccountViewItem 65class POP3folderItem : public AccountViewItem
65{ 66{
66 67
67public: 68public:
68 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); 69 POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
69 virtual ~POP3folderItem(); 70 virtual ~POP3folderItem();
70 virtual void refresh(QList<RecMail>&); 71 virtual void refresh(QList<RecMail>&);
71 virtual RecBody fetchBody(const RecMail&); 72 virtual RecBody fetchBody(const RecMail&);
72 virtual QPopupMenu * getContextMenu(); 73 virtual QPopupMenu * getContextMenu();
73 virtual void contextMenuSelected(int); 74 virtual void contextMenuSelected(int);
74 75
75protected: 76protected:
76 void downloadMails(); 77 void downloadMails();
77 POP3viewItem *pop3; 78 POP3viewItem *pop3;
78}; 79};
79 80
80 81
81class NNTPviewItem : public AccountViewItem 82class NNTPviewItem : public AccountViewItem
82{ 83{
83 84
84public: 85public:
85 NNTPviewItem( NNTPaccount *a, AccountView *parent ); 86 NNTPviewItem( NNTPaccount *a, AccountView *parent );
86 virtual ~NNTPviewItem(); 87 virtual ~NNTPviewItem();
87 virtual void refresh( QList<RecMail> &target ); 88 virtual void refresh( QList<RecMail> &target );
88 virtual RecBody fetchBody( const RecMail &mail ); 89 virtual RecBody fetchBody( const RecMail &mail );
89 AbstractMail *getWrapper(); 90 AbstractMail *getWrapper();
90 virtual QPopupMenu * getContextMenu(); 91 virtual QPopupMenu * getContextMenu();
91 virtual void contextMenuSelected(int); 92 virtual void contextMenuSelected(int);
92 93
93protected: 94protected:
94 NNTPaccount *account; 95 NNTPaccount *account;
95 virtual void refresh(); 96 virtual void refresh();
96 AbstractMail *wrapper; 97 AbstractMail *wrapper;
97 void disconnect(); 98 void disconnect();
98 void setOnOffline(); 99 void setOnOffline();
99 void subscribeGroups(); 100 void subscribeGroups();
100}; 101};
101 102
102class NNTPfolderItem : public AccountViewItem 103class NNTPfolderItem : public AccountViewItem
103{ 104{
104 105
105public: 106public:
106 NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after ); 107 NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after );
107 virtual ~NNTPfolderItem(); 108 virtual ~NNTPfolderItem();
108 virtual void refresh(QList<RecMail>&); 109 virtual void refresh(QList<RecMail>&);
109 virtual RecBody fetchBody(const RecMail&); 110 virtual RecBody fetchBody(const RecMail&);
110 virtual QPopupMenu * getContextMenu(); 111 virtual QPopupMenu * getContextMenu();
111 virtual void contextMenuSelected(int); 112 virtual void contextMenuSelected(int);
112 113
113protected: 114protected:
114 void downloadMails(); 115 void downloadMails();
115 NNTPviewItem *nntp; 116 NNTPviewItem *nntp;
116}; 117};
117 118
118 119
119 120
120class IMAPviewItem : public AccountViewItem 121class IMAPviewItem : public AccountViewItem
121{ 122{
122 friend class IMAPfolderItem; 123 friend class IMAPfolderItem;
123public: 124public:
124 IMAPviewItem( IMAPaccount *a, AccountView *parent ); 125 IMAPviewItem( IMAPaccount *a, AccountView *parent );
125 virtual ~IMAPviewItem(); 126 virtual ~IMAPviewItem();
126 virtual void refresh(QList<RecMail>&); 127 virtual void refresh(QList<RecMail>&);
127 virtual RecBody fetchBody(const RecMail&); 128 virtual RecBody fetchBody(const RecMail&);
128 AbstractMail *getWrapper(); 129 AbstractMail *getWrapper();
129 virtual QPopupMenu * getContextMenu(); 130 virtual QPopupMenu * getContextMenu();
130 virtual void contextMenuSelected(int); 131 virtual void contextMenuSelected(int);
131 const QStringList&subFolders(); 132 const QStringList&subFolders();
132 virtual void refreshFolders(bool force=false); 133 virtual void refreshFolders(bool force=false);
133 bool offline(); 134 bool offline();
134 135
135protected: 136protected:
136 virtual void createNewFolder(); 137 virtual void createNewFolder();
137 IMAPaccount *account; 138 IMAPaccount *account;
138 AbstractMail *wrapper; 139 AbstractMail *wrapper;
139 QStringList currentFolders; 140 QStringList currentFolders;
140}; 141};
141 142
142class IMAPfolderItem : public AccountViewItem 143class IMAPfolderItem : public AccountViewItem
143{ 144{
144 145
145public: 146public:
146 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); 147 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
147 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); 148 IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
148 virtual ~IMAPfolderItem(); 149 virtual ~IMAPfolderItem();
149 virtual void refresh(QList<RecMail>&); 150 virtual void refresh(QList<RecMail>&);
150 virtual RecBody fetchBody(const RecMail&); 151 virtual RecBody fetchBody(const RecMail&);
151 virtual QPopupMenu * getContextMenu(); 152 virtual QPopupMenu * getContextMenu();
152 virtual void contextMenuSelected(int); 153 virtual void contextMenuSelected(int);
153 virtual const QString& Delemiter()const; 154 virtual const QString& Delemiter()const;
154protected: 155protected:
155 virtual void createNewFolder(); 156 virtual void createNewFolder();
156 virtual void deleteFolder(); 157 virtual void deleteFolder();
157 virtual void downloadMails(); 158 virtual void downloadMails();
158 IMAPviewItem *imap; 159 IMAPviewItem *imap;
159}; 160};
160 161
161class MHviewItem : public AccountViewItem 162class MHviewItem : public AccountViewItem
162{ 163{
163 friend class MHfolderItem; 164 friend class MHfolderItem;
164 165
165public: 166public:
166 MHviewItem( const QString&aMboxPath, AccountView *parent ); 167 MHviewItem( const QString&aMboxPath, AccountView *parent );
167 virtual ~MHviewItem(); 168 virtual ~MHviewItem();
168 virtual void refresh( QList<RecMail> &target ); 169 virtual void refresh( QList<RecMail> &target );
169 virtual RecBody fetchBody( const RecMail &mail ); 170 virtual RecBody fetchBody( const RecMail &mail );
170 AbstractMail *getWrapper(); 171 AbstractMail *getWrapper();
171 virtual QPopupMenu * getContextMenu(); 172 virtual QPopupMenu * getContextMenu();
172 virtual void contextMenuSelected(int); 173 virtual void contextMenuSelected(int);
173 QStringList subFolders(); 174 QStringList subFolders();
174 virtual void refresh(bool force=false); 175 virtual void refresh(bool force=false);
175 176
176protected: 177protected:
177 void downloadMails(); 178 void downloadMails();
178 virtual void createFolder(); 179 virtual void createFolder();
179 QString m_Path; 180 QString m_Path;
180 AbstractMail *wrapper; 181 AbstractMail *wrapper;
181 QStringList currentFolders; 182 QStringList currentFolders;
182}; 183};
183 184
184class MHfolderItem : public AccountViewItem 185class MHfolderItem : public AccountViewItem
185{ 186{
186 187
187public: 188public:
188 MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); 189 MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after );
189 MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); 190 MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
190 virtual ~MHfolderItem(); 191 virtual ~MHfolderItem();
191 virtual void refresh(QList<RecMail>&); 192 virtual void refresh(QList<RecMail>&);
192 virtual RecBody fetchBody(const RecMail&); 193 virtual RecBody fetchBody(const RecMail&);
193 virtual QPopupMenu * getContextMenu(); 194 virtual QPopupMenu * getContextMenu();
194 virtual void contextMenuSelected(int); 195 virtual void contextMenuSelected(int);
195 virtual Folder*getFolder(); 196 virtual Folder*getFolder();
197 virtual bool isDraftfolder();
196 198
197protected: 199protected:
198 void downloadMails(); 200 void downloadMails();
199 virtual void createFolder(); 201 virtual void createFolder();
200 virtual void deleteFolder(); 202 virtual void deleteFolder();
201 void initName(); 203 void initName();
202 MHviewItem *mbox; 204 MHviewItem *mbox;
203}; 205};
204 206
205#endif 207#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 4375044..7938d4f 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,170 +1,177 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
8#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12 12
13/* QT */ 13/* QT */
14#include <qmessagebox.h> 14#include <qmessagebox.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16 16
17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
18 : QListView( parent, name, flags ) 18 : QListView( parent, name, flags )
19{ 19{
20 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 20 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
21 SLOT( refresh(QListViewItem*) ) ); 21 SLOT( refresh(QListViewItem*) ) );
22 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 22 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
23 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 23 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
24 setSorting(0); 24 setSorting(0);
25} 25}
26 26
27AccountView::~AccountView() 27AccountView::~AccountView()
28{ 28{
29 imapAccounts.clear(); 29 imapAccounts.clear();
30 mhAccounts.clear(); 30 mhAccounts.clear();
31} 31}
32 32
33void AccountView::slotContextMenu(int id) 33void AccountView::slotContextMenu(int id)
34{ 34{
35 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 35 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
36 if (!view) return; 36 if (!view) return;
37 view->contextMenuSelected(id); 37 view->contextMenuSelected(id);
38} 38}
39 39
40void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 40void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
41{ 41{
42 if (button==1) {return;} 42 if (button==1) {return;}
43 if (!item) return; 43 if (!item) return;
44 AccountViewItem *view = static_cast<AccountViewItem *>(item); 44 AccountViewItem *view = static_cast<AccountViewItem *>(item);
45 QPopupMenu*m = view->getContextMenu(); 45 QPopupMenu*m = view->getContextMenu();
46 if (!m) return; 46 if (!m) return;
47 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 47 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
48 m->setFocus(); 48 m->setFocus();
49 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 49 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
50 delete m; 50 delete m;
51} 51}
52 52
53void AccountView::populate( QList<Account> list ) 53void AccountView::populate( QList<Account> list )
54{ 54{
55 clear(); 55 clear();
56 56
57 imapAccounts.clear(); 57 imapAccounts.clear();
58 mhAccounts.clear(); 58 mhAccounts.clear();
59 59
60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
61 61
62 Account *it; 62 Account *it;
63 for ( it = list.first(); it; it = list.next() ) 63 for ( it = list.first(); it; it = list.next() )
64 { 64 {
65 if ( it->getType() == MAILLIB::A_IMAP ) 65 if ( it->getType() == MAILLIB::A_IMAP )
66 { 66 {
67 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 67 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
68 qDebug( "added IMAP " + imap->getAccountName() ); 68 qDebug( "added IMAP " + imap->getAccountName() );
69 imapAccounts.append(new IMAPviewItem( imap, this )); 69 imapAccounts.append(new IMAPviewItem( imap, this ));
70 } 70 }
71 else if ( it->getType() == MAILLIB::A_POP3 ) 71 else if ( it->getType() == MAILLIB::A_POP3 )
72 { 72 {
73 POP3account *pop3 = static_cast<POP3account *>(it); 73 POP3account *pop3 = static_cast<POP3account *>(it);
74 qDebug( "added POP3 " + pop3->getAccountName() ); 74 qDebug( "added POP3 " + pop3->getAccountName() );
75 /* must not be hold 'cause it isn't required */ 75 /* must not be hold 'cause it isn't required */
76 (void) new POP3viewItem( pop3, this ); 76 (void) new POP3viewItem( pop3, this );
77 } 77 }
78 else if ( it->getType() == MAILLIB::A_NNTP ) 78 else if ( it->getType() == MAILLIB::A_NNTP )
79 { 79 {
80 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 80 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
81 qDebug( "added NNTP " + nntp->getAccountName() ); 81 qDebug( "added NNTP " + nntp->getAccountName() );
82 /* must not be hold 'cause it isn't required */ 82 /* must not be hold 'cause it isn't required */
83 (void) new NNTPviewItem( nntp, this ); 83 (void) new NNTPviewItem( nntp, this );
84 } 84 }
85 } 85 }
86} 86}
87 87
88void AccountView::refresh(QListViewItem *item) 88void AccountView::refresh(QListViewItem *item)
89{ 89{
90 90
91 qDebug("AccountView refresh..."); 91 qDebug("AccountView refresh...");
92 if ( item ) 92 if ( item )
93 { 93 {
94 m_currentItem = item; 94 m_currentItem = item;
95 QList<RecMail> headerlist; 95 QList<RecMail> headerlist;
96 headerlist.setAutoDelete(true); 96 headerlist.setAutoDelete(true);
97 AccountViewItem *view = static_cast<AccountViewItem *>(item); 97 AccountViewItem *view = static_cast<AccountViewItem *>(item);
98 view->refresh(headerlist); 98 view->refresh(headerlist);
99 emit refreshMailview(&headerlist); 99 emit refreshMailview(&headerlist);
100 } 100 }
101} 101}
102 102
103void AccountView::refreshCurrent() 103void AccountView::refreshCurrent()
104{ 104{
105 m_currentItem = currentItem(); 105 m_currentItem = currentItem();
106 if ( !m_currentItem ) return; 106 if ( !m_currentItem ) return;
107 QList<RecMail> headerlist; 107 QList<RecMail> headerlist;
108 headerlist.setAutoDelete(true); 108 headerlist.setAutoDelete(true);
109 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 109 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
110 view->refresh(headerlist); 110 view->refresh(headerlist);
111 emit refreshMailview(&headerlist); 111 emit refreshMailview(&headerlist);
112} 112}
113 113
114void AccountView::refreshAll() 114void AccountView::refreshAll()
115{ 115{
116} 116}
117 117
118RecBody AccountView::fetchBody(const RecMail&aMail) 118RecBody AccountView::fetchBody(const RecMail&aMail)
119{ 119{
120 QListViewItem*item = selectedItem (); 120 QListViewItem*item = selectedItem ();
121 if (!item) return RecBody(); 121 if (!item) return RecBody();
122 AccountViewItem *view = static_cast<AccountViewItem *>(item); 122 AccountViewItem *view = static_cast<AccountViewItem *>(item);
123 return view->fetchBody(aMail); 123 return view->fetchBody(aMail);
124} 124}
125 125
126void AccountView::setupFolderselect(Selectstore*sels) 126void AccountView::setupFolderselect(Selectstore*sels)
127{ 127{
128 QPEApplication::showDialog( sels ); 128 QPEApplication::showDialog( sels );
129 QStringList sFolders; 129 QStringList sFolders;
130 unsigned int i = 0; 130 unsigned int i = 0;
131 for (i=0; i < mhAccounts.count();++i) 131 for (i=0; i < mhAccounts.count();++i)
132 { 132 {
133 mhAccounts[i]->refresh(false); 133 mhAccounts[i]->refresh(false);
134 sFolders = mhAccounts[i]->subFolders(); 134 sFolders = mhAccounts[i]->subFolders();
135 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 135 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
136 } 136 }
137 for (i=0; i < imapAccounts.count();++i) 137 for (i=0; i < imapAccounts.count();++i)
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
146void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) 146void AccountView::downloadMails(Folder*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();
155 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 155 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
156 targetFolder.isEmpty()) 156 targetFolder.isEmpty())
157 { 157 {
158 return; 158 return;
159 } 159 }
160 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 160 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
161 { 161 {
162 QMessageBox::critical(0,tr("Error creating new Folder"), 162 QMessageBox::critical(0,tr("Error creating new Folder"),
163 tr("<center>Error while creating<br>new folder - breaking.</center>")); 163 tr("<center>Error while creating<br>new folder - breaking.</center>"));
164 return; 164 return;
165 } 165 }
166 qDebug("Targetfolder: %s",targetFolder.latin1()); 166 qDebug("Targetfolder: %s",targetFolder.latin1());
167 qDebug("Fromfolder: %s",fromFolder->getName().latin1()); 167 qDebug("Fromfolder: %s",fromFolder->getName().latin1());
168 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 168 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
169 refreshCurrent(); 169 refreshCurrent();
170} 170}
171
172bool AccountView::currentisDraft()
173{
174 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
175 if (!view) return false;
176 return view->isDraftfolder();
177}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 9f92090..5000202 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,44 +1,45 @@
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 6
7class Selectstore; 7class Selectstore;
8class RecMail; 8class RecMail;
9class RecBody; 9class RecBody;
10class Folder; 10class Folder;
11class AbstractMail; 11class AbstractMail;
12class Account; 12class Account;
13class IMAPviewItem; 13class IMAPviewItem;
14class MHviewItem; 14class MHviewItem;
15 15
16class AccountView : public QListView 16class AccountView : public QListView
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
22 virtual ~AccountView(); 22 virtual ~AccountView();
23 virtual void populate( QList<Account> list ); 23 virtual void populate( QList<Account> list );
24 virtual RecBody fetchBody(const RecMail&aMail); 24 virtual RecBody fetchBody(const RecMail&aMail);
25 virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); 25 virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper);
26 virtual bool currentisDraft();
26 27
27public slots: 28public slots:
28 virtual void refreshAll(); 29 virtual void refreshAll();
29 virtual void refresh(QListViewItem *item); 30 virtual void refresh(QListViewItem *item);
30 virtual void refreshCurrent(); 31 virtual void refreshCurrent();
31 virtual void slotHold(int, QListViewItem *,const QPoint&,int); 32 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
32 virtual void slotContextMenu(int id); 33 virtual void slotContextMenu(int id);
33 void setupFolderselect(Selectstore*sels); 34 void setupFolderselect(Selectstore*sels);
34 35
35signals: 36signals:
36 void refreshMailview(QList<RecMail>*); 37 void refreshMailview(QList<RecMail>*);
37 38
38protected: 39protected:
39 QListViewItem* m_currentItem; 40 QListViewItem* m_currentItem;
40 QValueList<IMAPviewItem*> imapAccounts; 41 QValueList<IMAPviewItem*> imapAccounts;
41 QValueList<MHviewItem*> mhAccounts; 42 QValueList<MHviewItem*> mhAccounts;
42}; 43};
43 44
44#endif 45#endif
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index b5cd75b..b9c9cbc 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -1,239 +1,301 @@
1#include <qt.h> 1#include <qt.h>
2 2
3#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <qpe/contact.h> 7#include <qpe/contact.h>
8 8
9#include "composemail.h" 9#include "composemail.h"
10 10
11#include <libmailwrapper/smtpwrapper.h> 11#include <libmailwrapper/smtpwrapper.h>
12#include <libmailwrapper/storemail.h>
13#include <libmailwrapper/abstractmail.h>
14#include <libmailwrapper/mailtypes.h>
12 15
13ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 16ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
14 : ComposeMailUI( parent, name, modal, flags ) 17 : ComposeMailUI( parent, name, modal, flags )
15{ 18{
16 settings = s; 19 settings = s;
17 m_replyid = ""; 20 m_replyid = "";
18 21
19 QString vfilename = Global::applicationFileName("addressbook", 22 QString vfilename = Global::applicationFileName("addressbook",
20 "businesscard.vcf"); 23 "businesscard.vcf");
21 Contact c; 24 Contact c;
22 if (QFile::exists(vfilename)) { 25 if (QFile::exists(vfilename)) {
23 c = Contact::readVCard( vfilename )[0]; 26 c = Contact::readVCard( vfilename )[0];
24 } 27 }
25 28
26 QStringList mails = c.emailList(); 29 QStringList mails = c.emailList();
27 QString defmail = c.defaultEmail(); 30 QString defmail = c.defaultEmail();
28 31
29 if (defmail.length()!=0) { 32 if (defmail.length()!=0) {
30 fromBox->insertItem(defmail); 33 fromBox->insertItem(defmail);
31 } 34 }
32 QStringList::ConstIterator sit = mails.begin(); 35 QStringList::ConstIterator sit = mails.begin();
33 for (;sit!=mails.end();++sit) { 36 for (;sit!=mails.end();++sit) {
34 if ( (*sit)==defmail) 37 if ( (*sit)==defmail)
35 continue; 38 continue;
36 fromBox->insertItem((*sit)); 39 fromBox->insertItem((*sit));
37 } 40 }
38 senderNameEdit->setText(c.firstName()+" "+c.lastName()); 41 senderNameEdit->setText(c.firstName()+" "+c.lastName());
39 Config cfg( "mail" ); 42 Config cfg( "mail" );
40 cfg.setGroup( "Compose" ); 43 cfg.setGroup( "Compose" );
41 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 44 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
42 45
43 attList->addColumn( tr( "Name" ) ); 46 attList->addColumn( tr( "Name" ) );
44 attList->addColumn( tr( "Size" ) ); 47 attList->addColumn( tr( "Size" ) );
45 48
46 QList<Account> accounts = settings->getAccounts(); 49 QList<Account> accounts = settings->getAccounts();
47 50
48 Account *it; 51 Account *it;
49 for ( it = accounts.first(); it; it = accounts.next() ) { 52 for ( it = accounts.first(); it; it = accounts.next() ) {
50 if ( it->getType()==MAILLIB::A_SMTP ) { 53 if ( it->getType()==MAILLIB::A_SMTP ) {
51 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 54 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
52 smtpAccountBox->insertItem( smtp->getAccountName() ); 55 smtpAccountBox->insertItem( smtp->getAccountName() );
53 smtpAccounts.append( smtp ); 56 smtpAccounts.append( smtp );
54 } 57 }
55 } 58 }
56 59
57 if ( smtpAccounts.count() > 0 ) { 60 if ( smtpAccounts.count() > 0 ) {
58 fillValues( smtpAccountBox->currentItem() ); 61 fillValues( smtpAccountBox->currentItem() );
59 } else { 62 } else {
60 QMessageBox::information( this, tr( "Problem" ), 63 QMessageBox::information( this, tr( "Problem" ),
61 tr( "<p>Please create an SMTP account first.</p>" ), 64 tr( "<p>Please create an SMTP account first.</p>" ),
62 tr( "Ok" ) ); 65 tr( "Ok" ) );
63 return; 66 return;
64 } 67 }
65 68
66 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 69 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
67 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 70 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
68 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 71 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
69 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 72 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
70 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 73 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
71 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 74 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
72 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 75 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
73} 76}
74 77
75void ComposeMail::pickAddress( QLineEdit *line ) 78void ComposeMail::pickAddress( QLineEdit *line )
76{ 79{
77 QString names = AddressPicker::getNames(); 80 QString names = AddressPicker::getNames();
78 if ( line->text().isEmpty() ) { 81 if ( line->text().isEmpty() ) {
79 line->setText( names ); 82 line->setText( names );
80 } else if ( !names.isEmpty() ) { 83 } else if ( !names.isEmpty() ) {
81 line->setText( line->text() + ", " + names ); 84 line->setText( line->text() + ", " + names );
82 } 85 }
83} 86}
84 87
85 88
86void ComposeMail::setTo( const QString & to ) 89void ComposeMail::setTo( const QString & to )
87{ 90{
88 toLine->setText( to ); 91 toLine->setText( to );
89} 92}
90 93
91void ComposeMail::setSubject( const QString & subject ) 94void ComposeMail::setSubject( const QString & subject )
92{ 95{
93 subjectLine->setText( subject ); 96 subjectLine->setText( subject );
94} 97}
95 98
96void ComposeMail::setInReplyTo( const QString & messageId ) 99void ComposeMail::setInReplyTo( const QString & messageId )
97{ 100{
98 m_replyid = messageId; 101 m_replyid = messageId;
99} 102}
100 103
101void ComposeMail::setMessage( const QString & text ) 104void ComposeMail::setMessage( const QString & text )
102{ 105{
103 message->setText( text ); 106 message->setText( text );
104} 107}
105 108
106 109
107void ComposeMail::pickAddressTo() 110void ComposeMail::pickAddressTo()
108{ 111{
109 pickAddress( toLine ); 112 pickAddress( toLine );
110} 113}
111 114
112void ComposeMail::pickAddressCC() 115void ComposeMail::pickAddressCC()
113{ 116{
114 pickAddress( ccLine ); 117 pickAddress( ccLine );
115} 118}
116 119
117void ComposeMail::pickAddressBCC() 120void ComposeMail::pickAddressBCC()
118{ 121{
119 pickAddress( bccLine ); 122 pickAddress( bccLine );
120} 123}
121 124
122void ComposeMail::pickAddressReply() 125void ComposeMail::pickAddressReply()
123{ 126{
124 pickAddress( replyLine ); 127 pickAddress( replyLine );
125} 128}
126 129
127void ComposeMail::fillValues( int current ) 130void ComposeMail::fillValues( int )
128{ 131{
129#if 0 132#if 0
130 SMTPaccount *smtp = smtpAccounts.at( current ); 133 SMTPaccount *smtp = smtpAccounts.at( current );
131 ccLine->clear(); 134 ccLine->clear();
132 if ( smtp->getUseCC() ) { 135 if ( smtp->getUseCC() ) {
133 ccLine->setText( smtp->getCC() ); 136 ccLine->setText( smtp->getCC() );
134 } 137 }
135 bccLine->clear(); 138 bccLine->clear();
136 if ( smtp->getUseBCC() ) { 139 if ( smtp->getUseBCC() ) {
137 bccLine->setText( smtp->getBCC() ); 140 bccLine->setText( smtp->getBCC() );
138 } 141 }
139 replyLine->clear(); 142 replyLine->clear();
140 if ( smtp->getUseReply() ) { 143 if ( smtp->getUseReply() ) {
141 replyLine->setText( smtp->getReply() ); 144 replyLine->setText( smtp->getReply() );
142 } 145 }
143 sigMultiLine->setText( smtp->getSignature() ); 146 sigMultiLine->setText( smtp->getSignature() );
144#endif 147#endif
145} 148}
146 149
147void ComposeMail::slotAdjustColumns() 150void ComposeMail::slotAdjustColumns()
148{ 151{
149 int currPage = tabWidget->currentPageIndex(); 152 int currPage = tabWidget->currentPageIndex();
150 153
151 tabWidget->showPage( attachTab ); 154 tabWidget->showPage( attachTab );
152 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 155 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
153 attList->setColumnWidth( 1, 80 ); 156 attList->setColumnWidth( 1, 80 );
154 157
155 tabWidget->setCurrentPage( currPage ); 158 tabWidget->setCurrentPage( currPage );
156} 159}
157 160
158void ComposeMail::addAttachment() 161void ComposeMail::addAttachment()
159{ 162{
160 DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); 163 DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" );
161 if ( !lnk.name().isEmpty() ) { 164 if ( !lnk.name().isEmpty() ) {
162 Attachment *att = new Attachment( lnk ); 165 Attachment *att = new Attachment( lnk );
163 (void) new AttachViewItem( attList, att ); 166 (void) new AttachViewItem( attList, att );
164 } 167 }
165} 168}
166 169
167void ComposeMail::removeAttachment() 170void ComposeMail::removeAttachment()
168{ 171{
169 if ( !attList->currentItem() ) { 172 if ( !attList->currentItem() ) {
170 QMessageBox::information( this, tr( "Error" ), 173 QMessageBox::information( this, tr( "Error" ),
171 tr( "<p>Please select a File.</p>" ), 174 tr( "<p>Please select a File.</p>" ),
172 tr( "Ok" ) ); 175 tr( "Ok" ) );
173 } else { 176 } else {
174 attList->takeItem( attList->currentItem() ); 177 attList->takeItem( attList->currentItem() );
175 } 178 }
176} 179}
177 180
178void ComposeMail::accept() 181void ComposeMail::accept()
179{ 182{
180 if ( checkBoxLater->isChecked() ) { 183 if ( checkBoxLater->isChecked() ) {
181 qDebug( "Send later" ); 184 qDebug( "Send later" );
182 } 185 }
183 186
184#if 0 187#if 0
185 qDebug( "Sending Mail with " + 188 qDebug( "Sending Mail with " +
186 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); 189 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
187#endif 190#endif
188 Mail *mail = new Mail(); 191 Mail mail;
189 192
190 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 193 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
191 mail->setMail(fromBox->currentText()); 194 mail.setMail(fromBox->currentText());
192 195
193 if ( !toLine->text().isEmpty() ) { 196 if ( !toLine->text().isEmpty() ) {
194 mail->setTo( toLine->text() ); 197 mail.setTo( toLine->text() );
195 } else { 198 } else {
196 qDebug( "No Reciever spezified -> returning" ); 199 QMessageBox::warning(0,tr("Sending mail"),
200 tr("No Receiver spezified" ) );
197 return; 201 return;
198 } 202 }
199 mail->setName(senderNameEdit->text()); 203 mail.setName(senderNameEdit->text());
200 mail->setCC( ccLine->text() ); 204 mail.setCC( ccLine->text() );
201 mail->setBCC( bccLine->text() ); 205 mail.setBCC( bccLine->text() );
202 mail->setReply( replyLine->text() ); 206 mail.setReply( replyLine->text() );
203 mail->setSubject( subjectLine->text() ); 207 mail.setSubject( subjectLine->text() );
204 if (!m_replyid.isEmpty()) { 208 if (!m_replyid.isEmpty()) {
205 QStringList ids; 209 QStringList ids;
206 ids.append(m_replyid); 210 ids.append(m_replyid);
207 mail->setInreply(ids); 211 mail.setInreply(ids);
208 } 212 }
209 QString txt = message->text(); 213 QString txt = message->text();
210 if ( !sigMultiLine->text().isEmpty() ) { 214 if ( !sigMultiLine->text().isEmpty() ) {
211 txt.append( "\n--\n" ); 215 txt.append( "\n--\n" );
212 txt.append( sigMultiLine->text() ); 216 txt.append( sigMultiLine->text() );
213 } 217 }
214 qDebug(txt); 218 qDebug(txt);
215 mail->setMessage( txt ); 219 mail.setMessage( txt );
216 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 220 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
217 while ( it != NULL ) { 221 while ( it != NULL ) {
218 mail->addAttachment( it->getAttachment() ); 222 mail.addAttachment( it->getAttachment() );
219 it = (AttachViewItem *) it->nextSibling(); 223 it = (AttachViewItem *) it->nextSibling();
220 } 224 }
221 225
222 SMTPwrapper wrapper( smtp ); 226 SMTPwrapper wrapper( smtp );
223 wrapper.sendMail( *mail,checkBoxLater->isChecked() ); 227 wrapper.sendMail( mail,checkBoxLater->isChecked() );
224 228
225 QDialog::accept(); 229 QDialog::accept();
226} 230}
227 231
232void ComposeMail::reject()
233{
234 int yesno = QMessageBox::warning(0,tr("Store message"),
235 tr("Store message into drafts?"),
236 tr("Yes"),
237 tr("No"),QString::null,0,1);
238
239 if (yesno == 0) {
240 Mail mail;
241 mail.setMail(fromBox->currentText());
242 mail.setTo( toLine->text() );
243 mail.setName(senderNameEdit->text());
244 mail.setCC( ccLine->text() );
245 mail.setBCC( bccLine->text() );
246 mail.setReply( replyLine->text() );
247 mail.setSubject( subjectLine->text() );
248 if (!m_replyid.isEmpty()) {
249 QStringList ids;
250 ids.append(m_replyid);
251 mail.setInreply(ids);
252 }
253 QString txt = message->text();
254 if ( !sigMultiLine->text().isEmpty() ) {
255 txt.append( "\n--\n" );
256 txt.append( sigMultiLine->text() );
257 }
258 qDebug(txt);
259 mail.setMessage( txt );
260
261 /* only use the default drafts folder name! */
262 Storemail wrapper(AbstractMail::draftFolder());
263 wrapper.storeMail(mail);
264
265 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
266 /* attachments we will ignore! */
267 if ( it != NULL ) {
268 QMessageBox::warning(0,tr("Store message"),
269 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
270 }
271 }
272 QDialog::reject();
273}
274
275ComposeMail::~ComposeMail()
276{
277}
278
279void ComposeMail::reEditMail(const RecMail&current)
280{
281 RecMail data = current;
282 message->setText(data.Wrapper()->fetchBody(current).Bodytext());
283 subjectLine->setText( data.getSubject());
284 toLine->setText(data.To().join(","));
285 ccLine->setText(data.CC().join(","));
286 bccLine->setText(data.Bcc().join(","));
287 replyLine->setText(data.Replyto());
288}
289
228AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 290AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
229 : QListViewItem( parent ) 291 : QListViewItem( parent )
230{ 292{
231 attachment = att; 293 attachment = att;
232 qDebug( att->getMimeType() ); 294 qDebug( att->getMimeType() );
233 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? 295 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
234 Resource::loadPixmap( "UnknownDocument-14" ) : 296 Resource::loadPixmap( "UnknownDocument-14" ) :
235 attachment->getDocLnk().pixmap() ); 297 attachment->getDocLnk().pixmap() );
236 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 298 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
237 setText( 1, QString::number( att->getSize() ) ); 299 setText( 1, QString::number( att->getSize() ) );
238} 300}
239 301
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h
index 886fb1d..1b9fc79 100644
--- a/noncore/net/mail/composemail.h
+++ b/noncore/net/mail/composemail.h
@@ -1,74 +1,79 @@
1#ifndef COMPOSEMAIL_H 1#ifndef COMPOSEMAIL_H
2#define COMPOSEMAIL_H 2#define COMPOSEMAIL_H
3 3
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "composemailui.h" 7#include "composemailui.h"
8#include "addresspickerui.h" 8#include "addresspickerui.h"
9#include <libmailwrapper/settings.h> 9#include <libmailwrapper/settings.h>
10#include <libmailwrapper/mailwrapper.h> 10#include <libmailwrapper/mailwrapper.h>
11 11
12 12
13 13
14class AddressPicker : public AddressPickerUI 14class AddressPicker : public AddressPickerUI
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 19 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
20 static QString getNames(); 20 static QString getNames();
21 21
22protected: 22protected:
23 QString selectedNames; 23 QString selectedNames;
24 void accept(); 24 void accept();
25 25
26}; 26};
27 27
28class RecMail;
28 29
29class ComposeMail : public ComposeMailUI 30class ComposeMail : public ComposeMailUI
30{ 31{
31 Q_OBJECT 32 Q_OBJECT
32 33
33public: 34public:
34 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 35 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
36 virtual ~ComposeMail();
37
38 void reEditMail(const RecMail&current);
35 39
36public slots: 40public slots:
37 void slotAdjustColumns(); 41 void slotAdjustColumns();
38 42
39 void setTo( const QString & to ); 43 void setTo( const QString & to );
40 void setSubject( const QString & subject ); 44 void setSubject( const QString & subject );
41 void setInReplyTo( const QString & messageId ); 45 void setInReplyTo( const QString & messageId );
42 void setMessage( const QString & text ); 46 void setMessage( const QString & text );
43 47
44protected slots: 48protected slots:
45 void accept(); 49 void accept();
46 50 void reject();
51
47private slots: 52private slots:
48 void fillValues( int current ); 53 void fillValues( int current );
49 void pickAddress( QLineEdit *line ); 54 void pickAddress( QLineEdit *line );
50 void pickAddressTo(); 55 void pickAddressTo();
51 void pickAddressCC(); 56 void pickAddressCC();
52 void pickAddressBCC(); 57 void pickAddressBCC();
53 void pickAddressReply(); 58 void pickAddressReply();
54 void addAttachment(); 59 void addAttachment();
55 void removeAttachment(); 60 void removeAttachment();
56 61
57protected: 62protected:
58 Settings *settings; 63 Settings *settings;
59 QList<SMTPaccount> smtpAccounts; 64 QList<SMTPaccount> smtpAccounts;
60 QString m_replyid; 65 QString m_replyid;
61}; 66};
62 67
63class AttachViewItem : public QListViewItem 68class AttachViewItem : public QListViewItem
64{ 69{
65 public: 70public:
66 AttachViewItem( QListView *parent, Attachment *att ); 71 AttachViewItem( QListView *parent, Attachment *att );
67 Attachment *getAttachment() { return attachment; } 72 Attachment *getAttachment() { return attachment; }
68 73
69private: 74private:
70 Attachment *attachment; 75 Attachment *attachment;
71 76
72}; 77};
73 78
74#endif 79#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 9960f88..d71d35c 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -1,143 +1,166 @@
1#include "abstractmail.h" 1#include "abstractmail.h"
2#include "imapwrapper.h" 2#include "imapwrapper.h"
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "nntpwrapper.h" 4#include "nntpwrapper.h"
5#include "mhwrapper.h" 5#include "mhwrapper.h"
6#include "mailtypes.h" 6#include "mailtypes.h"
7 7
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <libetpan/mailmime_content.h> 11#include <libetpan/mailmime_content.h>
12#include <libetpan/mailmime.h> 12#include <libetpan/mailmime.h>
13 13
14AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 14AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
15{ 15{
16 return new IMAPwrapper(a); 16 return new IMAPwrapper(a);
17} 17}
18 18
19AbstractMail* AbstractMail::getWrapper(POP3account *a) 19AbstractMail* AbstractMail::getWrapper(POP3account *a)
20{ 20{
21 return new POP3wrapper(a); 21 return new POP3wrapper(a);
22} 22}
23 23
24AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) 24AbstractMail* AbstractMail::getWrapper(NNTPaccount *a)
25{ 25{
26 return new NNTPwrapper(a); 26 return new NNTPwrapper(a);
27} 27}
28 28
29AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) 29AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
30{ 30{
31 return new MHwrapper(a,name); 31 return new MHwrapper(a,name);
32} 32}
33 33
34AbstractMail* AbstractMail::getWrapper(Account*a)
35{
36 if (!a) return 0;
37 switch (a->getType()) {
38 case MAILLIB::A_IMAP:
39 return new IMAPwrapper((IMAPaccount*)a);
40 break;
41 case MAILLIB::A_POP3:
42 return new POP3wrapper((POP3account*)a);
43 break;
44 case MAILLIB::A_NNTP:
45 return new NNTPwrapper((NNTPaccount*)a);
46 break;
47 default:
48 return 0;
49 }
50}
51
34encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 52encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
35{ 53{
36 qDebug("Decode string start"); 54 qDebug("Decode string start");
37 char*result_text; 55 char*result_text;
38 size_t index = 0; 56 size_t index = 0;
39 /* reset for recursive use! */ 57 /* reset for recursive use! */
40 size_t target_length = 0; 58 size_t target_length = 0;
41 result_text = 0; 59 result_text = 0;
42 int mimetype = MAILMIME_MECHANISM_7BIT; 60 int mimetype = MAILMIME_MECHANISM_7BIT;
43 if (enc.lower()=="quoted-printable") { 61 if (enc.lower()=="quoted-printable") {
44 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 62 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
45 } else if (enc.lower()=="base64") { 63 } else if (enc.lower()=="base64") {
46 mimetype = MAILMIME_MECHANISM_BASE64; 64 mimetype = MAILMIME_MECHANISM_BASE64;
47 } else if (enc.lower()=="8bit") { 65 } else if (enc.lower()=="8bit") {
48 mimetype = MAILMIME_MECHANISM_8BIT; 66 mimetype = MAILMIME_MECHANISM_8BIT;
49 } else if (enc.lower()=="binary") { 67 } else if (enc.lower()=="binary") {
50 mimetype = MAILMIME_MECHANISM_BINARY; 68 mimetype = MAILMIME_MECHANISM_BINARY;
51 } 69 }
52 70
53 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 71 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
54 &result_text,&target_length); 72 &result_text,&target_length);
55 73
56 encodedString* result = new encodedString(); 74 encodedString* result = new encodedString();
57 if (err == MAILIMF_NO_ERROR) { 75 if (err == MAILIMF_NO_ERROR) {
58 result->setContent(result_text,target_length); 76 result->setContent(result_text,target_length);
59 } 77 }
60 qDebug("Decode string finished"); 78 qDebug("Decode string finished");
61 return result; 79 return result;
62} 80}
63 81
64QString AbstractMail::convert_String(const char*text) 82QString AbstractMail::convert_String(const char*text)
65{ 83{
66 size_t index = 0; 84 size_t index = 0;
67 char*res = 0; 85 char*res = 0;
68 86
69 /* attention - doesn't work with arm systems! */ 87 /* attention - doesn't work with arm systems! */
70 int err = mailmime_encoded_phrase_parse("iso-8859-1", 88 int err = mailmime_encoded_phrase_parse("iso-8859-1",
71 text, strlen(text),&index, "iso-8859-1",&res); 89 text, strlen(text),&index, "iso-8859-1",&res);
72 if (err != MAILIMF_NO_ERROR) { 90 if (err != MAILIMF_NO_ERROR) {
73 if (res) free(res); 91 if (res) free(res);
74 return QString(text); 92 return QString(text);
75 } 93 }
76 if (res) { 94 if (res) {
77 QString result(res); 95 QString result(res);
78 free(res); 96 free(res);
79 return result; 97 return result;
80 } 98 }
81 return QString(text); 99 return QString(text);
82} 100}
83 101
84/* cp & paste from launcher */ 102/* cp & paste from launcher */
85QString AbstractMail::gen_attachment_id() 103QString AbstractMail::gen_attachment_id()
86{ 104{
87 QFile file( "/proc/sys/kernel/random/uuid" ); 105 QFile file( "/proc/sys/kernel/random/uuid" );
88 if (!file.open(IO_ReadOnly ) ) 106 if (!file.open(IO_ReadOnly ) )
89 return QString::null; 107 return QString::null;
90 108
91 QTextStream stream(&file); 109 QTextStream stream(&file);
92 110
93 return "{" + stream.read().stripWhiteSpace() + "}"; 111 return "{" + stream.read().stripWhiteSpace() + "}";
94} 112}
95 113
96int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) 114int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
97{ 115{
98 return 0; 116 return 0;
99} 117}
100 118
101QString AbstractMail::defaultLocalfolder() 119QString AbstractMail::defaultLocalfolder()
102{ 120{
103 QString f = getenv( "HOME" ); 121 QString f = getenv( "HOME" );
104 f += "/Applications/opiemail/localmail"; 122 f += "/Applications/opiemail/localmail";
105 return f; 123 return f;
106} 124}
107 125
126QString AbstractMail::draftFolder()
127{
128 return QString("Drafts");
129}
130
108/* temporary - will be removed when implemented in all classes */ 131/* temporary - will be removed when implemented in all classes */
109void AbstractMail::deleteMails(const QString &,QList<RecMail> &) 132void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
110{ 133{
111} 134}
112 135
113void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 136void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
114{ 137{
115 QList<RecMail> t; 138 QList<RecMail> t;
116 listMessages(fromFolder->getName(),t); 139 listMessages(fromFolder->getName(),t);
117 encodedString*st = 0; 140 encodedString*st = 0;
118 while (t.count()>0) { 141 while (t.count()>0) {
119 RecMail*r = t.at(0); 142 RecMail*r = t.at(0);
120 st = fetchRawBody(*r); 143 st = fetchRawBody(*r);
121 if (st) { 144 if (st) {
122 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 145 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
123 delete st; 146 delete st;
124 } 147 }
125 t.removeFirst(); 148 t.removeFirst();
126 } 149 }
127 if (moveit) { 150 if (moveit) {
128 deleteAllMail(fromFolder); 151 deleteAllMail(fromFolder);
129 } 152 }
130} 153}
131 154
132void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 155void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
133{ 156{
134 encodedString*st = 0; 157 encodedString*st = 0;
135 st = fetchRawBody(mail); 158 st = fetchRawBody(mail);
136 if (st) { 159 if (st) {
137 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 160 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
138 delete st; 161 delete st;
139 } 162 }
140 if (moveit) { 163 if (moveit) {
141 deleteMail(mail); 164 deleteMail(mail);
142 } 165 }
143} 166}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 442ebfe..d377452 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,68 +1,70 @@
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> 6#include <qobject.h>
7#include "settings.h" 7#include "settings.h"
8 8
9class RecMail; 9class RecMail;
10class RecBody; 10class RecBody;
11class RecPart; 11class RecPart;
12class IMAPwrapper; 12class IMAPwrapper;
13class POP3wrapper; 13class POP3wrapper;
14class Folder; 14class Folder;
15class encodedString; 15class encodedString;
16struct folderStat; 16struct folderStat;
17 17
18class AbstractMail:public QObject 18class AbstractMail:public QObject
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 AbstractMail(){}; 22 AbstractMail(){};
23 virtual ~AbstractMail(){} 23 virtual ~AbstractMail(){}
24 virtual QList<Folder>* listFolders()=0; 24 virtual QList<Folder>* listFolders()=0;
25 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 25 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
26 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; 26 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
27 virtual RecBody fetchBody(const RecMail&mail)=0; 27 virtual RecBody fetchBody(const RecMail&mail)=0;
28 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 28 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
29 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 29 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
30 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 30 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
31 virtual encodedString* fetchRawBody(const RecMail&mail)=0; 31 virtual encodedString* fetchRawBody(const RecMail&mail)=0;
32 32
33 virtual void deleteMail(const RecMail&mail)=0; 33 virtual void deleteMail(const RecMail&mail)=0;
34 virtual void answeredMail(const RecMail&mail)=0; 34 virtual void answeredMail(const RecMail&mail)=0;
35 virtual int deleteAllMail(const Folder*)=0; 35 virtual int deleteAllMail(const Folder*)=0;
36 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); 36 virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
37 virtual int deleteMbox(const Folder*)=0; 37 virtual int deleteMbox(const Folder*)=0;
38 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 38 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
39 39
40 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 40 virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
41 virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 41 virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
42 42
43 virtual void cleanMimeCache(){}; 43 virtual void cleanMimeCache(){};
44 /* mail box methods */ 44 /* mail box methods */
45 /* parameter is the box to create. 45 /* parameter is the box to create.
46 * if the implementing subclass has prefixes, 46 * if the implementing subclass has prefixes,
47 * them has to be appended automatic. 47 * them has to be appended automatic.
48 */ 48 */
49 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 49 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
50 virtual void logout()=0; 50 virtual void logout()=0;
51 51
52 static AbstractMail* getWrapper(IMAPaccount *a); 52 static AbstractMail* getWrapper(IMAPaccount *a);
53 static AbstractMail* getWrapper(POP3account *a); 53 static AbstractMail* getWrapper(POP3account *a);
54 static AbstractMail* getWrapper(NNTPaccount *a); 54 static AbstractMail* getWrapper(NNTPaccount *a);
55 /* mbox only! */ 55 /* mbox only! */
56 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); 56 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
57 static AbstractMail* getWrapper(Account*a);
57 58
58 static QString defaultLocalfolder(); 59 static QString defaultLocalfolder();
59 60 static QString draftFolder();
61
60 virtual MAILLIB::ATYPE getType()const=0; 62 virtual MAILLIB::ATYPE getType()const=0;
61 virtual const QString&getName()const=0; 63 virtual const QString&getName()const=0;
62 64
63protected: 65protected:
64 static encodedString*decode_String(const encodedString*text,const QString&enc); 66 static encodedString*decode_String(const encodedString*text,const QString&enc);
65 static QString convert_String(const char*text); 67 static QString convert_String(const char*text);
66 static QString gen_attachment_id(); 68 static QString gen_attachment_id();
67}; 69};
68#endif 70#endif
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 137a6ef..ffa049f 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -69,399 +69,407 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
69 } 69 }
70 } 70 }
71 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 71 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
72 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 72 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
73 field = (mailmime_field*)current->data; 73 field = (mailmime_field*)current->data;
74 switch(field->fld_type) { 74 switch(field->fld_type) {
75 case MAILMIME_FIELD_TRANSFER_ENCODING: 75 case MAILMIME_FIELD_TRANSFER_ENCODING:
76 target.setEncoding(getencoding(field->fld_data.fld_encoding)); 76 target.setEncoding(getencoding(field->fld_data.fld_encoding));
77 break; 77 break;
78 case MAILMIME_FIELD_ID: 78 case MAILMIME_FIELD_ID:
79 target.setIdentifier(field->fld_data.fld_id); 79 target.setIdentifier(field->fld_data.fld_id);
80 break; 80 break;
81 case MAILMIME_FIELD_DESCRIPTION: 81 case MAILMIME_FIELD_DESCRIPTION:
82 target.setDescription(field->fld_data.fld_description); 82 target.setDescription(field->fld_data.fld_description);
83 break; 83 break;
84 default: 84 default:
85 break; 85 break;
86 } 86 }
87 } 87 }
88 } 88 }
89} 89}
90 90
91void Genericwrapper::fillParameters(RecPart&target,clist*parameters) 91void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
92{ 92{
93 if (!parameters) {return;} 93 if (!parameters) {return;}
94 clistcell*current=0; 94 clistcell*current=0;
95 mailmime_parameter*param; 95 mailmime_parameter*param;
96 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 96 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
97 param = (mailmime_parameter*)current->data; 97 param = (mailmime_parameter*)current->data;
98 if (param) { 98 if (param) {
99 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 99 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
100 } 100 }
101 } 101 }
102} 102}
103 103
104QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 104QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
105{ 105{
106 QString enc="7bit"; 106 QString enc="7bit";
107 if (!aEnc) return enc; 107 if (!aEnc) return enc;
108 switch(aEnc->enc_type) { 108 switch(aEnc->enc_type) {
109 case MAILMIME_MECHANISM_7BIT: 109 case MAILMIME_MECHANISM_7BIT:
110 enc = "7bit"; 110 enc = "7bit";
111 break; 111 break;
112 case MAILMIME_MECHANISM_8BIT: 112 case MAILMIME_MECHANISM_8BIT:
113 enc = "8bit"; 113 enc = "8bit";
114 break; 114 break;
115 case MAILMIME_MECHANISM_BINARY: 115 case MAILMIME_MECHANISM_BINARY:
116 enc = "binary"; 116 enc = "binary";
117 break; 117 break;
118 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 118 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
119 enc = "quoted-printable"; 119 enc = "quoted-printable";
120 break; 120 break;
121 case MAILMIME_MECHANISM_BASE64: 121 case MAILMIME_MECHANISM_BASE64:
122 enc = "base64"; 122 enc = "base64";
123 break; 123 break;
124 case MAILMIME_MECHANISM_TOKEN: 124 case MAILMIME_MECHANISM_TOKEN:
125 default: 125 default:
126 if (aEnc->enc_token) { 126 if (aEnc->enc_token) {
127 enc = QString(aEnc->enc_token); 127 enc = QString(aEnc->enc_token);
128 } 128 }
129 break; 129 break;
130 } 130 }
131 return enc; 131 return enc;
132} 132}
133 133
134void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 134void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
135{ 135{
136 if (current_rec >= 10) { 136 if (current_rec >= 10) {
137 qDebug("too deep recursion!"); 137 qDebug("too deep recursion!");
138 } 138 }
139 if (!message || !mime) { 139 if (!message || !mime) {
140 return; 140 return;
141 } 141 }
142 int r; 142 int r;
143 char*data = 0; 143 char*data = 0;
144 size_t len; 144 size_t len;
145 clistiter * cur = 0; 145 clistiter * cur = 0;
146 QString b; 146 QString b;
147 RecPart part; 147 RecPart part;
148 148
149 switch (mime->mm_type) { 149 switch (mime->mm_type) {
150 case MAILMIME_SINGLE: 150 case MAILMIME_SINGLE:
151 { 151 {
152 QValueList<int>countlist = recList; 152 QValueList<int>countlist = recList;
153 countlist.append(current_count); 153 countlist.append(current_count);
154 r = mailmessage_fetch_section(message,mime,&data,&len); 154 r = mailmessage_fetch_section(message,mime,&data,&len);
155 part.setSize(len); 155 part.setSize(len);
156 part.setPositionlist(countlist); 156 part.setPositionlist(countlist);
157 b = gen_attachment_id(); 157 b = gen_attachment_id();
158 part.setIdentifier(b); 158 part.setIdentifier(b);
159 fillSingleBody(part,message,mime); 159 fillSingleBody(part,message,mime);
160 if (part.Type()=="text" && target.Bodytext().isNull()) { 160 if (part.Type()=="text" && target.Bodytext().isNull()) {
161 encodedString*r = new encodedString(); 161 encodedString*r = new encodedString();
162 r->setContent(data,len); 162 r->setContent(data,len);
163 encodedString*res = decode_String(r,part.Encoding()); 163 encodedString*res = decode_String(r,part.Encoding());
164 if (countlist.count()>2) { 164 if (countlist.count()>2) {
165 bodyCache[b]=r; 165 bodyCache[b]=r;
166 target.addPart(part); 166 target.addPart(part);
167 } else { 167 } else {
168 delete r; 168 delete r;
169 } 169 }
170 b = QString(res->Content()); 170 b = QString(res->Content());
171 delete res; 171 delete res;
172 target.setBodytext(b); 172 target.setBodytext(b);
173 target.setDescription(part); 173 target.setDescription(part);
174 } else { 174 } else {
175 bodyCache[b]=new encodedString(data,len); 175 bodyCache[b]=new encodedString(data,len);
176 target.addPart(part); 176 target.addPart(part);
177 } 177 }
178 } 178 }
179 break; 179 break;
180 case MAILMIME_MULTIPLE: 180 case MAILMIME_MULTIPLE:
181 { 181 {
182 unsigned int ccount = 1; 182 unsigned int ccount = 1;
183 mailmime*cbody=0; 183 mailmime*cbody=0;
184 QValueList<int>countlist = recList; 184 QValueList<int>countlist = recList;
185 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 185 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
186 cbody = (mailmime*)clist_content(cur); 186 cbody = (mailmime*)clist_content(cur);
187 if (cbody->mm_type==MAILMIME_MULTIPLE) { 187 if (cbody->mm_type==MAILMIME_MULTIPLE) {
188 RecPart targetPart; 188 RecPart targetPart;
189 targetPart.setType("multipart"); 189 targetPart.setType("multipart");
190 countlist.append(current_count); 190 countlist.append(current_count);
191 targetPart.setPositionlist(countlist); 191 targetPart.setPositionlist(countlist);
192 target.addPart(targetPart); 192 target.addPart(targetPart);
193 } 193 }
194 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 194 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
195 if (cbody->mm_type==MAILMIME_MULTIPLE) { 195 if (cbody->mm_type==MAILMIME_MULTIPLE) {
196 countlist = recList; 196 countlist = recList;
197 } 197 }
198 ++ccount; 198 ++ccount;
199 } 199 }
200 } 200 }
201 break; 201 break;
202 case MAILMIME_MESSAGE: 202 case MAILMIME_MESSAGE:
203 { 203 {
204 QValueList<int>countlist = recList; 204 QValueList<int>countlist = recList;
205 countlist.append(current_count); 205 countlist.append(current_count);
206 /* the own header is always at recursion 0 - we don't need that */ 206 /* the own header is always at recursion 0 - we don't need that */
207 if (current_rec > 0) { 207 if (current_rec > 0) {
208 part.setPositionlist(countlist); 208 part.setPositionlist(countlist);
209 r = mailmessage_fetch_section(message,mime,&data,&len); 209 r = mailmessage_fetch_section(message,mime,&data,&len);
210 part.setSize(len); 210 part.setSize(len);
211 part.setPositionlist(countlist); 211 part.setPositionlist(countlist);
212 b = gen_attachment_id(); 212 b = gen_attachment_id();
213 part.setIdentifier(b); 213 part.setIdentifier(b);
214 part.setType("message"); 214 part.setType("message");
215 part.setSubtype("rfc822"); 215 part.setSubtype("rfc822");
216 bodyCache[b]=new encodedString(data,len); 216 bodyCache[b]=new encodedString(data,len);
217 target.addPart(part); 217 target.addPart(part);
218 } 218 }
219 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 219 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
220 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 220 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
221 } 221 }
222 } 222 }
223 break; 223 break;
224 } 224 }
225} 225}
226 226
227RecBody Genericwrapper::parseMail( mailmessage * msg ) 227RecBody Genericwrapper::parseMail( mailmessage * msg )
228{ 228{
229 int err = MAILIMF_NO_ERROR; 229 int err = MAILIMF_NO_ERROR;
230 mailmime_single_fields fields; 230 mailmime_single_fields fields;
231 /* is bound to msg and will be freed there */ 231 /* is bound to msg and will be freed there */
232 mailmime * mime=0; 232 mailmime * mime=0;
233 RecBody body; 233 RecBody body;
234 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 234 memset(&fields, 0, sizeof(struct mailmime_single_fields));
235 err = mailmessage_get_bodystructure(msg,&mime); 235 err = mailmessage_get_bodystructure(msg,&mime);
236 QValueList<int>recList; 236 QValueList<int>recList;
237 traverseBody(body,msg,mime,recList); 237 traverseBody(body,msg,mime,recList);
238 return body; 238 return body;
239} 239}
240 240
241QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 241QString Genericwrapper::parseDateTime( mailimf_date_time *date )
242{ 242{
243 char tmp[23]; 243 char tmp[23];
244 244
245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
247 247
248 return QString( tmp ); 248 return QString( tmp );
249} 249}
250 250
251QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 251QString Genericwrapper::parseAddressList( mailimf_address_list *list )
252{ 252{
253 QString result( "" ); 253 QString result( "" );
254 254
255 bool first = true; 255 bool first = true;
256 if (list == 0) return result; 256 if (list == 0) return result;
257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
258 mailimf_address *addr = (mailimf_address *) current->data; 258 mailimf_address *addr = (mailimf_address *) current->data;
259 259
260 if ( !first ) { 260 if ( !first ) {
261 result.append( "," ); 261 result.append( "," );
262 } else { 262 } else {
263 first = false; 263 first = false;
264 } 264 }
265 265
266 switch ( addr->ad_type ) { 266 switch ( addr->ad_type ) {
267 case MAILIMF_ADDRESS_MAILBOX: 267 case MAILIMF_ADDRESS_MAILBOX:
268 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 268 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
269 break; 269 break;
270 case MAILIMF_ADDRESS_GROUP: 270 case MAILIMF_ADDRESS_GROUP:
271 result.append( parseGroup( addr->ad_data.ad_group ) ); 271 result.append( parseGroup( addr->ad_data.ad_group ) );
272 break; 272 break;
273 default: 273 default:
274 qDebug( "Generic: unkown mailimf address type" ); 274 qDebug( "Generic: unkown mailimf address type" );
275 break; 275 break;
276 } 276 }
277 } 277 }
278 278
279 return result; 279 return result;
280} 280}
281 281
282QString Genericwrapper::parseGroup( mailimf_group *group ) 282QString Genericwrapper::parseGroup( mailimf_group *group )
283{ 283{
284 QString result( "" ); 284 QString result( "" );
285 285
286 result.append( group->grp_display_name ); 286 result.append( group->grp_display_name );
287 result.append( ": " ); 287 result.append( ": " );
288 288
289 if ( group->grp_mb_list != NULL ) { 289 if ( group->grp_mb_list != NULL ) {
290 result.append( parseMailboxList( group->grp_mb_list ) ); 290 result.append( parseMailboxList( group->grp_mb_list ) );
291 } 291 }
292 292
293 result.append( ";" ); 293 result.append( ";" );
294 294
295 return result; 295 return result;
296} 296}
297 297
298QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 298QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
299{ 299{
300 QString result( "" ); 300 QString result( "" );
301 301
302 if ( box->mb_display_name == NULL ) { 302 if ( box->mb_display_name == NULL ) {
303 result.append( box->mb_addr_spec ); 303 result.append( box->mb_addr_spec );
304 } else { 304 } else {
305 result.append( convert_String(box->mb_display_name).latin1() ); 305 result.append( convert_String(box->mb_display_name).latin1() );
306 result.append( " <" ); 306 result.append( " <" );
307 result.append( box->mb_addr_spec ); 307 result.append( box->mb_addr_spec );
308 result.append( ">" ); 308 result.append( ">" );
309 } 309 }
310 310
311 return result; 311 return result;
312} 312}
313 313
314QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 314QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
315{ 315{
316 QString result( "" ); 316 QString result( "" );
317 317
318 bool first = true; 318 bool first = true;
319 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 319 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
320 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 320 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
321 321
322 if ( !first ) { 322 if ( !first ) {
323 result.append( "," ); 323 result.append( "," );
324 } else { 324 } else {
325 first = false; 325 first = false;
326 } 326 }
327 327
328 result.append( parseMailbox( box ) ); 328 result.append( parseMailbox( box ) );
329 } 329 }
330 330
331 return result; 331 return result;
332} 332}
333 333
334encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) 334encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part)
335{ 335{
336 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 336 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
337 if (it==bodyCache.end()) return new encodedString(); 337 if (it==bodyCache.end()) return new encodedString();
338 encodedString*t = decode_String(it.data(),part.Encoding()); 338 encodedString*t = decode_String(it.data(),part.Encoding());
339 return t; 339 return t;
340} 340}
341 341
342encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) 342encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
343{ 343{
344 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 344 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
345 if (it==bodyCache.end()) return new encodedString(); 345 if (it==bodyCache.end()) return new encodedString();
346 encodedString*t = it.data(); 346 encodedString*t = it.data();
347 return t; 347 return t;
348} 348}
349 349
350QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) 350QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
351{ 351{
352 encodedString*t = fetchDecodedPart(mail,part); 352 encodedString*t = fetchDecodedPart(mail,part);
353 QString text=t->Content(); 353 QString text=t->Content();
354 delete t; 354 delete t;
355 return text; 355 return text;
356} 356}
357 357
358void Genericwrapper::cleanMimeCache() 358void Genericwrapper::cleanMimeCache()
359{ 359{
360 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 360 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
361 for (;it!=bodyCache.end();++it) { 361 for (;it!=bodyCache.end();++it) {
362 encodedString*t = it.data(); 362 encodedString*t = it.data();
363 //it.setValue(0); 363 //it.setValue(0);
364 if (t) delete t; 364 if (t) delete t;
365 } 365 }
366 bodyCache.clear(); 366 bodyCache.clear();
367 qDebug("Genericwrapper: cache cleaned"); 367 qDebug("Genericwrapper: cache cleaned");
368} 368}
369 369
370QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 370QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
371{ 371{
372 QStringList res; 372 QStringList res;
373 if (!in_replies || !in_replies->mid_list) return res; 373 if (!in_replies || !in_replies->mid_list) return res;
374 clistiter * current = 0; 374 clistiter * current = 0;
375 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 375 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
376 QString h((char*)current->data); 376 QString h((char*)current->data);
377 while (h.length()>0 && h[0]=='<') { 377 while (h.length()>0 && h[0]=='<') {
378 h.remove(0,1); 378 h.remove(0,1);
379 } 379 }
380 while (h.length()>0 && h[h.length()-1]=='>') { 380 while (h.length()>0 && h[h.length()-1]=='>') {
381 h.remove(h.length()-1,1); 381 h.remove(h.length()-1,1);
382 } 382 }
383 if (h.length()>0) { 383 if (h.length()>0) {
384 res.append(h); 384 res.append(h);
385 } 385 }
386 } 386 }
387 return res; 387 return res;
388} 388}
389 389
390void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) 390void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
391{ 391{
392 int r; 392 int r;
393 mailmessage_list * env_list = 0; 393 mailmessage_list * env_list = 0;
394 r = mailsession_get_messages_list(session,&env_list); 394 r = mailsession_get_messages_list(session,&env_list);
395 if (r != MAIL_NO_ERROR) { 395 if (r != MAIL_NO_ERROR) {
396 qDebug("Error message list"); 396 qDebug("Error message list");
397 return; 397 return;
398 } 398 }
399 r = mailsession_get_envelopes_list(session, env_list); 399 r = mailsession_get_envelopes_list(session, env_list);
400 if (r != MAIL_NO_ERROR) { 400 if (r != MAIL_NO_ERROR) {
401 qDebug("Error filling message list"); 401 qDebug("Error filling message list");
402 if (env_list) { 402 if (env_list) {
403 mailmessage_list_free(env_list); 403 mailmessage_list_free(env_list);
404 } 404 }
405 return; 405 return;
406 } 406 }
407 mailimf_references * refs = 0; 407 mailimf_references * refs = 0;
408 mailimf_in_reply_to * in_replies = 0; 408 mailimf_in_reply_to * in_replies = 0;
409 uint32_t i = 0; 409 uint32_t i = 0;
410 for(; i < carray_count(env_list->msg_tab) ; ++i) { 410 for(; i < carray_count(env_list->msg_tab) ; ++i) {
411 mailmessage * msg; 411 mailmessage * msg;
412 QBitArray mFlags(7); 412 QBitArray mFlags(7);
413 msg = (mailmessage*)carray_get(env_list->msg_tab, i); 413 msg = (mailmessage*)carray_get(env_list->msg_tab, i);
414 if (msg->msg_fields == NULL) { 414 if (msg->msg_fields == NULL) {
415 //qDebug("could not fetch envelope of message %i", i); 415 //qDebug("could not fetch envelope of message %i", i);
416 continue; 416 continue;
417 } 417 }
418 RecMail * mail = new RecMail(); 418 RecMail * mail = new RecMail();
419 mail->setWrapper(this); 419 mail->setWrapper(this);
420 mail_flags * flag_result = 0; 420 mail_flags * flag_result = 0;
421 r = mailmessage_get_flags(msg,&flag_result); 421 r = mailmessage_get_flags(msg,&flag_result);
422 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 422 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
423 mFlags.setBit(FLAG_SEEN); 423 mFlags.setBit(FLAG_SEEN);
424 } 424 }
425 mailimf_single_fields single_fields; 425 mailimf_single_fields single_fields;
426 mailimf_single_fields_init(&single_fields, msg->msg_fields); 426 mailimf_single_fields_init(&single_fields, msg->msg_fields);
427 mail->setMsgsize(msg->msg_size); 427 mail->setMsgsize(msg->msg_size);
428 mail->setFlags(mFlags); 428 mail->setFlags(mFlags);
429 mail->setMbox(mailbox); 429 mail->setMbox(mailbox);
430 mail->setNumber(msg->msg_index); 430 mail->setNumber(msg->msg_index);
431 if (single_fields.fld_subject) 431 if (single_fields.fld_subject)
432 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); 432 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
433 if (single_fields.fld_from) 433 if (single_fields.fld_from)
434 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); 434 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
435 if (!mbox_as_to) { 435 if (!mbox_as_to) {
436 if (single_fields.fld_to) 436 if (single_fields.fld_to)
437 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); 437 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
438 } else { 438 } else {
439 mail->setTo(mailbox); 439 mail->setTo(mailbox);
440 } 440 }
441 if (single_fields.fld_cc) 441 if (single_fields.fld_cc)
442 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); 442 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
443 if (single_fields.fld_bcc) 443 if (single_fields.fld_bcc)
444 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); 444 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
445 if (single_fields.fld_orig_date) 445 if (single_fields.fld_orig_date)
446 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); 446 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
447 // crashes when accessing pop3 account? 447 // crashes when accessing pop3 account?
448 if (single_fields.fld_message_id->mid_value) { 448 if (single_fields.fld_message_id->mid_value) {
449 mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 449 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
450 qDebug("Msgid == %s",mail->Msgid().latin1()); 450 qDebug("Msgid == %s",mail->Msgid().latin1());
451 } 451 }
452 452
453 if (single_fields.fld_reply_to) {
454 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
455 if (t.count()>0) {
456 mail->setReplyto(t[0]);
457 }
458 }
459#if 0
453 refs = single_fields.fld_references; 460 refs = single_fields.fld_references;
454 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 461 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
455 char * text = (char*)refs->mid_list->first->data; 462 char * text = (char*)refs->mid_list->first->data;
456 mail->setReplyto(QString(text)); 463 mail->setReplyto(QString(text));
457 } 464 }
465#endif
458 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && 466 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
459 clist_count(single_fields.fld_in_reply_to->mid_list)) { 467 clist_count(single_fields.fld_in_reply_to->mid_list)) {
460 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); 468 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
461 } 469 }
462 target.append(mail); 470 target.append(mail);
463 } 471 }
464 if (env_list) { 472 if (env_list) {
465 mailmessage_list_free(env_list); 473 mailmessage_list_free(env_list);
466 } 474 }
467} 475}
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
index cb1e573..d28079e 100644
--- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro
+++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
@@ -1,52 +1,54 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3 3
4HEADERS = mailwrapper.h \ 4HEADERS = mailwrapper.h \
5 imapwrapper.h \ 5 imapwrapper.h \
6 mailtypes.h \ 6 mailtypes.h \
7 pop3wrapper.h \ 7 pop3wrapper.h \
8 abstractmail.h \ 8 abstractmail.h \
9 smtpwrapper.h \ 9 smtpwrapper.h \
10 genericwrapper.h \ 10 genericwrapper.h \
11 mboxwrapper.h \ 11 mboxwrapper.h \
12 settings.h \ 12 settings.h \
13 logindialog.h \ 13 logindialog.h \
14 sendmailprogress.h \ 14 sendmailprogress.h \
15 statusmail.h \ 15 statusmail.h \
16 mhwrapper.h \ 16 mhwrapper.h \
17 nntpwrapper.h \ 17 nntpwrapper.h \
18 generatemail.h 18 generatemail.h \
19 storemail.h
19 20
20SOURCES = imapwrapper.cpp \ 21SOURCES = imapwrapper.cpp \
21 mailwrapper.cpp \ 22 mailwrapper.cpp \
22 mailtypes.cpp \ 23 mailtypes.cpp \
23 pop3wrapper.cpp \ 24 pop3wrapper.cpp \
24 abstractmail.cpp \ 25 abstractmail.cpp \
25 smtpwrapper.cpp \ 26 smtpwrapper.cpp \
26 genericwrapper.cpp \ 27 genericwrapper.cpp \
27 mboxwrapper.cpp \ 28 mboxwrapper.cpp \
28 settings.cpp \ 29 settings.cpp \
29 logindialog.cpp \ 30 logindialog.cpp \
30 sendmailprogress.cpp \ 31 sendmailprogress.cpp \
31 statusmail.cpp \ 32 statusmail.cpp \
32 mhwrapper.cpp \ 33 mhwrapper.cpp \
33 nntpwrapper.cpp \ 34 nntpwrapper.cpp \
34 generatemail.cpp 35 generatemail.cpp \
36 storemail.cpp
35 37
36INTERFACES = logindialogui.ui \ 38INTERFACES = logindialogui.ui \
37 sendmailprogressui.ui 39 sendmailprogressui.ui
38 40
39 41
40INCLUDEPATH += $(OPIEDIR)/include 42INCLUDEPATH += $(OPIEDIR)/include
41 43
42CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 44CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
43contains( CONFTEST, y ){ 45contains( CONFTEST, y ){
44 LIBS += -lqpe -letpan -lssl -lcrypto -liconv 46 LIBS += -lqpe -letpan -lssl -lcrypto -liconv
45}else{ 47}else{
46 LIBS += -lqpe -letpan -lssl -lcrypto 48 LIBS += -lqpe -letpan -lssl -lcrypto
47} 49}
48 50
49DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 51DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
50TARGET = mailwrapper 52TARGET = mailwrapper
51 53
52include ( $(OPIEDIR)/include.pro ) 54include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index e4646d9..49b3caa 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,368 +1,369 @@
1#include "mailtypes.h" 1#include "mailtypes.h"
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4RecMail::RecMail() 4RecMail::RecMail()
5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) 5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
6{ 6{
7 init(); 7 init();
8} 8}
9 9
10RecMail::RecMail(const RecMail&old) 10RecMail::RecMail(const RecMail&old)
11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) 11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
12{ 12{
13 init(); 13 init();
14 copy_old(old); 14 copy_old(old);
15 qDebug("Copy constructor RecMail"); 15 qDebug("Copy constructor RecMail");
16} 16}
17 17
18RecMail::~RecMail() 18RecMail::~RecMail()
19{ 19{
20 wrapper = 0; 20 wrapper = 0;
21} 21}
22 22
23void RecMail::copy_old(const RecMail&old) 23void RecMail::copy_old(const RecMail&old)
24{ 24{
25 subject = old.subject; 25 subject = old.subject;
26 date = old.date; 26 date = old.date;
27 mbox = old.mbox; 27 mbox = old.mbox;
28 msg_id = old.msg_id; 28 msg_id = old.msg_id;
29 msg_size = old.msg_size; 29 msg_size = old.msg_size;
30 msg_number = old.msg_number; 30 msg_number = old.msg_number;
31 from = old.from; 31 from = old.from;
32 msg_flags = old.msg_flags; 32 msg_flags = old.msg_flags;
33 to = old.to; 33 to = old.to;
34 cc = old.cc; 34 cc = old.cc;
35 bcc = old.bcc; 35 bcc = old.bcc;
36 wrapper = old.wrapper; 36 wrapper = old.wrapper;
37 in_reply_to = old.in_reply_to; 37 in_reply_to = old.in_reply_to;
38 references = old.references; 38 references = old.references;
39 replyto = old.replyto;
39} 40}
40 41
41void RecMail::init() 42void RecMail::init()
42{ 43{
43 to.clear(); 44 to.clear();
44 cc.clear(); 45 cc.clear();
45 bcc.clear(); 46 bcc.clear();
46 in_reply_to.clear(); 47 in_reply_to.clear();
47 references.clear(); 48 references.clear();
48 wrapper = 0; 49 wrapper = 0;
49} 50}
50 51
51void RecMail::setWrapper(AbstractMail*awrapper) 52void RecMail::setWrapper(AbstractMail*awrapper)
52{ 53{
53 wrapper = awrapper; 54 wrapper = awrapper;
54} 55}
55 56
56AbstractMail* RecMail::Wrapper() 57AbstractMail* RecMail::Wrapper()
57{ 58{
58 return wrapper; 59 return wrapper;
59} 60}
60 61
61void RecMail::setTo(const QStringList&list) 62void RecMail::setTo(const QStringList&list)
62{ 63{
63 to = list; 64 to = list;
64} 65}
65 66
66const QStringList&RecMail::To()const 67const QStringList&RecMail::To()const
67{ 68{
68 return to; 69 return to;
69} 70}
70 71
71void RecMail::setCC(const QStringList&list) 72void RecMail::setCC(const QStringList&list)
72{ 73{
73 cc = list; 74 cc = list;
74} 75}
75 76
76const QStringList&RecMail::CC()const 77const QStringList&RecMail::CC()const
77{ 78{
78 return cc; 79 return cc;
79} 80}
80 81
81void RecMail::setBcc(const QStringList&list) 82void RecMail::setBcc(const QStringList&list)
82{ 83{
83 bcc = list; 84 bcc = list;
84} 85}
85 86
86const QStringList& RecMail::Bcc()const 87const QStringList& RecMail::Bcc()const
87{ 88{
88 return bcc; 89 return bcc;
89} 90}
90 91
91void RecMail::setInreply(const QStringList&list) 92void RecMail::setInreply(const QStringList&list)
92{ 93{
93 in_reply_to = list; 94 in_reply_to = list;
94} 95}
95 96
96const QStringList& RecMail::Inreply()const 97const QStringList& RecMail::Inreply()const
97{ 98{
98 return in_reply_to; 99 return in_reply_to;
99} 100}
100 101
101void RecMail::setReferences(const QStringList&list) 102void RecMail::setReferences(const QStringList&list)
102{ 103{
103 references = list; 104 references = list;
104} 105}
105 106
106const QStringList& RecMail::References()const 107const QStringList& RecMail::References()const
107{ 108{
108 return references; 109 return references;
109} 110}
110 111
111RecPart::RecPart() 112RecPart::RecPart()
112 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) 113 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
113{ 114{
114 m_Parameters.clear(); 115 m_Parameters.clear();
115 m_poslist.clear(); 116 m_poslist.clear();
116} 117}
117 118
118RecPart::~RecPart() 119RecPart::~RecPart()
119{ 120{
120} 121}
121 122
122void RecPart::setSize(unsigned int size) 123void RecPart::setSize(unsigned int size)
123{ 124{
124 m_size = size; 125 m_size = size;
125} 126}
126 127
127const unsigned int RecPart::Size()const 128const unsigned int RecPart::Size()const
128{ 129{
129 return m_size; 130 return m_size;
130} 131}
131 132
132void RecPart::setLines(unsigned int lines) 133void RecPart::setLines(unsigned int lines)
133{ 134{
134 m_lines = lines; 135 m_lines = lines;
135} 136}
136 137
137const unsigned int RecPart::Lines()const 138const unsigned int RecPart::Lines()const
138{ 139{
139 return m_lines; 140 return m_lines;
140} 141}
141 142
142const QString& RecPart::Type()const 143const QString& RecPart::Type()const
143{ 144{
144 return m_type; 145 return m_type;
145} 146}
146 147
147void RecPart::setType(const QString&type) 148void RecPart::setType(const QString&type)
148{ 149{
149 m_type = type; 150 m_type = type;
150} 151}
151 152
152const QString& RecPart::Subtype()const 153const QString& RecPart::Subtype()const
153{ 154{
154 return m_subtype; 155 return m_subtype;
155} 156}
156 157
157void RecPart::setSubtype(const QString&subtype) 158void RecPart::setSubtype(const QString&subtype)
158{ 159{
159 m_subtype = subtype; 160 m_subtype = subtype;
160} 161}
161 162
162const QString& RecPart::Identifier()const 163const QString& RecPart::Identifier()const
163{ 164{
164 return m_identifier; 165 return m_identifier;
165} 166}
166 167
167void RecPart::setIdentifier(const QString&identifier) 168void RecPart::setIdentifier(const QString&identifier)
168{ 169{
169 m_identifier = identifier; 170 m_identifier = identifier;
170} 171}
171 172
172const QString& RecPart::Encoding()const 173const QString& RecPart::Encoding()const
173{ 174{
174 return m_encoding; 175 return m_encoding;
175} 176}
176 177
177void RecPart::setEncoding(const QString&encoding) 178void RecPart::setEncoding(const QString&encoding)
178{ 179{
179 m_encoding = encoding; 180 m_encoding = encoding;
180} 181}
181 182
182const QString& RecPart::Description()const 183const QString& RecPart::Description()const
183{ 184{
184 return m_description; 185 return m_description;
185} 186}
186 187
187void RecPart::setDescription(const QString&desc) 188void RecPart::setDescription(const QString&desc)
188{ 189{
189 m_description = desc; 190 m_description = desc;
190} 191}
191 192
192void RecPart::setParameters(const part_plist_t&list) 193void RecPart::setParameters(const part_plist_t&list)
193{ 194{
194 m_Parameters = list; 195 m_Parameters = list;
195} 196}
196 197
197const part_plist_t& RecPart::Parameters()const 198const part_plist_t& RecPart::Parameters()const
198{ 199{
199 return m_Parameters; 200 return m_Parameters;
200} 201}
201 202
202void RecPart::addParameter(const QString&key,const QString&value) 203void RecPart::addParameter(const QString&key,const QString&value)
203{ 204{
204 m_Parameters[key]=value; 205 m_Parameters[key]=value;
205} 206}
206 207
207const QString RecPart::searchParamter(const QString&key)const 208const QString RecPart::searchParamter(const QString&key)const
208{ 209{
209 QString value(""); 210 QString value("");
210 part_plist_t::ConstIterator it = m_Parameters.find(key); 211 part_plist_t::ConstIterator it = m_Parameters.find(key);
211 if (it != m_Parameters.end()) { 212 if (it != m_Parameters.end()) {
212 value = it.data(); 213 value = it.data();
213 } 214 }
214 return value; 215 return value;
215} 216}
216 217
217void RecPart::setPositionlist(const QValueList<int>&poslist) 218void RecPart::setPositionlist(const QValueList<int>&poslist)
218{ 219{
219 m_poslist = poslist; 220 m_poslist = poslist;
220} 221}
221 222
222const QValueList<int>& RecPart::Positionlist()const 223const QValueList<int>& RecPart::Positionlist()const
223{ 224{
224 return m_poslist; 225 return m_poslist;
225} 226}
226 227
227RecBody::RecBody() 228RecBody::RecBody()
228 : m_BodyText(),m_PartsList(),m_description() 229 : m_BodyText(),m_PartsList(),m_description()
229{ 230{
230 m_PartsList.clear(); 231 m_PartsList.clear();
231} 232}
232 233
233RecBody::~RecBody() 234RecBody::~RecBody()
234{ 235{
235} 236}
236 237
237void RecBody::setBodytext(const QString&bodyText) 238void RecBody::setBodytext(const QString&bodyText)
238{ 239{
239 m_BodyText = bodyText; 240 m_BodyText = bodyText;
240} 241}
241 242
242const QString& RecBody::Bodytext()const 243const QString& RecBody::Bodytext()const
243{ 244{
244 return m_BodyText; 245 return m_BodyText;
245} 246}
246 247
247void RecBody::setParts(const QValueList<RecPart>&parts) 248void RecBody::setParts(const QValueList<RecPart>&parts)
248{ 249{
249 m_PartsList.clear(); 250 m_PartsList.clear();
250 m_PartsList = parts; 251 m_PartsList = parts;
251} 252}
252 253
253const QValueList<RecPart>& RecBody::Parts()const 254const QValueList<RecPart>& RecBody::Parts()const
254{ 255{
255 return m_PartsList; 256 return m_PartsList;
256} 257}
257 258
258void RecBody::addPart(const RecPart& part) 259void RecBody::addPart(const RecPart& part)
259{ 260{
260 m_PartsList.append(part); 261 m_PartsList.append(part);
261} 262}
262 263
263void RecBody::setDescription(const RecPart&des) 264void RecBody::setDescription(const RecPart&des)
264{ 265{
265 m_description = des; 266 m_description = des;
266} 267}
267 268
268const RecPart& RecBody::Description()const 269const RecPart& RecBody::Description()const
269{ 270{
270 return m_description; 271 return m_description;
271} 272}
272 273
273/* handling encoded content */ 274/* handling encoded content */
274encodedString::encodedString() 275encodedString::encodedString()
275{ 276{
276 init(); 277 init();
277} 278}
278 279
279encodedString::encodedString(const char*nContent,unsigned int nSize) 280encodedString::encodedString(const char*nContent,unsigned int nSize)
280{ 281{
281 init(); 282 init();
282 setContent(nContent,nSize); 283 setContent(nContent,nSize);
283} 284}
284 285
285encodedString::encodedString(char*nContent,unsigned int nSize) 286encodedString::encodedString(char*nContent,unsigned int nSize)
286{ 287{
287 init(); 288 init();
288 setContent(nContent,nSize); 289 setContent(nContent,nSize);
289} 290}
290 291
291encodedString::encodedString(const encodedString&old) 292encodedString::encodedString(const encodedString&old)
292{ 293{
293 init(); 294 init();
294 copy_old(old); 295 copy_old(old);
295 qDebug("encodedeString: copy constructor!"); 296 qDebug("encodedeString: copy constructor!");
296} 297}
297 298
298encodedString& encodedString::operator=(const encodedString&old) 299encodedString& encodedString::operator=(const encodedString&old)
299{ 300{
300 init(); 301 init();
301 copy_old(old); 302 copy_old(old);
302 qDebug("encodedString: assign operator!"); 303 qDebug("encodedString: assign operator!");
303 return *this; 304 return *this;
304} 305}
305 306
306encodedString::~encodedString() 307encodedString::~encodedString()
307{ 308{
308 clean(); 309 clean();
309} 310}
310 311
311void encodedString::init() 312void encodedString::init()
312{ 313{
313 content = 0; 314 content = 0;
314 size = 0; 315 size = 0;
315} 316}
316 317
317void encodedString::clean() 318void encodedString::clean()
318{ 319{
319 if (content) { 320 if (content) {
320 free(content); 321 free(content);
321 } 322 }
322 content = 0; 323 content = 0;
323 size = 0; 324 size = 0;
324} 325}
325 326
326void encodedString::copy_old(const encodedString&old) 327void encodedString::copy_old(const encodedString&old)
327{ 328{
328 clean(); 329 clean();
329 if (old.size>0 && old.content) { 330 if (old.size>0 && old.content) {
330 content = (char*)malloc(old.size*sizeof(char)); 331 content = (char*)malloc(old.size*sizeof(char));
331 memcpy(content,old.content,size); 332 memcpy(content,old.content,size);
332 size = old.size; 333 size = old.size;
333 } 334 }
334} 335}
335 336
336const char*encodedString::Content()const 337const char*encodedString::Content()const
337{ 338{
338 return content; 339 return content;
339} 340}
340 341
341const int encodedString::Length()const 342const int encodedString::Length()const
342{ 343{
343 return size; 344 return size;
344} 345}
345 346
346void encodedString::setContent(const char*nContent,int nSize) 347void encodedString::setContent(const char*nContent,int nSize)
347{ 348{
348 if (nSize>0 && nContent) { 349 if (nSize>0 && nContent) {
349 content = (char*)malloc(nSize*sizeof(char)); 350 content = (char*)malloc(nSize*sizeof(char));
350 memcpy(content,nContent,nSize); 351 memcpy(content,nContent,nSize);
351 size = nSize; 352 size = nSize;
352 } 353 }
353} 354}
354 355
355void encodedString::setContent(char*nContent,int nSize) 356void encodedString::setContent(char*nContent,int nSize)
356{ 357{
357 content = nContent; 358 content = nContent;
358 size = nSize; 359 size = nSize;
359} 360}
360 361
361folderStat&folderStat::operator=(const folderStat&old) 362folderStat&folderStat::operator=(const folderStat&old)
362{ 363{
363 message_count = old.message_count; 364 message_count = old.message_count;
364 message_unseen = old.message_unseen; 365 message_unseen = old.message_unseen;
365 message_recent = old.message_recent; 366 message_recent = old.message_recent;
366 return *this; 367 return *this;
367} 368}
368 369
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp
new file mode 100644
index 0000000..53101f8
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/storemail.cpp
@@ -0,0 +1,90 @@
1#include "storemail.h"
2#include "mailwrapper.h"
3#include "settings.h"
4#include "abstractmail.h"
5
6#include <libetpan/libetpan.h>
7
8#include <qstring.h>
9
10#include <stdlib.h>
11
12Storemail::Storemail(Account*aAccount,const QString&aFolder)
13 : Generatemail()
14{
15 wrapper = 0;
16 m_Account = aAccount;
17 m_tfolder = aFolder;
18 wrapper = AbstractMail::getWrapper(m_Account);
19 if (wrapper) {
20 wrapper->createMbox(m_tfolder);
21 }
22}
23
24Storemail::Storemail(const QString&dir,const QString&aFolder)
25 : Generatemail()
26{
27 wrapper = 0;
28 m_Account = 0;
29 m_tfolder = aFolder;
30 wrapper = AbstractMail::getWrapper(dir);
31 if (wrapper) {
32 wrapper->createMbox(m_tfolder);
33 }
34}
35
36Storemail::Storemail(const QString&aFolder)
37 : Generatemail()
38{
39 wrapper = 0;
40 m_Account = 0;
41 m_tfolder = aFolder;
42 wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder());
43 if (wrapper) {
44 wrapper->createMbox(m_tfolder);
45 }
46}
47
48Storemail::~Storemail()
49{
50}
51
52int Storemail::storeMail(const Mail&mail)
53{
54 if (!wrapper) return 0;
55 int ret = 1;
56
57 mailmime * mimeMail = 0;
58 mimeMail = createMimeMail(mail );
59 if ( mimeMail == NULL ) {
60 qDebug( "storeMail: error creating mime mail" );
61 return 0;
62 }
63 char *data;
64 size_t size;
65 data = 0;
66
67 mailmessage * msg = 0;
68 msg = mime_message_init(mimeMail);
69 mime_message_set_tmpdir(msg,getenv( "HOME" ));
70 int r = mailmessage_fetch(msg,&data,&size);
71 mime_message_detach_mime(msg);
72 mailmessage_free(msg);
73 msg = 0;
74 if (r != MAIL_NO_ERROR || !data) {
75 qDebug("Error fetching mime...");
76 ret = 0;
77 }
78
79 if (ret) {
80 wrapper->storeMessage(data,size,m_tfolder);
81 }
82
83 if (data) {
84 free(data);
85 }
86 if (mimeMail) {
87 mailmime_free( mimeMail );
88 }
89 return ret;
90}
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h
new file mode 100644
index 0000000..872c981
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/storemail.h
@@ -0,0 +1,29 @@
1#ifndef __STORE_MAIL_H
2#define __STORE_MAIL_H
3
4#include <qpe/applnk.h>
5
6#include "generatemail.h"
7
8class Account;
9class Mail;
10class AbstractMail;
11
12class Storemail : public Generatemail
13{
14 Q_OBJECT
15public:
16 Storemail(Account*aAccount,const QString&aFolder);
17 Storemail(const QString&dir,const QString&aFolder);
18 Storemail(const QString&aFolder);
19 virtual ~Storemail();
20
21 int storeMail(const Mail&mail);
22
23protected:
24 Account* m_Account;
25 QString m_tfolder;
26 AbstractMail*wrapper;
27};
28
29#endif
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp
index f224dc3..75633ef 100644
--- a/noncore/net/mail/mailistviewitem.cpp
+++ b/noncore/net/mail/mailistviewitem.cpp
@@ -1,65 +1,72 @@
1#include "mailistviewitem.h" 1#include "mailistviewitem.h"
2#include <libmailwrapper/abstractmail.h>
2#include <qtextstream.h> 3#include <qtextstream.h>
3#include <qpe/resource.h> 4#include <qpe/resource.h>
4 5
5MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 6MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
6 :QListViewItem(parent,item),mail_data() 7 :QListViewItem(parent,item),mail_data()
7{ 8{
8} 9}
9 10
10void MailListViewItem::showEntry() 11void MailListViewItem::showEntry()
11{ 12{
12 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { 13 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
13 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); 14 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
14 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 15 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
15 /* I think it looks nicer if there are not such a log of icons but only on mails 16 /* I think it looks nicer if there are not such a log of icons but only on mails
16 replied or new - Alwin*/ 17 replied or new - Alwin*/
17 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); 18 //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
18 } else { 19 } else {
19 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); 20 setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
20 } 21 }
21 double s = mail_data.Msgsize(); 22 double s = mail_data.Msgsize();
22 int w; 23 int w;
23 w=0; 24 w=0;
24 25
25 while (s>1024) { 26 while (s>1024) {
26 s/=1024; 27 s/=1024;
27 ++w; 28 ++w;
28 if (w>=2) break; 29 if (w>=2) break;
29 } 30 }
30 31
31 QString q=""; 32 QString q="";
32 QString fsize=""; 33 QString fsize="";
33 switch(w) { 34 switch(w) {
34 case 1: 35 case 1:
35 q="k"; 36 q="k";
36 break; 37 break;
37 case 2: 38 case 2:
38 q="M"; 39 q="M";
39 break; 40 break;
40 default: 41 default:
41 break; 42 break;
42 } 43 }
43 44
44 { 45 {
45 QTextOStream o(&fsize); 46 QTextOStream o(&fsize);
46 if (w>0) o.precision(2); else o.precision(0); 47 if (w>0) o.precision(2); else o.precision(0);
47 o.setf(QTextStream::fixed); 48 o.setf(QTextStream::fixed);
48 o << s << " " << q << "Byte"; 49 o << s << " " << q << "Byte";
49 } 50 }
50 51
51 setText(1,mail_data.getSubject()); 52 setText(1,mail_data.getSubject());
52 setText(2,mail_data.getFrom()); 53 setText(2,mail_data.getFrom());
53 setText(3,fsize); 54 setText(3,fsize);
54 setText(4,mail_data.getDate()); 55 setText(4,mail_data.getDate());
55} 56}
56 57
57void MailListViewItem::storeData(const RecMail&data) 58void MailListViewItem::storeData(const RecMail&data)
58{ 59{
59 mail_data = data; 60 mail_data = data;
60} 61}
61 62
62const RecMail& MailListViewItem::data()const 63const RecMail& MailListViewItem::data()const
63{ 64{
64 return mail_data; 65 return mail_data;
65} 66}
67
68MAILLIB::ATYPE MailListViewItem::wrapperType()
69{
70 if (!mail_data.Wrapper()) return MAILLIB::A_UNDEFINED;
71 return mail_data.Wrapper()->getType();
72}
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index 3b352a2..f736de0 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -1,21 +1,23 @@
1#ifndef __MAILLISTVIEWITEM_H 1#ifndef __MAILLISTVIEWITEM_H
2#define __MAILLISTVIEWITEM_H 2#define __MAILLISTVIEWITEM_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <libmailwrapper/mailtypes.h> 5#include <libmailwrapper/mailtypes.h>
6#include <libmailwrapper/maildefines.h>
6 7
7class MailListViewItem:public QListViewItem 8class MailListViewItem:public QListViewItem
8{ 9{
9public: 10public:
10 MailListViewItem(QListView * parent, MailListViewItem * after ); 11 MailListViewItem(QListView * parent, MailListViewItem * after );
11 virtual ~MailListViewItem(){} 12 virtual ~MailListViewItem(){}
12 13
13 void storeData(const RecMail&data); 14 void storeData(const RecMail&data);
14 const RecMail&data()const; 15 const RecMail&data()const;
15 void showEntry(); 16 void showEntry();
16 17 MAILLIB::ATYPE wrapperType();
18
17protected: 19protected:
18 RecMail mail_data; 20 RecMail mail_data;
19}; 21};
20 22
21#endif 23#endif
diff --git a/noncore/net/mail/nntpgroupsdlg.cpp b/noncore/net/mail/nntpgroupsdlg.cpp
index 752ce3c..c94d9fa 100644
--- a/noncore/net/mail/nntpgroupsdlg.cpp
+++ b/noncore/net/mail/nntpgroupsdlg.cpp
@@ -1,29 +1,29 @@
1#include "nntpgroupsdlg.h" 1#include "nntpgroupsdlg.h"
2#include "nntpgroups.h" 2#include "nntpgroups.h"
3 3
4#include <libmailwrapper/settings.h> 4#include <libmailwrapper/settings.h>
5 5
6#include <qlayout.h> 6#include <qlayout.h>
7 7
8NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name) 8NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name)
9 : QDialog(parent,name,true) 9 : QDialog(parent,name,true,WStyle_ContextHelp)
10{ 10{
11 setCaption(tr("Subscribed newsgroups")); 11 setCaption(tr("Subscribed newsgroups"));
12 m_Account = account; 12 m_Account = account;
13 QVBoxLayout*dlglayout = new QVBoxLayout(this); 13 QVBoxLayout*dlglayout = new QVBoxLayout(this);
14 dlglayout->setSpacing(2); 14 dlglayout->setSpacing(2);
15 dlglayout->setMargin(1); 15 dlglayout->setMargin(1);
16 groupsWidget = new NNTPGroups(account,this); 16 groupsWidget = new NNTPGroups(account,this);
17 dlglayout->addWidget(groupsWidget); 17 dlglayout->addWidget(groupsWidget);
18} 18}
19 19
20NNTPGroupsDlg::~NNTPGroupsDlg() 20NNTPGroupsDlg::~NNTPGroupsDlg()
21{ 21{
22} 22}
23 23
24void NNTPGroupsDlg::accept() 24void NNTPGroupsDlg::accept()
25{ 25{
26 groupsWidget->storeValues(); 26 groupsWidget->storeValues();
27 m_Account->save(); 27 m_Account->save();
28 QDialog::accept(); 28 QDialog::accept();
29} 29}
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 61e7dc4..d95b3c9 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,261 +1,278 @@
1 1
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include "mailistviewitem.h" 6#include "mailistviewitem.h"
7#include "viewmail.h" 7#include "viewmail.h"
8#include "selectstore.h" 8#include "selectstore.h"
9#include "selectsmtp.h" 9#include "selectsmtp.h"
10 10
11/* OPIE */ 11/* OPIE */
12#include <libmailwrapper/smtpwrapper.h> 12#include <libmailwrapper/smtpwrapper.h>
13#include <libmailwrapper/mailtypes.h> 13#include <libmailwrapper/mailtypes.h>
14#include <libmailwrapper/abstractmail.h> 14#include <libmailwrapper/abstractmail.h>
15#include <qpe/resource.h> 15#include <qpe/resource.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17 17
18/* QT */ 18/* QT */
19 19
20OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 20OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
21 : MainWindow( parent, name, WStyle_ContextHelp ) 21 : MainWindow( parent, name, WStyle_ContextHelp )
22{ 22{
23 settings = new Settings(); 23 settings = new Settings();
24 24
25 folderView->populate( settings->getAccounts() ); 25 folderView->populate( settings->getAccounts() );
26} 26}
27 27
28OpieMail::~OpieMail() 28OpieMail::~OpieMail()
29{ 29{
30 if (settings) delete settings; 30 if (settings) delete settings;
31} 31}
32 32
33void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 33void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
34{ 34{
35 // copied from old mail2 35 // copied from old mail2
36 if (msg == "writeMail(QString,QString)") 36 if (msg == "writeMail(QString,QString)")
37 { 37 {
38 QDataStream stream(data,IO_ReadOnly); 38 QDataStream stream(data,IO_ReadOnly);
39 QString name, email; 39 QString name, email;
40 stream >> name >> email; 40 stream >> name >> email;
41 // removing the whitespaces at beginning and end is needed! 41 // removing the whitespaces at beginning and end is needed!
42 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 42 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
43 } 43 }
44 else if (msg == "newMail()") 44 else if (msg == "newMail()")
45 { 45 {
46 slotComposeMail(); 46 slotComposeMail();
47 } 47 }
48} 48}
49 49
50void OpieMail::slotwriteMail(const QString&name,const QString&email) 50void OpieMail::slotwriteMail(const QString&name,const QString&email)
51{ 51{
52 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 52 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
53 if (!email.isEmpty()) 53 if (!email.isEmpty())
54 { 54 {
55 if (!name.isEmpty()) 55 if (!name.isEmpty())
56 { 56 {
57 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 57 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
58 } 58 }
59 else 59 else
60 { 60 {
61 compose.setTo(email); 61 compose.setTo(email);
62 } 62 }
63 } 63 }
64 compose.slotAdjustColumns(); 64 compose.slotAdjustColumns();
65 QPEApplication::execDialog( &compose ); 65 QPEApplication::execDialog( &compose );
66} 66}
67 67
68void OpieMail::slotComposeMail() 68void OpieMail::slotComposeMail()
69{ 69{
70 qDebug( "Compose Mail" ); 70 qDebug( "Compose Mail" );
71 slotwriteMail(0l,0l); 71 slotwriteMail(0l,0l);
72} 72}
73 73
74void OpieMail::slotSendQueued() 74void OpieMail::slotSendQueued()
75{ 75{
76 qDebug( "Send Queued" ); 76 qDebug( "Send Queued" );
77 SMTPaccount *smtp = 0; 77 SMTPaccount *smtp = 0;
78 78
79 QList<Account> list = settings->getAccounts(); 79 QList<Account> list = settings->getAccounts();
80 QList<SMTPaccount> smtpList; 80 QList<SMTPaccount> smtpList;
81 smtpList.setAutoDelete(false); 81 smtpList.setAutoDelete(false);
82 Account *it; 82 Account *it;
83 for ( it = list.first(); it; it = list.next() ) 83 for ( it = list.first(); it; it = list.next() )
84 { 84 {
85 if ( it->getType() == MAILLIB::A_SMTP ) 85 if ( it->getType() == MAILLIB::A_SMTP )
86 { 86 {
87 smtp = static_cast<SMTPaccount *>(it); 87 smtp = static_cast<SMTPaccount *>(it);
88 smtpList.append(smtp); 88 smtpList.append(smtp);
89 } 89 }
90 } 90 }
91 if (smtpList.count()==0) 91 if (smtpList.count()==0)
92 { 92 {
93 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 93 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
94 return; 94 return;
95 } 95 }
96 if (smtpList.count()==1) 96 if (smtpList.count()==1)
97 { 97 {
98 smtp = smtpList.at(0); 98 smtp = smtpList.at(0);
99 } 99 }
100 else 100 else
101 { 101 {
102 smtp = 0; 102 smtp = 0;
103 selectsmtp selsmtp; 103 selectsmtp selsmtp;
104 selsmtp.setSelectionlist(&smtpList); 104 selsmtp.setSelectionlist(&smtpList);
105 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) 105 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
106 { 106 {
107 smtp = selsmtp.selected_smtp(); 107 smtp = selsmtp.selected_smtp();
108 } 108 }
109 } 109 }
110 if (smtp) 110 if (smtp)
111 { 111 {
112 SMTPwrapper * wrap = new SMTPwrapper(smtp); 112 SMTPwrapper * wrap = new SMTPwrapper(smtp);
113 if ( wrap->flushOutbox() ) 113 if ( wrap->flushOutbox() )
114 { 114 {
115 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 115 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
116 } 116 }
117 delete wrap; 117 delete wrap;
118 } 118 }
119} 119}
120 120
121void OpieMail::slotSearchMails() 121void OpieMail::slotSearchMails()
122{ 122{
123 qDebug( "Search Mails" ); 123 qDebug( "Search Mails" );
124} 124}
125 125
126void OpieMail::slotEditSettings() 126void OpieMail::slotEditSettings()
127{ 127{
128 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 128 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
129 QPEApplication::execDialog( &settingsDialog ); 129 QPEApplication::execDialog( &settingsDialog );
130} 130}
131 131
132void OpieMail::slotEditAccounts() 132void OpieMail::slotEditAccounts()
133{ 133{
134 qDebug( "Edit Accounts" ); 134 qDebug( "Edit Accounts" );
135 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 135 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
136 eaDialog.slotAdjustColumns(); 136 eaDialog.slotAdjustColumns();
137 QPEApplication::execDialog( &eaDialog ); 137 QPEApplication::execDialog( &eaDialog );
138 if ( settings ) delete settings; 138 if ( settings ) delete settings;
139 settings = new Settings(); 139 settings = new Settings();
140 140
141 folderView->populate( settings->getAccounts() ); 141 folderView->populate( settings->getAccounts() );
142} 142}
143 143
144void OpieMail::displayMail() 144void OpieMail::displayMail()
145{ 145{
146 QListViewItem*item = mailView->currentItem(); 146 QListViewItem*item = mailView->currentItem();
147 if (!item) return; 147 if (!item) return;
148 RecMail mail = ((MailListViewItem*)item)->data(); 148 RecMail mail = ((MailListViewItem*)item)->data();
149 RecBody body = folderView->fetchBody(mail); 149 RecBody body = folderView->fetchBody(mail);
150 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 150 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
151 readMail.setBody( body ); 151 readMail.setBody( body );
152 readMail.setMail( mail ); 152 readMail.setMail( mail );
153 readMail.showMaximized(); 153 readMail.showMaximized();
154 readMail.exec(); 154 readMail.exec();
155 155
156 if ( readMail.deleted ) 156 if ( readMail.deleted )
157 { 157 {
158 folderView->refreshCurrent(); 158 folderView->refreshCurrent();
159 } 159 }
160 else 160 else
161 { 161 {
162 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 162 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
163 } 163 }
164} 164}
165 165
166void OpieMail::slotDeleteMail() 166void OpieMail::slotDeleteMail()
167{ 167{
168 if (!mailView->currentItem()) return; 168 if (!mailView->currentItem()) return;
169 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 169 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
170 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 170 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
171 { 171 {
172 mail.Wrapper()->deleteMail( mail ); 172 mail.Wrapper()->deleteMail( mail );
173 folderView->refreshCurrent(); 173 folderView->refreshCurrent();
174 } 174 }
175} 175}
176 176
177void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 177void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
178{ 178{
179 if (!mailView->currentItem()) return; 179 if (!mailView->currentItem()) return;
180 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 180 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
181 /* just the RIGHT button - or hold on pda */ 181 /* just the RIGHT button - or hold on pda */
182 if (button!=2) {return;} 182 if (button!=2) {return;}
183 qDebug("Event right/hold"); 183 qDebug("Event right/hold");
184 if (!item) return; 184 if (!item) return;
185 QPopupMenu *m = new QPopupMenu(0); 185 QPopupMenu *m = new QPopupMenu(0);
186 if (m) 186 if (m)
187 { 187 {
188 if (mail.Wrapper()->getType()==MAILLIB::A_NNTP) { 188 if (mailtype==MAILLIB::A_NNTP) {
189 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 189 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
190// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 190// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
191 } else { 191 } else {
192 if (folderView->currentisDraft()) {
193 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
194 }
192 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 195 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
193 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 196 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
194 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 197 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
195 } 198 }
196 m->setFocus(); 199 m->setFocus();
197 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 200 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
198 delete m; 201 delete m;
199 } 202 }
200} 203}
201 204
202void OpieMail::slotShowFolders( bool show ) 205void OpieMail::slotShowFolders( bool show )
203{ 206{
204 qDebug( "Show Folders" ); 207 qDebug( "Show Folders" );
205 if ( show && folderView->isHidden() ) 208 if ( show && folderView->isHidden() )
206 { 209 {
207 qDebug( "-> showing" ); 210 qDebug( "-> showing" );
208 folderView->show(); 211 folderView->show();
209 } 212 }
210 else if ( !show && !folderView->isHidden() ) 213 else if ( !show && !folderView->isHidden() )
211 { 214 {
212 qDebug( "-> hiding" ); 215 qDebug( "-> hiding" );
213 folderView->hide(); 216 folderView->hide();
214 } 217 }
215} 218}
216 219
217void OpieMail::refreshMailView(QList<RecMail>*list) 220void OpieMail::refreshMailView(QList<RecMail>*list)
218{ 221{
219 MailListViewItem*item = 0; 222 MailListViewItem*item = 0;
220 mailView->clear(); 223 mailView->clear();
221 for (unsigned int i = 0; i < list->count();++i) 224 for (unsigned int i = 0; i < list->count();++i)
222 { 225 {
223 item = new MailListViewItem(mailView,item); 226 item = new MailListViewItem(mailView,item);
224 item->storeData(*(list->at(i))); 227 item->storeData(*(list->at(i)));
225 item->showEntry(); 228 item->showEntry();
226 } 229 }
227} 230}
228 231
229void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 232void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
230{ 233{
231 /* just LEFT button - or tap with stylus on pda */ 234 /* just LEFT button - or tap with stylus on pda */
232 if (button!=1) return; 235 if (button!=1) return;
233 if (!item) return; 236 if (!item) return;
234 displayMail(); 237 if (folderView->currentisDraft()) {
238 reEditMail();
239 } else {
240 displayMail();
241 }
235} 242}
236 243
237void OpieMail::slotMoveCopyMail() 244void OpieMail::slotMoveCopyMail()
238{ 245{
239 if (!mailView->currentItem()) return; 246 if (!mailView->currentItem()) return;
240 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 247 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
241 AbstractMail*targetMail = 0; 248 AbstractMail*targetMail = 0;
242 QString targetFolder = ""; 249 QString targetFolder = "";
243 Selectstore sels; 250 Selectstore sels;
244 folderView->setupFolderselect(&sels); 251 folderView->setupFolderselect(&sels);
245 if (!sels.exec()) return; 252 if (!sels.exec()) return;
246 targetMail = sels.currentMail(); 253 targetMail = sels.currentMail();
247 targetFolder = sels.currentFolder(); 254 targetFolder = sels.currentFolder();
248 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || 255 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
249 targetFolder.isEmpty()) 256 targetFolder.isEmpty())
250 { 257 {
251 return; 258 return;
252 } 259 }
253 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 260 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
254 { 261 {
255 QMessageBox::critical(0,tr("Error creating new Folder"), 262 QMessageBox::critical(0,tr("Error creating new Folder"),
256 tr("<center>Error while creating<br>new folder - breaking.</center>")); 263 tr("<center>Error while creating<br>new folder - breaking.</center>"));
257 return; 264 return;
258 } 265 }
259 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 266 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
260 folderView->refreshCurrent(); 267 folderView->refreshCurrent();
261} 268}
269
270void OpieMail::reEditMail()
271{
272 if (!mailView->currentItem()) return;
273
274 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
275 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
276 compose.slotAdjustColumns();
277 QPEApplication::execDialog( &compose );
278}
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 5821856..88c7ea1 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,39 +1,40 @@
1#ifndef OPIEMAIL_H 1#ifndef OPIEMAIL_H
2#define OPIEMAIL_H 2#define OPIEMAIL_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6 6
7 7
8class OpieMail : public MainWindow 8class OpieMail : public MainWindow
9{ 9{
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 13 OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
14 virtual ~OpieMail(); 14 virtual ~OpieMail();
15 static QString appName() { return QString::fromLatin1("opiemail"); } 15 static QString appName() { return QString::fromLatin1("opiemail"); }
16 16
17public slots: 17public slots:
18 virtual void slotwriteMail(const QString&name,const QString&email); 18 virtual void slotwriteMail(const QString&name,const QString&email);
19 virtual void slotComposeMail(); 19 virtual void slotComposeMail();
20 virtual void appMessage(const QCString &msg, const QByteArray &data); 20 virtual void appMessage(const QCString &msg, const QByteArray &data);
21protected slots: 21protected slots:
22 virtual void slotSendQueued(); 22 virtual void slotSendQueued();
23 virtual void slotSearchMails(); 23 virtual void slotSearchMails();
24 virtual void slotEditSettings(); 24 virtual void slotEditSettings();
25 virtual void slotEditAccounts(); 25 virtual void slotEditAccounts();
26 virtual void displayMail(); 26 virtual void displayMail();
27 virtual void slotDeleteMail(); 27 virtual void slotDeleteMail();
28 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 28 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
29 virtual void slotShowFolders( bool show ); 29 virtual void slotShowFolders( bool show );
30 virtual void refreshMailView(QList<RecMail>*); 30 virtual void refreshMailView(QList<RecMail>*);
31 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 31 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
32 virtual void slotMoveCopyMail(); 32 virtual void slotMoveCopyMail();
33 virtual void reEditMail();
33 34
34private: 35private:
35 Settings *settings; 36 Settings *settings;
36 37
37}; 38};
38 39
39#endif 40#endif