summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp10
-rw-r--r--libkdepim/libkdepim.pro2
-rw-r--r--microkde/kdecore/kstandarddirs.cpp27
3 files changed, 27 insertions, 12 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f4ac0d6..7bf33d3 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -616,519 +616,519 @@ void MainWindow::initActions()
616 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 616 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
617 this ); 617 this );
618 action->addTo( importMenu ); 618 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 619 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
620 action = new QAction( "import_quick", i18n("Import last file"), 0, 620 action = new QAction( "import_quick", i18n("Import last file"), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 623 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
624 importMenu->insertSeparator(); 624 importMenu->insertSeparator();
625 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 625 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 628 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
629#ifndef DESKTOP_VERSION 629#ifndef DESKTOP_VERSION
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 631 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
632 this ); 632 this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 634 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
635#else 635#else
636#ifdef _WIN32_ 636#ifdef _WIN32_
637 importMenu->insertSeparator(); 637 importMenu->insertSeparator();
638 action = new QAction( "import_ol", i18n("Import from OL"), 0, 638 action = new QAction( "import_ol", i18n("Import from OL"), 0,
639 this ); 639 this );
640 action->addTo( importMenu ); 640 action->addTo( importMenu );
641 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 641 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
642#endif 642#endif
643#endif 643#endif
644 644
645 importMenu->insertSeparator(); 645 importMenu->insertSeparator();
646 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 646 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
647 this ); 647 this );
648 action->addTo( importMenu ); 648 action->addTo( importMenu );
649 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 649 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
650 650
651 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 651 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
652 this ); 652 this );
653 action->addTo( importMenu ); 653 action->addTo( importMenu );
654 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 654 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
655 655
656 importMenu->insertSeparator(); 656 importMenu->insertSeparator();
657 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 657 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
658 this ); 658 this );
659 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 659 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
660 importMenu->insertSeparator(); 660 importMenu->insertSeparator();
661 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 661 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
662 this ); 662 this );
663 action->addTo( importMenu ); 663 action->addTo( importMenu );
664 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 664 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 importMenu->insertSeparator(); 666 importMenu->insertSeparator();
667 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 667 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
668 this ); 668 this );
669 action->addTo( importMenu ); 669 action->addTo( importMenu );
670 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 670 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
671 671
672 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 672 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
673 this ); 673 this );
674 action->addTo( importMenu ); 674 action->addTo( importMenu );
675 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 675 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
676#else 676#else
677 importMenu->insertSeparator(); 677 importMenu->insertSeparator();
678 icon = loadPixmap( pathString + "print" ); 678 icon = loadPixmap( pathString + "print" );
679 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 679 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
680 action->addTo( importMenu ); 680 action->addTo( importMenu );
681 connect( action, SIGNAL( activated() ), 681 connect( action, SIGNAL( activated() ),
682 this, SLOT( printCal() ) ); 682 this, SLOT( printCal() ) );
683 683
684 icon = loadPixmap( pathString + "print" ); 684 icon = loadPixmap( pathString + "print" );
685 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 685 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
686 action->addTo( importMenu ); 686 action->addTo( importMenu );
687 connect( action, SIGNAL( activated() ), 687 connect( action, SIGNAL( activated() ),
688 this, SLOT( printSel() ) ); 688 this, SLOT( printSel() ) );
689#endif 689#endif
690 importMenu->insertSeparator(); 690 importMenu->insertSeparator();
691 action = new QAction( "beam all", i18n("Save"), 0, 691 action = new QAction( "beam all", i18n("Save"), 0,
692 this ); 692 this );
693 action->addTo( importMenu ); 693 action->addTo( importMenu );
694 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 694 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
695 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 695 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
696 this ); 696 this );
697 action->addTo( importMenu ); 697 action->addTo( importMenu );
698 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 698 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
699 699
700 //menuBar->insertItem( "Configure",configureMenu ); 700 //menuBar->insertItem( "Configure",configureMenu );
701 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 701 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
702 icon = loadPixmap( "korganizer/korganizer" ); 702 icon = loadPixmap( "korganizer/korganizer" );
703 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 703 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
704 action->addTo( helpMenu ); 704 action->addTo( helpMenu );
705 connect( action, SIGNAL( activated() ), 705 connect( action, SIGNAL( activated() ),
706 SLOT( keyBindings() ) ); 706 SLOT( keyBindings() ) );
707 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 707 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
708 action->addTo( helpMenu ); 708 action->addTo( helpMenu );
709 connect( action, SIGNAL( activated() ), 709 connect( action, SIGNAL( activated() ),
710 SLOT( features() ) ); 710 SLOT( features() ) );
711 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 711 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
712 action->addTo( helpMenu ); 712 action->addTo( helpMenu );
713 connect( action, SIGNAL( activated() ), 713 connect( action, SIGNAL( activated() ),
714 SLOT( aboutAutoSaving() ) ); 714 SLOT( aboutAutoSaving() ) );
715 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 715 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
716 action->addTo( helpMenu ); 716 action->addTo( helpMenu );
717 connect( action, SIGNAL( activated() ), 717 connect( action, SIGNAL( activated() ),
718 SLOT( aboutKnownBugs() ) ); 718 SLOT( aboutKnownBugs() ) );
719 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 719 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
720 action->addTo( helpMenu ); 720 action->addTo( helpMenu );
721 connect( action, SIGNAL( activated() ), 721 connect( action, SIGNAL( activated() ),
722 SLOT( usertrans() ) ); 722 SLOT( usertrans() ) );
723 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 723 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
724 action->addTo( helpMenu ); 724 action->addTo( helpMenu );
725 connect( action, SIGNAL( activated() ), 725 connect( action, SIGNAL( activated() ),
726 SLOT( synchowto() ) ); 726 SLOT( synchowto() ) );
727 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 727 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
728 action->addTo( helpMenu ); 728 action->addTo( helpMenu );
729 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
730 SLOT( whatsNew() ) ); 730 SLOT( whatsNew() ) );
731 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 731 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
732 action->addTo( helpMenu ); 732 action->addTo( helpMenu );
733 connect( action, SIGNAL( activated() ), 733 connect( action, SIGNAL( activated() ),
734 SLOT( faq() ) ); 734 SLOT( faq() ) );
735 735
736 736
737 action = new QAction( "about", i18n("About..."), 0, this ); 737 action = new QAction( "about", i18n("About..."), 0, this );
738 action->addTo( helpMenu ); 738 action->addTo( helpMenu );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 SLOT( about() ) ); 740 SLOT( about() ) );
741 action = new QAction( "licence", i18n("Licence..."), 0, this ); 741 action = new QAction( "licence", i18n("Licence..."), 0, this );
742 action->addTo( helpMenu ); 742 action->addTo( helpMenu );
743 connect( action, SIGNAL( activated() ), 743 connect( action, SIGNAL( activated() ),
744 SLOT( licence() ) ); 744 SLOT( licence() ) );
745 //menuBar->insertSeparator(); 745 //menuBar->insertSeparator();
746 746
747 // ****************************************************** 747 // ******************************************************
748 // menubar icons 748 // menubar icons
749 749
750 750
751 iconToolBar->setHorizontalStretchable (true ); 751 iconToolBar->setHorizontalStretchable (true );
752 //menuBar->insertItem( iconToolBar ); 752 //menuBar->insertItem( iconToolBar );
753 //xdays_action 753 //xdays_action
754 if (p-> mShowIconNewEvent) 754 if (p-> mShowIconNewEvent)
755 ne_action->addTo( iconToolBar ); 755 ne_action->addTo( iconToolBar );
756 if (p->mShowIconNewTodo ) 756 if (p->mShowIconNewTodo )
757 nt_action->addTo( iconToolBar ); 757 nt_action->addTo( iconToolBar );
758 if (p-> mShowIconSearch) 758 if (p-> mShowIconSearch)
759 search_action->addTo( iconToolBar ); 759 search_action->addTo( iconToolBar );
760 if (p-> mShowIconNext) 760 if (p-> mShowIconNext)
761 whatsnext_action->addTo( iconToolBar ); 761 whatsnext_action->addTo( iconToolBar );
762 if (p-> mShowIconNextDays) 762 if (p-> mShowIconNextDays)
763 xdays_action->addTo( iconToolBar ); 763 xdays_action->addTo( iconToolBar );
764 if (p-> mShowIconList) 764 if (p-> mShowIconList)
765 showlist_action->addTo( iconToolBar ); 765 showlist_action->addTo( iconToolBar );
766 if (p-> mShowIconDay1) 766 if (p-> mShowIconDay1)
767 day1_action->addTo( iconToolBar ); 767 day1_action->addTo( iconToolBar );
768 if (p-> mShowIconDay5) 768 if (p-> mShowIconDay5)
769 day5_action->addTo( iconToolBar ); 769 day5_action->addTo( iconToolBar );
770 if (p-> mShowIconDay7) 770 if (p-> mShowIconDay7)
771 day7_action->addTo( iconToolBar ); 771 day7_action->addTo( iconToolBar );
772 if (p-> mShowIconMonth) 772 if (p-> mShowIconMonth)
773 month_action->addTo( iconToolBar ); 773 month_action->addTo( iconToolBar );
774 if (p-> mShowIconTodoview) 774 if (p-> mShowIconTodoview)
775 todoview_action->addTo( iconToolBar ); 775 todoview_action->addTo( iconToolBar );
776 if (p-> mShowIconJournal) 776 if (p-> mShowIconJournal)
777 viewjournal_action->addTo( iconToolBar ); 777 viewjournal_action->addTo( iconToolBar );
778 icon = loadPixmap( pathString + "2leftarrowB" ); 778 icon = loadPixmap( pathString + "2leftarrowB" );
779 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 779 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
780 if (p-> mShowIconBackFast) { 780 if (p-> mShowIconBackFast) {
781 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 781 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
782 connect( action, SIGNAL( activated() ), 782 connect( action, SIGNAL( activated() ),
783 mView, SLOT( goPreviousMonth() ) ); 783 mView, SLOT( goPreviousMonth() ) );
784 action->addTo( iconToolBar ); 784 action->addTo( iconToolBar );
785 } 785 }
786 icon = loadPixmap( pathString + "1leftarrowB" ); 786 icon = loadPixmap( pathString + "1leftarrowB" );
787 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 787 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
788 if (p-> mShowIconBack) { 788 if (p-> mShowIconBack) {
789 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 789 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
790 connect( action, SIGNAL( activated() ), 790 connect( action, SIGNAL( activated() ),
791 mView, SLOT( goPrevious() ) ); 791 mView, SLOT( goPrevious() ) );
792 action->addTo( iconToolBar ); 792 action->addTo( iconToolBar );
793 } 793 }
794 if (p-> mShowIconToday) 794 if (p-> mShowIconToday)
795 today_action->addTo( iconToolBar ); 795 today_action->addTo( iconToolBar );
796 icon = loadPixmap( pathString + "1rightarrowB" ); 796 icon = loadPixmap( pathString + "1rightarrowB" );
797 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 797 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
798 if (p-> mShowIconForward) { 798 if (p-> mShowIconForward) {
799 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 799 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 mView, SLOT( goNext() ) ); 801 mView, SLOT( goNext() ) );
802 action->addTo( iconToolBar ); 802 action->addTo( iconToolBar );
803 } 803 }
804 icon = loadPixmap( pathString + "2rightarrowB" ); 804 icon = loadPixmap( pathString + "2rightarrowB" );
805 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 805 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
806 if (p-> mShowIconForwardFast) { 806 if (p-> mShowIconForwardFast) {
807 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 807 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 mView, SLOT( goNextMonth() ) ); 809 mView, SLOT( goNextMonth() ) );
810 action->addTo( iconToolBar ); 810 action->addTo( iconToolBar );
811 } 811 }
812 812
813 813
814 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 814 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
815 815
816 if (p-> mShowIconNewEvent) 816 if (p-> mShowIconNewEvent)
817 configureToolBarMenu->setItemChecked( 10, true ); 817 configureToolBarMenu->setItemChecked( 10, true );
818 if (p->mShowIconNewTodo ) 818 if (p->mShowIconNewTodo )
819 configureToolBarMenu->setItemChecked( 20, true ); 819 configureToolBarMenu->setItemChecked( 20, true );
820 if (p-> mShowIconSearch) 820 if (p-> mShowIconSearch)
821 configureToolBarMenu->setItemChecked( 120, true ); 821 configureToolBarMenu->setItemChecked( 120, true );
822 if (p-> mShowIconList) 822 if (p-> mShowIconList)
823 configureToolBarMenu->setItemChecked( 30, true ); 823 configureToolBarMenu->setItemChecked( 30, true );
824 if (p-> mShowIconDay1) 824 if (p-> mShowIconDay1)
825 configureToolBarMenu->setItemChecked( 40, true ); 825 configureToolBarMenu->setItemChecked( 40, true );
826 if (p-> mShowIconDay5) 826 if (p-> mShowIconDay5)
827 configureToolBarMenu->setItemChecked( 50, true ); 827 configureToolBarMenu->setItemChecked( 50, true );
828 if (p-> mShowIconDay7) 828 if (p-> mShowIconDay7)
829 configureToolBarMenu->setItemChecked( 60, true ); 829 configureToolBarMenu->setItemChecked( 60, true );
830 if (p-> mShowIconMonth) 830 if (p-> mShowIconMonth)
831 configureToolBarMenu->setItemChecked( 70, true ); 831 configureToolBarMenu->setItemChecked( 70, true );
832 if (p-> mShowIconTodoview) 832 if (p-> mShowIconTodoview)
833 configureToolBarMenu->setItemChecked( 80, true ); 833 configureToolBarMenu->setItemChecked( 80, true );
834 if (p-> mShowIconBackFast) 834 if (p-> mShowIconBackFast)
835 configureToolBarMenu->setItemChecked( 200, true ); 835 configureToolBarMenu->setItemChecked( 200, true );
836 if (p-> mShowIconBack) 836 if (p-> mShowIconBack)
837 configureToolBarMenu->setItemChecked( 210, true ); 837 configureToolBarMenu->setItemChecked( 210, true );
838 if (p-> mShowIconToday) 838 if (p-> mShowIconToday)
839 configureToolBarMenu->setItemChecked( 130, true ); 839 configureToolBarMenu->setItemChecked( 130, true );
840 if (p-> mShowIconForward) 840 if (p-> mShowIconForward)
841 configureToolBarMenu->setItemChecked( 220, true ); 841 configureToolBarMenu->setItemChecked( 220, true );
842 if (p-> mShowIconForwardFast) 842 if (p-> mShowIconForwardFast)
843 configureToolBarMenu->setItemChecked( 230, true ); 843 configureToolBarMenu->setItemChecked( 230, true );
844 if (p-> mShowIconNextDays) 844 if (p-> mShowIconNextDays)
845 configureToolBarMenu->setItemChecked( 100, true ); 845 configureToolBarMenu->setItemChecked( 100, true );
846 if (p-> mShowIconNext) 846 if (p-> mShowIconNext)
847 configureToolBarMenu->setItemChecked( 110, true ); 847 configureToolBarMenu->setItemChecked( 110, true );
848 if (p-> mShowIconJournal) 848 if (p-> mShowIconJournal)
849 configureToolBarMenu->setItemChecked( 90, true ); 849 configureToolBarMenu->setItemChecked( 90, true );
850 if (p-> mShowIconWhatsThis) 850 if (p-> mShowIconWhatsThis)
851 configureToolBarMenu->setItemChecked( 300, true ); 851 configureToolBarMenu->setItemChecked( 300, true );
852 852
853 QLabel* dummy = new QLabel( iconToolBar ); 853 QLabel* dummy = new QLabel( iconToolBar );
854 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 854 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
855 if (!p-> mShowIconStretch) 855 if (!p-> mShowIconStretch)
856 iconToolBar->setStretchableWidget ( dummy ) ; 856 iconToolBar->setStretchableWidget ( dummy ) ;
857 else 857 else
858 configureToolBarMenu->setItemChecked( 5, true ); 858 configureToolBarMenu->setItemChecked( 5, true );
859 if (p-> mShowIconWhatsThis) 859 if (p-> mShowIconWhatsThis)
860 QWhatsThis::whatsThisButton ( iconToolBar ); 860 QWhatsThis::whatsThisButton ( iconToolBar );
861 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 861 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
862 configureAgenda( p->mHourSize ); 862 configureAgenda( p->mHourSize );
863 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 863 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
864} 864}
865void MainWindow::fillSyncMenu() 865void MainWindow::fillSyncMenu()
866{ 866{
867 if ( syncMenu->count() ) 867 if ( syncMenu->count() )
868 syncMenu->clear(); 868 syncMenu->clear();
869 syncMenu->insertItem( i18n("Configure..."), 0 ); 869 syncMenu->insertItem( i18n("Configure..."), 0 );
870 syncMenu->insertSeparator(); 870 syncMenu->insertSeparator();
871 if ( mServerSocket == 0 ) { 871 if ( mServerSocket == 0 ) {
872 syncMenu->insertItem( i18n("Enable Easy-Pi-Sync"), 2 ); 872 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
873 } else { 873 } else {
874 syncMenu->insertItem( i18n("Disable Easy-Pi-Sync"), 3 ); 874 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
875 } 875 }
876 syncMenu->insertSeparator(); 876 syncMenu->insertSeparator();
877 syncMenu->insertItem( i18n("New Easy-Pi-Sync!"), 4 ); 877 syncMenu->insertItem( i18n("New Pi-Sync!"), 4 );
878 syncMenu->insertItem( i18n("Quick Easy-Pi-Sync!"), 5 ); 878 syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 );
879 syncMenu->insertSeparator(); 879 syncMenu->insertSeparator();
880 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 880 syncMenu->insertItem( i18n("Multiple sync"), 1 );
881 syncMenu->insertSeparator(); 881 syncMenu->insertSeparator();
882 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 882 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
883 config.setGroup("General"); 883 config.setGroup("General");
884 QStringList prof = config.readListEntry("SyncProfileNames"); 884 QStringList prof = config.readListEntry("SyncProfileNames");
885 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 885 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
886 if ( prof.count() < 3 ) { 886 if ( prof.count() < 3 ) {
887 prof.clear(); 887 prof.clear();
888 prof << i18n("Sharp_DTM"); 888 prof << i18n("Sharp_DTM");
889 prof << i18n("Local_file"); 889 prof << i18n("Local_file");
890 prof << i18n("Last_file"); 890 prof << i18n("Last_file");
891 KSyncProfile* temp = new KSyncProfile (); 891 KSyncProfile* temp = new KSyncProfile ();
892 temp->setName( prof[0] ); 892 temp->setName( prof[0] );
893 temp->writeConfig(&config); 893 temp->writeConfig(&config);
894 temp->setName( prof[1] ); 894 temp->setName( prof[1] );
895 temp->writeConfig(&config); 895 temp->writeConfig(&config);
896 temp->setName( prof[2] ); 896 temp->setName( prof[2] );
897 temp->writeConfig(&config); 897 temp->writeConfig(&config);
898 config.setGroup("General"); 898 config.setGroup("General");
899 config.writeEntry("SyncProfileNames",prof); 899 config.writeEntry("SyncProfileNames",prof);
900 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 900 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
901 config.sync(); 901 config.sync();
902 delete temp; 902 delete temp;
903 } 903 }
904 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 904 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
905 KOPrefs::instance()->mSyncProfileNames = prof; 905 KOPrefs::instance()->mSyncProfileNames = prof;
906 int i; 906 int i;
907 for ( i = 0; i < prof.count(); ++i ) { 907 for ( i = 0; i < prof.count(); ++i ) {
908 908
909 syncMenu->insertItem( prof[i], 1000+i ); 909 syncMenu->insertItem( prof[i], 1000+i );
910 if ( i == 2 ) 910 if ( i == 2 )
911 syncMenu->insertSeparator(); 911 syncMenu->insertSeparator();
912 } 912 }
913 QDir app_dir; 913 QDir app_dir;
914 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 914 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
915 syncMenu->setItemEnabled( false , 1000 ); 915 syncMenu->setItemEnabled( false , 1000 );
916 } 916 }
917 mView->setupExternSyncProfiles(); 917 mView->setupExternSyncProfiles();
918} 918}
919 919
920int MainWindow::ringSync() 920int MainWindow::ringSync()
921{ 921{
922 int syncedProfiles = 0; 922 int syncedProfiles = 0;
923 int i; 923 int i;
924 QTime timer; 924 QTime timer;
925 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 925 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
926 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 926 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
927 KSyncProfile* temp = new KSyncProfile (); 927 KSyncProfile* temp = new KSyncProfile ();
928 KOPrefs::instance()->mAskForPreferences = false; 928 KOPrefs::instance()->mAskForPreferences = false;
929 for ( i = 0; i < syncProfileNames.count(); ++i ) { 929 for ( i = 0; i < syncProfileNames.count(); ++i ) {
930 mCurrentSyncProfile = i; 930 mCurrentSyncProfile = i;
931 temp->setName(syncProfileNames[mCurrentSyncProfile]); 931 temp->setName(syncProfileNames[mCurrentSyncProfile]);
932 temp->readConfig(&config); 932 temp->readConfig(&config);
933 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 933 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
934 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 934 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
935 ++syncedProfiles; 935 ++syncedProfiles;
936 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 936 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
937 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 937 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
938 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 938 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
939 KOPrefs::instance()->mWriteBackInFuture = 0; 939 KOPrefs::instance()->mWriteBackInFuture = 0;
940 if ( temp->getWriteBackFuture() ) 940 if ( temp->getWriteBackFuture() )
941 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 941 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
942 KOPrefs::instance()->mShowSyncSummary = false; 942 KOPrefs::instance()->mShowSyncSummary = false;
943 mView->setSyncDevice(syncProfileNames[i] ); 943 mView->setSyncDevice(syncProfileNames[i] );
944 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 944 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
945 if ( i == 0 ) { 945 if ( i == 0 ) {
946 syncSharp(); 946 syncSharp();
947 } else { 947 } else {
948 if ( temp->getIsLocalFileSync() ) { 948 if ( temp->getIsLocalFileSync() ) {
949 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 949 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
950 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 950 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
951 } else { 951 } else {
952 if ( temp->getIsPhoneSync() ) { 952 if ( temp->getIsPhoneSync() ) {
953 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 953 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
954 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 954 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
955 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 955 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
956 syncPhone(); 956 syncPhone();
957 } else 957 } else
958 syncRemote( temp, false ); 958 syncRemote( temp, false );
959 959
960 } 960 }
961 } 961 }
962 timer.start(); 962 timer.start();
963 setCaption(i18n("Multiple sync in progress ... please wait!") ); 963 setCaption(i18n("Multiple sync in progress ... please wait!") );
964 while ( timer.elapsed () < 2000 ) { 964 while ( timer.elapsed () < 2000 ) {
965 qApp->processEvents(); 965 qApp->processEvents();
966#ifndef _WIN32_ 966#ifndef _WIN32_
967 sleep (1); 967 sleep (1);
968#endif 968#endif
969 } 969 }
970 970
971 } 971 }
972 972
973 } 973 }
974 delete temp; 974 delete temp;
975 return syncedProfiles; 975 return syncedProfiles;
976} 976}
977 977
978void MainWindow::multiSync( bool askforPrefs ) 978void MainWindow::multiSync( bool askforPrefs )
979{ 979{
980 if (mBlockSaveFlag) 980 if (mBlockSaveFlag)
981 return; 981 return;
982 mBlockSaveFlag = true; 982 mBlockSaveFlag = true;
983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
985 question, 985 question,
986 i18n("Yes"), i18n("No"), 986 i18n("Yes"), i18n("No"),
987 0, 0 ) != 0 ) { 987 0, 0 ) != 0 ) {
988 mBlockSaveFlag = false; 988 mBlockSaveFlag = false;
989 setCaption(i18n("Aborted! Nothing synced!")); 989 setCaption(i18n("Aborted! Nothing synced!"));
990 return; 990 return;
991 } 991 }
992 mView->setSyncDevice(i18n("Multiple profiles") ); 992 mView->setSyncDevice(i18n("Multiple profiles") );
993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
994 if ( askforPrefs ) { 994 if ( askforPrefs ) {
995 mView->edit_sync_options(); 995 mView->edit_sync_options();
996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
997 } 997 }
998 setCaption(i18n("Multiple sync started.") ); 998 setCaption(i18n("Multiple sync started.") );
999 qApp->processEvents(); 999 qApp->processEvents();
1000 int num = ringSync() ; 1000 int num = ringSync() ;
1001 if ( num > 1 ) 1001 if ( num > 1 )
1002 ringSync(); 1002 ringSync();
1003 mBlockSaveFlag = false; 1003 mBlockSaveFlag = false;
1004 if ( num ) 1004 if ( num )
1005 save(); 1005 save();
1006 if ( num ) 1006 if ( num )
1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1008 else 1008 else
1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1010 return; 1010 return;
1011} 1011}
1012void MainWindow::slotSyncMenu( int action ) 1012void MainWindow::slotSyncMenu( int action )
1013{ 1013{
1014 qDebug("syncaction %d ", action); 1014 qDebug("syncaction %d ", action);
1015 if ( action == 0 ) { 1015 if ( action == 0 ) {
1016 1016
1017 // seems to be a Qt2 event handling bug 1017 // seems to be a Qt2 event handling bug
1018 // syncmenu.clear causes a segfault at first time 1018 // syncmenu.clear causes a segfault at first time
1019 // when we call it after the main event loop, it is ok 1019 // when we call it after the main event loop, it is ok
1020 // same behaviour when calling OM/Pi via QCOP for the first time 1020 // same behaviour when calling OM/Pi via QCOP for the first time
1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1022 //confSync(); 1022 //confSync();
1023 1023
1024 return; 1024 return;
1025 } 1025 }
1026 if ( action == 1 ) { 1026 if ( action == 1 ) {
1027 multiSync( true ); 1027 multiSync( true );
1028 return; 1028 return;
1029 } 1029 }
1030 if ( action == 2 ) { 1030 if ( action == 2 ) {
1031 enableQuick(); 1031 enableQuick();
1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1033 return; 1033 return;
1034 } 1034 }
1035 if ( action == 3 ) { 1035 if ( action == 3 ) {
1036 delete mServerSocket; 1036 delete mServerSocket;
1037 mServerSocket = 0; 1037 mServerSocket = 0;
1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1039 return; 1039 return;
1040 } 1040 }
1041 if ( action == 4 ) { 1041 if ( action == 4 ) {
1042 performQuick(); 1042 performQuick();
1043 return; 1043 return;
1044 } 1044 }
1045 if ( action == 5 ) { 1045 if ( action == 5 ) {
1046 performQuickQuick(); 1046 performQuickQuick();
1047 return; 1047 return;
1048 } 1048 }
1049 1049
1050 if (mBlockSaveFlag) 1050 if (mBlockSaveFlag)
1051 return; 1051 return;
1052 mBlockSaveFlag = true; 1052 mBlockSaveFlag = true;
1053 mCurrentSyncProfile = action - 1000 ; 1053 mCurrentSyncProfile = action - 1000 ;
1054 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1054 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1055 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1055 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1056 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1056 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1057 KSyncProfile* temp = new KSyncProfile (); 1057 KSyncProfile* temp = new KSyncProfile ();
1058 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1058 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1059 temp->readConfig(&config); 1059 temp->readConfig(&config);
1060 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1060 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1061 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1061 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1062 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1062 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1063 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1063 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1064 KOPrefs::instance()->mWriteBackInFuture = 0; 1064 KOPrefs::instance()->mWriteBackInFuture = 0;
1065 if ( temp->getWriteBackFuture() ) 1065 if ( temp->getWriteBackFuture() )
1066 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1066 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1067 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1067 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1068 if ( action == 1000 ) { 1068 if ( action == 1000 ) {
1069 syncSharp(); 1069 syncSharp();
1070 1070
1071 } else if ( action == 1001 ) { 1071 } else if ( action == 1001 ) {
1072 syncLocalFile(); 1072 syncLocalFile();
1073 1073
1074 } else if ( action == 1002 ) { 1074 } else if ( action == 1002 ) {
1075 quickSyncLocalFile(); 1075 quickSyncLocalFile();
1076 1076
1077 } else if ( action >= 1003 ) { 1077 } else if ( action >= 1003 ) {
1078 if ( temp->getIsLocalFileSync() ) { 1078 if ( temp->getIsLocalFileSync() ) {
1079 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1079 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1080 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1080 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1081 } else { 1081 } else {
1082 if ( temp->getIsPhoneSync() ) { 1082 if ( temp->getIsPhoneSync() ) {
1083 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1083 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1084 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1084 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1085 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1085 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1086 syncPhone(); 1086 syncPhone();
1087 } else 1087 } else
1088 syncRemote( temp ); 1088 syncRemote( temp );
1089 1089
1090 } 1090 }
1091 } 1091 }
1092 delete temp; 1092 delete temp;
1093 mBlockSaveFlag = false; 1093 mBlockSaveFlag = false;
1094} 1094}
1095void MainWindow::setDefaultPreferences() 1095void MainWindow::setDefaultPreferences()
1096{ 1096{
1097 KOPrefs *p = KOPrefs::instance(); 1097 KOPrefs *p = KOPrefs::instance();
1098 1098
1099 p->mCompactDialogs = true; 1099 p->mCompactDialogs = true;
1100 p->mConfirm = true; 1100 p->mConfirm = true;
1101 // p->mEnableQuickTodo = false; 1101 // p->mEnableQuickTodo = false;
1102} 1102}
1103 1103
1104QString MainWindow::resourcePath() 1104QString MainWindow::resourcePath()
1105{ 1105{
1106 return KGlobal::iconLoader()->iconPath(); 1106 return KGlobal::iconLoader()->iconPath();
1107} 1107}
1108 1108
1109void MainWindow::displayText( QString text ,QString cap ) 1109void MainWindow::displayText( QString text ,QString cap )
1110{ 1110{
1111 QDialog dia( this, "name", true ); ; 1111 QDialog dia( this, "name", true ); ;
1112 dia.setCaption( cap ); 1112 dia.setCaption( cap );
1113 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1113 QVBoxLayout* lay = new QVBoxLayout( &dia );
1114 lay->setSpacing( 3 ); 1114 lay->setSpacing( 3 );
1115 lay->setMargin( 3 ); 1115 lay->setMargin( 3 );
1116 QTextBrowser tb ( &dia ); 1116 QTextBrowser tb ( &dia );
1117 lay->addWidget( &tb ); 1117 lay->addWidget( &tb );
1118 tb.setText( text ); 1118 tb.setText( text );
1119#ifdef DESKTOP_VERSION 1119#ifdef DESKTOP_VERSION
1120 dia.resize( 640, 480); 1120 dia.resize( 640, 480);
1121#else 1121#else
1122 dia.showMaximized(); 1122 dia.showMaximized();
1123#endif 1123#endif
1124 dia.exec(); 1124 dia.exec();
1125} 1125}
1126void MainWindow::displayFile( QString fn, QString cap ) 1126void MainWindow::displayFile( QString fn, QString cap )
1127{ 1127{
1128 QString fileName = resourcePath() + fn; 1128 QString fileName = resourcePath() + fn;
1129 QString text; 1129 QString text;
1130 QFile file( fileName ); 1130 QFile file( fileName );
1131 if (!file.open( IO_ReadOnly ) ) { 1131 if (!file.open( IO_ReadOnly ) ) {
1132 return ; 1132 return ;
1133 1133
1134 } 1134 }
@@ -1754,513 +1754,515 @@ void MainWindow::loadCalendar()
1754 1754
1755 QString fn = KOPrefs::instance()->mLastLoadFile; 1755 QString fn = KOPrefs::instance()->mLastLoadFile;
1756 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1756 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1757 1757
1758 if ( fn == "" ) 1758 if ( fn == "" )
1759 return; 1759 return;
1760 QFileInfo info; 1760 QFileInfo info;
1761 info.setFile( fn ); 1761 info.setFile( fn );
1762 QString mess; 1762 QString mess;
1763 bool loadbup = true; 1763 bool loadbup = true;
1764 if ( info. exists() ) { 1764 if ( info. exists() ) {
1765 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1765 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1766 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1766 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1767 mess, 1767 mess,
1768 i18n("Load!"), i18n("Cancel"), 0, 1768 i18n("Load!"), i18n("Cancel"), 0,
1769 0, 1 ); 1769 0, 1 );
1770 if ( result != 0 ) { 1770 if ( result != 0 ) {
1771 loadbup = false; 1771 loadbup = false;
1772 } 1772 }
1773 } else { 1773 } else {
1774 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1774 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1775 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1775 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1776 0, 1 ); 1776 0, 1 );
1777 1777
1778 return; 1778 return;
1779 } 1779 }
1780 if ( loadbup ) { 1780 if ( loadbup ) {
1781 mView->openCalendar( fn ); 1781 mView->openCalendar( fn );
1782 KOPrefs::instance()->mLastLoadFile = fn; 1782 KOPrefs::instance()->mLastLoadFile = fn;
1783 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1783 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1784 setCaption(mess); 1784 setCaption(mess);
1785 } 1785 }
1786 1786
1787} 1787}
1788void MainWindow::quickImportIcal() 1788void MainWindow::quickImportIcal()
1789{ 1789{
1790 importFile( KOPrefs::instance()->mLastImportFile, false ); 1790 importFile( KOPrefs::instance()->mLastImportFile, false );
1791} 1791}
1792void MainWindow::importFile( QString fn, bool quick ) 1792void MainWindow::importFile( QString fn, bool quick )
1793{ 1793{
1794 QFileInfo info; 1794 QFileInfo info;
1795 info.setFile( fn ); 1795 info.setFile( fn );
1796 QString mess; 1796 QString mess;
1797 bool loadbup = true; 1797 bool loadbup = true;
1798 if ( !info. exists() ) { 1798 if ( !info. exists() ) {
1799 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1799 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1800 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1800 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1801 mess ); 1801 mess );
1802 return; 1802 return;
1803 } 1803 }
1804 int result = 0; 1804 int result = 0;
1805 if ( !quick ) { 1805 if ( !quick ) {
1806 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1806 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1807 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1807 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1808 mess, 1808 mess,
1809 "Import", "Cancel", 0, 1809 "Import", "Cancel", 0,
1810 0, 1 ); 1810 0, 1 );
1811 } 1811 }
1812 if ( result == 0 ) { 1812 if ( result == 0 ) {
1813 if ( mView->openCalendar( fn, true )) { 1813 if ( mView->openCalendar( fn, true )) {
1814 KOPrefs::instance()->mLastImportFile = fn; 1814 KOPrefs::instance()->mLastImportFile = fn;
1815 setCaption(i18n("Imported file successfully")); 1815 setCaption(i18n("Imported file successfully"));
1816 } else { 1816 } else {
1817 setCaption(i18n("Error importing file")); 1817 setCaption(i18n("Error importing file"));
1818 } 1818 }
1819 } 1819 }
1820} 1820}
1821 1821
1822void MainWindow::importIcal() 1822void MainWindow::importIcal()
1823{ 1823{
1824 1824
1825 QString fn =KOPrefs::instance()->mLastImportFile; 1825 QString fn =KOPrefs::instance()->mLastImportFile;
1826 1826
1827 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1827 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1828 if ( fn == "" ) 1828 if ( fn == "" )
1829 return; 1829 return;
1830 importFile( fn, true ); 1830 importFile( fn, true );
1831 1831
1832} 1832}
1833 1833
1834void MainWindow::exportVCalendar() 1834void MainWindow::exportVCalendar()
1835{ 1835{
1836 QString fn = KOPrefs::instance()->mLastVcalFile; 1836 QString fn = KOPrefs::instance()->mLastVcalFile;
1837 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1837 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1838 if ( fn == "" ) 1838 if ( fn == "" )
1839 return; 1839 return;
1840 QFileInfo info; 1840 QFileInfo info;
1841 info.setFile( fn ); 1841 info.setFile( fn );
1842 QString mes; 1842 QString mes;
1843 bool createbup = true; 1843 bool createbup = true;
1844 if ( info. exists() ) { 1844 if ( info. exists() ) {
1845 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1845 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1846 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1846 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1847 i18n("Overwrite!"), i18n("Cancel"), 0, 1847 i18n("Overwrite!"), i18n("Cancel"), 0,
1848 0, 1 ); 1848 0, 1 );
1849 if ( result != 0 ) { 1849 if ( result != 0 ) {
1850 createbup = false; 1850 createbup = false;
1851 } 1851 }
1852 } 1852 }
1853 if ( createbup ) { 1853 if ( createbup ) {
1854 if ( mView->exportVCalendar( fn ) ) { 1854 if ( mView->exportVCalendar( fn ) ) {
1855 KOPrefs::instance()->mLastVcalFile = fn; 1855 KOPrefs::instance()->mLastVcalFile = fn;
1856 if ( fn.length() > 20 ) 1856 if ( fn.length() > 20 )
1857 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1857 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1858 else 1858 else
1859 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1859 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1860 setCaption(mes); 1860 setCaption(mes);
1861 } 1861 }
1862 } 1862 }
1863 1863
1864} 1864}
1865QString MainWindow::getPassword( ) 1865QString MainWindow::getPassword( )
1866{ 1866{
1867 QString retfile = ""; 1867 QString retfile = "";
1868 QDialog dia ( this, "input-dialog", true ); 1868 QDialog dia ( this, "input-dialog", true );
1869 QLineEdit lab ( &dia ); 1869 QLineEdit lab ( &dia );
1870 lab.setEchoMode( QLineEdit::Password ); 1870 lab.setEchoMode( QLineEdit::Password );
1871 QVBoxLayout lay( &dia ); 1871 QVBoxLayout lay( &dia );
1872 lay.setMargin(7); 1872 lay.setMargin(7);
1873 lay.setSpacing(7); 1873 lay.setSpacing(7);
1874 lay.addWidget( &lab); 1874 lay.addWidget( &lab);
1875 dia.setFixedSize( 230,50 ); 1875 dia.setFixedSize( 230,50 );
1876 dia.setCaption( i18n("Enter password") ); 1876 dia.setCaption( i18n("Enter password") );
1877 QPushButton pb ( "OK", &dia); 1877 QPushButton pb ( "OK", &dia);
1878 lay.addWidget( &pb ); 1878 lay.addWidget( &pb );
1879 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1879 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1880 dia.show(); 1880 dia.show();
1881 int res = dia.exec(); 1881 int res = dia.exec();
1882 if ( res ) 1882 if ( res )
1883 retfile = lab.text(); 1883 retfile = lab.text();
1884 dia.hide(); 1884 dia.hide();
1885 qApp->processEvents(); 1885 qApp->processEvents();
1886 return retfile; 1886 return retfile;
1887 1887
1888} 1888}
1889 1889
1890void MainWindow::enableQuick() 1890void MainWindow::enableQuick()
1891{ 1891{
1892 QString retfile = ""; 1892 QString retfile = "";
1893 QDialog dia ( this, "input-dialog", true ); 1893 QDialog dia ( this, "input-dialog", true );
1894 QLineEdit lab ( &dia ); 1894 QLineEdit lab ( &dia );
1895 QVBoxLayout lay( &dia ); 1895 QVBoxLayout lay( &dia );
1896 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1896 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1897 lay.setMargin(7); 1897 lay.setMargin(7);
1898 lay.setSpacing(7); 1898 lay.setSpacing(7);
1899 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1899 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1900 lay.addWidget( &label); 1900 lay.addWidget( &label);
1901 lay.addWidget( &lab); 1901 lay.addWidget( &lab);
1902 dia.setFixedSize( 230,80 ); 1902 dia.setFixedSize( 230,80 );
1903 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); 1903 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") );
1904 QPushButton pb ( "OK", &dia); 1904 QPushButton pb ( "OK", &dia);
1905 lay.addWidget( &pb ); 1905 lay.addWidget( &pb );
1906 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1906 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1907 dia.show(); 1907 dia.show();
1908 int res = dia.exec(); 1908 int res = dia.exec();
1909 if ( res ) 1909 if ( res )
1910 retfile = lab.text(); 1910 retfile = lab.text();
1911 else 1911 else
1912 return; 1912 return;
1913 dia.hide(); 1913 dia.hide();
1914 qApp->processEvents(); 1914 qApp->processEvents();
1915 KOPrefs::instance()->mPassiveSyncPort = retfile; 1915 KOPrefs::instance()->mPassiveSyncPort = retfile;
1916 bool ok; 1916 bool ok;
1917 Q_UINT16 port = retfile.toUInt(&ok); 1917 Q_UINT16 port = retfile.toUInt(&ok);
1918 if ( ! ok ) { 1918 if ( ! ok ) {
1919 qDebug("no valid port "); 1919 qDebug("no valid port ");
1920 return; 1920 return;
1921 } 1921 }
1922 qDebug("port %d ", port); 1922 qDebug("port %d ", port);
1923 mServerSocket = new KServerSocket ( port ,1 ); 1923 mServerSocket = new KServerSocket ( port ,1 );
1924 qDebug("connected "); 1924 qDebug("connected ");
1925 if ( !mServerSocket->ok() ) { 1925 if ( !mServerSocket->ok() ) {
1926 qWarning("Failed to bind to port %d", port); 1926 qWarning("Failed to bind to port %d", port);
1927 delete mServerSocket; 1927 delete mServerSocket;
1928 mServerSocket = 0; 1928 mServerSocket = 0;
1929 return; 1929 return;
1930 } 1930 }
1931 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); 1931 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1932 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); 1932 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1933} 1933}
1934void MainWindow::sendFile(QSocket* socket) 1934void MainWindow::sendFile(QSocket* socket)
1935{ 1935{
1936 setCaption( i18n("Received request for file") ); 1936 setCaption( i18n("Received request for file") );
1937 qDebug("MainWindow::sendFile(QSocket* s) "); 1937 qDebug("MainWindow::sendFile(QSocket* s) ");
1938 if ( mSyncActionDialog ) 1938 if ( mSyncActionDialog )
1939 delete mSyncActionDialog; 1939 delete mSyncActionDialog;
1940 mSyncActionDialog = new QDialog ( this, "input-dialog", true ); 1940 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1941 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); 1941 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1942 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); 1942 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1943 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1943 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1944 lay->addWidget( label); 1944 lay->addWidget( label);
1945 lay->setMargin(7); 1945 lay->setMargin(7);
1946 lay->setSpacing(7); 1946 lay->setSpacing(7);
1947 mSyncActionDialog->setFixedSize( 200,100 ); 1947 mSyncActionDialog->setFixedSize( 200,100 );
1948 mSyncActionDialog->show(); 1948 mSyncActionDialog->show();
1949 qApp->processEvents(); 1949 qApp->processEvents();
1950 qDebug("saving ... "); 1950 qDebug("saving ... ");
1951 save(); 1951 save();
1952 QString fileName = defaultFileName(); 1952 QString fileName = defaultFileName();
1953 QFile file( fileName ); 1953 QFile file( fileName );
1954 if (!file.open( IO_ReadOnly ) ) { 1954 if (!file.open( IO_ReadOnly ) ) {
1955 setCaption( i18n("Error open file") ); 1955 setCaption( i18n("Error open file") );
1956 delete mSyncActionDialog; 1956 delete mSyncActionDialog;
1957 mSyncActionDialog = 0; 1957 mSyncActionDialog = 0;
1958 qDebug("error open cal file "); 1958 qDebug("error open cal file ");
1959 return ; 1959 return ;
1960 1960
1961 } 1961 }
1962 setCaption( i18n("Sending file...") ); 1962 setCaption( i18n("Sending file...") );
1963 QTextStream ts( &file ); 1963 QTextStream ts( &file );
1964 ts.setCodec( QTextCodec::codecForName("utf8") ); 1964 ts.setCodec( QTextCodec::codecForName("utf8") );
1965 QTextStream os( socket ); 1965 QTextStream os( socket );
1966 os.setCodec( QTextCodec::codecForName("utf8") ); 1966 os.setCodec( QTextCodec::codecForName("utf8") );
1967 //os.setEncoding( QTextStream::UnicodeUTF8 ); 1967 //os.setEncoding( QTextStream::UnicodeUTF8 );
1968 while ( ! ts.atEnd() ) { 1968 while ( ! ts.atEnd() ) {
1969 os << ts.readLine() << "\n"; 1969 os << ts.readLine() << "\n";
1970 } 1970 }
1971 //os << ts.read(); 1971 //os << ts.read();
1972 socket->close(); 1972 socket->close();
1973 file.close(); 1973 file.close();
1974 setCaption( i18n("File sent. Waiting to get back synced file") ); 1974 setCaption( i18n("File sent. Waiting to get back synced file") );
1975 qDebug("file sent "); 1975 qDebug("file sent ");
1976} 1976}
1977void MainWindow::getFile(QSocket* socket) 1977void MainWindow::getFile(QSocket* socket)
1978{ 1978{
1979 setCaption( i18n("Receiving synced file...") ); 1979 setCaption( i18n("Receiving synced file...") );
1980 1980
1981 QString fileName = defaultFileName(); 1981 QString fileName = defaultFileName();
1982 QFile file( fileName ); 1982 QFile file( fileName );
1983 if (!file.open( IO_WriteOnly ) ) { 1983 if (!file.open( IO_WriteOnly ) ) {
1984 setCaption( i18n("Error open file") ); 1984 setCaption( i18n("Error open file") );
1985 delete mSyncActionDialog; 1985 delete mSyncActionDialog;
1986 mSyncActionDialog = 0; 1986 mSyncActionDialog = 0;
1987 qDebug("error open cal file "); 1987 qDebug("error open cal file ");
1988 return ; 1988 return ;
1989 1989
1990 } 1990 }
1991 1991
1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1993 QTextStream ts( &file ); 1993 QTextStream ts( &file );
1994 ts.setCodec( QTextCodec::codecForName("utf8") ); 1994 ts.setCodec( QTextCodec::codecForName("utf8") );
1995 bool first = true; 1995 bool first = true;
1996 while ( socket->canReadLine () || first ) { 1996 while ( socket->canReadLine () || first ) {
1997 first = false; 1997 first = false;
1998 while ( socket->canReadLine () ) { 1998 while ( socket->canReadLine () ) {
1999 qDebug("avail %d ", socket->bytesAvailable () ); 1999 qDebug("avail %d ", socket->bytesAvailable () );
2000 ts << socket->readLine (); 2000 ts << socket->readLine ();
2001 } 2001 }
2002 QTime ti; 2002 QTime ti;
2003 ti.start(); 2003 ti.start();
2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { 2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) {
2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); 2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () );
2006 //qApp->processEvents(); 2006 //qApp->processEvents();
2007 qDebug("waiting1b %d ",ti.elapsed () ); 2007 qDebug("waiting1b %d ",ti.elapsed () );
2008 if ( !socket->canReadLine () ) { 2008 if ( !socket->canReadLine () ) {
2009 qDebug("waiting1c %d ",ti.elapsed () ); 2009 qDebug("waiting1c %d ",ti.elapsed () );
2010#ifndef _WIN32_
2010 usleep( 100000); 2011 usleep( 100000);
2012#endif
2011 } 2013 }
2012 //socket->waitForMore ( 100 ); 2014 //socket->waitForMore ( 100 );
2013 } 2015 }
2014 ts << socket->readLine (); 2016 ts << socket->readLine ();
2015#if 0 2017#if 0
2016#ifdef DESKTOP_VERSION 2018#ifdef DESKTOP_VERSION
2017 socket->waitForMore ( 5000 ); 2019 socket->waitForMore ( 5000 );
2018#else 2020#else
2019 // socket->waitForMore ( 5000 ); 2021 // socket->waitForMore ( 5000 );
2020 // seems to be broken in qt2 2022 // seems to be broken in qt2
2021 bool stop = false; 2023 bool stop = false;
2022 QTime ti; 2024 QTime ti;
2023 ti.start(); 2025 ti.start();
2024 while ( ti.elapsed < 5000 && !stop ) { 2026 while ( ti.elapsed < 5000 && !stop ) {
2025 qApp->processEvents(); 2027 qApp->processEvents();
2026 if ( socket->canReadLine () ) 2028 if ( socket->canReadLine () )
2027 stop = true ; 2029 stop = true ;
2028 else { 2030 else {
2029 usleep( 100000 ); 2031 usleep( 100000 );
2030 2032
2031 } 2033 }
2032 } 2034 }
2033#endif 2035#endif
2034#endif 2036#endif
2035 } 2037 }
2036 setCaption( i18n("File received - reloading calendar...") ); 2038 setCaption( i18n("File received - reloading calendar...") );
2037 socket->close(); 2039 socket->close();
2038 file.close(); 2040 file.close();
2039 mView->watchSavedFile(); 2041 mView->watchSavedFile();
2040 mView->openCalendar( defaultFileName() ); 2042 mView->openCalendar( defaultFileName() );
2041 setCaption( i18n("Easy-Pi-Sync successful!") ); 2043 setCaption( i18n("Easy-Pi-Sync successful!") );
2042 delete mSyncActionDialog; 2044 delete mSyncActionDialog;
2043 mSyncActionDialog = 0; 2045 mSyncActionDialog = 0;
2044 2046
2045 2047
2046} 2048}
2047void MainWindow::endConnect() 2049void MainWindow::endConnect()
2048{ 2050{
2049 setCaption( i18n("No file received - syncing successful") ); 2051 setCaption( i18n("No file received - syncing successful") );
2050 delete mSyncActionDialog; 2052 delete mSyncActionDialog;
2051 mSyncActionDialog = 0; 2053 mSyncActionDialog = 0;
2052} 2054}
2053void MainWindow::performQuick() 2055void MainWindow::performQuick()
2054{ 2056{
2055 setCaption( i18n("Please input connection settings") ); 2057 setCaption( i18n("Please input connection settings") );
2056 QString retfile = ""; 2058 QString retfile = "";
2057 QDialog dia ( this, "input-dialog", true ); 2059 QDialog dia ( this, "input-dialog", true );
2058 QLineEdit lab ( &dia ); 2060 QLineEdit lab ( &dia );
2059 QVBoxLayout lay( &dia ); 2061 QVBoxLayout lay( &dia );
2060 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); 2062 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2061 lay.addWidget( &label); 2063 lay.addWidget( &label);
2062 lab.setText( KOPrefs::instance()->mActiveSyncIP ); 2064 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2063 lay.setMargin(7); 2065 lay.setMargin(7);
2064 lay.setSpacing(7); 2066 lay.setSpacing(7);
2065 lay.addWidget( &lab); 2067 lay.addWidget( &lab);
2066 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); 2068 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2067 lay.addWidget( &label2); 2069 lay.addWidget( &label2);
2068 QLineEdit lab2 ( &dia ); 2070 QLineEdit lab2 ( &dia );
2069 lab2.setText( KOPrefs::instance()->mActiveSyncPort ); 2071 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2070 lay.addWidget( &lab2); 2072 lay.addWidget( &lab2);
2071 dia.setFixedSize( 230,200 ); 2073 dia.setFixedSize( 230,200 );
2072 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); 2074 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") );
2073 QPushButton pb ( "OK", &dia); 2075 QPushButton pb ( "OK", &dia);
2074 lay.addWidget( &pb ); 2076 lay.addWidget( &pb );
2075 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2077 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2076 dia.show(); 2078 dia.show();
2077 int res = dia.exec(); 2079 int res = dia.exec();
2078 if ( !res ) { 2080 if ( !res ) {
2079 setCaption( i18n("Syncing cancelled!") ); 2081 setCaption( i18n("Syncing cancelled!") );
2080 return; 2082 return;
2081 } 2083 }
2082 dia.hide(); 2084 dia.hide();
2083 KOPrefs::instance()->mActiveSyncPort = lab2.text(); 2085 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2084 KOPrefs::instance()->mActiveSyncIP = lab.text(); 2086 KOPrefs::instance()->mActiveSyncIP = lab.text();
2085 qApp->processEvents(); 2087 qApp->processEvents();
2086 performQuickQuick(); 2088 performQuickQuick();
2087} 2089}
2088 2090
2089void MainWindow::performQuickQuick() 2091void MainWindow::performQuickQuick()
2090{ 2092{
2091 // setCaption( i18n("") ); 2093 // setCaption( i18n("") );
2092 2094
2093 bool ok; 2095 bool ok;
2094 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2096 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2095 if ( ! ok ) { 2097 if ( ! ok ) {
2096 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2098 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2097 return; 2099 return;
2098 } 2100 }
2099 if ( !mCommandSocket ) { 2101 if ( !mCommandSocket ) {
2100 mCommandSocket = new QSocket( this ); 2102 mCommandSocket = new QSocket( this );
2101 // delete mCommandSocket; 2103 // delete mCommandSocket;
2102 //mCommandSocket = new QSocket( this ); 2104 //mCommandSocket = new QSocket( this );
2103 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); 2105 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2104 } 2106 }
2105 QString host = KOPrefs::instance()->mActiveSyncIP; 2107 QString host = KOPrefs::instance()->mActiveSyncIP;
2106 mCommandSocket->connectToHost( host, port ); 2108 mCommandSocket->connectToHost( host, port );
2107 QTextStream os( mCommandSocket ); 2109 QTextStream os( mCommandSocket );
2108 os.setEncoding( QTextStream::UnicodeUTF8 ); 2110 os.setEncoding( QTextStream::UnicodeUTF8 );
2109 os << "GET\r\n"; 2111 os << "GET\r\n";
2110 setCaption( i18n("Sending request for remote file ...") ); 2112 setCaption( i18n("Sending request for remote file ...") );
2111 2113
2112} 2114}
2113void MainWindow::readFileFromSocket() 2115void MainWindow::readFileFromSocket()
2114{ 2116{
2115 setCaption( i18n("Receiving remote file ...") ); 2117 setCaption( i18n("Receiving remote file ...") );
2116 qDebug("MainWindow::readFileFromSocket() "); 2118 qDebug("MainWindow::readFileFromSocket() ");
2117 QString fileName; 2119 QString fileName;
2118#ifdef _WIN32_ 2120#ifdef _WIN32_
2119 fileName = defaultFileName() +"sync"; 2121 fileName = defaultFileName() +"sync";
2120#else 2122#else
2121 fileName = "/tmp/kopitempfile.ics"; 2123 fileName = "/tmp/kopitempfile.ics";
2122#endif 2124#endif
2123 QFile file( fileName ); 2125 QFile file( fileName );
2124 if (!file.open( IO_WriteOnly ) ) { 2126 if (!file.open( IO_WriteOnly ) ) {
2125 setCaption( i18n("Error: Cannot open temp file for write.") ); 2127 setCaption( i18n("Error: Cannot open temp file for write.") );
2126 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2128 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2127 return ; 2129 return ;
2128 } 2130 }
2129 2131
2130 //QTextStream os2( mCommandSocket ); 2132 //QTextStream os2( mCommandSocket );
2131 //os2.setEncoding( QTextStream::UnicodeUTF8 ); 2133 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2132 2134
2133 QTextStream ts( &file ); 2135 QTextStream ts( &file );
2134 ts.setCodec( QTextCodec::codecForName("utf8") ); 2136 ts.setCodec( QTextCodec::codecForName("utf8") );
2135 bool first = true; 2137 bool first = true;
2136 while ( mCommandSocket->canReadLine () || first) { 2138 while ( mCommandSocket->canReadLine () || first) {
2137 first = false; 2139 first = false;
2138 while ( mCommandSocket->canReadLine () ) { 2140 while ( mCommandSocket->canReadLine () ) {
2139 ts << mCommandSocket->readLine (); 2141 ts << mCommandSocket->readLine ();
2140 } 2142 }
2141 QTime ti; 2143 QTime ti;
2142 ti.start(); 2144 ti.start();
2143 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { 2145 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) {
2144 qApp->processEvents(); 2146 qApp->processEvents();
2145 qDebug("waiting2 %d ",ti.elapsed () ); 2147 qDebug("waiting2 %d ",ti.elapsed () );
2146 if ( !mCommandSocket->canReadLine () ) 2148 if ( !mCommandSocket->canReadLine () )
2147 mCommandSocket->waitForMore ( 100 ); 2149 mCommandSocket->waitForMore ( 100 );
2148 } 2150 }
2149 //mCommandSocket->waitForMore ( 5000 ); 2151 //mCommandSocket->waitForMore ( 5000 );
2150 } 2152 }
2151 file.close(); 2153 file.close();
2152 mCommandSocket->close(); 2154 mCommandSocket->close();
2153 // pending: deleting after signal SIGNAL(delayedCloseFinished()) 2155 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2154 //delete mCommandSocket; 2156 //delete mCommandSocket;
2155 setCaption( i18n("Remote file saved to temp file.") ); 2157 setCaption( i18n("Remote file saved to temp file.") );
2156 //mCommandSocket = 0; 2158 //mCommandSocket = 0;
2157 mCurrentSyncProfile = 2 ; // last file 2159 mCurrentSyncProfile = 2 ; // last file
2158 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2160 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2159 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2161 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2160 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2162 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2161 KSyncProfile* temp = new KSyncProfile (); 2163 KSyncProfile* temp = new KSyncProfile ();
2162 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2164 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2163 temp->readConfig(&config); 2165 temp->readConfig(&config);
2164 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2166 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2165 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2167 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2166 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2168 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2167 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2169 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2168 KOPrefs::instance()->mWriteBackInFuture = 0; 2170 KOPrefs::instance()->mWriteBackInFuture = 0;
2169 if ( temp->getWriteBackFuture() ) 2171 if ( temp->getWriteBackFuture() )
2170 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2172 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2171 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2173 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2172 2174
2173 setCaption( i18n("Remote file saved to temp file.") ); 2175 setCaption( i18n("Remote file saved to temp file.") );
2174 if ( ! syncWithFile( fileName , true ) ) { 2176 if ( ! syncWithFile( fileName , true ) ) {
2175 setCaption( i18n("Syncing failed.") ); 2177 setCaption( i18n("Syncing failed.") );
2176 qDebug("Syncing failed "); 2178 qDebug("Syncing failed ");
2177 return; 2179 return;
2178 } 2180 }
2179 2181
2180 if ( !mCommandSocketFinish ) { 2182 if ( !mCommandSocketFinish ) {
2181 mCommandSocketFinish = new QSocket( this ); 2183 mCommandSocketFinish = new QSocket( this );
2182 } 2184 }
2183 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); 2185 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2184 2186
2185 // pending connect signals connected () and error to new slots 2187 // pending connect signals connected () and error to new slots
2186 QString host = KOPrefs::instance()->mActiveSyncIP; 2188 QString host = KOPrefs::instance()->mActiveSyncIP;
2187 QFile file2( fileName ); 2189 QFile file2( fileName );
2188 if (!file2.open( IO_ReadOnly ) ) { 2190 if (!file2.open( IO_ReadOnly ) ) {
2189 setCaption( i18n("Error: Cannot open temp file for read.") ); 2191 setCaption( i18n("Error: Cannot open temp file for read.") );
2190 qDebug("error open cal file "); 2192 qDebug("error open cal file ");
2191 return ; 2193 return ;
2192 2194
2193 } 2195 }
2194 setCaption( i18n("Sending back synced file...") ); 2196 setCaption( i18n("Sending back synced file...") );
2195 QTextStream ts2( &file2 ); 2197 QTextStream ts2( &file2 );
2196 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2198 ts2.setCodec( QTextCodec::codecForName("utf8") );
2197 QTextStream os2( mCommandSocketFinish ); 2199 QTextStream os2( mCommandSocketFinish );
2198 os2.setCodec( QTextCodec::codecForName("utf8") ); 2200 os2.setCodec( QTextCodec::codecForName("utf8") );
2199 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2201 //os.setEncoding( QTextStream::UnicodeUTF8 );
2200 if ( KOPrefs::instance()->mWriteBackFile ) { 2202 if ( KOPrefs::instance()->mWriteBackFile ) {
2201 os2 << "PUT\r\n"; 2203 os2 << "PUT\r\n";
2202 while ( ! ts2.atEnd() ) { 2204 while ( ! ts2.atEnd() ) {
2203 os2 << ts2.readLine() << "\n"; 2205 os2 << ts2.readLine() << "\n";
2204 } 2206 }
2205 } else { 2207 } else {
2206 os2 << "STOP\r\n"; 2208 os2 << "STOP\r\n";
2207 } 2209 }
2208 mCommandSocketFinish->close(); 2210 mCommandSocketFinish->close();
2209 file.close(); 2211 file.close();
2210 // pending: deleting after signal SIGNAL(delayedCloseFinished()) 2212 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2211 //delete ( mCommandSocket); 2213 //delete ( mCommandSocket);
2212 //mCommandSocket = 0; 2214 //mCommandSocket = 0;
2213 qDebug("Syncing succesful! "); 2215 qDebug("Syncing succesful! ");
2214 setCaption( i18n("Easy-Pi-Sync succesful!") ); 2216 setCaption( i18n("Easy-Pi-Sync succesful!") );
2215 2217
2216 2218
2217} 2219}
2218 2220
2219void MainWindow::syncLocalFile() 2221void MainWindow::syncLocalFile()
2220{ 2222{
2221 2223
2222 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2224 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2223 2225
2224 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2226 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2225 if ( fn == "" ) 2227 if ( fn == "" )
2226 return; 2228 return;
2227 //mView->setSyncDevice("local-file" ); 2229 //mView->setSyncDevice("local-file" );
2228 if ( syncWithFile( fn, false ) ) { 2230 if ( syncWithFile( fn, false ) ) {
2229 // Event* e = mView->getLastSyncEvent(); 2231 // Event* e = mView->getLastSyncEvent();
2230// e->setReadOnly( false ); 2232// e->setReadOnly( false );
2231// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2233// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2232// e->setReadOnly( true ); 2234// e->setReadOnly( true );
2233 } 2235 }
2234 2236
2235} 2237}
2236 2238
2237bool MainWindow::syncWithFile( QString fn , bool quick ) 2239bool MainWindow::syncWithFile( QString fn , bool quick )
2238{ 2240{
2239 bool ret = false; 2241 bool ret = false;
2240 QFileInfo info; 2242 QFileInfo info;
2241 info.setFile( fn ); 2243 info.setFile( fn );
2242 QString mess; 2244 QString mess;
2243 bool loadbup = true; 2245 bool loadbup = true;
2244 if ( !info. exists() ) { 2246 if ( !info. exists() ) {
2245 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2247 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2246 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2248 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2247 mess ); 2249 mess );
2248 return ret; 2250 return ret;
2249 } 2251 }
2250 int result = 0; 2252 int result = 0;
2251 if ( !quick ) { 2253 if ( !quick ) {
2252 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2254 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2253 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2255 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2254 mess, 2256 mess,
2255 i18n("Sync"), i18n("Cancel"), 0, 2257 i18n("Sync"), i18n("Cancel"), 0,
2256 0, 1 ); 2258 0, 1 );
2257 if ( result ) 2259 if ( result )
2258 return false; 2260 return false;
2259 } 2261 }
2260 if ( KOPrefs::instance()->mAskForPreferences ) 2262 if ( KOPrefs::instance()->mAskForPreferences )
2261 mView->edit_sync_options(); 2263 mView->edit_sync_options();
2262 if ( result == 0 ) { 2264 if ( result == 0 ) {
2263 //qDebug("Now sycing ... "); 2265 //qDebug("Now sycing ... ");
2264 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2266 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2265 setCaption( i18n("Synchronization successful") ); 2267 setCaption( i18n("Synchronization successful") );
2266 else 2268 else
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 7231842..eac19ea 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,57 +1,59 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \ 33 kprefswidget.h \
34 ksyncmanager.h \
34 ksyncprofile.h \ 35 ksyncprofile.h \
35 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
36 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
37 kcmconfigs/kdepimconfigwidget.h 38 kcmconfigs/kdepimconfigwidget.h
38 39
39SOURCES = \ 40SOURCES = \
40 categoryeditdialog.cpp \ 41 categoryeditdialog.cpp \
41 categoryeditdialog_base.cpp \ 42 categoryeditdialog_base.cpp \
42 categoryselectdialog.cpp \ 43 categoryselectdialog.cpp \
43 categoryselectdialog_base.cpp \ 44 categoryselectdialog_base.cpp \
44 externalapphandler.cpp \ 45 externalapphandler.cpp \
45 kdateedit.cpp \ 46 kdateedit.cpp \
46 kdatepicker.cpp \ 47 kdatepicker.cpp \
47 kinputdialog.cpp \ 48 kinputdialog.cpp \
48 kpimprefs.cpp \ 49 kpimprefs.cpp \
49 kpimglobalprefs.cpp \ 50 kpimglobalprefs.cpp \
50 kprefsdialog.cpp \ 51 kprefsdialog.cpp \
51 kprefswidget.cpp \ 52 kprefswidget.cpp \
53 ksyncmanager.cpp \
52 ksyncprofile.cpp \ 54 ksyncprofile.cpp \
53 ksyncprefsdialog.cpp \ 55 ksyncprefsdialog.cpp \
54 kcmconfigs/kcmkdepimconfig.cpp \ 56 kcmconfigs/kcmkdepimconfig.cpp \
55 kcmconfigs/kdepimconfigwidget.cpp 57 kcmconfigs/kdepimconfigwidget.cpp
56 58
57 59
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index 7f2a326..1c3e0ae 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1,300 +1,301 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org>
3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org> 3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org> 4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> 22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
23 * Version:$Id$ 23 * Version:$Id$
24 * Generated:Thu Mar 5 16:05:28 EST 1998 24 * Generated:Thu Mar 5 16:05:28 EST 1998
25 */ 25 */
26 26
27//US #include "config.h" 27//US #include "config.h"
28 28
29#include <stdlib.h> 29#include <stdlib.h>
30#include <assert.h> 30#include <assert.h>
31//US#include <errno.h> 31//US#include <errno.h>
32//US #ifdef HAVE_SYS_STAT_H 32//US #ifdef HAVE_SYS_STAT_H
33//US #include <sys/stat.h> 33//US #include <sys/stat.h>
34//US #endif 34//US #endif
35//US#include <sys/types.h> 35//US#include <sys/types.h>
36//US#include <dirent.h> 36//US#include <dirent.h>
37//US#include <pwd.h> 37//US#include <pwd.h>
38 38
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qasciidict.h> 40#include <qasciidict.h>
41#include <qdict.h> 41#include <qdict.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qmessagebox.h>
45#include <qapplication.h> 46#include <qapplication.h>
46 47
47#include <qstringlist.h> 48#include <qstringlist.h>
48 49
49#include "kstandarddirs.h" 50#include "kstandarddirs.h"
50#include "kconfig.h" 51#include "kconfig.h"
51#include "kdebug.h" 52#include "kdebug.h"
52//US #include "kinstance.h" 53//US #include "kinstance.h"
53#include "kshell.h" 54#include "kshell.h"
54//US#include <sys/param.h> 55//US#include <sys/param.h>
55//US#include <unistd.h> 56//US#include <unistd.h>
56 57
57//US 58//US
58QString KStandardDirs::mAppDir = QString::null; 59QString KStandardDirs::mAppDir = QString::null;
59 60
60 61
61template class QDict<QStringList>; 62template class QDict<QStringList>;
62 63
63#if 0 64#if 0
64#include <qtextedit.h> 65#include <qtextedit.h>
65void ddd( QString op ) 66void ddd( QString op )
66{ 67{
67 static QTextEdit * dot = 0; 68 static QTextEdit * dot = 0;
68 if ( ! dot ) 69 if ( ! dot )
69 dot = new QTextEdit(); 70 dot = new QTextEdit();
70 71
71 dot->show(); 72 dot->show();
72 73
73 dot->append( op ); 74 dot->append( op );
74 75
75} 76}
76#endif 77#endif
77class KStandardDirs::KStandardDirsPrivate 78class KStandardDirs::KStandardDirsPrivate
78{ 79{
79public: 80public:
80 KStandardDirsPrivate() 81 KStandardDirsPrivate()
81 : restrictionsActive(false), 82 : restrictionsActive(false),
82 dataRestrictionActive(false) 83 dataRestrictionActive(false)
83 { } 84 { }
84 85
85 bool restrictionsActive; 86 bool restrictionsActive;
86 bool dataRestrictionActive; 87 bool dataRestrictionActive;
87 QAsciiDict<bool> restrictions; 88 QAsciiDict<bool> restrictions;
88 QStringList xdgdata_prefixes; 89 QStringList xdgdata_prefixes;
89 QStringList xdgconf_prefixes; 90 QStringList xdgconf_prefixes;
90}; 91};
91 92
92static const char* const types[] = {"html", "icon", "apps", "sound", 93static const char* const types[] = {"html", "icon", "apps", "sound",
93 "data", "locale", "services", "mime", 94 "data", "locale", "services", "mime",
94 "servicetypes", "config", "exe", "tmp", 95 "servicetypes", "config", "exe", "tmp",
95 "wallpaper", "lib", "pixmap", "templates", 96 "wallpaper", "lib", "pixmap", "templates",
96 "module", "qtplugins", 97 "module", "qtplugins",
97 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; 98 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 };
98 99
99static int tokenize( QStringList& token, const QString& str, 100static int tokenize( QStringList& token, const QString& str,
100 const QString& delim ); 101 const QString& delim );
101 102
102KStandardDirs::KStandardDirs( ) : addedCustoms(false) 103KStandardDirs::KStandardDirs( ) : addedCustoms(false)
103{ 104{
104 d = new KStandardDirsPrivate; 105 d = new KStandardDirsPrivate;
105 dircache.setAutoDelete(true); 106 dircache.setAutoDelete(true);
106 relatives.setAutoDelete(true); 107 relatives.setAutoDelete(true);
107 absolutes.setAutoDelete(true); 108 absolutes.setAutoDelete(true);
108 savelocations.setAutoDelete(true); 109 savelocations.setAutoDelete(true);
109 addKDEDefaults(); 110 addKDEDefaults();
110} 111}
111 112
112KStandardDirs::~KStandardDirs() 113KStandardDirs::~KStandardDirs()
113{ 114{
114 delete d; 115 delete d;
115} 116}
116 117
117bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const 118bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const
118{ 119{
119 if (!d || !d->restrictionsActive) 120 if (!d || !d->restrictionsActive)
120 return false; 121 return false;
121 122
122 if (d->restrictions[type]) 123 if (d->restrictions[type])
123 return true; 124 return true;
124 125
125 if (strcmp(type, "data")==0) 126 if (strcmp(type, "data")==0)
126 { 127 {
127 applyDataRestrictions(relPath); 128 applyDataRestrictions(relPath);
128 if (d->dataRestrictionActive) 129 if (d->dataRestrictionActive)
129 { 130 {
130 d->dataRestrictionActive = false; 131 d->dataRestrictionActive = false;
131 return true; 132 return true;
132 } 133 }
133 } 134 }
134 return false; 135 return false;
135} 136}
136 137
137void KStandardDirs::applyDataRestrictions(const QString &relPath) const 138void KStandardDirs::applyDataRestrictions(const QString &relPath) const
138{ 139{
139 QString key; 140 QString key;
140 int i = relPath.find('/'); 141 int i = relPath.find('/');
141 if (i != -1) 142 if (i != -1)
142 key = "data_"+relPath.left(i); 143 key = "data_"+relPath.left(i);
143 else 144 else
144 key = "data_"+relPath; 145 key = "data_"+relPath;
145 146
146 if (d && d->restrictions[key.latin1()]) 147 if (d && d->restrictions[key.latin1()])
147 d->dataRestrictionActive = true; 148 d->dataRestrictionActive = true;
148} 149}
149 150
150 151
151QStringList KStandardDirs::allTypes() const 152QStringList KStandardDirs::allTypes() const
152{ 153{
153 QStringList list; 154 QStringList list;
154 for (int i = 0; types[i] != 0; ++i) 155 for (int i = 0; types[i] != 0; ++i)
155 list.append(QString::fromLatin1(types[i])); 156 list.append(QString::fromLatin1(types[i]));
156 return list; 157 return list;
157} 158}
158 159
159void KStandardDirs::addPrefix( const QString& _dir ) 160void KStandardDirs::addPrefix( const QString& _dir )
160{ 161{
161 if (_dir.isNull()) 162 if (_dir.isNull())
162 return; 163 return;
163 164
164 QString dir = _dir; 165 QString dir = _dir;
165 if (dir.at(dir.length() - 1) != '/') 166 if (dir.at(dir.length() - 1) != '/')
166 dir += '/'; 167 dir += '/';
167 168
168 if (!prefixes.contains(dir)) { 169 if (!prefixes.contains(dir)) {
169 prefixes.append(dir); 170 prefixes.append(dir);
170 dircache.clear(); 171 dircache.clear();
171 } 172 }
172} 173}
173 174
174void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) 175void KStandardDirs::addXdgConfigPrefix( const QString& _dir )
175{ 176{
176 if (_dir.isNull()) 177 if (_dir.isNull())
177 return; 178 return;
178 179
179 QString dir = _dir; 180 QString dir = _dir;
180 if (dir.at(dir.length() - 1) != '/') 181 if (dir.at(dir.length() - 1) != '/')
181 dir += '/'; 182 dir += '/';
182 183
183 if (!d->xdgconf_prefixes.contains(dir)) { 184 if (!d->xdgconf_prefixes.contains(dir)) {
184 d->xdgconf_prefixes.append(dir); 185 d->xdgconf_prefixes.append(dir);
185 dircache.clear(); 186 dircache.clear();
186 } 187 }
187} 188}
188 189
189void KStandardDirs::addXdgDataPrefix( const QString& _dir ) 190void KStandardDirs::addXdgDataPrefix( const QString& _dir )
190{ 191{
191 if (_dir.isNull()) 192 if (_dir.isNull())
192 return; 193 return;
193 194
194 QString dir = _dir; 195 QString dir = _dir;
195 if (dir.at(dir.length() - 1) != '/') 196 if (dir.at(dir.length() - 1) != '/')
196 dir += '/'; 197 dir += '/';
197 198
198 if (!d->xdgdata_prefixes.contains(dir)) { 199 if (!d->xdgdata_prefixes.contains(dir)) {
199 d->xdgdata_prefixes.append(dir); 200 d->xdgdata_prefixes.append(dir);
200 dircache.clear(); 201 dircache.clear();
201 } 202 }
202} 203}
203 204
204 205
205QString KStandardDirs::kfsstnd_prefixes() 206QString KStandardDirs::kfsstnd_prefixes()
206{ 207{
207 return prefixes.join(":"); 208 return prefixes.join(":");
208} 209}
209 210
210bool KStandardDirs::addResourceType( const char *type, 211bool KStandardDirs::addResourceType( const char *type,
211 const QString& relativename ) 212 const QString& relativename )
212{ 213{
213 if (relativename.isNull()) 214 if (relativename.isNull())
214 return false; 215 return false;
215 216
216 QStringList *rels = relatives.find(type); 217 QStringList *rels = relatives.find(type);
217 if (!rels) { 218 if (!rels) {
218 rels = new QStringList(); 219 rels = new QStringList();
219 relatives.insert(type, rels); 220 relatives.insert(type, rels);
220 } 221 }
221 QString copy = relativename; 222 QString copy = relativename;
222 if (copy.at(copy.length() - 1) != '/') 223 if (copy.at(copy.length() - 1) != '/')
223 copy += '/'; 224 copy += '/';
224 if (!rels->contains(copy)) { 225 if (!rels->contains(copy)) {
225 rels->prepend(copy); 226 rels->prepend(copy);
226 dircache.remove(type); // clean the cache 227 dircache.remove(type); // clean the cache
227 return true; 228 return true;
228 } 229 }
229 return false; 230 return false;
230} 231}
231 232
232bool KStandardDirs::addResourceDir( const char *type, 233bool KStandardDirs::addResourceDir( const char *type,
233 const QString& absdir) 234 const QString& absdir)
234{ 235{
235 QStringList *paths = absolutes.find(type); 236 QStringList *paths = absolutes.find(type);
236 if (!paths) { 237 if (!paths) {
237 paths = new QStringList(); 238 paths = new QStringList();
238 absolutes.insert(type, paths); 239 absolutes.insert(type, paths);
239 } 240 }
240 QString copy = absdir; 241 QString copy = absdir;
241 if (copy.at(copy.length() - 1) != '/') 242 if (copy.at(copy.length() - 1) != '/')
242 copy += '/'; 243 copy += '/';
243 244
244 if (!paths->contains(copy)) { 245 if (!paths->contains(copy)) {
245 paths->append(copy); 246 paths->append(copy);
246 dircache.remove(type); // clean the cache 247 dircache.remove(type); // clean the cache
247 return true; 248 return true;
248 } 249 }
249 return false; 250 return false;
250} 251}
251 252
252QString KStandardDirs::findResource( const char *type, 253QString KStandardDirs::findResource( const char *type,
253 const QString& filename ) const 254 const QString& filename ) const
254{ 255{
255 if (filename.at(0) == '/') 256 if (filename.at(0) == '/')
256 return filename; // absolute dirs are absolute dirs, right? :-/ 257 return filename; // absolute dirs are absolute dirs, right? :-/
257 258
258#if 0 259#if 0
259kdDebug() << "Find resource: " << type << endl; 260kdDebug() << "Find resource: " << type << endl;
260for (QStringList::ConstIterator pit = prefixes.begin(); 261for (QStringList::ConstIterator pit = prefixes.begin();
261 pit != prefixes.end(); 262 pit != prefixes.end();
262 pit++) 263 pit++)
263{ 264{
264 kdDebug() << "Prefix: " << *pit << endl; 265 kdDebug() << "Prefix: " << *pit << endl;
265} 266}
266#endif 267#endif
267 268
268 QString dir = findResourceDir(type, filename); 269 QString dir = findResourceDir(type, filename);
269 if (dir.isNull()) 270 if (dir.isNull())
270 return dir; 271 return dir;
271 else return dir + filename; 272 else return dir + filename;
272} 273}
273/*US 274/*US
274static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) 275static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash)
275{ 276{
276 QCString cFile = QFile::encodeName(file); 277 QCString cFile = QFile::encodeName(file);
277//US struct stat buff; 278//US struct stat buff;
278//US if ((access(cFile, R_OK) == 0) && 279//US if ((access(cFile, R_OK) == 0) &&
279//US (stat( cFile, &buff ) == 0) && 280//US (stat( cFile, &buff ) == 0) &&
280//US (S_ISREG( buff.st_mode ))) 281//US (S_ISREG( buff.st_mode )))
281 QFileInfo pathfnInfo(cFile); 282 QFileInfo pathfnInfo(cFile);
282 if (( pathfnInfo.isReadable() == true ) && 283 if (( pathfnInfo.isReadable() == true ) &&
283 ( pathfnInfo.isFile()) ) 284 ( pathfnInfo.isFile()) )
284 { 285 {
285//US hash = hash + (Q_UINT32) buff.st_ctime; 286//US hash = hash + (Q_UINT32) buff.st_ctime;
286 hash = hash + (Q_UINT32) pathfnInfo.lastModified(); 287 hash = hash + (Q_UINT32) pathfnInfo.lastModified();
287 } 288 }
288 return hash; 289 return hash;
289} 290}
290*/ 291*/
291/*US 292/*US
292Q_UINT32 KStandardDirs::calcResourceHash( const char *type, 293Q_UINT32 KStandardDirs::calcResourceHash( const char *type,
293 const QString& filename, bool deep) const 294 const QString& filename, bool deep) const
294{ 295{
295 Q_UINT32 hash = 0; 296 Q_UINT32 hash = 0;
296 297
297 if (filename.at(0) == '/') 298 if (filename.at(0) == '/')
298 { 299 {
299 // absolute dirs are absolute dirs, right? :-/ 300 // absolute dirs are absolute dirs, right? :-/
300 return updateHash(filename, hash); 301 return updateHash(filename, hash);
@@ -951,577 +952,587 @@ QString KStandardDirs::kde_default(const char *type) {
951 if (!strcmp(type, "data")) 952 if (!strcmp(type, "data"))
952 return "apps/"; 953 return "apps/";
953 if (!strcmp(type, "html")) 954 if (!strcmp(type, "html"))
954 return "share/doc/HTML/"; 955 return "share/doc/HTML/";
955 if (!strcmp(type, "icon")) 956 if (!strcmp(type, "icon"))
956 return "share/icons/"; 957 return "share/icons/";
957 if (!strcmp(type, "config")) 958 if (!strcmp(type, "config"))
958 return "config/"; 959 return "config/";
959 if (!strcmp(type, "pixmap")) 960 if (!strcmp(type, "pixmap"))
960 return "share/pixmaps/"; 961 return "share/pixmaps/";
961 if (!strcmp(type, "apps")) 962 if (!strcmp(type, "apps"))
962 return "share/applnk/"; 963 return "share/applnk/";
963 if (!strcmp(type, "sound")) 964 if (!strcmp(type, "sound"))
964 return "share/sounds/"; 965 return "share/sounds/";
965 if (!strcmp(type, "locale")) 966 if (!strcmp(type, "locale"))
966 return "share/locale/"; 967 return "share/locale/";
967 if (!strcmp(type, "services")) 968 if (!strcmp(type, "services"))
968 return "share/services/"; 969 return "share/services/";
969 if (!strcmp(type, "servicetypes")) 970 if (!strcmp(type, "servicetypes"))
970 return "share/servicetypes/"; 971 return "share/servicetypes/";
971 if (!strcmp(type, "mime")) 972 if (!strcmp(type, "mime"))
972 return "share/mimelnk/"; 973 return "share/mimelnk/";
973 if (!strcmp(type, "cgi")) 974 if (!strcmp(type, "cgi"))
974 return "cgi-bin/"; 975 return "cgi-bin/";
975 if (!strcmp(type, "wallpaper")) 976 if (!strcmp(type, "wallpaper"))
976 return "share/wallpapers/"; 977 return "share/wallpapers/";
977 if (!strcmp(type, "templates")) 978 if (!strcmp(type, "templates"))
978 return "share/templates/"; 979 return "share/templates/";
979 if (!strcmp(type, "exe")) 980 if (!strcmp(type, "exe"))
980 return "bin/"; 981 return "bin/";
981 if (!strcmp(type, "lib")) 982 if (!strcmp(type, "lib"))
982 return "lib/"; 983 return "lib/";
983 if (!strcmp(type, "module")) 984 if (!strcmp(type, "module"))
984 return "lib/kde3/"; 985 return "lib/kde3/";
985 if (!strcmp(type, "qtplugins")) 986 if (!strcmp(type, "qtplugins"))
986 return "lib/kde3/plugins"; 987 return "lib/kde3/plugins";
987 if (!strcmp(type, "xdgdata-apps")) 988 if (!strcmp(type, "xdgdata-apps"))
988 return "applications/"; 989 return "applications/";
989 if (!strcmp(type, "xdgdata-dirs")) 990 if (!strcmp(type, "xdgdata-dirs"))
990 return "desktop-directories/"; 991 return "desktop-directories/";
991 if (!strcmp(type, "xdgconf-menu")) 992 if (!strcmp(type, "xdgconf-menu"))
992 return "menus/"; 993 return "menus/";
993 if (!strcmp(type, "tmp")) 994 if (!strcmp(type, "tmp"))
994 return "tmp/"; 995 return "tmp/";
995 996
996 qFatal("unknown resource type %s", type); 997 qFatal("unknown resource type %s", type);
997 return QString::null; 998 return QString::null;
998} 999}
999 1000
1000QString KStandardDirs::saveLocation(const char *type, 1001QString KStandardDirs::saveLocation(const char *type,
1001 const QString& suffix, 1002 const QString& suffix,
1002 bool create) const 1003 bool create) const
1003{ 1004{
1004 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 1005 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
1005 //return ""; 1006 //return "";
1006 checkConfig(); 1007 checkConfig();
1007 1008
1008 QString *pPath = savelocations.find(type); 1009 QString *pPath = savelocations.find(type);
1009 if (!pPath) 1010 if (!pPath)
1010 { 1011 {
1011 QStringList *dirs = relatives.find(type); 1012 QStringList *dirs = relatives.find(type);
1012 if (!dirs && ( 1013 if (!dirs && (
1013 (strcmp(type, "socket") == 0) || 1014 (strcmp(type, "socket") == 0) ||
1014 (strcmp(type, "tmp") == 0) || 1015 (strcmp(type, "tmp") == 0) ||
1015 (strcmp(type, "cache") == 0) )) 1016 (strcmp(type, "cache") == 0) ))
1016 { 1017 {
1017 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1018 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1018 dirs = relatives.find(type); // Search again. 1019 dirs = relatives.find(type); // Search again.
1019 } 1020 }
1020 if (dirs) 1021 if (dirs)
1021 { 1022 {
1022 // Check for existance of typed directory + suffix 1023 // Check for existance of typed directory + suffix
1023 if (strncmp(type, "xdgdata-", 8) == 0) 1024 if (strncmp(type, "xdgdata-", 8) == 0)
1024 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1025 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1025 else if (strncmp(type, "xdgconf-", 8) == 0) 1026 else if (strncmp(type, "xdgconf-", 8) == 0)
1026 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1027 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1027 else 1028 else
1028 pPath = new QString(realPath(localkdedir() + dirs->last())); 1029 pPath = new QString(realPath(localkdedir() + dirs->last()));
1029 } 1030 }
1030 else { 1031 else {
1031 dirs = absolutes.find(type); 1032 dirs = absolutes.find(type);
1032 if (!dirs) 1033 if (!dirs)
1033 qFatal("KStandardDirs: The resource type %s is not registered", type); 1034 qFatal("KStandardDirs: The resource type %s is not registered", type);
1034 pPath = new QString(realPath(dirs->last())); 1035 pPath = new QString(realPath(dirs->last()));
1035 } 1036 }
1036 1037
1037 savelocations.insert(type, pPath); 1038 savelocations.insert(type, pPath);
1038 } 1039 }
1039 1040
1040 QString fullPath = *pPath + suffix; 1041 QString fullPath = *pPath + suffix;
1041//US struct stat st; 1042//US struct stat st;
1042//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1043//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1043 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1044 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1044 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1045 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1045 1046
1046 1047
1047 { 1048 {
1048 if(!create) { 1049 if(!create) {
1049#ifndef NDEBUG 1050#ifndef NDEBUG
1050 qDebug("save location %s doesn't exist", fullPath.latin1()); 1051 qDebug("save location %s doesn't exist", fullPath.latin1());
1051#endif 1052#endif
1052 return fullPath; 1053 return fullPath;
1053 } 1054 }
1054 if(!makeDir(fullPath, 0700)) { 1055 if(!makeDir(fullPath, 0700)) {
1055 qWarning("failed to create %s", fullPath.latin1()); 1056 qWarning("failed to create %s", fullPath.latin1());
1056 return fullPath; 1057 return fullPath;
1057 } 1058 }
1058 dircache.remove(type); 1059 dircache.remove(type);
1059 } 1060 }
1060 return fullPath; 1061 return fullPath;
1061} 1062}
1062 1063
1063QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1064{ 1065{
1065 QString fullPath = absPath; 1066 QString fullPath = absPath;
1066 int i = absPath.findRev('/'); 1067 int i = absPath.findRev('/');
1067 if (i != -1) 1068 if (i != -1)
1068 { 1069 {
1069 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1070 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1070 } 1071 }
1071 1072
1072 QStringList candidates = resourceDirs(type); 1073 QStringList candidates = resourceDirs(type);
1073 1074
1074 for (QStringList::ConstIterator it = candidates.begin(); 1075 for (QStringList::ConstIterator it = candidates.begin();
1075 it != candidates.end(); it++) 1076 it != candidates.end(); it++)
1076 if (fullPath.startsWith(*it)) 1077 if (fullPath.startsWith(*it))
1077 { 1078 {
1078 return fullPath.mid((*it).length()); 1079 return fullPath.mid((*it).length());
1079 } 1080 }
1080 1081
1081 return absPath; 1082 return absPath;
1082} 1083}
1083 1084
1084 1085
1085bool KStandardDirs::makeDir(const QString& dir2, int mode) 1086bool KStandardDirs::makeDir(const QString& dir2, int mode)
1086{ 1087{
1087 QString dir = QDir::convertSeparators( dir2 ); 1088 QString dir = QDir::convertSeparators( dir2 );
1088#if 0 1089#if 0
1089 //LR 1090 //LR
1090 1091
1091 // we want an absolute path 1092 // we want an absolute path
1092 if (dir.at(0) != '/') 1093 if (dir.at(0) != '/')
1093 return false; 1094 return false;
1094 1095
1095 QString target = dir; 1096 QString target = dir;
1096 uint len = target.length(); 1097 uint len = target.length();
1097 1098
1098 // append trailing slash if missing 1099 // append trailing slash if missing
1099 if (dir.at(len - 1) != '/') 1100 if (dir.at(len - 1) != '/')
1100 target += '/'; 1101 target += '/';
1101 1102
1102 QString base(""); 1103 QString base("");
1103 uint i = 1; 1104 uint i = 1;
1104 1105
1105 while( i < len ) 1106 while( i < len )
1106 { 1107 {
1107//US struct stat st; 1108//US struct stat st;
1108 int pos = target.find('/', i); 1109 int pos = target.find('/', i);
1109 base += target.mid(i - 1, pos - i + 1); 1110 base += target.mid(i - 1, pos - i + 1);
1110 QCString baseEncoded = QFile::encodeName(base); 1111 QCString baseEncoded = QFile::encodeName(base);
1111 // bail out if we encountered a problem 1112 // bail out if we encountered a problem
1112//US if (stat(baseEncoded, &st) != 0) 1113//US if (stat(baseEncoded, &st) != 0)
1113 QFileInfo baseEncodedInfo(baseEncoded); 1114 QFileInfo baseEncodedInfo(baseEncoded);
1114 if (!baseEncodedInfo.exists()) 1115 if (!baseEncodedInfo.exists())
1115 { 1116 {
1116 // Directory does not exist.... 1117 // Directory does not exist....
1117 // Or maybe a dangling symlink ? 1118 // Or maybe a dangling symlink ?
1118//US if (lstat(baseEncoded, &st) == 0) 1119//US if (lstat(baseEncoded, &st) == 0)
1119 if (baseEncodedInfo.isSymLink()) { 1120 if (baseEncodedInfo.isSymLink()) {
1120//US (void)unlink(baseEncoded); // try removing 1121//US (void)unlink(baseEncoded); // try removing
1121 QFile(baseEncoded).remove(); 1122 QFile(baseEncoded).remove();
1122 } 1123 }
1123 1124
1124 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1125 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1125 QDir dirObj; 1126 QDir dirObj;
1126 if ( dirObj.mkdir(baseEncoded) != true ) 1127 if ( dirObj.mkdir(baseEncoded) != true )
1127 { 1128 {
1128 //US perror("trying to create local folder"); 1129 //US perror("trying to create local folder");
1129 return false; // Couldn't create it :-( 1130 return false; // Couldn't create it :-(
1130 } 1131 }
1131 } 1132 }
1132 i = pos + 1; 1133 i = pos + 1;
1133 } 1134 }
1134 return true; 1135 return true;
1135#endif 1136#endif
1136 1137
1137 // ******************************************** 1138 // ********************************************
1138 // new code for WIN32 1139 // new code for WIN32
1139 QDir dirObj; 1140 QDir dirObj;
1140 1141
1141 1142
1142 // we want an absolute path 1143 // we want an absolute path
1143#ifndef _WIN32_ 1144#ifndef _WIN32_
1144 if (dir.at(0) != '/') 1145 if (dir.at(0) != '/')
1145 return false; 1146 return false;
1146#endif 1147#endif
1147 1148
1148 QString target = dir; 1149 QString target = dir;
1149 uint len = target.length(); 1150 uint len = target.length();
1150#ifndef _WIN32_ 1151#ifndef _WIN32_
1151 // append trailing slash if missing 1152 // append trailing slash if missing
1152 if (dir.at(len - 1) != '/') 1153 if (dir.at(len - 1) != '/')
1153 target += '/'; 1154 target += '/';
1154#endif 1155#endif
1155 1156
1156 QString base(""); 1157 QString base("");
1157 uint i = 1; 1158 uint i = 1;
1158 1159
1159 while( i < len ) 1160 while( i < len )
1160 { 1161 {
1161//US struct stat st; 1162//US struct stat st;
1162#ifndef _WIN32_ 1163#ifndef _WIN32_
1163 int pos = target.find('/', i); 1164 int pos = target.find('/', i);
1164#else 1165#else
1165 int pos = target.find('\\', i); 1166 int pos = target.find('\\', i);
1166#endif 1167#endif
1167 if ( pos < 0 ) 1168 if ( pos < 0 )
1168 return true; 1169 return true;
1169 base += target.mid(i - 1, pos - i + 1); 1170 base += target.mid(i - 1, pos - i + 1);
1170 //QMessageBox::information( 0,"cap111", base, 1 ); 1171 //QMessageBox::information( 0,"cap111", base, 1 );
1171/*US 1172/*US
1172 QCString baseEncoded = QFile::encodeName(base); 1173 QCString baseEncoded = QFile::encodeName(base);
1173 // bail out if we encountered a problem 1174 // bail out if we encountered a problem
1174 if (stat(baseEncoded, &st) != 0) 1175 if (stat(baseEncoded, &st) != 0)
1175 { 1176 {
1176 // Directory does not exist.... 1177 // Directory does not exist....
1177 // Or maybe a dangling symlink ? 1178 // Or maybe a dangling symlink ?
1178 if (lstat(baseEncoded, &st) == 0) 1179 if (lstat(baseEncoded, &st) == 0)
1179 (void)unlink(baseEncoded); // try removing 1180 (void)unlink(baseEncoded); // try removing
1180 1181
1181 1182
1182 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1183 perror("trying to create local folder"); 1184 perror("trying to create local folder");
1184 return false; // Couldn't create it :-( 1185 return false; // Couldn't create it :-(
1185 } 1186 }
1186 } 1187 }
1187*/ 1188*/
1188 1189
1189 if (dirObj.exists(base) == false) 1190 if (dirObj.exists(base) == false)
1190 { 1191 {
1191 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1192 if (dirObj.mkdir(base) != true) 1193 if (dirObj.mkdir(base) != true)
1193 { 1194 {
1194 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1195 return false; 1196 return false;
1196 } 1197 }
1197 } 1198 }
1198 1199
1199 i = pos + 1; 1200 i = pos + 1;
1200 } 1201 }
1201 return true; 1202 return true;
1202 1203
1203} 1204}
1204 1205
1205static QString readEnvPath(const char *env) 1206static QString readEnvPath(const char *env)
1206{ 1207{
1207#ifdef _WIN32_ 1208 //#ifdef _WIN32_
1208 return ""; 1209 // return "";
1209#else 1210 //#else
1210 QCString c_path = getenv(env); 1211 QCString c_path;
1211 if (c_path.isEmpty()) 1212 if ( getenv(env) != NULL )
1212 return QString::null; 1213 c_path = QString ( getenv(env) );
1213 return QFile::decodeName(c_path); 1214 if (c_path.isEmpty())
1214#endif 1215 return QString::null;
1216 return QFile::decodeName(c_path);
1217 //#endif
1218
1215} 1219}
1216 1220
1217void KStandardDirs::addKDEDefaults() 1221void KStandardDirs::addKDEDefaults()
1218{ 1222{
1223
1219 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1220 //return; 1225 //return;
1221 QStringList kdedirList; 1226 QStringList kdedirList;
1222 1227
1223 // begin KDEDIRS 1228 // begin KDEDIRS
1224 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1229 QString kdedirs = readEnvPath("MICROKDEDIRS");
1225 if (!kdedirs.isEmpty()) 1230 if (!kdedirs.isEmpty())
1226 { 1231 {
1227 tokenize(kdedirList, kdedirs, ":"); 1232 tokenize(kdedirList, kdedirs, ":");
1228 } 1233 }
1229 else 1234 else
1230 { 1235 {
1231 QString kdedir = readEnvPath("MICROKDEDIR"); 1236 QString kdedir = readEnvPath("MICROKDEDIR");
1232 if (!kdedir.isEmpty()) 1237 if (!kdedir.isEmpty())
1233 { 1238 {
1234 kdedir = KShell::tildeExpand(kdedir); 1239 kdedir = KShell::tildeExpand(kdedir);
1235 kdedirList.append(kdedir); 1240 kdedirList.append(kdedir);
1236 } 1241 }
1237 } 1242 }
1238//US kdedirList.append(KDEDIR); 1243//US kdedirList.append(KDEDIR);
1239//US for embedded, add qtopia dir as kdedir 1244//US for embedded, add qtopia dir as kdedir
1240 1245
1241#ifndef DESKTOP_VERSION 1246#ifndef DESKTOP_VERSION
1242 QString tmp = readEnvPath("QPEDIR"); 1247 QString tmp = readEnvPath("QPEDIR");
1243 if (!tmp.isEmpty()) 1248 if (!tmp.isEmpty())
1244 kdedirList.append(tmp); 1249 kdedirList.append(tmp);
1245 1250
1246 tmp = readEnvPath("QTDIR"); 1251 tmp = readEnvPath("QTDIR");
1247 if (!tmp.isEmpty()) 1252 if (!tmp.isEmpty())
1248 kdedirList.append(tmp); 1253 kdedirList.append(tmp);
1249 1254
1250 tmp = readEnvPath("OPIEDIR"); 1255 tmp = readEnvPath("OPIEDIR");
1251 if (!tmp.isEmpty()) 1256 if (!tmp.isEmpty())
1252 kdedirList.append(tmp); 1257 kdedirList.append(tmp);
1253 1258
1254#endif 1259#endif
1255 1260
1256#ifdef __KDE_EXECPREFIX 1261#ifdef __KDE_EXECPREFIX
1257 QString execPrefix(__KDE_EXECPREFIX); 1262 QString execPrefix(__KDE_EXECPREFIX);
1258 if (execPrefix!="NONE") 1263 if (execPrefix!="NONE")
1259 kdedirList.append(execPrefix); 1264 kdedirList.append(execPrefix);
1260#endif 1265#endif
1261 1266
1262 QString localKdeDir; 1267 QString localKdeDir;
1263 1268
1264//US if (getuid()) 1269//US if (getuid())
1265 if (true) 1270 if (true)
1266 { 1271 {
1267 localKdeDir = readEnvPath("MICROKDEHOME"); 1272 localKdeDir = readEnvPath("MICROKDEHOME");
1268 if (!localKdeDir.isEmpty()) 1273 if (!localKdeDir.isEmpty())
1269 { 1274 {
1275#ifdef _WIN32_
1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\')
1277 localKdeDir += '\\';
1278#else
1270 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1279 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1271 localKdeDir += '/'; 1280 localKdeDir += '/';
1281#endif
1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
1272 } 1283 }
1273 else 1284 else
1274 { 1285 {
1275 localKdeDir = QDir::homeDirPath() + "/kdepim/"; 1286 localKdeDir = QDir::homeDirPath() + "/kdepim/";
1276 } 1287 }
1277 } 1288 }
1278 else 1289 else
1279 { 1290 {
1280 // We treat root different to prevent root messing up the 1291 // We treat root different to prevent root messing up the
1281 // file permissions in the users home directory. 1292 // file permissions in the users home directory.
1282 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1293 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1283 if (!localKdeDir.isEmpty()) 1294 if (!localKdeDir.isEmpty())
1284 { 1295 {
1285 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1296 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1286 localKdeDir += '/'; 1297 localKdeDir += '/';
1287 } 1298 }
1288 else 1299 else
1289 { 1300 {
1290//US struct passwd *pw = getpwuid(0); 1301//US struct passwd *pw = getpwuid(0);
1291//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1302//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1292 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1303 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1293 } 1304 }
1294 1305
1295 } 1306 }
1296 1307
1297//US localKdeDir = appDir(); 1308//US localKdeDir = appDir();
1298 1309
1299//US 1310//US
1300// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1311// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1301 if (localKdeDir != "-/") 1312 if (localKdeDir != "-/")
1302 { 1313 {
1303 localKdeDir = KShell::tildeExpand(localKdeDir); 1314 localKdeDir = KShell::tildeExpand(localKdeDir);
1304 addPrefix(localKdeDir); 1315 addPrefix(localKdeDir);
1305 } 1316 }
1306 1317
1307 for (QStringList::ConstIterator it = kdedirList.begin(); 1318 for (QStringList::ConstIterator it = kdedirList.begin();
1308 it != kdedirList.end(); it++) 1319 it != kdedirList.end(); it++)
1309 { 1320 {
1310 QString dir = KShell::tildeExpand(*it); 1321 QString dir = KShell::tildeExpand(*it);
1311 addPrefix(dir); 1322 addPrefix(dir);
1312 } 1323 }
1313 // end KDEDIRS 1324 // end KDEDIRS
1314 1325
1315 // begin XDG_CONFIG_XXX 1326 // begin XDG_CONFIG_XXX
1316 QStringList xdgdirList; 1327 QStringList xdgdirList;
1317 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1328 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1318 if (!xdgdirs.isEmpty()) 1329 if (!xdgdirs.isEmpty())
1319 { 1330 {
1320 tokenize(xdgdirList, xdgdirs, ":"); 1331 tokenize(xdgdirList, xdgdirs, ":");
1321 } 1332 }
1322 else 1333 else
1323 { 1334 {
1324 xdgdirList.clear(); 1335 xdgdirList.clear();
1325 xdgdirList.append("/etc/xdg"); 1336 xdgdirList.append("/etc/xdg");
1326 } 1337 }
1327 1338
1328 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1339 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1329 if (!localXdgDir.isEmpty()) 1340 if (!localXdgDir.isEmpty())
1330 { 1341 {
1331 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1342 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1332 localXdgDir += '/'; 1343 localXdgDir += '/';
1333 } 1344 }
1334 else 1345 else
1335 { 1346 {
1336//US if (getuid()) 1347//US if (getuid())
1337 if (true) 1348 if (true)
1338 { 1349 {
1339 localXdgDir = QDir::homeDirPath() + "/.config/"; 1350 localXdgDir = QDir::homeDirPath() + "/.config/";
1340 } 1351 }
1341 else 1352 else
1342 { 1353 {
1343//US struct passwd *pw = getpwuid(0); 1354//US struct passwd *pw = getpwuid(0);
1344//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1355//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1345 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1356 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1346 } 1357 }
1347 } 1358 }
1348 1359
1349 localXdgDir = KShell::tildeExpand(localXdgDir); 1360 localXdgDir = KShell::tildeExpand(localXdgDir);
1350 addXdgConfigPrefix(localXdgDir); 1361 addXdgConfigPrefix(localXdgDir);
1351 1362
1352 for (QStringList::ConstIterator it = xdgdirList.begin(); 1363 for (QStringList::ConstIterator it = xdgdirList.begin();
1353 it != xdgdirList.end(); it++) 1364 it != xdgdirList.end(); it++)
1354 { 1365 {
1355 QString dir = KShell::tildeExpand(*it); 1366 QString dir = KShell::tildeExpand(*it);
1356 addXdgConfigPrefix(dir); 1367 addXdgConfigPrefix(dir);
1357 } 1368 }
1358 // end XDG_CONFIG_XXX 1369 // end XDG_CONFIG_XXX
1359 1370
1360 // begin XDG_DATA_XXX 1371 // begin XDG_DATA_XXX
1361 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1372 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1362 if (!xdgdirs.isEmpty()) 1373 if (!xdgdirs.isEmpty())
1363 { 1374 {
1364 tokenize(xdgdirList, xdgdirs, ":"); 1375 tokenize(xdgdirList, xdgdirs, ":");
1365 } 1376 }
1366 else 1377 else
1367 { 1378 {
1368 xdgdirList.clear(); 1379 xdgdirList.clear();
1369 for (QStringList::ConstIterator it = kdedirList.begin(); 1380 for (QStringList::ConstIterator it = kdedirList.begin();
1370 it != kdedirList.end(); it++) 1381 it != kdedirList.end(); it++)
1371 { 1382 {
1372 QString dir = *it; 1383 QString dir = *it;
1373 if (dir.at(dir.length()-1) != '/') 1384 if (dir.at(dir.length()-1) != '/')
1374 dir += '/'; 1385 dir += '/';
1375 xdgdirList.append(dir+"share/"); 1386 xdgdirList.append(dir+"share/");
1376 } 1387 }
1377 1388
1378 xdgdirList.append("/usr/local/share/"); 1389 xdgdirList.append("/usr/local/share/");
1379 xdgdirList.append("/usr/share/"); 1390 xdgdirList.append("/usr/share/");
1380 } 1391 }
1381 1392
1382 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1393 localXdgDir = readEnvPath("XDG_DATA_HOME");
1383 if (!localXdgDir.isEmpty()) 1394 if (!localXdgDir.isEmpty())
1384 { 1395 {
1385 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1396 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1386 localXdgDir += '/'; 1397 localXdgDir += '/';
1387 } 1398 }
1388 else 1399 else
1389 { 1400 {
1390//US if (getuid()) 1401//US if (getuid())
1391 if (true) 1402 if (true)
1392 { 1403 {
1393 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1404 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1394 } 1405 }
1395 else 1406 else
1396 { 1407 {
1397//US struct passwd *pw = getpwuid(0); 1408//US struct passwd *pw = getpwuid(0);
1398//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1409//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1399 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1410 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1400 } 1411 }
1401 } 1412 }
1402 1413
1403 localXdgDir = KShell::tildeExpand(localXdgDir); 1414 localXdgDir = KShell::tildeExpand(localXdgDir);
1404 addXdgDataPrefix(localXdgDir); 1415 addXdgDataPrefix(localXdgDir);
1405 1416
1406 for (QStringList::ConstIterator it = xdgdirList.begin(); 1417 for (QStringList::ConstIterator it = xdgdirList.begin();
1407 it != xdgdirList.end(); it++) 1418 it != xdgdirList.end(); it++)
1408 { 1419 {
1409 QString dir = KShell::tildeExpand(*it); 1420 QString dir = KShell::tildeExpand(*it);
1410 1421
1411 addXdgDataPrefix(dir); 1422 addXdgDataPrefix(dir);
1412 } 1423 }
1413 // end XDG_DATA_XXX 1424 // end XDG_DATA_XXX
1414 1425
1415 1426
1416 uint index = 0; 1427 uint index = 0;
1417 while (types[index] != 0) { 1428 while (types[index] != 0) {
1418 addResourceType(types[index], kde_default(types[index])); 1429 addResourceType(types[index], kde_default(types[index]));
1419 index++; 1430 index++;
1420 } 1431 }
1421 1432
1422 addResourceDir("home", QDir::homeDirPath()); 1433 addResourceDir("home", QDir::homeDirPath());
1423} 1434}
1424 1435
1425void KStandardDirs::checkConfig() const 1436void KStandardDirs::checkConfig() const
1426{ 1437{
1427/*US 1438/*US
1428 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1439 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1429 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1440 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1430*/ 1441*/
1431 if (!addedCustoms && KGlobal::config()) 1442 if (!addedCustoms && KGlobal::config())
1432 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1443 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1433} 1444}
1434 1445
1435bool KStandardDirs::addCustomized(KConfig *config) 1446bool KStandardDirs::addCustomized(KConfig *config)
1436{ 1447{
1437 if (addedCustoms) // there are already customized entries 1448 if (addedCustoms) // there are already customized entries
1438 return false; // we just quite and hope they are the right ones 1449 return false; // we just quite and hope they are the right ones
1439 1450
1440 // save the numbers of config directories. If this changes, 1451 // save the numbers of config directories. If this changes,
1441 // we will return true to give KConfig a chance to reparse 1452 // we will return true to give KConfig a chance to reparse
1442 uint configdirs = resourceDirs("config").count(); 1453 uint configdirs = resourceDirs("config").count();
1443 1454
1444 // reading the prefixes in 1455 // reading the prefixes in
1445 QString oldGroup = config->group(); 1456 QString oldGroup = config->group();
1446 config->setGroup("Directories"); 1457 config->setGroup("Directories");
1447 1458
1448 QStringList list; 1459 QStringList list;
1449 QStringList::ConstIterator it; 1460 QStringList::ConstIterator it;
1450 list = config->readListEntry("prefixes"); 1461 list = config->readListEntry("prefixes");
1451 for (it = list.begin(); it != list.end(); it++) 1462 for (it = list.begin(); it != list.end(); it++)
1452 addPrefix(*it); 1463 addPrefix(*it);
1453 1464
1454 // iterating over all entries in the group Directories 1465 // iterating over all entries in the group Directories
1455 // to find entries that start with dir_$type 1466 // to find entries that start with dir_$type
1456/*US 1467/*US
1457 QMap<QString, QString> entries = config->entryMap("Directories"); 1468 QMap<QString, QString> entries = config->entryMap("Directories");
1458 1469
1459 QMap<QString, QString>::ConstIterator it2; 1470 QMap<QString, QString>::ConstIterator it2;
1460 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1471 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1461 { 1472 {
1462 QString key = it2.key(); 1473 QString key = it2.key();
1463 if (key.left(4) == "dir_") { 1474 if (key.left(4) == "dir_") {
1464 // generate directory list, there may be more than 1. 1475 // generate directory list, there may be more than 1.
1465 QStringList dirs = QStringList::split(',', *it2); 1476 QStringList dirs = QStringList::split(',', *it2);
1466 QStringList::Iterator sIt(dirs.begin()); 1477 QStringList::Iterator sIt(dirs.begin());
1467 QString resType = key.mid(4, key.length()); 1478 QString resType = key.mid(4, key.length());
1468 for (; sIt != dirs.end(); ++sIt) { 1479 for (; sIt != dirs.end(); ++sIt) {
1469 addResourceDir(resType.latin1(), *sIt); 1480 addResourceDir(resType.latin1(), *sIt);
1470 } 1481 }
1471 } 1482 }
1472 } 1483 }
1473 1484
1474 // Process KIOSK restrictions. 1485 // Process KIOSK restrictions.
1475 config->setGroup("KDE Resource Restrictions"); 1486 config->setGroup("KDE Resource Restrictions");
1476 entries = config->entryMap("KDE Resource Restrictions"); 1487 entries = config->entryMap("KDE Resource Restrictions");
1477 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1488 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1478 { 1489 {
1479 QString key = it2.key(); 1490 QString key = it2.key();
1480 if (!config->readBoolEntry(key, true)) 1491 if (!config->readBoolEntry(key, true))
1481 { 1492 {
1482 d->restrictionsActive = true; 1493 d->restrictionsActive = true;
1483 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1494 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1484 dircache.remove(key.latin1()); 1495 dircache.remove(key.latin1());
1485 } 1496 }
1486 } 1497 }
1487*/ 1498*/
1488 // save it for future calls - that will return 1499 // save it for future calls - that will return
1489 addedCustoms = true; 1500 addedCustoms = true;
1490 config->setGroup(oldGroup); 1501 config->setGroup(oldGroup);
1491 1502
1492 // return true if the number of config dirs changed 1503 // return true if the number of config dirs changed
1493 return (resourceDirs("config").count() != configdirs); 1504 return (resourceDirs("config").count() != configdirs);
1494} 1505}
1495 1506
1496QString KStandardDirs::localkdedir() const 1507QString KStandardDirs::localkdedir() const
1497{ 1508{
1498 // Return the prefix to use for saving 1509 // Return the prefix to use for saving
1499 return prefixes.first(); 1510 return prefixes.first();
1500} 1511}
1501 1512
1502QString KStandardDirs::localxdgdatadir() const 1513QString KStandardDirs::localxdgdatadir() const
1503{ 1514{
1504 // Return the prefix to use for saving 1515 // Return the prefix to use for saving
1505 return d->xdgdata_prefixes.first(); 1516 return d->xdgdata_prefixes.first();
1506} 1517}
1507 1518
1508QString KStandardDirs::localxdgconfdir() const 1519QString KStandardDirs::localxdgconfdir() const
1509{ 1520{
1510 // Return the prefix to use for saving 1521 // Return the prefix to use for saving
1511 return d->xdgconf_prefixes.first(); 1522 return d->xdgconf_prefixes.first();
1512} 1523}
1513 1524
1514void KStandardDirs::setAppDir( const QString &appDir ) 1525void KStandardDirs::setAppDir( const QString &appDir )
1515{ 1526{
1516 mAppDir = appDir; 1527 mAppDir = appDir;
1517 1528
1518 if ( mAppDir.right( 1 ) != "/" ) 1529 if ( mAppDir.right( 1 ) != "/" )
1519 mAppDir += "/"; 1530 mAppDir += "/";
1520} 1531}
1521 1532
1522QString KStandardDirs::appDir() 1533QString KStandardDirs::appDir()
1523{ 1534{
1524 return mAppDir; 1535 return mAppDir;
1525} 1536}
1526 1537
1527// just to make code more readable without macros 1538// just to make code more readable without macros